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 <hutter2@llnl.gov>
Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Rob Wing <rob.wing@klarasystems.com>
Co-authored-by: Rob Wing <rob.wing@klarasystems.com>
Sponsored-by: Seagate Technology
Submitted-by: Klara, Inc.
Closes #14311
This commit is contained in:
rob-wing 2023-01-11 14:14:35 -09:00 committed by GitHub
parent 926715b9fc
commit 6f2ffd272c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 11 deletions

View File

@ -5184,21 +5184,14 @@ get_stat_flags(zpool_list_t *list)
static int static int
is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data) is_vdev_cb(void *zhp_data, nvlist_t *nv, void *cb_data)
{ {
uint64_t guid;
vdev_cbdata_t *cb = cb_data; vdev_cbdata_t *cb = cb_data;
char *name = NULL;
int ret = 1; /* assume match */
zpool_handle_t *zhp = zhp_data; zpool_handle_t *zhp = zhp_data;
name = zpool_vdev_name(g_zfs, zhp, nv, cb->cb_name_flags); if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID, &guid) != 0)
return (0);
if (strcmp(name, cb->cb_names[0])) { return (guid == zpool_vdev_path_to_guid(zhp, 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);
return (ret);
} }
/* /*