b_vflags update requries bufobj lock

The trunc_dependencies() issue was reported by	Alexander Lochmann
<alexander.lochmann@tu-dortmund.de>, who found the problem by performing
lock analysis using LockDoc, see https://doi.org/10.1145/3302424.3303948.

Tested by:	pho
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
Konstantin Belousov 2021-04-13 13:22:56 +03:00
parent cebcca89f1
commit e3d6759585
2 changed files with 5 additions and 1 deletions

View file

@ -7546,7 +7546,9 @@ trunc_dependencies(ip, freeblks, lastlbn, lastoff, flags)
BO_LOCK(bo);
goto cleanrestart;
}
BO_LOCK(bo);
bp->b_vflags |= BV_SCANNED;
BO_UNLOCK(bo);
bremfree(bp);
if (blkoff != 0) {
allocbuf(bp, blkoff);

View file

@ -321,8 +321,9 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
if (BUF_LOCK(bp,
LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK,
BO_LOCKPTR(bo)) != 0) {
BO_LOCK(bo);
bp->b_vflags &= ~BV_SCANNED;
goto next;
goto next_locked;
}
} else
continue;
@ -385,6 +386,7 @@ ffs_syncvnode(struct vnode *vp, int waitfor, int flags)
* to start from a known point.
*/
BO_LOCK(bo);
next_locked:
nbp = TAILQ_FIRST(&bo->bo_dirty.bv_hd);
}
if (waitfor != MNT_WAIT) {