summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorLOLi <loli10K@users.noreply.github.com>2020-04-28 12:58:22 -0500
committerJason King <jason.king@joyent.com>2020-04-30 12:29:18 -0500
commitf343451914d0efaf2d6fc84d8818a16246b223dc (patch)
treee808ea7e816231e4cccca2011b385f42015ab68f /usr/src
parent19325e87abbf92e73010df2342fc48019027aee1 (diff)
downloadillumos-joyent-f343451914d0efaf2d6fc84d8818a16246b223dc.tar.gz
12635 Allow for '-o feature@<feature>=disabled' on the command line
Portions contributed by: Turbo Fredriksson <turbo@bayour.com> Portions contributed by: Jason King <jason.king@joyent.com> Reviewed by: Toomas Soome <tsoome@me.com> Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com> Approved by: Robert Mustacchi <rm@fingolfin.org>
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/cmd/zpool/zpool_main.c43
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c5
-rw-r--r--usr/src/man/man1m/zpool.1m15
-rw-r--r--usr/src/pkg/manifests/system-test-zfstest.mf3
-rw-r--r--usr/src/test/zfs-tests/runfiles/omnios.run4
-rw-r--r--usr/src/test/zfs-tests/runfiles/openindiana.run4
-rw-r--r--usr/src/test/zfs-tests/runfiles/smartos.run4
-rw-r--r--usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh2
-rwxr-xr-xusr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_005_pos.ksh93
9 files changed, 144 insertions, 29 deletions
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index 5cd20ad4d2..39cdf276c8 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -1081,6 +1081,7 @@ errout:
* '/<pool>'
* -t Use the temporary name until the pool is exported.
* -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
@@ -1414,22 +1415,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);
-
- /*
- * Skip feature if user specified it manually
- * on the command line.
- */
- if (nvlist_exists(props, propname))
- continue;
+ spa_feature_t i;
+ for (i = 0; i < SPA_FEATURES; i++) {
+ char propname[MAXPATHLEN];
+ char *propval;
+ zfeature_info_t *feat = &spa_feature_table[i];
+ (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)
@@ -3408,20 +3413,20 @@ print_iostat_labels(iostat_cbdata_t *cb, unsigned int force_column_width,
/*
* Utility function to print out a line of dashes like:
*
- * -------------------------------- ----- ----- ----- ----- -----
+ * -------------------------------- ----- ----- ----- ----- -----
*
* ...or a dashed named-row line like:
*
- * logs - - - - -
+ * logs - - - - -
*
* @cb: iostat data
*
* @force_column_width If non-zero, use the value as the column width.
- * Otherwise use the default column widths.
+ * Otherwise use the default column widths.
*
* @name: Print a dashed named-row line starting
- * with @name. Otherwise, print a regular
- * dashed line.
+ * with @name. Otherwise, print a regular
+ * dashed line.
*/
static void
print_iostat_dashes(iostat_cbdata_t *cb, unsigned int force_column_width,
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index 2986fc1b8c..60c83be1a9 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -473,10 +473,11 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
}
(void) nvpair_value_string(elem, &strval);
- if (strcmp(strval, ZFS_FEATURE_ENABLED) != 0) {
+ if (strcmp(strval, ZFS_FEATURE_ENABLED) != 0 &&
+ strcmp(strval, ZFS_FEATURE_DISABLED) != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' can only be set to "
- "'enabled'"), propname);
+ "'enabled' or 'disabled'"), propname);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}
diff --git a/usr/src/man/man1m/zpool.1m b/usr/src/man/man1m/zpool.1m
index fdbf7e741b..402c4d03a0 100644
--- a/usr/src/man/man1m/zpool.1m
+++ b/usr/src/man/man1m/zpool.1m
@@ -27,7 +27,7 @@
.\" Copyright 2020 Joyent, Inc.
.\" Copyright (c) 2012 Cyril Plisko. All Rights Reserved.
.\"
-.Dd August 30, 2019
+.Dd April 29, 2020
.Dt ZPOOL 1M
.Os
.Sh NAME
@@ -60,6 +60,7 @@
.Op Fl B
.Op Fl m Ar mountpoint
.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
+.Oo Fl o Cm feature@ Ns Ar feature Ns = Ns Ar value Oc Ns ...
.Oo Fl O Ar file-system-property Ns = Ns Ar value Oc Ns ...
.Op Fl R Ar root
.Op Fl t Ar tempname
@@ -1044,6 +1045,7 @@ another host, and resuming I/O could result in pool damage.
.Op Fl B
.Op Fl m Ar mountpoint
.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
+.Oo Fl o Cm feature@ Ns Ar feature Ns = Ns Ar value Oc Ns ...
.Oo Fl O Ar file-system-property Ns = Ns Ar value Oc Ns ...
.Op Fl R Ar root
.Op Fl t Ar tempname
@@ -1174,6 +1176,17 @@ Sets the given pool properties.
See the
.Sx Properties
section for a list of valid properties that can be set.
+.It Fl o Cm feature@ Ns Ar feature Ns = Ns Ar value
+Sets the given pool feature.
+See
+.Xr zpool-features 5
+for a list of valid features that can be set.
+.Pp
+.Ar value
+can either be
+.Sy disabled
+or
+.Sy enabled .
.It Fl O Ar file-system-property Ns = Ns Ar value
Sets the given file system properties in the root file system of the pool.
See the
diff --git a/usr/src/pkg/manifests/system-test-zfstest.mf b/usr/src/pkg/manifests/system-test-zfstest.mf
index 6ffc0b4f56..09d431d538 100644
--- a/usr/src/pkg/manifests/system-test-zfstest.mf
+++ b/usr/src/pkg/manifests/system-test-zfstest.mf
@@ -1631,6 +1631,9 @@ file \
path=opt/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg \
mode=0555
file \
+ path=opt/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_005_pos \
+ mode=0555
+file \
path=opt/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_tempname \
mode=0555
file \
diff --git a/usr/src/test/zfs-tests/runfiles/omnios.run b/usr/src/test/zfs-tests/runfiles/omnios.run
index 010a16af3a..dd8f0738de 100644
--- a/usr/src/test/zfs-tests/runfiles/omnios.run
+++ b/usr/src/test/zfs-tests/runfiles/omnios.run
@@ -12,7 +12,7 @@
#
# Copyright (c) 2013, 2017 by Delphix. All rights reserved.
# Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2019 Joyent, Inc.
+# Copyright 2020 Joyent, Inc.
# Copyright 2019 RackTop Systems.
#
@@ -285,7 +285,7 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos',
'zpool_create_encrypted', 'zpool_create_crypt_combos',
'zpool_create_features_001_pos', 'zpool_create_features_002_pos',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
- 'zpool_create_tempname', 'create-o_ashift']
+ 'zpool_create_features_005_pos', 'zpool_create_tempname', 'create-o_ashift']
[/opt/zfs-tests/tests/functional/cli_root/zpool_destroy]
tests = ['zpool_destroy_001_pos', 'zpool_destroy_002_pos',
diff --git a/usr/src/test/zfs-tests/runfiles/openindiana.run b/usr/src/test/zfs-tests/runfiles/openindiana.run
index 71bad54e0f..031bd8bf0f 100644
--- a/usr/src/test/zfs-tests/runfiles/openindiana.run
+++ b/usr/src/test/zfs-tests/runfiles/openindiana.run
@@ -12,7 +12,7 @@
#
# Copyright (c) 2012, 2017 by Delphix. All rights reserved.
# Copyright 2016, OmniTI Computer Consulting, Inc. All rights reserved.
-# Copyright 2019 Joyent, Inc.
+# Copyright 2020 Joyent, Inc.
# Copyright 2019 RackTop Systems.
#
@@ -285,7 +285,7 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos',
'zpool_create_encrypted', 'zpool_create_crypt_combos',
'zpool_create_features_001_pos', 'zpool_create_features_002_pos',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
- 'zpool_create_tempname', 'create-o_ashift']
+ 'zpool_create_features_005_pos', 'zpool_create_tempname', 'create-o_ashift']
[/opt/zfs-tests/tests/functional/cli_root/zpool_destroy]
tests = ['zpool_destroy_001_pos', 'zpool_destroy_002_pos',
diff --git a/usr/src/test/zfs-tests/runfiles/smartos.run b/usr/src/test/zfs-tests/runfiles/smartos.run
index 7b1c27b214..1a3f3b7bae 100644
--- a/usr/src/test/zfs-tests/runfiles/smartos.run
+++ b/usr/src/test/zfs-tests/runfiles/smartos.run
@@ -10,7 +10,7 @@
#
#
-# Copyright 2019 Joyent, Inc.
+# Copyright 2020 Joyent, Inc.
#
[DEFAULT]
@@ -241,7 +241,7 @@ tests = ['zpool_create_001_pos', 'zpool_create_002_pos',
'zpool_create_encrypted', 'zpool_create_crypt_combos',
'zpool_create_features_001_pos', 'zpool_create_features_002_pos',
'zpool_create_features_003_pos', 'zpool_create_features_004_neg',
- 'zpool_create_tempname', 'create-o_ashift']
+ 'zpool_create_features_005_pos', 'zpool_create_tempname', 'create-o_ashift']
[/opt/zfs-tests/tests/functional/cli_root/zpool_destroy]
tests = ['zpool_destroy_001_pos', 'zpool_destroy_002_pos',
diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh
index 83886533c4..84af87d613 100644
--- a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh
+++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_004_neg.ksh
@@ -38,7 +38,7 @@
verify_runnable "global"
properties="\
-feature@async_destroy=disabled \
+feature@async_destroy=disable \
feature@async_destroy=active \
feature@xxx_fake_xxx=enabled \
unsupported@some_feature=inactive \
diff --git a/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_005_pos.ksh b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_005_pos.ksh
new file mode 100755
index 0000000000..a8ed95109f
--- /dev/null
+++ b/usr/src/test/zfs-tests/tests/functional/cli_root/zpool_create/zpool_create_features_005_pos.ksh
@@ -0,0 +1,93 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (the "License").
+# You may not use this file except in compliance with the License.
+#
+# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
+# or http://www.opensolaris.org/os/licensing.
+# See the License for the specific language governing permissions
+# and limitations under the License.
+#
+# When distributing Covered Code, include this CDDL HEADER in each
+# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
+# If applicable, add the following below this CDDL HEADER, with the
+# fields enclosed by brackets "[]" replaced with your own identifying
+# information: Portions Copyright [yyyy] [name of copyright owner]
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+. $STF_SUITE/include/libtest.shlib
+. $STF_SUITE/tests/functional/cli_root/zpool_create/zpool_create.shlib
+
+################################################################################
+#
+# Specifically disabling a feature, all other features should be enabled.
+#
+# 1. Loop through all existing features:
+# a. Create a new pool with '-o feature@XXX=disabled'.
+# b. Verify that every other feature is 'enabled' or 'active'.
+#
+################################################################################
+
+verify_runnable "global"
+
+function cleanup
+{
+ datasetexists $TESTPOOL && log_must zpool destroy $TESTPOOL
+}
+
+function check_features
+{
+ typeset feature="${1}"
+
+ zpool get all ${TESTPOOL} | grep feature@ | while read line; do
+ set -- $(echo "${line}")
+
+ if [[ "feature@${feature}" == "${2}" ]]; then
+ # Failure passed feature must be disabled.
+ if [[ "${3}" != "disabled" ]]; then
+ return 1;
+ fi
+ else
+ # Failure other features must be enabled or active.
+ if [[ "${3}" != "enabled" && "${3}" != "active" ]]; then
+ return 2;
+ fi
+ fi
+ done
+
+ # All features enabled or active except the expected one.
+ return 0
+}
+
+log_onexit cleanup
+
+# Several representative features are tested to keep the test time short.
+# The features 'extensible_dataset' and 'enabled_txg' are intentionally
+# excluded because other features depend on them.
+set -A features \
+ "hole_birth" \
+ "large_blocks" \
+ "large_dnode" \
+ "userobj_accounting"
+
+typeset -i i=0
+while (( $i < ${#features[*]} )); do
+ log_assert "'zpool create' creates pools with ${features[i]} disabled"
+
+ log_must zpool create -f -o "feature@${features[i]}=disabled" \
+ $TESTPOOL $DISKS
+ log_must check_features "${features[i]}"
+ log_must zpool destroy -f $TESTPOOL
+ (( i = i+1 ))
+done
+
+log_pass "'zpool create -o feature@feature=disabled' disables features"