- 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:
Jeff Roberson 2003-03-13 07:22:53 +00:00
parent 09f11da5a3
commit e99215a614
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=112182

View file

@ -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;
}
}