diff options
author | LOLi <[email protected]> | 2016-10-26 01:17:47 +0200 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-10-25 16:17:47 -0700 |
commit | e4010f2719e3381ae15563d50b99e51ffe2b2168 (patch) | |
tree | 9504e43ef804991a8f576d8df29339738692d711 /cmd | |
parent | 16fa68f07d268192552693f83a747c9141ea726b (diff) |
Allow for '-o feature@<feature>=disabled' on the command line
Sometimes it is desirable to specifically disable one or several
features directly on the 'zpool create' command line.
$ zpool create -o feature@<feature>=disabled ...
Original-patch-by: Turbo Fredriksson <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: loli10K <[email protected]>
Closes #3460
Closes #5142
Closes #5324
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zpool/zpool_main.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 3431ec67a..b6702f22c 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -920,6 +920,7 @@ errout: * -m Set default mountpoint for the root dataset. By default it's * '/<pool>' * -o Set property=value. + * -o Set feature@feature=enabled|disabled. * -d Don't automatically enable all supported pool features * (individual features can be enabled with -o). * -O Set fsproperty=value in the pool's root file system @@ -1188,22 +1189,26 @@ zpool_do_create(int argc, char **argv) /* * Hand off to libzfs. */ - if (enable_all_pool_feat) { - spa_feature_t i; - for (i = 0; i < SPA_FEATURES; i++) { - char propname[MAXPATHLEN]; - zfeature_info_t *feat = &spa_feature_table[i]; - - (void) snprintf(propname, sizeof (propname), - "feature@%s", feat->fi_uname); + spa_feature_t i; + for (i = 0; i < SPA_FEATURES; i++) { + char propname[MAXPATHLEN]; + char *propval; + zfeature_info_t *feat = &spa_feature_table[i]; - /* - * Skip feature if user specified it manually - * on the command line. - */ - if (nvlist_exists(props, propname)) - continue; + (void) snprintf(propname, sizeof (propname), + "feature@%s", feat->fi_uname); + /* + * Only features contained in props will be enabled: + * remove from the nvlist every ZFS_FEATURE_DISABLED + * value and add every missing ZFS_FEATURE_ENABLED if + * enable_all_pool_feat is set. + */ + if (!nvlist_lookup_string(props, propname, &propval)) { + if (strcmp(propval, ZFS_FEATURE_DISABLED) == 0) + (void) nvlist_remove_all(props, + propname); + } else if (enable_all_pool_feat) { ret = add_prop_list(propname, ZFS_FEATURE_ENABLED, &props, B_TRUE); if (ret != 0) |