diff options
author | kmacy <kmacy@FreeBSD.org> | 2007-04-04 21:27:01 +0000 |
---|---|---|
committer | kmacy <kmacy@FreeBSD.org> | 2007-04-04 21:27:01 +0000 |
commit | 3daa1603f79fbbe86aab06441508614bb5fadde5 (patch) | |
tree | d7b885c5f5f4ac512538e687c91f06aa3c425993 /sys/kern/kern_mbuf.c | |
parent | 905a5d05e0cdcf6fb8ff5e1c725bad84cb4f07db (diff) | |
download | FreeBSD-src-3daa1603f79fbbe86aab06441508614bb5fadde5.zip FreeBSD-src-3daa1603f79fbbe86aab06441508614bb5fadde5.tar.gz |
Fix mb_ctor_clust and mb_dtor_clust to reference the appropriate zone,
simplify setting refcnt
Reviewed by: andre, rwatson, and glebius
MFC after: 3 days
Diffstat (limited to 'sys/kern/kern_mbuf.c')
-rw-r--r-- | sys/kern/kern_mbuf.c | 66 |
1 files changed, 37 insertions, 29 deletions
diff --git a/sys/kern/kern_mbuf.c b/sys/kern/kern_mbuf.c index 3934965..5f4882d 100644 --- a/sys/kern/kern_mbuf.c +++ b/sys/kern/kern_mbuf.c @@ -395,32 +395,40 @@ mb_ctor_clust(void *mem, int size, void *arg, int how) { struct mbuf *m; u_int *refcnt; - int type = 0; - + int type; + uma_zone_t zone; + #ifdef INVARIANTS trash_ctor(mem, size, arg, how); #endif - m = (struct mbuf *)arg; - if (m != NULL) { - switch (size) { - case MCLBYTES: - type = EXT_CLUSTER; - break; + switch (size) { + case MCLBYTES: + type = EXT_CLUSTER; + zone = zone_clust; + break; #if MJUMPAGESIZE != MCLBYTES - case MJUMPAGESIZE: - type = EXT_JUMBOP; - break; + case MJUMPAGESIZE: + type = EXT_JUMBOP; + zone = zone_jumbop; + break; #endif - case MJUM9BYTES: - type = EXT_JUMBO9; - break; - case MJUM16BYTES: - type = EXT_JUMBO16; - break; - default: - panic("unknown cluster size"); - break; - } + case MJUM9BYTES: + type = EXT_JUMBO9; + zone = zone_jumbo9; + break; + case MJUM16BYTES: + type = EXT_JUMBO16; + zone = zone_jumbo16; + break; + default: + panic("unknown cluster size"); + break; + } + + m = (struct mbuf *)arg; + refcnt = uma_find_refcnt(zone, mem); + *refcnt = 1; + if (m != NULL) { m->m_ext.ext_buf = (caddr_t)mem; m->m_data = m->m_ext.ext_buf; m->m_flags |= M_EXT; @@ -428,12 +436,9 @@ mb_ctor_clust(void *mem, int size, void *arg, int how) m->m_ext.ext_args = NULL; m->m_ext.ext_size = size; m->m_ext.ext_type = type; - m->m_ext.ref_cnt = uma_find_refcnt(zone_clust, mem); - *m->m_ext.ref_cnt = 1; - } else { - refcnt = uma_find_refcnt(zone_clust, mem); - *refcnt = 1; + m->m_ext.ref_cnt = refcnt; } + return (0); } @@ -443,11 +448,14 @@ mb_ctor_clust(void *mem, int size, void *arg, int how) static void mb_dtor_clust(void *mem, int size, void *arg) { +#ifdef INVARIANTS + uma_zone_t zone; - KASSERT(*(uma_find_refcnt(zone_clust, mem)) <= 1, + zone = m_getzone(size); + KASSERT(*(uma_find_refcnt(zone, mem)) <= 1, ("%s: refcnt incorrect %u", __func__, - *(uma_find_refcnt(zone_clust, mem))) ); -#ifdef INVARIANTS + *(uma_find_refcnt(zone, mem))) ); + trash_dtor(mem, size, arg); #endif } |