diff options
author | Attila Fülöp <[email protected]> | 2020-12-04 23:04:39 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-12-04 14:04:39 -0800 |
commit | 0cb40fa38903298b7af2b1084e8228b2c8315c4e (patch) | |
tree | 6ce40a229058baa2cb1fcb3fcd517f59cbceb6f9 /lib/libzfs | |
parent | 4b6e2a5a33957af806b708723f32b83dbafce326 (diff) |
zpool: Dryrun fails to list some devices
`zpool create -n` fails to list cache and spare vdevs.
`zpool add -n` fails to list spare devices.
`zpool split -n` fails to list `special` and `dedup` labels.
`zpool add -n` and `zpool split -n` shouldn't list hole devices.
Reviewed-by: Ryan Moeller <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Attila Fülöp <[email protected]>
Closes #11122
Closes #11167
Diffstat (limited to 'lib/libzfs')
-rw-r--r-- | lib/libzfs/libzfs_pool.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/libzfs/libzfs_pool.c b/lib/libzfs/libzfs_pool.c index c1dc0d75b..c661ab313 100644 --- a/lib/libzfs/libzfs_pool.c +++ b/lib/libzfs/libzfs_pool.c @@ -3431,7 +3431,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, nvlist_t *props, splitflags_t flags) { zfs_cmd_t zc = {"\0"}; - char msg[1024]; + char msg[1024], *bias; nvlist_t *tree, *config, **child, **newchild, *newconfig = NULL; nvlist_t **varray = NULL, *zc_props = NULL; uint_t c, children, newchildren, lastlog = 0, vcount, found = 0; @@ -3489,6 +3489,7 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, for (c = 0; c < children; c++) { uint64_t is_log = B_FALSE, is_hole = B_FALSE; + boolean_t is_special = B_FALSE, is_dedup = B_FALSE; char *type; nvlist_t **mchild, *vdev; uint_t mchildren; @@ -3535,6 +3536,13 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, goto out; } + if (nvlist_lookup_string(child[c], + ZPOOL_CONFIG_ALLOCATION_BIAS, &bias) == 0) { + if (strcmp(bias, VDEV_ALLOC_BIAS_SPECIAL) == 0) + is_special = B_TRUE; + else if (strcmp(bias, VDEV_ALLOC_BIAS_DEDUP) == 0) + is_dedup = B_TRUE; + } verify(nvlist_lookup_nvlist_array(child[c], ZPOOL_CONFIG_CHILDREN, &mchild, &mchildren) == 0); @@ -3552,6 +3560,20 @@ zpool_vdev_split(zpool_handle_t *zhp, char *newname, nvlist_t **newroot, if (nvlist_dup(vdev, &varray[vcount++], 0) != 0) goto out; + + if (flags.dryrun != 0) { + if (is_dedup == B_TRUE) { + if (nvlist_add_string(varray[vcount - 1], + ZPOOL_CONFIG_ALLOCATION_BIAS, + VDEV_ALLOC_BIAS_DEDUP) != 0) + goto out; + } else if (is_special == B_TRUE) { + if (nvlist_add_string(varray[vcount - 1], + ZPOOL_CONFIG_ALLOCATION_BIAS, + VDEV_ALLOC_BIAS_SPECIAL) != 0) + goto out; + } + } } /* did we find every disk the user specified? */ |