Deleted Added
full compact
uipc_mbuf.c (169624) uipc_mbuf.c (172463)
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1982, 1986, 1988, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 16 unchanged lines hidden (view full) ---

25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)uipc_mbuf.c 8.2 (Berkeley) 1/4/94
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 169624 2007-05-16 20:41:08Z rwatson $");
33__FBSDID("$FreeBSD: head/sys/kern/uipc_mbuf.c 172463 2007-10-06 21:42:39Z kmacy $");
34
35#include "opt_mac.h"
36#include "opt_param.h"
37#include "opt_mbuf_stress_test.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>

--- 164 unchanged lines hidden (view full) ---

206
207/*
208 * Non-directly-exported function to clean up after mbufs with M_EXT
209 * storage attached to them if the reference count hits 1.
210 */
211void
212mb_free_ext(struct mbuf *m)
213{
34
35#include "opt_mac.h"
36#include "opt_param.h"
37#include "opt_mbuf_stress_test.h"
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/kernel.h>

--- 164 unchanged lines hidden (view full) ---

206
207/*
208 * Non-directly-exported function to clean up after mbufs with M_EXT
209 * storage attached to them if the reference count hits 1.
210 */
211void
212mb_free_ext(struct mbuf *m)
213{
214 int skipmbuf;
215
214 KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__));
215 KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__));
216
216 KASSERT((m->m_flags & M_EXT) == M_EXT, ("%s: M_EXT not set", __func__));
217 KASSERT(m->m_ext.ref_cnt != NULL, ("%s: ref_cnt not set", __func__));
218
219
220 /*
221 * check if the header is embedded in the cluster
222 */
223 skipmbuf = (m->m_flags & M_NOFREE);
224
217 /* Free attached storage if this mbuf is the only reference to it. */
218 if (*(m->m_ext.ref_cnt) == 1 ||
219 atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
220 switch (m->m_ext.ext_type) {
221 case EXT_PACKET: /* The packet zone is special. */
222 if (*(m->m_ext.ref_cnt) == 0)
223 *(m->m_ext.ref_cnt) = 1;
224 uma_zfree(zone_pack, m);

--- 24 unchanged lines hidden (view full) ---

249 (*(m->m_ext.ext_free))(m->m_ext.ext_buf,
250 m->m_ext.ext_args);
251 break;
252 default:
253 KASSERT(m->m_ext.ext_type == 0,
254 ("%s: unknown ext_type", __func__));
255 }
256 }
225 /* Free attached storage if this mbuf is the only reference to it. */
226 if (*(m->m_ext.ref_cnt) == 1 ||
227 atomic_fetchadd_int(m->m_ext.ref_cnt, -1) == 1) {
228 switch (m->m_ext.ext_type) {
229 case EXT_PACKET: /* The packet zone is special. */
230 if (*(m->m_ext.ref_cnt) == 0)
231 *(m->m_ext.ref_cnt) = 1;
232 uma_zfree(zone_pack, m);

--- 24 unchanged lines hidden (view full) ---

257 (*(m->m_ext.ext_free))(m->m_ext.ext_buf,
258 m->m_ext.ext_args);
259 break;
260 default:
261 KASSERT(m->m_ext.ext_type == 0,
262 ("%s: unknown ext_type", __func__));
263 }
264 }
265 if (skipmbuf)
266 return;
267
257 /*
258 * Free this mbuf back to the mbuf zone with all m_ext
259 * information purged.
260 */
261 m->m_ext.ext_buf = NULL;
262 m->m_ext.ext_free = NULL;
263 m->m_ext.ext_args = NULL;
264 m->m_ext.ref_cnt = NULL;

--- 1576 unchanged lines hidden ---
268 /*
269 * Free this mbuf back to the mbuf zone with all m_ext
270 * information purged.
271 */
272 m->m_ext.ext_buf = NULL;
273 m->m_ext.ext_free = NULL;
274 m->m_ext.ext_args = NULL;
275 m->m_ext.ref_cnt = NULL;

--- 1576 unchanged lines hidden ---