mirror of
https://git.FreeBSD.org/src.git
synced 2024-11-22 07:20:00 +00:00
Make MBUF_EXT_PGS_ASSERT_SANITY() a macro, so that it prints file:line.
While here, stop using struct mbuf_ext_pgs. Reviewed by: gallatin Differential Revision: https://reviews.freebsd.org/D24598
This commit is contained in:
parent
6fbcdeb6f1
commit
b363a438b1
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=360577
@ -1145,40 +1145,6 @@ mb_alloc_ext_pgs(int how, m_ext_free_t ext_free)
|
||||
return (m);
|
||||
}
|
||||
|
||||
#ifdef INVARIANT_SUPPORT
|
||||
void
|
||||
mb_ext_pgs_check(struct mbuf *m)
|
||||
{
|
||||
struct mbuf_ext_pgs *ext_pgs = &m->m_ext_pgs;
|
||||
|
||||
/*
|
||||
* NB: This expects a non-empty buffer (npgs > 0 and
|
||||
* last_pg_len > 0).
|
||||
*/
|
||||
KASSERT(ext_pgs->npgs > 0,
|
||||
("ext_pgs with no valid pages: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->npgs <= nitems(m->m_epg_pa),
|
||||
("ext_pgs with too many pages: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->nrdy <= ext_pgs->npgs,
|
||||
("ext_pgs with too many ready pages: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->first_pg_off < PAGE_SIZE,
|
||||
("ext_pgs with too large page offset: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->last_pg_len > 0,
|
||||
("ext_pgs with zero last page length: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->last_pg_len <= PAGE_SIZE,
|
||||
("ext_pgs with too large last page length: %p", ext_pgs));
|
||||
if (ext_pgs->npgs == 1) {
|
||||
KASSERT(ext_pgs->first_pg_off + ext_pgs->last_pg_len <=
|
||||
PAGE_SIZE, ("ext_pgs with single page too large: %p",
|
||||
ext_pgs));
|
||||
}
|
||||
KASSERT(ext_pgs->hdr_len <= sizeof(m->m_epg_hdr),
|
||||
("ext_pgs with too large header length: %p", ext_pgs));
|
||||
KASSERT(ext_pgs->trail_len <= sizeof(m->m_epg_trail),
|
||||
("ext_pgs with too large header length: %p", ext_pgs));
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Clean up after mbufs with M_EXT storage attached to them if the
|
||||
* reference count hits 1.
|
||||
|
@ -401,13 +401,36 @@ m_epg_pagelen(const struct mbuf *m, int pidx, int pgoff)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef INVARIANT_SUPPORT
|
||||
void mb_ext_pgs_check(struct mbuf *m);
|
||||
#endif
|
||||
#ifdef INVARIANTS
|
||||
#define MBUF_EXT_PGS_ASSERT_SANITY(m) mb_ext_pgs_check((m))
|
||||
#define MCHECK(ex, msg) KASSERT((ex), \
|
||||
("Multi page mbuf %p with " #msg " at %s:%d", \
|
||||
m, __FILE__, __LINE__))
|
||||
/*
|
||||
* NB: This expects a non-empty buffer (npgs > 0 and
|
||||
* last_pg_len > 0).
|
||||
*/
|
||||
#define MBUF_EXT_PGS_ASSERT_SANITY(m) do { \
|
||||
MCHECK(m->m_ext_pgs.npgs > 0, "no valid pages"); \
|
||||
MCHECK(m->m_ext_pgs.npgs <= nitems(m->m_epg_pa), \
|
||||
"too many pages"); \
|
||||
MCHECK(m->m_ext_pgs.nrdy <= m->m_ext_pgs.npgs, \
|
||||
"too many ready pages"); \
|
||||
MCHECK(m->m_ext_pgs.first_pg_off < PAGE_SIZE, \
|
||||
"too large page offset"); \
|
||||
MCHECK(m->m_ext_pgs.last_pg_len > 0, "zero last page length"); \
|
||||
MCHECK(m->m_ext_pgs.last_pg_len <= PAGE_SIZE, \
|
||||
"too large last page length"); \
|
||||
if (m->m_ext_pgs.npgs == 1) \
|
||||
MCHECK(m->m_ext_pgs.first_pg_off + \
|
||||
m->m_ext_pgs.last_pg_len <= PAGE_SIZE, \
|
||||
"single page too large"); \
|
||||
MCHECK(m->m_ext_pgs.hdr_len <= sizeof(m->m_epg_hdr), \
|
||||
"too large header length"); \
|
||||
MCHECK(m->m_ext_pgs.trail_len <= sizeof(m->m_epg_trail), \
|
||||
"too large header length"); \
|
||||
} while (0)
|
||||
#else
|
||||
#define MBUF_EXT_PGS_ASSERT_SANITY(m)
|
||||
#define MBUF_EXT_PGS_ASSERT_SANITY(m) do {} while (0);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user