mirror of
https://github.com/freebsd/freebsd-src
synced 2024-10-19 06:44:31 +00:00
- Remove a dead check for bp->b_vp == vp in vtruncbuf(). This has not been
possible for some time. - Lock the buf before accessing fields. This should very rarely be locked. - Assert that B_DELWRI is set after we acquire the buf. This should always be the case now.
This commit is contained in:
parent
09f11da5a3
commit
e99215a614
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112182
|
@ -1345,21 +1345,24 @@ vtruncbuf(vp, cred, td, length, blksize)
|
|||
restartsync:
|
||||
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
|
||||
nbp = TAILQ_NEXT(bp, b_vnbufs);
|
||||
if ((bp->b_flags & B_DELWRI) && (bp->b_lblkno < 0)) {
|
||||
if (BUF_LOCK(bp,
|
||||
LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK,
|
||||
VI_MTX(vp)) == ENOLCK)
|
||||
goto restart;
|
||||
bremfree(bp);
|
||||
if (bp->b_vp == vp)
|
||||
bp->b_flags |= B_ASYNC;
|
||||
else
|
||||
bp->b_flags &= ~B_ASYNC;
|
||||
|
||||
BUF_WRITE(bp);
|
||||
VI_LOCK(vp);
|
||||
goto restartsync;
|
||||
if (bp->b_lblkno > 0)
|
||||
continue;
|
||||
/*
|
||||
* Since we hold the vnode lock this should only
|
||||
* fail if we're racing with the buf daemon.
|
||||
*/
|
||||
if (BUF_LOCK(bp,
|
||||
LK_EXCLUSIVE | LK_SLEEPFAIL | LK_INTERLOCK,
|
||||
VI_MTX(vp)) == ENOLCK) {
|
||||
goto restart;
|
||||
}
|
||||
KASSERT((bp->b_flags & B_DELWRI),
|
||||
("buf(%p) on dirty queue without DELWRI.", bp));
|
||||
|
||||
bremfree(bp);
|
||||
bawrite(bp);
|
||||
VI_LOCK(vp);
|
||||
goto restartsync;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue