]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Add path handling for aux vdevs in `label_path`
authorAmeer Hamza <ahamza@ixsystems.com>
Thu, 4 Jan 2024 14:35:04 +0000 (19:35 +0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 16 Jan 2024 21:18:07 +0000 (13:18 -0800)
If the AUX vdev is added using UUID, importing the pool falls back AUX
vdev to open it with disk name instead of UUID due to the absence of
path information for AUX vdevs. Since AUX label now have path
information, this PR adds path handling for it in `label_path`.

Reviewed-by: Umer Saleem <usaleem@ixsystems.com>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Ameer Hamza <ahamza@ixsystems.com>
Closes #15737

lib/libzutil/zutil_import.c

index 0b5c47b08c619c0c12006b643775e59bf6a15eef..eb91311904586f3402326153724f8f46a80562ee 100644 (file)
@@ -1221,13 +1221,26 @@ label_paths(libpc_handle_t *hdl, nvlist_t *label, const char **path,
        nvlist_t *nvroot;
        uint64_t pool_guid;
        uint64_t vdev_guid;
+       uint64_t state;
 
        *path = NULL;
        *devid = NULL;
+       if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_GUID, &vdev_guid) != 0)
+               return (ENOENT);
+
+       /*
+        * In case of spare or l2cache, we directly return path/devid from the
+        * label.
+        */
+       if (!(nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_STATE, &state)) &&
+           (state == POOL_STATE_SPARE || state == POOL_STATE_L2CACHE)) {
+               (void) nvlist_lookup_string(label, ZPOOL_CONFIG_PATH, path);
+               (void) nvlist_lookup_string(label, ZPOOL_CONFIG_DEVID, devid);
+               return (0);
+       }
 
        if (nvlist_lookup_nvlist(label, ZPOOL_CONFIG_VDEV_TREE, &nvroot) ||
-           nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_GUID, &pool_guid) ||
-           nvlist_lookup_uint64(label, ZPOOL_CONFIG_GUID, &vdev_guid))
+           nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_GUID, &pool_guid))
                return (ENOENT);
 
        return (label_paths_impl(hdl, nvroot, pool_guid, vdev_guid, path,