Add a test for VI_DOOMED just after nfs_upgrade_vnlock() in

nfs_bioread_check_cons(). This is required since it is possible
for the vnode to be vgonel()'d while in nfs_upgrade_vnlock() when
a forced dismount is in progress. Also, move the check for VI_DOOMED
in nfs_vinvalbuf() down to after nfs_upgrade_vnlock() and replace the
out of date comment for it.

Submitted by:	jhb
Tested by:	pho
Approved by:	kib (mentor)
MFC after:	1 month
This commit is contained in:
Rick Macklem 2009-06-10 21:03:57 +00:00
parent d8b0556c6d
commit 5081c8c757
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=193952

View File

@ -389,6 +389,11 @@ nfs_bioread_check_cons(struct vnode *vp, struct thread *td, struct ucred *cred)
* But for now, this suffices.
*/
old_lock = nfs_upgrade_vnlock(vp);
if (vp->v_iflag & VI_DOOMED) {
nfs_downgrade_vnlock(vp, old_lock);
return (EBADF);
}
mtx_lock(&np->n_mtx);
if (np->n_flag & NMODIFIED) {
mtx_unlock(&np->n_mtx);
@ -1289,14 +1294,6 @@ nfs_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg)
ASSERT_VOP_LOCKED(vp, "nfs_vinvalbuf");
/*
* XXX This check stops us from needlessly doing a vinvalbuf when
* being called through vclean(). It is not clear that this is
* unsafe.
*/
if (vp->v_iflag & VI_DOOMED)
return (0);
if ((nmp->nm_flag & NFSMNT_INT) == 0)
intrflg = 0;
if (intrflg) {
@ -1308,6 +1305,16 @@ nfs_vinvalbuf(struct vnode *vp, int flags, struct thread *td, int intrflg)
}
old_lock = nfs_upgrade_vnlock(vp);
if (vp->v_iflag & VI_DOOMED) {
/*
* Since vgonel() uses the generic vinvalbuf() to flush
* dirty buffers and it does not call this function, it
* is safe to just return OK when VI_DOOMED is set.
*/
nfs_downgrade_vnlock(vp, old_lock);
return (0);
}
/*
* Now, flush as required.
*/