Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Aug 2020 19:36:08 +0000 (UTC)
From:      Mateusz Guzik <mjg@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r364042 - head/sys/kern
Message-ID:  <202008071936.077Ja831056734@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
 	}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202008071936.077Ja831056734>