6915532 snapshot related activity causes akd to hang
authorSanjeev Bagewadi <Sanjeev.Bagewadi@Sun.COM>
Fri, 19 Feb 2010 12:12:39 +0530
changeset 11701 6f890435df16
parent 11700 2329cb77b47a
child 11702 ed2d662c5135
6915532 snapshot related activity causes akd to hang
usr/src/uts/common/fs/zfs/dsl_dataset.c
--- a/usr/src/uts/common/fs/zfs/dsl_dataset.c	Thu Feb 18 22:15:23 2010 -0800
+++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c	Fri Feb 19 12:12:39 2010 +0530
@@ -2314,12 +2314,7 @@
 	err = dsl_dir_open(oldname, FTAG, &dd, &tail);
 	if (err)
 		return (err);
-	/*
-	 * If there are more than 2 references there may be holds
-	 * hanging around that haven't been cleared out yet.
-	 */
-	if (dmu_buf_refcount(dd->dd_dbuf) > 2)
-		txg_wait_synced(dd->dd_pool, 0);
+
 	if (tail == NULL) {
 		int delta = strlen(newname) - strlen(oldname);
 
@@ -2328,11 +2323,21 @@
 			err = dmu_objset_find(oldname, dsl_valid_rename,
 			    &delta, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
 
-		if (!err)
+		if (!err) {
+			/*
+			 * If there are more than 2 references there may be
+			 * holds hanging around that haven't been cleared
+			 * out yet.
+			 */
+			if (dmu_buf_refcount(dd->dd_dbuf) > 2)
+				txg_wait_synced(dd->dd_pool, 0);
+
 			err = dsl_dir_rename(dd, newname);
+		}
 		dsl_dir_close(dd, FTAG);
 		return (err);
 	}
+
 	if (tail[0] != '@') {
 		/* the name ended in a nonexistent component */
 		dsl_dir_close(dd, FTAG);