git: ff2263469ad0 - main - Revert "vfs_subr: optimize inval_buf_range"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 10 Oct 2024 10:46:05 UTC
The branch main has been updated by dougm: URL: https://cgit.FreeBSD.org/src/commit/?id=ff2263469ad0f304b2e5f44f1a62c9b20c0306a3 commit ff2263469ad0f304b2e5f44f1a62c9b20c0306a3 Author: Doug Moore <dougm@FreeBSD.org> AuthorDate: 2024-10-10 10:43:40 +0000 Commit: Doug Moore <dougm@FreeBSD.org> CommitDate: 2024-10-10 10:45:43 +0000 Revert "vfs_subr: optimize inval_buf_range" @pho has reported that this change leads to a failure of the mmap28.sh stress test, and I have confirmed it, so I withdraw it for further study. This reverts commit af4cd5e7b5b50502922b5d2bb42daa7fc66545bb. --- sys/kern/vfs_subr.c | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/sys/kern/vfs_subr.c b/sys/kern/vfs_subr.c index 328507efd1fd..f192c6798858 100644 --- a/sys/kern/vfs_subr.c +++ b/sys/kern/vfs_subr.c @@ -2616,24 +2616,17 @@ static int v_inval_buf_range_locked(struct vnode *vp, struct bufobj *bo, daddr_t startlbn, daddr_t endlbn) { - struct bufv *bv; struct buf *bp, *nbp; - uint8_t anyfreed; - bool clean; + bool anyfreed; ASSERT_VOP_LOCKED(vp, "v_inval_buf_range_locked"); ASSERT_BO_LOCKED(bo); - anyfreed = 1; - clean = true; do { - bv = clean ? &bo->bo_clean : &bo->bo_dirty; - bp = BUF_PCTRIE_LOOKUP_GE(&bv->bv_root, startlbn); - if (bp == NULL) - continue; - TAILQ_FOREACH_FROM_SAFE(bp, &bv->bv_hd, b_bobufs, nbp) { - if (bp->b_lblkno >= endlbn) - break; + anyfreed = false; + TAILQ_FOREACH_SAFE(bp, &bo->bo_clean.bv_hd, b_bobufs, nbp) { + if (bp->b_lblkno < startlbn || bp->b_lblkno >= endlbn) + continue; if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, BO_LOCKPTR(bo)) == ENOLCK) { @@ -2645,17 +2638,39 @@ v_inval_buf_range_locked(struct vnode *vp, struct bufobj *bo, bp->b_flags |= B_INVAL | B_RELBUF; bp->b_flags &= ~B_ASYNC; brelse(bp); - anyfreed = 2; + anyfreed = true; BO_LOCK(bo); if (nbp != NULL && - (((nbp->b_xflags & - (clean ? BX_VNCLEAN : BX_VNDIRTY)) == 0) || + (((nbp->b_xflags & BX_VNCLEAN) == 0) || nbp->b_vp != vp || - (nbp->b_flags & B_DELWRI) == (clean? B_DELWRI: 0))) + (nbp->b_flags & B_DELWRI) != 0)) + return (EAGAIN); + } + + TAILQ_FOREACH_SAFE(bp, &bo->bo_dirty.bv_hd, b_bobufs, nbp) { + if (bp->b_lblkno < startlbn || bp->b_lblkno >= endlbn) + continue; + if (BUF_LOCK(bp, + LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK, + BO_LOCKPTR(bo)) == ENOLCK) { + BO_LOCK(bo); + return (EAGAIN); + } + bremfree(bp); + bp->b_flags |= B_INVAL | B_RELBUF; + bp->b_flags &= ~B_ASYNC; + brelse(bp); + anyfreed = true; + + BO_LOCK(bo); + if (nbp != NULL && + (((nbp->b_xflags & BX_VNDIRTY) == 0) || + (nbp->b_vp != vp) || + (nbp->b_flags & B_DELWRI) == 0)) return (EAGAIN); } - } while (clean = !clean, anyfreed-- > 0); + } while (anyfreed); return (0); }