Author: rmacklem
Date: Wed Jun 10 21:03:57 2009
New Revision: 193952
URL: http://svn.freebsd.org/changeset/base/193952

Log:
  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

Modified:
  head/sys/nfsclient/nfs_bio.c

Modified: head/sys/nfsclient/nfs_bio.c
==============================================================================
--- head/sys/nfsclient/nfs_bio.c        Wed Jun 10 20:59:32 2009        
(r193951)
+++ head/sys/nfsclient/nfs_bio.c        Wed Jun 10 21:03:57 2009        
(r193952)
@@ -389,6 +389,11 @@ nfs_bioread_check_cons(struct vnode *vp,
         * 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 flag
 
        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 flag
        }
 
        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.
         */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to