diff options
author | rmacklem <rmacklem@FreeBSD.org> | 2009-06-10 21:03:57 +0000 |
---|---|---|
committer | rmacklem <rmacklem@FreeBSD.org> | 2009-06-10 21:03:57 +0000 |
commit | 3d458aebb237ed48284381415d395204842369a0 (patch) | |
tree | 0877b75b866537a3c19b67f77201fdd3883774cf | |
parent | e1cb2941d4424de90eb68716d6c4d95f4c0af0ba (diff) | |
download | FreeBSD-src-3d458aebb237ed48284381415d395204842369a0.zip FreeBSD-src-3d458aebb237ed48284381415d395204842369a0.tar.gz |
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
-rw-r--r-- | sys/nfsclient/nfs_bio.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index ae8a05d..4b6096a 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -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. */ |