Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 10 Oct 2018 19:39:47 +0000 (UTC)
From:      Allan Jude <allanjude@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r339289 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201810101939.w9AJdldw032309@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: allanjude
Date: Wed Oct 10 19:39:47 2018
New Revision: 339289
URL: https://svnweb.freebsd.org/changeset/base/339289

Log:
  Resolve a hang in ZFS during vnode reclaimation
  
  This is caused by a deadlock between zil_commit() and zfs_zget()
  
  Add a way for zfs_zget() to break out of the retry loop in the common case
  
  PR:		229614
  Reported by:	grembo, Andreas Sommer, many others
  Tested by:	Andreas Sommer, Vicki Pfau
  Reviewed by:	avg (no objection)
  Approved by:	re (gjb)
  MFC after:	2 months
  Sponsored by:	Klara Systems
  Differential Revision:	https://reviews.freebsd.org/D17460

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	Wed Oct 10 16:34:53 2018	(r339288)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c	Wed Oct 10 19:39:47 2018	(r339289)
@@ -1165,15 +1165,27 @@ again:
 		 */
 		ASSERT3P(zp, !=, NULL);
 		ASSERT3U(zp->z_id, ==, obj_num);
-		*zpp = zp;
-		vp = ZTOV(zp);
+		if (zp->z_unlinked) {
+			err = SET_ERROR(ENOENT);
+		} else {
+			vp = ZTOV(zp);
+			/*
+			 * Don't let the vnode disappear after
+			 * ZFS_OBJ_HOLD_EXIT.
+			 */
+			VN_HOLD(vp);
+			*zpp = zp;
+			err = 0;
+		}
 
-		/* Don't let the vnode disappear after ZFS_OBJ_HOLD_EXIT. */
-		VN_HOLD(vp);
-
 		sa_buf_rele(db, NULL);
 		ZFS_OBJ_HOLD_EXIT(zfsvfs, obj_num);
 
+		if (err) {
+			getnewvnode_drop_reserve();
+			return (err);
+		}
+
 		locked = VOP_ISLOCKED(vp);
 		VI_LOCK(vp);
 		if ((vp->v_iflag & VI_DOOMED) != 0 &&
@@ -1206,7 +1218,7 @@ again:
 		}
 		VI_UNLOCK(vp);
 		getnewvnode_drop_reserve();
-		return (0);
+		return (err);
 	}
 
 	/*



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