Date: Wed, 7 May 2014 03:06:50 +0000 (UTC) From: Navdeep Parhar <np@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r265479 - stable/9/sys/sys Message-ID: <201405070306.s4736oX8096886@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: np Date: Wed May 7 03:06:50 2014 New Revision: 265479 URL: http://svnweb.freebsd.org/changeset/base/265479 Log: MFC r255047 (with a manual tweak to match the ext_free in stable/9): 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: stable/9/sys/sys/mbuf.h Directory Properties: stable/9/sys/ (props changed) stable/9/sys/sys/ (props changed) Modified: stable/9/sys/sys/mbuf.h ============================================================================== --- stable/9/sys/sys/mbuf.h Wed May 7 02:13:55 2014 (r265478) +++ stable/9/sys/sys/mbuf.h Wed May 7 03:06:50 2014 (r265479) @@ -450,6 +450,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, + void (*freef)(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?201405070306.s4736oX8096886>