summaryrefslogtreecommitdiffstats
path: root/cddl
diff options
context:
space:
mode:
authormav <mav@FreeBSD.org>2015-08-12 23:59:17 +0000
committermav <mav@FreeBSD.org>2015-08-12 23:59:17 +0000
commit95e93478d428d5dde3e6e0e5ab08d3e1bbcf8290 (patch)
treefde4c6e72afe9d2b5eb0a48efeff4e899efcd81a /cddl
parent99cadf9eedff63c2d1d6b1a5296b21ca12ac2aa0 (diff)
downloadFreeBSD-src-95e93478d428d5dde3e6e0e5ab08d3e1bbcf8290.zip
FreeBSD-src-95e93478d428d5dde3e6e0e5ab08d3e1bbcf8290.tar.gz
MFV 286707: 5959 clean up per-dataset feature count code
Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: George Wilson <george@delphix.com> Reviewed by: Alex Reece <alex@delphix.com> Approved by: Richard Lowe <richlowe@richlowe.net> Author: Matthew Ahrens <mahrens@delphix.com> illumos/illumos-gate@ca0cc3918a1789fa839194af2a9245f801a06b1a A ZFS feature flags (large blocks) tracks its refcounts as the number of datasets that have ever used the feature. Several features of this type are planned to be added (new checksum functions). This code should be made common infrastructure rather than duplicating the code for each feature.
Diffstat (limited to 'cddl')
-rw-r--r--cddl/contrib/opensolaris/cmd/zdb/zdb.c50
-rw-r--r--cddl/contrib/opensolaris/cmd/zhack/zhack.c20
-rw-r--r--cddl/contrib/opensolaris/cmd/zpool/zpool_main.c5
3 files changed, 46 insertions, 29 deletions
diff --git a/cddl/contrib/opensolaris/cmd/zdb/zdb.c b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
index 75adc71..4f5c372 100644
--- a/cddl/contrib/opensolaris/cmd/zdb/zdb.c
+++ b/cddl/contrib/opensolaris/cmd/zdb/zdb.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
*/
#include <stdio.h>
@@ -2221,7 +2221,7 @@ dump_label(const char *dev)
(void) close(fd);
}
-static uint64_t num_large_blocks;
+static uint64_t dataset_feature_count[SPA_FEATURES];
/*ARGSUSED*/
static int
@@ -2235,8 +2235,15 @@ dump_one_dir(const char *dsname, void *arg)
(void) printf("Could not open %s, error %d\n", dsname, error);
return (0);
}
- if (dmu_objset_ds(os)->ds_large_blocks)
- num_large_blocks++;
+
+ for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
+ if (!dmu_objset_ds(os)->ds_feature_inuse[f])
+ continue;
+ ASSERT(spa_feature_table[f].fi_flags &
+ ZFEATURE_FLAG_PER_DATASET);
+ dataset_feature_count[f]++;
+ }
+
dump_dir(os);
dmu_objset_disown(os, FTAG);
fuid_table_destroy();
@@ -3035,7 +3042,6 @@ dump_zpool(spa_t *spa)
dump_metaslab_groups(spa);
if (dump_opt['d'] || dump_opt['i']) {
- uint64_t refcount;
dump_dir(dp->dp_meta_objset);
if (dump_opt['d'] >= 3) {
dump_full_bpobj(&spa->spa_deferred_bpobj,
@@ -3057,17 +3063,29 @@ dump_zpool(spa_t *spa)
(void) dmu_objset_find(spa_name(spa), dump_one_dir,
NULL, DS_FIND_SNAPSHOTS | DS_FIND_CHILDREN);
- (void) feature_get_refcount(spa,
- &spa_feature_table[SPA_FEATURE_LARGE_BLOCKS], &refcount);
- if (num_large_blocks != refcount) {
- (void) printf("large_blocks feature refcount mismatch: "
- "expected %lld != actual %lld\n",
- (longlong_t)num_large_blocks,
- (longlong_t)refcount);
- rc = 2;
- } else {
- (void) printf("Verified large_blocks feature refcount "
- "is correct (%llu)\n", (longlong_t)refcount);
+ for (spa_feature_t f = 0; f < SPA_FEATURES; f++) {
+ uint64_t refcount;
+
+ if (!(spa_feature_table[f].fi_flags &
+ ZFEATURE_FLAG_PER_DATASET)) {
+ ASSERT0(dataset_feature_count[f]);
+ continue;
+ }
+ (void) feature_get_refcount(spa,
+ &spa_feature_table[f], &refcount);
+ if (dataset_feature_count[f] != refcount) {
+ (void) printf("%s feature refcount mismatch: "
+ "%lld datasets != %lld refcount\n",
+ spa_feature_table[f].fi_uname,
+ (longlong_t)dataset_feature_count[f],
+ (longlong_t)refcount);
+ rc = 2;
+ } else {
+ (void) printf("Verified %s feature refcount "
+ "of %llu is correct\n",
+ spa_feature_table[f].fi_uname,
+ (longlong_t)refcount);
+ }
}
}
if (rc == 0 && (dump_opt['b'] || dump_opt['c']))
diff --git a/cddl/contrib/opensolaris/cmd/zhack/zhack.c b/cddl/contrib/opensolaris/cmd/zhack/zhack.c
index 6e3f029..f4434a1 100644
--- a/cddl/contrib/opensolaris/cmd/zhack/zhack.c
+++ b/cddl/contrib/opensolaris/cmd/zhack/zhack.c
@@ -20,7 +20,7 @@
*/
/*
- * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2013 Steven Hartland. All rights reserved.
*/
@@ -294,8 +294,8 @@ zhack_feature_enable_sync(void *arg, dmu_tx_t *tx)
feature_enable_sync(spa, feature, tx);
spa_history_log_internal(spa, "zhack enable feature", tx,
- "name=%s can_readonly=%u",
- feature->fi_guid, feature->fi_can_readonly);
+ "guid=%s flags=%x",
+ feature->fi_guid, feature->fi_flags);
}
static void
@@ -314,9 +314,7 @@ zhack_do_feature_enable(int argc, char **argv)
*/
desc = NULL;
feature.fi_uname = "zhack";
- feature.fi_mos = B_FALSE;
- feature.fi_can_readonly = B_FALSE;
- feature.fi_activate_on_enable = B_FALSE;
+ feature.fi_flags = 0;
feature.fi_depends = nodeps;
feature.fi_feature = SPA_FEATURE_NONE;
@@ -324,7 +322,7 @@ zhack_do_feature_enable(int argc, char **argv)
while ((c = getopt(argc, argv, "rmd:")) != -1) {
switch (c) {
case 'r':
- feature.fi_can_readonly = B_TRUE;
+ feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT;
break;
case 'd':
desc = strdup(optarg);
@@ -413,7 +411,7 @@ zhack_do_feature_ref(int argc, char **argv)
* disk later.
*/
feature.fi_uname = "zhack";
- feature.fi_mos = B_FALSE;
+ feature.fi_flags = 0;
feature.fi_desc = NULL;
feature.fi_depends = nodeps;
feature.fi_feature = SPA_FEATURE_NONE;
@@ -422,7 +420,7 @@ zhack_do_feature_ref(int argc, char **argv)
while ((c = getopt(argc, argv, "md")) != -1) {
switch (c) {
case 'm':
- feature.fi_mos = B_TRUE;
+ feature.fi_flags |= ZFEATURE_FLAG_MOS;
break;
case 'd':
decr = B_TRUE;
@@ -455,10 +453,10 @@ zhack_do_feature_ref(int argc, char **argv)
if (0 == zap_contains(mos, spa->spa_feat_for_read_obj,
feature.fi_guid)) {
- feature.fi_can_readonly = B_FALSE;
+ feature.fi_flags &= ~ZFEATURE_FLAG_READONLY_COMPAT;
} else if (0 == zap_contains(mos, spa->spa_feat_for_write_obj,
feature.fi_guid)) {
- feature.fi_can_readonly = B_TRUE;
+ feature.fi_flags |= ZFEATURE_FLAG_READONLY_COMPAT;
} else {
fatal(spa, FTAG, "feature is not enabled: %s", feature.fi_guid);
}
diff --git a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
index d8243f3..a3eabd1 100644
--- a/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
+++ b/cddl/contrib/opensolaris/cmd/zpool/zpool_main.c
@@ -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) 2011, 2014 by Delphix. All rights reserved.
+ * Copyright (c) 2011, 2015 by Delphix. All rights reserved.
* Copyright (c) 2012 by Frederik Wessels. All rights reserved.
* Copyright (c) 2012 Martin Matuska <mm@FreeBSD.org>. All rights reserved.
* Copyright (c) 2013 by Prasad Joshi (sTec). All rights reserved.
@@ -4986,7 +4986,8 @@ zpool_do_upgrade(int argc, char **argv)
"---------------\n");
for (i = 0; i < SPA_FEATURES; i++) {
zfeature_info_t *fi = &spa_feature_table[i];
- const char *ro = fi->fi_can_readonly ?
+ const char *ro =
+ (fi->fi_flags & ZFEATURE_FLAG_READONLY_COMPAT) ?
" (read-only compatible)" : "";
(void) printf("%-37s%s\n", fi->fi_uname, ro);
OpenPOWER on IntegriCloud