zpool: bogus error for invalid dedupditto value

When provided with an invalid 'dedupditto' value zpool prints
a misleading error message:

    $ sudo zpool set dedupditto=99 pp
    cannot set property for 'pp': property 'dedupditto'(14) not defined

Fix this by printing a meaningful error description for unsupported
'dedupditto' values.

Reviewed-by: Olaf Faaland <faaland1@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: loli10K <ezomori.nozomu@gmail.com>
Closes #8079
This commit is contained in:
LOLi 2018-11-06 19:14:56 +01:00 committed by Brian Behlendorf
parent 09b85f2ded
commit f0f9786545

View File

@ -27,6 +27,7 @@
* Copyright (c) 2018 Datto Inc.
* Copyright (c) 2017 Open-E, Inc. All Rights Reserved.
* Copyright (c) 2017, Intel Corporation.
* Copyright (c) 2018, loli10K <ezomori.nozomu@gmail.com>
*/
#include <errno.h>
@ -580,9 +581,9 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
if (intval != 0 &&
(intval < ASHIFT_MIN || intval > ASHIFT_MAX)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid '%s=%d' property: only values "
"between %" PRId32 " and %" PRId32 " "
"are allowed.\n"),
"property '%s' number %d is invalid, only "
"values between %" PRId32 " and "
"%" PRId32 " are allowed."),
propname, intval, ASHIFT_MIN, ASHIFT_MAX);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
@ -720,6 +721,17 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
goto error;
}
break;
case ZPOOL_PROP_DEDUPDITTO:
if (intval < ZIO_DEDUPDITTO_MIN && intval != 0) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' value %d is invalid; only "
"values of 0 or >= %" PRId32 " are allowed "
"for this property."),
propname, intval, ZIO_DEDUPDITTO_MIN);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
goto error;
}
break;
default:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,