vdev_to_nvlist_iter: ignore draid parameters when matching names (#17228)

Various tools will display draid vdev names with parameters embedded in
them, but would not accept them as valid vdev names when looking them
up, making it difficult to build pipelines involving draid vdevs.

This commit makes it so that if a full draid name is offered for match,
it gets truncated at the first ':' character.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.

Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
(cherry picked from commit 131df3bbf2)
This commit is contained in:
Rob Norris
2025-04-15 10:10:48 +10:00
committed by Tony Hutter
parent c2424f8d1a
commit 7fde3933fb
4 changed files with 107 additions and 1 deletions
+12
View File
@@ -2961,6 +2961,18 @@ vdev_to_nvlist_iter(nvlist_t *nv, nvlist_t *search, boolean_t *avail_spare,
idx = p + 1;
*p = '\0';
/*
* draid names are presented like: draid2:4d:6c:0s
* We match them up to the first ':' so we can still
* do the parity check below, but the other params
* are ignored.
*/
if ((p = strchr(type, ':')) != NULL) {
if (strncmp(type, VDEV_TYPE_DRAID,
strlen(VDEV_TYPE_DRAID)) == 0)
*p = '\0';
}
/*
* If the types don't match then keep looking.
*/