svn commit: r255047 - head/sys/sys
Navdeep Parhar
np at FreeBSD.org
Thu Aug 29 23:46:39 UTC 2013
Author: np
Date: Thu Aug 29 23:46:38 2013
New Revision: 255047
URL: http://svnweb.freebsd.org/changeset/base/255047
Log:
Add a routine for attaching an mbuf to a buffer with an external
refcount. This one is willing to work with buffers that may already be
referenced. MEXTADD/m_extadd are suitable only for the first attachment
to a cluster -- they initialize the refcount to 1.
Modified:
head/sys/sys/mbuf.h
Modified: head/sys/sys/mbuf.h
==============================================================================
--- head/sys/sys/mbuf.h Thu Aug 29 23:11:58 2013 (r255046)
+++ head/sys/sys/mbuf.h Thu Aug 29 23:46:38 2013 (r255047)
@@ -545,6 +545,28 @@ m_gettype(int size)
return (type);
}
+/*
+ * Associated an external reference counted buffer with an mbuf.
+ */
+static __inline void
+m_extaddref(struct mbuf *m, caddr_t buf, u_int size, u_int *ref_cnt,
+ int (*freef)(struct mbuf *, void *, void *), void *arg1, void *arg2)
+{
+
+ KASSERT(ref_cnt != NULL, ("%s: ref_cnt not provided", __func__));
+
+ atomic_add_int(ref_cnt, 1);
+ m->m_flags |= M_EXT;
+ m->m_ext.ext_buf = buf;
+ m->m_ext.ref_cnt = ref_cnt;
+ m->m_data = m->m_ext.ext_buf;
+ m->m_ext.ext_size = size;
+ m->m_ext.ext_free = freef;
+ m->m_ext.ext_arg1 = arg1;
+ m->m_ext.ext_arg2 = arg2;
+ m->m_ext.ext_type = EXT_EXTREF;
+}
+
static __inline uma_zone_t
m_getzone(int size)
{
More information about the svn-src-all
mailing list