From c24fa4b19a1b117945f3235e014f926fe93b0c5a Mon Sep 17 00:00:00 2001 From: loli10K Date: Tue, 7 Jan 2020 00:40:06 +0100 Subject: Fix "zpool add -n" for dedup, special and log devices For dedup, special and log devices "zpool add -n" does not print correctly their vdev type: ~# zpool add -n pool dedup /tmp/dedup special /tmp/special log /tmp/log would update 'pool' to the following configuration: pool /tmp/normal /tmp/dedup /tmp/special /tmp/log This could lead storage administrators to modify their ZFS pools to unexpected and unintended vdev configurations. Reviewed-by: Brian Behlendorf Signed-off-by: loli10K Closes #9783 Closes #9390 --- module/zcommon/zfs_comutil.c | 8 ++++++-- module/zfs/spa.c | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'module') diff --git a/module/zcommon/zfs_comutil.c b/module/zcommon/zfs_comutil.c index a3ff7d8e6..1cec60ac1 100644 --- a/module/zcommon/zfs_comutil.c +++ b/module/zcommon/zfs_comutil.c @@ -68,7 +68,7 @@ zfs_allocatable_devs(nvlist_t *nv) * Are there special vdevs? */ boolean_t -zfs_special_devs(nvlist_t *nv) +zfs_special_devs(nvlist_t *nv, char *type) { char *bias; uint_t c; @@ -84,7 +84,11 @@ zfs_special_devs(nvlist_t *nv) &bias) == 0) { if (strcmp(bias, VDEV_ALLOC_BIAS_SPECIAL) == 0 || strcmp(bias, VDEV_ALLOC_BIAS_DEDUP) == 0) { - return (B_TRUE); + if (type != NULL && strcmp(bias, type) == 0) { + return (B_TRUE); + } else if (type == NULL) { + return (B_TRUE); + } } } } diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 6cadefe91..39b59d5ce 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -5690,7 +5690,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props, return (error); } } - if (!has_allocclass && zfs_special_devs(nvroot)) { + if (!has_allocclass && zfs_special_devs(nvroot, NULL)) { spa_deactivate(spa); spa_remove(spa); mutex_exit(&spa_namespace_lock); -- cgit v1.2.3