diff options
author | rob-wing <[email protected]> | 2023-01-11 14:14:35 -0900 |
---|---|---|
committer | GitHub <[email protected]> | 2023-01-11 15:14:35 -0800 |
commit | 6f2ffd272cfd4487816174bf37c30b56a6443705 (patch) | |
tree | be471fe5e5fd29ed89e8520af49b9706020b169d /cmd | |
parent | 926715b9fcf043d5302e2fe07b7f2e29a29a57b4 (diff) |
zpool: do guid-based comparison in is_vdev_cb()
is_vdev_cb() uses string comparison to find a matching vdev and
will fallback to comparing the guid via a string. These changes
drop the string comparison and compare the guids instead.
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Richard Yao <[email protected]>
Reviewed-by: Allan Jude <[email protected]>
Signed-off-by: Rob Wing <[email protected]>
Co-authored-by: Rob Wing <[email protected]>
Sponsored-by: Seagate Technology
Submitted-by: Klara, Inc.
Closes #14311
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/zpool/zpool_main.c | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index 04e80efbb..6d9ff24e0 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -5184,21 +5184,14 @@ get_stat_flags(zpool_list_t *list) static int is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data) { + uint64_t guid; vdev_cbdata_t *cb = cb_data; - char *name = NULL; - int ret = 1; /* assume match */ zpool_handle_t *zhp = zhp_data; - name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags); - - if (strcmp(name, cb->cb_names[0])) { - free(name); - name = zpool_vdev_name(g_zfs, zhp, nv, VDEV_NAME_GUID); - ret = (strcmp(name, cb->cb_names[0]) == 0); - } - free(name); + if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0) + return (0); - return (ret); + return (guid == zpool_vdev_path_to_guid(zhp, cb->cb_names[0])); } /* |