summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJason Wright <jason@cvs.openbsd.org>1999-10-01 02:00:13 +0000
committerJason Wright <jason@cvs.openbsd.org>1999-10-01 02:00:13 +0000
commitdafe6b2ba67aa9d366e36b1bf057134de3f44fc8 (patch)
tree39551f4cd0b945ee662390e60671d8b13faad062 /sys
parent21f72b0b66ec9c8bbb3eb3b5f3448a7ad22ea7ee (diff)
remove dependency on external storage managed by mclusters and
add more support for external managers
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c17
-rw-r--r--sys/sys/mbuf.h25
2 files changed, 21 insertions, 21 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index a36ef397a0e..9022a20b284 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.16 1999/09/12 11:46:53 niklas Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.17 1999/10/01 02:00:12 jason Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -342,7 +342,10 @@ m_copym(m, off0, len, wait)
n->m_len = min(len, m->m_len - off);
if (m->m_flags & M_EXT) {
n->m_data = m->m_data + off;
- mclrefcnt[mtocl(m->m_ext.ext_buf)]++;
+ if (!m->m_ext.ext_ref)
+ mclrefcnt[mtocl(m->m_ext.ext_buf)]++;
+ else
+ (*(m->m_ext.ext_ref))(m);
n->m_ext = m->m_ext;
n->m_flags |= M_EXT;
} else
@@ -771,7 +774,10 @@ extpacket:
if (m->m_flags & M_EXT) {
n->m_flags |= M_EXT;
n->m_ext = m->m_ext;
- mclrefcnt[mtocl(m->m_ext.ext_buf)]++;
+ if(!m->m_ext.ext_ref)
+ mclrefcnt[mtocl(m->m_ext.ext_buf)]++;
+ else
+ (*(m->m_ext.ext_ref))(m);
m->m_ext.ext_size = 0; /* For Accounting XXXXXX danger */
n->m_data = m->m_data + len;
} else {
@@ -868,8 +874,9 @@ m_zero(m)
sizeof(struct pkthdr), MHLEN);
else
bzero((void *)m + sizeof(struct m_hdr), MLEN);
- if ((m->m_flags & M_EXT) &&
- !mclrefcnt[mtocl((m)->m_ext.ext_buf)])
+ if ((m->m_flags & M_EXT) &&
+ (m->m_ext.ext_free == NULL) &&
+ !mclrefcnt[mtocl((m)->m_ext.ext_buf)])
bzero(m->m_ext.ext_buf, m->m_ext.ext_size);
m = m->m_next;
}
diff --git a/sys/sys/mbuf.h b/sys/sys/mbuf.h
index 82f6b704869..cd797121b03 100644
--- a/sys/sys/mbuf.h
+++ b/sys/sys/mbuf.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: mbuf.h,v 1.11 1999/07/02 01:02:52 cmetz Exp $ */
+/* $OpenBSD: mbuf.h,v 1.12 1999/10/01 02:00:11 jason Exp $ */
/* $NetBSD: mbuf.h,v 1.19 1996/02/09 18:25:14 christos Exp $ */
/*
@@ -88,8 +88,11 @@ struct pkthdr {
struct m_ext {
caddr_t ext_buf; /* start of buffer */
void (*ext_free) /* free routine if not the usual */
- __P((caddr_t, u_int));
+ __P((struct mbuf *));
u_int ext_size; /* size of buffer, for ext_free */
+ void (*ext_ref) /* add a reference to the ext object */
+ __P((struct mbuf *));
+ void *ext_handle; /* handle for storage manager */
};
struct mbuf {
@@ -239,7 +242,9 @@ union mcluster {
(m)->m_data = (m)->m_ext.ext_buf; \
(m)->m_flags |= M_EXT; \
(m)->m_ext.ext_size = MCLBYTES; \
- (m)->m_ext.ext_free = 0; \
+ (m)->m_ext.ext_free = NULL; \
+ (m)->m_ext.ext_ref = NULL; \
+ (m)->m_ext.ext_handle = NULL; \
} \
}
@@ -263,29 +268,17 @@ union mcluster {
* Free a single mbuf and associated external storage.
* Place the successor, if any, in n.
*/
-#ifdef notyet
#define MFREE(m, n) \
{ MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--;) \
if ((m)->m_flags & M_EXT) { \
if ((m)->m_ext.ext_free) \
- (*((m)->m_ext.ext_free))((m)->m_ext.ext_buf, \
- (m)->m_ext.ext_size); \
+ (*((m)->m_ext.ext_free))(m); \
else \
MCLFREE((m)->m_ext.ext_buf); \
} \
(n) = (m)->m_next; \
FREE((m), mbtypes[(m)->m_type]); \
}
-#else /* notyet */
-#define MFREE(m, nn) \
- { MBUFLOCK(mbstat.m_mtypes[(m)->m_type]--;) \
- if ((m)->m_flags & M_EXT) { \
- MCLFREE((m)->m_ext.ext_buf); \
- } \
- (nn) = (m)->m_next; \
- FREE((m), mbtypes[(m)->m_type]); \
- }
-#endif
/*
* Copy mbuf pkthdr from from to to.