diff options
author | Rick Macklem <rmacklem@FreeBSD.org> | 2009-06-10 21:03:57 +0000 |
---|---|---|
committer | Rick Macklem <rmacklem@FreeBSD.org> | 2009-06-10 21:03:57 +0000 |
commit | 5081c8c75792481b2f4e7976077420c1579c644f (patch) | |
tree | 0877b75b866537a3c19b67f77201fdd3883774cf /sys/nfsclient/nfs_bio.c | |
parent | d8b0556c6dcaf4c506039f86af2b52b29524f89e (diff) | |
download | src-5081c8c75792481b2f4e7976077420c1579c644f.tar.gz src-5081c8c75792481b2f4e7976077420c1579c644f.zip |
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
Notes
Notes:
svn path=/head/; revision=193952
Diffstat (limited to 'sys/nfsclient/nfs_bio.c')
-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 ae8a05d7ab95..4b6096a00030 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. */ |