From f0f978654581cea4cc042e7f185e1843d727acdb Mon Sep 17 00:00:00 2001 From: LOLi Date: Tue, 6 Nov 2018 19:14:56 +0100 Subject: [PATCH] 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 Reviewed-by: Brian Behlendorf Signed-off-by: loli10K Closes #8079 --- lib/libzfs/libzfs_pool.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index 128c6efe9..bc320e516 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -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 */ #include @@ -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,