mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
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 <ahamza@ixsystems.com> Reviewed-by: Umer Saleem <usaleem@ixsystems.com> Signed-off-by: Tony Hutter <hutter2@llnl.gov> Closes #16217
This commit is contained in:
committed by
Brian Behlendorf
parent
dab810014e
commit
02a9f7fed7
+33
-4
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user