mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 18:40:43 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: loli10K <ezomori.nozomu@gmail.com> Closes #9783 Closes #9390
This commit is contained in:
committed by
Brian Behlendorf
parent
bc9cef11fd
commit
c24fa4b19a
+27
-12
@@ -936,20 +936,35 @@ zpool_do_add(int argc, char **argv)
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0, "", name_flags);
|
||||
|
||||
/* print other classes: 'dedup', 'special', and 'log' */
|
||||
print_vdev_tree(zhp, "dedup", poolnvroot, 0,
|
||||
VDEV_ALLOC_BIAS_DEDUP, name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0, VDEV_ALLOC_BIAS_DEDUP,
|
||||
name_flags);
|
||||
if (zfs_special_devs(poolnvroot, VDEV_ALLOC_BIAS_DEDUP)) {
|
||||
print_vdev_tree(zhp, "dedup", poolnvroot, 0,
|
||||
VDEV_ALLOC_BIAS_DEDUP, name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_DEDUP, name_flags);
|
||||
} else if (zfs_special_devs(nvroot, VDEV_ALLOC_BIAS_DEDUP)) {
|
||||
print_vdev_tree(zhp, "dedup", nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_DEDUP, name_flags);
|
||||
}
|
||||
|
||||
print_vdev_tree(zhp, "special", poolnvroot, 0,
|
||||
VDEV_ALLOC_BIAS_SPECIAL, name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0, VDEV_ALLOC_BIAS_SPECIAL,
|
||||
name_flags);
|
||||
if (zfs_special_devs(poolnvroot, VDEV_ALLOC_BIAS_SPECIAL)) {
|
||||
print_vdev_tree(zhp, "special", poolnvroot, 0,
|
||||
VDEV_ALLOC_BIAS_SPECIAL, name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_SPECIAL, name_flags);
|
||||
} else if (zfs_special_devs(nvroot, VDEV_ALLOC_BIAS_SPECIAL)) {
|
||||
print_vdev_tree(zhp, "special", nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_SPECIAL, name_flags);
|
||||
}
|
||||
|
||||
print_vdev_tree(zhp, "logs", poolnvroot, 0, VDEV_ALLOC_BIAS_LOG,
|
||||
name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0, VDEV_ALLOC_BIAS_LOG,
|
||||
name_flags);
|
||||
if (num_logs(poolnvroot) > 0) {
|
||||
print_vdev_tree(zhp, "logs", poolnvroot, 0,
|
||||
VDEV_ALLOC_BIAS_LOG, name_flags);
|
||||
print_vdev_tree(zhp, NULL, nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_LOG, name_flags);
|
||||
} else if (num_logs(nvroot) > 0) {
|
||||
print_vdev_tree(zhp, "logs", nvroot, 0,
|
||||
VDEV_ALLOC_BIAS_LOG, name_flags);
|
||||
}
|
||||
|
||||
/* Do the same for the caches */
|
||||
if (nvlist_lookup_nvlist_array(poolnvroot, ZPOOL_CONFIG_L2CACHE,
|
||||
|
||||
Reference in New Issue
Block a user