svn commit: r258374 - vendor-sys/illumos/dist/common/zfs vendor-sys/illumos/dist/uts/common/fs/zfs vendor-sys/illumos/dist/uts/common/fs/zfs/sys vendor/illumos/dist/cmd/zdb vendor/illumos/dist/cmd/...

Andriy Gapon avg at FreeBSD.org
Wed Nov 20 10:54:12 UTC 2013


Author: avg
Date: Wed Nov 20 10:54:06 2013
New Revision: 258374
URL: http://svnweb.freebsd.org/changeset/base/258374

Log:
  4171 clean up spa_feature_*() interfaces
  
  4172 implement extensible_dataset feature for use by other zpool
  features
  
  illumos/illumos-gate at 2acef22db7808606888f8f92715629ff3ba555b9

Modified:
  vendor/illumos/dist/cmd/zdb/zdb.c
  vendor/illumos/dist/cmd/zhack/zhack.c
  vendor/illumos/dist/cmd/zpool/zpool_main.c
  vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c
  vendor/illumos/dist/man/man5/zpool-features.5

Changes in other areas also in this revision:
Modified:
  vendor-sys/illumos/dist/common/zfs/zfeature_common.c
  vendor-sys/illumos/dist/common/zfs/zfeature_common.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/bpobj.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_object.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dmu_traverse.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dnode_sync.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_dataset.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_destroy.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_dir.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_pool.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/dsl_scan.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/spa_misc.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/space_map.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dmu_impl.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dnode.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/dsl_dataset.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zap.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/zfeature.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/zap_micro.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfeature.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zfs_ioctl.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/zvol.c

Modified: vendor/illumos/dist/cmd/zdb/zdb.c
==============================================================================
--- vendor/illumos/dist/cmd/zdb/zdb.c	Wed Nov 20 10:52:48 2013	(r258373)
+++ vendor/illumos/dist/cmd/zdb/zdb.c	Wed Nov 20 10:54:06 2013	(r258374)
@@ -563,16 +563,20 @@ get_metaslab_refcount(vdev_t *vd)
 static int
 verify_spacemap_refcounts(spa_t *spa)
 {
-	int expected_refcount, actual_refcount;
+	uint64_t expected_refcount = 0;
+	uint64_t actual_refcount;
 
-	expected_refcount = spa_feature_get_refcount(spa,
-	    &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM]);
+	(void) feature_get_refcount(spa,
+	    &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM],
+	    &expected_refcount);
 	actual_refcount = get_dtl_refcount(spa->spa_root_vdev);
 	actual_refcount += get_metaslab_refcount(spa->spa_root_vdev);
 
 	if (expected_refcount != actual_refcount) {
-		(void) printf("space map refcount mismatch: expected %d != "
-		    "actual %d\n", expected_refcount, actual_refcount);
+		(void) printf("space map refcount mismatch: expected %lld != "
+		    "actual %lld\n",
+		    (longlong_t)expected_refcount,
+		    (longlong_t)actual_refcount);
 		return (2);
 	}
 	return (0);
@@ -674,8 +678,7 @@ dump_metaslab(metaslab_t *msp)
 	}
 
 	if (dump_opt['m'] > 1 && sm != NULL &&
-	    spa_feature_is_active(spa,
-	    &spa_feature_table[SPA_FEATURE_SPACEMAP_HISTOGRAM])) {
+	    spa_feature_is_active(spa, SPA_FEATURE_SPACEMAP_HISTOGRAM)) {
 		/*
 		 * The space map histogram represents free space in chunks
 		 * of sm_shift (i.e. bucket 0 refers to 2^sm_shift).
@@ -2466,8 +2469,7 @@ dump_block_stats(spa_t *spa)
 		(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
 		    count_block_cb, &zcb, NULL);
 	}
-	if (spa_feature_is_active(spa,
-	    &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+	if (spa_feature_is_active(spa, SPA_FEATURE_ASYNC_DESTROY)) {
 		VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
 		    spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
 		    &zcb, NULL));
@@ -2793,7 +2795,7 @@ dump_zpool(spa_t *spa)
 			}
 
 			if (spa_feature_is_active(spa,
-			    &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+			    SPA_FEATURE_ASYNC_DESTROY)) {
 				dump_bptree(spa->spa_meta_objset,
 				    spa->spa_dsl_pool->dp_bptree_obj,
 				    "Pool dataset frees");

Modified: vendor/illumos/dist/cmd/zhack/zhack.c
==============================================================================
--- vendor/illumos/dist/cmd/zhack/zhack.c	Wed Nov 20 10:52:48 2013	(r258373)
+++ vendor/illumos/dist/cmd/zhack/zhack.c	Wed Nov 20 10:54:06 2013	(r258374)
@@ -283,12 +283,13 @@ zhack_do_feature_stat(int argc, char **a
 }
 
 static void
-feature_enable_sync(void *arg, dmu_tx_t *tx)
+zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
 {
 	spa_t *spa = dmu_tx_pool(tx)->dp_spa;
 	zfeature_info_t *feature = arg;
 
-	spa_feature_enable(spa, feature, tx);
+	feature_enable_sync(spa, feature, tx);
+
 	spa_history_log_internal(spa, "zhack enable feature", tx,
 	    "guid=%s can_readonly=%u",
 	    feature->fi_guid, feature->fi_can_readonly);
@@ -302,7 +303,7 @@ zhack_do_feature_enable(int argc, char *
 	spa_t *spa;
 	objset_t *mos;
 	zfeature_info_t feature;
-	zfeature_info_t *nodeps[] = { NULL };
+	spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
 
 	/*
 	 * Features are not added to the pool's label until their refcounts
@@ -349,14 +350,14 @@ zhack_do_feature_enable(int argc, char *
 	zhack_spa_open(target, B_FALSE, FTAG, &spa);
 	mos = spa->spa_meta_objset;
 
-	if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
+	if (zfeature_is_supported(feature.fi_guid))
 		fatal(spa, FTAG, "'%s' is a real feature, will not enable");
 	if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid))
 		fatal(spa, FTAG, "feature already enabled: %s",
 		    feature.fi_guid);
 
 	VERIFY0(dsl_sync_task(spa_name(spa), NULL,
-	    feature_enable_sync, &feature, 5));
+	    zhack_feature_enable_sync, &feature, 5));
 
 	spa_close(spa, FTAG);
 
@@ -368,8 +369,10 @@ feature_incr_sync(void *arg, dmu_tx_t *t
 {
 	spa_t *spa = dmu_tx_pool(tx)->dp_spa;
 	zfeature_info_t *feature = arg;
+	uint64_t refcount;
 
-	spa_feature_incr(spa, feature, tx);
+	VERIFY0(feature_get_refcount(spa, feature, &refcount));
+	feature_sync(spa, feature, refcount + 1, tx);
 	spa_history_log_internal(spa, "zhack feature incr", tx,
 	    "guid=%s", feature->fi_guid);
 }
@@ -379,8 +382,10 @@ feature_decr_sync(void *arg, dmu_tx_t *t
 {
 	spa_t *spa = dmu_tx_pool(tx)->dp_spa;
 	zfeature_info_t *feature = arg;
+	uint64_t refcount;
 
-	spa_feature_decr(spa, feature, tx);
+	VERIFY0(feature_get_refcount(spa, feature, &refcount));
+	feature_sync(spa, feature, refcount - 1, tx);
 	spa_history_log_internal(spa, "zhack feature decr", tx,
 	    "guid=%s", feature->fi_guid);
 }
@@ -394,7 +399,7 @@ zhack_do_feature_ref(int argc, char **ar
 	spa_t *spa;
 	objset_t *mos;
 	zfeature_info_t feature;
-	zfeature_info_t *nodeps[] = { NULL };
+	spa_feature_t nodeps[] = { SPA_FEATURE_NONE };
 
 	/*
 	 * fi_desc does not matter here because it was written to disk
@@ -437,9 +442,10 @@ zhack_do_feature_ref(int argc, char **ar
 	zhack_spa_open(target, B_FALSE, FTAG, &spa);
 	mos = spa->spa_meta_objset;
 
-	if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
-		fatal(spa, FTAG, "'%s' is a real feature, will not change "
-		    "refcount");
+	if (zfeature_is_supported(feature.fi_guid)) {
+		fatal(spa, FTAG,
+		    "'%s' is a real feature, will not change refcount");
+	}
 
 	if (0 == zap_contains(mos, spa->spa_feat_for_read_obj,
 	    feature.fi_guid)) {
@@ -451,9 +457,14 @@ zhack_do_feature_ref(int argc, char **ar
 		fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid);
 	}
 
-	if (decr && !spa_feature_is_active(spa, &feature))
-		fatal(spa, FTAG, "feature refcount already 0: %s",
-		    feature.fi_guid);
+	if (decr) {
+		uint64_t count;
+		if (feature_get_refcount(spa, &feature, &count) == 0 &&
+		    count != 0) {
+			fatal(spa, FTAG, "feature refcount already 0: %s",
+			    feature.fi_guid);
+		}
+	}
 
 	VERIFY0(dsl_sync_task(spa_name(spa), NULL,
 	    decr ? feature_decr_sync : feature_incr_sync, &feature, 5));

Modified: vendor/illumos/dist/cmd/zpool/zpool_main.c
==============================================================================
--- vendor/illumos/dist/cmd/zpool/zpool_main.c	Wed Nov 20 10:52:48 2013	(r258373)
+++ vendor/illumos/dist/cmd/zpool/zpool_main.c	Wed Nov 20 10:54:06 2013	(r258374)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  * Copyright (c) 2012 by Frederik Wessels. All rights reserved.
  * Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
  */
@@ -876,7 +876,7 @@ zpool_do_create(int argc, char **argv)
 		 * Hand off to libzfs.
 		 */
 		if (enable_all_pool_feat) {
-			int i;
+			spa_feature_t i;
 			for (i = 0; i < SPA_FEATURES; i++) {
 				char propname[MAXPATHLEN];
 				zfeature_info_t *feat = &spa_feature_table[i];

Modified: vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c
==============================================================================
--- vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c	Wed Nov 20 10:52:48 2013	(r258373)
+++ vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c	Wed Nov 20 10:54:06 2013	(r258374)
@@ -22,7 +22,7 @@
 /*
  * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2013 by Delphix. All rights reserved.
  * Copyright (c) 2013, Joyent, Inc. All rights reserved.
  */
 
@@ -413,10 +413,9 @@ zpool_valid_proplist(libzfs_handle_t *hd
 		prop = zpool_name_to_prop(propname);
 		if (prop == ZPROP_INVAL && zpool_prop_feature(propname)) {
 			int err;
-			zfeature_info_t *feature;
 			char *fname = strchr(propname, '@') + 1;
 
-			err = zfeature_lookup_name(fname, &feature);
+			err = zfeature_lookup_name(fname, NULL);
 			if (err != 0) {
 				ASSERT3U(err, ==, ENOENT);
 				zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
@@ -807,14 +806,14 @@ zpool_prop_get_feature(zpool_handle_t *z
 	 */
 	if (supported) {
 		int ret;
-		zfeature_info_t *fi;
+		spa_feature_t fid;
 
-		ret = zfeature_lookup_name(feature, &fi);
+		ret = zfeature_lookup_name(feature, &fid);
 		if (ret != 0) {
 			(void) strlcpy(buf, "-", len);
 			return (ENOTSUP);
 		}
-		feature = fi->fi_guid;
+		feature = spa_feature_table[fid].fi_guid;
 	}
 
 	if (nvlist_lookup_uint64(features, feature, &refcount) == 0)

Modified: vendor/illumos/dist/man/man5/zpool-features.5
==============================================================================
--- vendor/illumos/dist/man/man5/zpool-features.5	Wed Nov 20 10:52:48 2013	(r258373)
+++ vendor/illumos/dist/man/man5/zpool-features.5	Wed Nov 20 10:54:06 2013	(r258374)
@@ -271,6 +271,29 @@ configuration.
 When the \fBmulti_vdev_crash_dump\fR feature is set to \fBenabled\fR,
 the administrator can use the \fBdumpadm\fR(1M) command to configure a
 dump device on a pool comprised of multiple vdevs.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBextensible_dataset\fR\fR
+.ad
+.RS 4n
+.TS
+l l .
+GUID	com.delphix:extensible_dataset
+READ\-ONLY COMPATIBLE	no
+DEPENDENCIES	none
+.TE
+
+This feature allows more flexible use of internal ZFS data structures,
+and exists for other features to depend on.
+
+This feature will be \fBactive\fR when the first dependent feature uses it,
+and will be returned to the \fBenabled\fR state when all datasets that use
+this feature are destroyed.
+
+.RE
 
 .SH "SEE ALSO"
 \fBzpool\fR(1M)


More information about the svn-src-all mailing list