Author: mjg
Date: Fri Aug  7 19:36:08 2020
New Revision: 364042
URL: https://svnweb.freebsd.org/changeset/base/364042

Log:
  vfs: release the interlock after failing to set VHOLD_NO_SMR
  
  While here add more comments.
  
  Diagnosed by: markj
  Reported by:  pho
  Fixes:        r362827 ("vfs: protect vnodes with smr")

Modified:
  head/sys/kern/vfs_subr.c

Modified: head/sys/kern/vfs_subr.c
==============================================================================
--- head/sys/kern/vfs_subr.c    Fri Aug  7 19:33:54 2020        (r364041)
+++ head/sys/kern/vfs_subr.c    Fri Aug  7 19:36:08 2020        (r364042)
@@ -3683,19 +3683,24 @@ vdropl(struct vnode *vp)
        }
        if (!VN_IS_DOOMED(vp)) {
                vdrop_deactivate(vp);
+               /*
+                * Also unlocks the interlock. We can't assert on it as we
+                * released our hold and by now the vnode might have been
+                * freed.
+                */
                return;
        }
        /*
-        * We may be racing against vhold_smr.
+        * Set the VHOLD_NO_SMR flag.
         *
-        * If they win we can just pretend we never got this far, they will
-        * vdrop later.
+        * We may be racing against vhold_smr. If they win we can just pretend
+        * we never got this far, they will vdrop later.
         */
        if (!atomic_cmpset_int(&vp->v_holdcnt, 0, VHOLD_NO_SMR)) {
+               VI_UNLOCK(vp);
                /*
-                * We lost the aforementioned race. Note that any subsequent
-                * access is invalid as they might have managed to vdropl on
-                * their own.
+                * We lost the aforementioned race. Any subsequent access is
+                * invalid as they might have managed to vdropl on their own.
                 */
                return;
        }
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to