In nfs_flush(), clear the NMODIFIED bit only if there are no dirty

buffers *and* there are no buffers queued up for writing.  The bug
was that NMODIFIED was being cleared even while there were buffers
scheduled to be written out, which leads to all sorts of interesting
bugs - one where the file could shrink (because of a post-op getattr
load, say) causing data in buffer(s) queued for write to be tossed,
resulting in data corruption.

Submitted by:	Mohan Srinivasan
This commit is contained in:
Paul Saab 2005-11-03 07:42:15 +00:00
parent 6e7a7ba194
commit 41ce2892bb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152000

View File

@ -2881,7 +2881,8 @@ nfs_flush(struct vnode *vp, int waitfor, struct thread *td,
error = np->n_error;
np->n_flag &= ~NWRITEERR;
}
if (commit && vp->v_bufobj.bo_dirty.bv_cnt == 0)
if (commit && vp->v_bufobj.bo_dirty.bv_cnt == 0 &&
vp->v_bufobj.bo_numoutput == 0)
np->n_flag &= ~NMODIFIED;
done:
if (bvec != NULL && bvec != bvec_on_stack)