summaryrefslogtreecommitdiffstats
path: root/module/zfs/zfeature.c
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2015-10-01 16:32:49 -0700
committerBrian Behlendorf <[email protected]>2016-05-17 11:00:21 -0700
commit83025286175d1ee1c29b842531070f3250a172ba (patch)
tree91400e75e8bc469e21af0a08baa5a0e53ca12c2f /module/zfs/zfeature.c
parent72c407f8272a4d534da4ecc2c374fd13a49629cc (diff)
zhack: Add 'feature disable' command
Signed-off-by: Brian Behlendorf <[email protected]> Issue #3878
Diffstat (limited to 'module/zfs/zfeature.c')
-rw-r--r--module/zfs/zfeature.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/module/zfs/zfeature.c b/module/zfs/zfeature.c
index bda954829..c83b14568 100644
--- a/module/zfs/zfeature.c
+++ b/module/zfs/zfeature.c
@@ -380,6 +380,43 @@ feature_enable_sync(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
}
}
+/*
+ * This function is non-static for zhack; it should otherwise not be used
+ * outside this file.
+ */
+void
+feature_disable_sync(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
+{
+ uint64_t descobj = spa->spa_feat_desc_obj;
+ uint64_t zapobj = feature->fi_can_readonly ?
+ spa->spa_feat_for_write_obj : spa->spa_feat_for_read_obj;
+
+ ASSERT(0 != zapobj);
+ ASSERT(zfeature_is_valid_guid(feature->fi_guid));
+ ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
+
+ if (zap_contains(spa->spa_meta_objset, descobj, feature->fi_guid) == 0)
+ VERIFY0(zap_remove(spa->spa_meta_objset, descobj,
+ feature->fi_guid, tx));
+
+ if (zap_contains(spa->spa_meta_objset, zapobj, feature->fi_guid) == 0)
+ VERIFY0(zap_remove(spa->spa_meta_objset, zapobj,
+ feature->fi_guid, tx));
+
+ spa_deactivate_mos_feature(spa, feature->fi_guid);
+
+ if (spa_feature_is_enabled(spa, SPA_FEATURE_ENABLED_TXG)) {
+ uint64_t txgobj = spa->spa_feat_enabled_txg_obj;
+
+ if (txgobj && (zap_contains(spa->spa_meta_objset,
+ txgobj, feature->fi_guid) == 0)) {
+ spa_feature_decr(spa, SPA_FEATURE_ENABLED_TXG, tx);
+ VERIFY0(zap_remove(spa->spa_meta_objset, txgobj,
+ feature->fi_guid, tx));
+ }
+ }
+}
+
static void
feature_do_action(spa_t *spa, spa_feature_t fid, feature_action_t action,
dmu_tx_t *tx)