Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 22 Aug 2018 16:32:53 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r338206 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs
Message-ID:  <201808221632.w7MGWrPM070368@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Aug 22 16:32:53 2018
New Revision: 338206
URL: https://svnweb.freebsd.org/changeset/base/338206

Log:
  Add dmu_tx_assign() error handling in zfs_unlinked_drain().
  
  The error handling got lost during r334810, while according to the report
  error there may happen in case of dataset being over quota.  In such case
  just leave the node in the unlinked list to be freed sometimes later.
  
  PR:		229887
  Sponsored by:	iXsystems, Inc.

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

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c	Wed Aug 22 16:27:24 2018	(r338205)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_dir.c	Wed Aug 22 16:32:53 2018	(r338206)
@@ -318,20 +318,27 @@ zfs_unlinked_drain(zfsvfs_t *zfsvfs)
 			continue;
 
 		vn_lock(ZTOV(zp), LK_EXCLUSIVE | LK_RETRY);
-		zp->z_unlinked = B_TRUE;
 #if defined(__FreeBSD__)
 		/*
 		 * Due to changes in zfs_rmnode we need to make sure the
 		 * link count is set to zero here.
 		 */
-		zp->z_links = 0;
-		tx = dmu_tx_create(zfsvfs->z_os);
-		dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
-		VERIFY(0 == dmu_tx_assign(tx, TXG_WAIT));
-		VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_LINKS(zfsvfs),
-		    &zp->z_links, sizeof (zp->z_links), tx));
-		dmu_tx_commit(tx);
+		if (zp->z_links != 0) {
+			tx = dmu_tx_create(zfsvfs->z_os);
+			dmu_tx_hold_sa(tx, zp->z_sa_hdl, B_FALSE);
+			error = dmu_tx_assign(tx, TXG_WAIT);
+			if (error != 0) {
+				dmu_tx_abort(tx);
+				vput(ZTOV(zp));
+				continue;
+			}
+			zp->z_links = 0;
+			VERIFY0(sa_update(zp->z_sa_hdl, SA_ZPL_LINKS(zfsvfs),
+			    &zp->z_links, sizeof (zp->z_links), tx));
+			dmu_tx_commit(tx);
+		}
 #endif
+		zp->z_unlinked = B_TRUE;
 		vput(ZTOV(zp));
 	}
 	zap_cursor_fini(&zc);



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