- Lock the buf before inspecting its contents.

This commit is contained in:
jeff 2003-03-13 07:04:11 +00:00
parent dc2fc01c02
commit 4b8b33db8a

View File

@ -2658,18 +2658,16 @@ nfs_flush(struct vnode *vp, struct ucred *cred, int waitfor, struct thread *td,
for (bp = TAILQ_FIRST(&vp->v_dirtyblkhd); bp; bp = nbp) {
if (bvecpos >= bvecsize)
break;
if (BUF_LOCK(bp, LK_EXCLUSIVE | LK_NOWAIT, NULL)) {
nbp = TAILQ_NEXT(bp, b_vnbufs);
continue;
}
if ((bp->b_flags & (B_DELWRI | B_NEEDCOMMIT)) !=
(B_DELWRI | B_NEEDCOMMIT)) {
nbp = TAILQ_NEXT(bp, b_vnbufs);
continue;
}
if (BUF_LOCK(bp,
LK_EXCLUSIVE | LK_NOWAIT | LK_INTERLOCK,
VI_MTX(vp))) {
VI_LOCK(vp);
nbp = TAILQ_NEXT(bp, b_vnbufs);
continue;
}
VI_UNLOCK(vp);
bremfree(bp);
/*
* Work out if all buffers are using the same cred