changeset 11823:c756cd80d532

6930022 zfs rename of non-shapshot is slower than necessary
author Matthew Ahrens <Matthew.Ahrens@Sun.COM>
date Thu, 25 Feb 2010 14:08:36 -0800
parents 9195ca3173d2
children 53128e5db7cf
files usr/src/uts/common/fs/zfs/dsl_dataset.c usr/src/uts/common/fs/zfs/dsl_dir.c usr/src/uts/common/fs/zfs/dsl_synctask.c
diffstat 3 files changed, 11 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/uts/common/fs/zfs/dsl_dataset.c	Thu Feb 25 11:56:41 2010 -0800
+++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c	Thu Feb 25 14:08:36 2010 -0800
@@ -2323,17 +2323,8 @@
 			err = dmu_objset_find(oldname, dsl_valid_rename,
 			    &delta, DS_FIND_CHILDREN | DS_FIND_SNAPSHOTS);
 
-		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);
-
+		if (err == 0)
 			err = dsl_dir_rename(dd, newname);
-		}
 		dsl_dir_close(dd, FTAG);
 		return (err);
 	}
--- a/usr/src/uts/common/fs/zfs/dsl_dir.c	Thu Feb 25 11:56:41 2010 -0800
+++ b/usr/src/uts/common/fs/zfs/dsl_dir.c	Thu Feb 25 14:08:36 2010 -0800
@@ -19,7 +19,7 @@
  * CDDL HEADER END
  */
 /*
- * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
+ * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
  */
 
@@ -1251,8 +1251,14 @@
 	int err;
 	uint64_t val;
 
-	/* There should be 2 references: the open and the dirty */
-	if (dmu_buf_refcount(dd->dd_dbuf) > 2)
+	/*
+	 * There should only be one reference, from dmu_objset_rename().
+	 * Fleeting holds are also possible (eg, from "zfs list" getting
+	 * stats), but any that are present in open context will likely
+	 * be gone by syncing context, so only fail from syncing
+	 * context.
+	 */
+	if (dmu_tx_is_syncing(tx) && dmu_buf_refcount(dd->dd_dbuf) > 1)
 		return (EBUSY);
 
 	/* check for existing name */
--- a/usr/src/uts/common/fs/zfs/dsl_synctask.c	Thu Feb 25 11:56:41 2010 -0800
+++ b/usr/src/uts/common/fs/zfs/dsl_synctask.c	Thu Feb 25 14:08:36 2010 -0800
@@ -169,7 +169,7 @@
 
 	/*
 	 * Check for sufficient space.  We just check against what's
-	 * on-disk; we don't wany any in-flight accounting to get in our
+	 * on-disk; we don't want any in-flight accounting to get in our
 	 * way, because open context may have already used up various
 	 * in-core limits (arc_tempreserve, dsl_pool_tempreserve).
 	 */