svn commit: r364189 - stable/12/sys/kern
Mark Johnston
markj at FreeBSD.org
Thu Aug 13 13:59:32 UTC 2020
Author: markj
Date: Thu Aug 13 13:59:31 2020
New Revision: 364189
URL: https://svnweb.freebsd.org/changeset/base/364189
Log:
MFC r363960:
Clean up reassignbuf() and buf_vlist_remove() a bit.
Modified:
stable/12/sys/kern/vfs_subr.c
Directory Properties:
stable/12/ (props changed)
Modified: stable/12/sys/kern/vfs_subr.c
==============================================================================
--- stable/12/sys/kern/vfs_subr.c Thu Aug 13 13:58:21 2020 (r364188)
+++ stable/12/sys/kern/vfs_subr.c Thu Aug 13 13:59:31 2020 (r364189)
@@ -2089,13 +2089,17 @@ static void
buf_vlist_remove(struct buf *bp)
{
struct bufv *bv;
+ b_xflags_t flags;
+ flags = bp->b_xflags;
+
KASSERT(bp->b_bufobj != NULL, ("No b_bufobj %p", bp));
ASSERT_BO_WLOCKED(bp->b_bufobj);
- KASSERT((bp->b_xflags & (BX_VNDIRTY|BX_VNCLEAN)) !=
- (BX_VNDIRTY|BX_VNCLEAN),
- ("buf_vlist_remove: Buf %p is on two lists", bp));
- if (bp->b_xflags & BX_VNDIRTY)
+ KASSERT((flags & (BX_VNDIRTY | BX_VNCLEAN)) != 0 &&
+ (flags & (BX_VNDIRTY | BX_VNCLEAN)) != (BX_VNDIRTY | BX_VNCLEAN),
+ ("%s: buffer %p has invalid queue state", __func__, bp));
+
+ if ((flags & BX_VNDIRTY) != 0)
bv = &bp->b_bufobj->bo_dirty;
else
bv = &bp->b_bufobj->bo_clean;
@@ -2204,10 +2208,7 @@ brelvp(struct buf *bp)
vp = bp->b_vp; /* XXX */
bo = bp->b_bufobj;
BO_LOCK(bo);
- if (bp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN))
- buf_vlist_remove(bp);
- else
- panic("brelvp: Buffer %p not on queue.", bp);
+ buf_vlist_remove(bp);
if ((bo->bo_flag & BO_ONWORKLST) && bo->bo_dirty.bv_cnt == 0) {
bo->bo_flag &= ~BO_ONWORKLST;
mtx_lock(&sync_mtx);
@@ -2519,9 +2520,7 @@ syncer_resume(void)
}
/*
- * Reassign a buffer from one vnode to another.
- * Used to assign file specific control information
- * (indirect blocks) to the vnode to which they belong.
+ * Move the buffer between the clean and dirty lists of its vnode.
*/
void
reassignbuf(struct buf *bp)
@@ -2536,23 +2535,15 @@ reassignbuf(struct buf *bp)
vp = bp->b_vp;
bo = bp->b_bufobj;
+ KASSERT((bp->b_flags & B_PAGING) == 0,
+ ("%s: cannot reassign paging buffer %p", __func__, bp));
+
CTR3(KTR_BUF, "reassignbuf(%p) vp %p flags %X",
bp, bp->b_vp, bp->b_flags);
- /*
- * B_PAGING flagged buffers cannot be reassigned because their vp
- * is not fully linked in.
- */
- if (bp->b_flags & B_PAGING)
- panic("cannot reassign paging buffer");
- /*
- * Delete from old vnode list, if on one.
- */
BO_LOCK(bo);
- if (bp->b_xflags & (BX_VNDIRTY | BX_VNCLEAN))
- buf_vlist_remove(bp);
- else
- panic("reassignbuf: Buffer %p not on queue.", bp);
+ buf_vlist_remove(bp);
+
/*
* If dirty, put on list of dirty buffers; otherwise insert onto list
* of clean buffers.
More information about the svn-src-all
mailing list