svn commit: r329379 - stable/11/sys/kern

Mateusz Guzik mjg at FreeBSD.org
Fri Feb 16 16:05:03 UTC 2018


Author: mjg
Date: Fri Feb 16 16:05:02 2018
New Revision: 329379
URL: https://svnweb.freebsd.org/changeset/base/329379

Log:
  MFC r327874:
  
      vfs: tidy up vdrop
  
      Skip vfs_refcount_release_if_not_last if the interlock is held and just
      go straight to refcount_release.
  
      While here do cosmetic rearrangement of _vhold to better show it contains
      equivalent behaviour.

Modified:
  stable/11/sys/kern/vfs_subr.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/kern/vfs_subr.c
==============================================================================
--- stable/11/sys/kern/vfs_subr.c	Fri Feb 16 16:01:39 2018	(r329378)
+++ stable/11/sys/kern/vfs_subr.c	Fri Feb 16 16:05:02 2018	(r329379)
@@ -2769,14 +2769,14 @@ _vhold(struct vnode *vp, bool locked)
 	else
 		ASSERT_VI_UNLOCKED(vp, __func__);
 	CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
-	if (!locked && vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
-		VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
-		    ("_vhold: vnode with holdcnt is free"));
-		return;
-	}
-
-	if (!locked)
+	if (!locked) {
+		if (vfs_refcount_acquire_if_not_zero(&vp->v_holdcnt)) {
+			VNASSERT((vp->v_iflag & VI_FREE) == 0, vp,
+			    ("_vhold: vnode with holdcnt is free"));
+			return;
+		}
 		VI_LOCK(vp);
+	}
 	if ((vp->v_iflag & VI_FREE) == 0) {
 		refcount_acquire(&vp->v_holdcnt);
 		if (!locked)
@@ -2830,14 +2830,11 @@ _vdrop(struct vnode *vp, bool locked)
 	CTR2(KTR_VFS, "%s: vp %p", __func__, vp);
 	if ((int)vp->v_holdcnt <= 0)
 		panic("vdrop: holdcnt %d", vp->v_holdcnt);
-	if (vfs_refcount_release_if_not_last(&vp->v_holdcnt)) {
-		if (locked)
-			VI_UNLOCK(vp);
-		return;
-	}
-
-	if (!locked)
+	if (!locked) {
+		if (vfs_refcount_release_if_not_last(&vp->v_holdcnt))
+			return;
 		VI_LOCK(vp);
+	}
 	if (refcount_release(&vp->v_holdcnt) == 0) {
 		VI_UNLOCK(vp);
 		return;


More information about the svn-src-all mailing list