aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zpool
diff options
context:
space:
mode:
authorTony Hutter <[email protected]>2024-07-11 15:35:40 -0700
committerBrian Behlendorf <[email protected]>2024-08-06 12:47:58 -0700
commit02a9f7fed7df12e3a18c984db6b8fc927daa4630 (patch)
treeed9e5821e01e3eec93a01678a633b61233348449 /cmd/zpool
parentdab810014e36241323d53eeab763009719209ed6 (diff)
JSON: Fix class values for mirrored special vdevs
This fixes things so mirrored special vdevs report themselves as "class=special" rather than "class=normal". This happens due to the way the vdev nvlists are constructed: mirrored special devices - The 'mirror' vdev has allocation bias as "special" and it's leaf vdevs are "normal" single or RAID0 special devices - Leaf vdevs have allocation bias as "special". This commit adds in code to check if a leaf's parent is a "special" vdev to see if it should also report "special". Reviewed-by: Ameer Hamza <[email protected]> Reviewed-by: Umer Saleem <[email protected]> Signed-off-by: Tony Hutter <[email protected]> Closes #16217
Diffstat (limited to 'cmd/zpool')
-rw-r--r--cmd/zpool/zpool_main.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 6f8817c09..620746f8e 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -1154,11 +1154,16 @@ fill_vdev_info(nvlist_t *list, zpool_handle_t *zhp, char *name,
vdev_stat_t *vs;
uint_t c;
nvlist_t *nvdev;
+ nvlist_t *nvdev_parent = NULL;
+ char *_name;
if (strcmp(name, zpool_get_name(zhp)) != 0)
- nvdev = zpool_find_vdev(zhp, name, NULL, &l2c, NULL);
+ _name = name;
else
- nvdev = zpool_find_vdev(zhp, "root-0", NULL, &l2c, NULL);
+ _name = (char *)"root-0";
+
+ nvdev = zpool_find_vdev(zhp, _name, NULL, &l2c, NULL);
+
fnvlist_add_string(list, "name", name);
if (addtype)
fnvlist_add_string(list, "type", "VDEV");
@@ -1203,8 +1208,32 @@ fill_vdev_info(nvlist_t *list, zpool_handle_t *zhp, char *name,
ZPOOL_CONFIG_ALLOCATION_BIAS, &bias);
if (bias != NULL)
fnvlist_add_string(list, "class", bias);
- else
- fnvlist_add_string(list, "class", "normal");
+ else {
+ nvdev_parent = NULL;
+ nvdev_parent = zpool_find_parent_vdev(zhp,
+ _name, NULL, NULL, NULL);
+
+ /*
+ * With a mirrored special device, the parent
+ * "mirror" vdev will have
+ * ZPOOL_CONFIG_ALLOCATION_BIAS set to "special"
+ * not the leaf vdevs. If we're a leaf vdev
+ * in that case we need to look at our parent
+ * to see if they're "special" to know if we
+ * are "special" too.
+ */
+ if (nvdev_parent) {
+ (void) nvlist_lookup_string(
+ nvdev_parent,
+ ZPOOL_CONFIG_ALLOCATION_BIAS,
+ &bias);
+ }
+ if (bias != NULL)
+ fnvlist_add_string(list, "class", bias);
+ else
+ fnvlist_add_string(list, "class",
+ "normal");
+ }
}
if (nvlist_lookup_uint64_array(nvdev, ZPOOL_CONFIG_VDEV_STATS,
(uint64_t **)&vs, &c) == 0) {