From 6809658d1c9ca4eeca1cc691f6104b6ac431e296 Mon Sep 17 00:00:00 2001 From: phk Date: Mon, 15 Nov 2004 08:47:18 +0000 Subject: Add pbgetbo()/pbrelbo() lighter weight versions of pbgetvp()/pbrelvp(). --- sys/vm/vm_pager.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'sys/vm') diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index a8d061a..87f74d8 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -442,6 +442,24 @@ pbgetvp(struct vnode *vp, struct buf *bp) } /* + * Associate a p-buffer with a vnode. + * + * Also sets B_PAGING flag to indicate that vnode is not fully associated + * with the buffer. i.e. the bp has not been linked into the vnode or + * ref-counted. + */ +void +pbgetbo(struct bufobj *bo, struct buf *bp) +{ + + KASSERT(bp->b_vp == NULL, ("pbgetbo: not free (vnode)")); + KASSERT(bp->b_bufobj == NULL, ("pbgetbo: not free (bufobj)")); + + bp->b_flags |= B_PAGING; + bp->b_bufobj = bo; +} + +/* * Disassociate a p-buffer from a vnode. */ void @@ -465,3 +483,27 @@ pbrelvp(struct buf *bp) bp->b_bufobj = NULL; bp->b_flags &= ~B_PAGING; } + +/* + * Disassociate a p-buffer from a bufobj. + */ +void +pbrelbo(struct buf *bp) +{ + + KASSERT(bp->b_vp == NULL, ("pbrelbo: vnode")); + KASSERT(bp->b_bufobj != NULL, ("pbrelbo: NULL bufobj")); + + /* XXX REMOVE ME */ + BO_LOCK(bp->b_bufobj); + if (TAILQ_NEXT(bp, b_bobufs) != NULL) { + panic( + "relpbuf(): b_vp was probably reassignbuf()d %p %x", + bp, + (int)bp->b_flags + ); + } + BO_UNLOCK(bp->b_bufobj); + bp->b_bufobj = NULL; + bp->b_flags &= ~B_PAGING; +} -- cgit v1.1