aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2021-06-30 10:37:20 -0400
committerTony Hutter <[email protected]>2021-09-14 12:10:44 -0700
commitd6c2b89032bef566187a0498200cc32b8366b403 (patch)
treefdfebef4a413ad241a6bce764c60c250ba515df0 /cmd
parentf3969ea78b5f54935474d49455cf9c4d6a1e107a (diff)
ZED: Match added disk by pool/vdev GUID if found (#12217)
This enables ZED to auto-online vdevs that are not wholedisk managed by ZFS. Signed-off-by: Ryan Moeller <[email protected]> Reviewed-by: Don Brady <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Tony Hutter <[email protected]>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/zed/agents/zfs_mod.c40
-rw-r--r--cmd/zed/zed_disk_event.c2
2 files changed, 36 insertions, 6 deletions
diff --git a/cmd/zed/agents/zfs_mod.c b/cmd/zed/agents/zfs_mod.c
index b564f2b12..3bcdf6e1d 100644
--- a/cmd/zed/agents/zfs_mod.c
+++ b/cmd/zed/agents/zfs_mod.c
@@ -641,6 +641,27 @@ devid_iter(const char *devid, zfs_process_func_t func, boolean_t is_slice)
}
/*
+ * Given a device guid, find any vdevs with a matching guid.
+ */
+static boolean_t
+guid_iter(uint64_t pool_guid, uint64_t vdev_guid, const char *devid,
+ zfs_process_func_t func, boolean_t is_slice)
+{
+ dev_data_t data = { 0 };
+
+ data.dd_func = func;
+ data.dd_found = B_FALSE;
+ data.dd_pool_guid = pool_guid;
+ data.dd_vdev_guid = vdev_guid;
+ data.dd_islabeled = is_slice;
+ data.dd_new_devid = devid;
+
+ (void) zpool_iter(g_zfshdl, zfs_iter_pool, &data);
+
+ return (data.dd_found);
+}
+
+/*
* Handle a EC_DEV_ADD.ESC_DISK event.
*
* illumos
@@ -663,15 +684,18 @@ static int
zfs_deliver_add(nvlist_t *nvl, boolean_t is_lofi)
{
char *devpath = NULL, *devid;
+ uint64_t pool_guid = 0, vdev_guid = 0;
boolean_t is_slice;
/*
- * Expecting a devid string and an optional physical location
+ * Expecting a devid string and an optional physical location and guid
*/
if (nvlist_lookup_string(nvl, DEV_IDENTIFIER, &devid) != 0)
return (-1);
(void) nvlist_lookup_string(nvl, DEV_PHYS_PATH, &devpath);
+ (void) nvlist_lookup_uint64(nvl, ZFS_EV_POOL_GUID, &pool_guid);
+ (void) nvlist_lookup_uint64(nvl, ZFS_EV_VDEV_GUID, &vdev_guid);
is_slice = (nvlist_lookup_boolean(nvl, DEV_IS_PART) == 0);
@@ -682,12 +706,16 @@ zfs_deliver_add(nvlist_t *nvl, boolean_t is_lofi)
* Iterate over all vdevs looking for a match in the following order:
* 1. ZPOOL_CONFIG_DEVID (identifies the unique disk)
* 2. ZPOOL_CONFIG_PHYS_PATH (identifies disk physical location).
- *
- * For disks, we only want to pay attention to vdevs marked as whole
- * disks or are a multipath device.
+ * 3. ZPOOL_CONFIG_GUID (identifies unique vdev).
*/
- if (!devid_iter(devid, zfs_process_add, is_slice) && devpath != NULL)
- (void) devphys_iter(devpath, devid, zfs_process_add, is_slice);
+ if (devid_iter(devid, zfs_process_add, is_slice))
+ return (0);
+ if (devpath != NULL && devphys_iter(devpath, devid, zfs_process_add,
+ is_slice))
+ return (0);
+ if (vdev_guid != 0)
+ (void) guid_iter(pool_guid, vdev_guid, devid, zfs_process_add,
+ is_slice);
return (0);
}
diff --git a/cmd/zed/zed_disk_event.c b/cmd/zed/zed_disk_event.c
index 6ec566cff..94e242360 100644
--- a/cmd/zed/zed_disk_event.c
+++ b/cmd/zed/zed_disk_event.c
@@ -72,6 +72,8 @@ zed_udev_event(const char *class, const char *subclass, nvlist_t *nvl)
zed_log_msg(LOG_INFO, "\t%s: %s", DEV_PATH, strval);
if (nvlist_lookup_string(nvl, DEV_IDENTIFIER, &strval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %s", DEV_IDENTIFIER, strval);
+ if (nvlist_lookup_boolean(nvl, DEV_IS_PART) == B_TRUE)
+ zed_log_msg(LOG_INFO, "\t%s: B_TRUE", DEV_IS_PART);
if (nvlist_lookup_string(nvl, DEV_PHYS_PATH, &strval) == 0)
zed_log_msg(LOG_INFO, "\t%s: %s", DEV_PHYS_PATH, strval);
if (nvlist_lookup_uint64(nvl, DEV_SIZE, &numval) == 0)