Add pbgetbo()/pbrelbo() lighter weight versions of pbgetvp()/pbrelvp().

This commit is contained in:
Poul-Henning Kamp 2004-11-15 08:47:18 +00:00
parent ce664eaf8e
commit 5c6e573ffb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=137725
2 changed files with 44 additions and 0 deletions

View File

@ -519,7 +519,9 @@ void vunmapbuf(struct buf *);
void relpbuf(struct buf *, int *);
void brelvp(struct buf *);
void bgetvp(struct vnode *, struct buf *);
void pbgetbo(struct bufobj *bo, struct buf *bp);
void pbgetvp(struct vnode *, struct buf *);
void pbrelbo(struct buf *);
void pbrelvp(struct buf *);
int allocbuf(struct buf *bp, int size);
void reassignbuf(struct buf *);

View File

@ -441,6 +441,24 @@ pbgetvp(struct vnode *vp, struct buf *bp)
bp->b_bufobj = &vp->v_bufobj;
}
/*
* 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.
*/
@ -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;
}