Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 29 Aug 2013 23:46:39 +0000 (UTC)
From:      Navdeep Parhar <np@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255047 - head/sys/sys
Message-ID:  <201308292346.r7TNkde1085558@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201308292346.r7TNkde1085558>