From 32366649d3164e994def7e5a26765ca6bc1e2315 Mon Sep 17 00:00:00 2001 From: nssrikanth <75025422+nssrikanth@users.noreply.github.com> Date: Fri, 5 Feb 2021 22:00:50 +0530 Subject: [PATCH] Fixed issue with processing of EC_dev_remove event The pool guid and vdev guid received by zfs_agent_post_event(), which calls zfs_retire_recv(), are normally non-zero. However, later in this same method they may be unconditionally reset to zero by the code which is intended to handle multipath, spare and l2arc vdevs. This will result in the EC_dev_remove not being handled. Reviewed-by: Brian Behlendorf \ Co-authored-by: Vipin Kumar Verma Signed-off-by: Srikanth N S Closes #11564 --- cmd/zed/agents/zfs_agents.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/cmd/zed/agents/zfs_agents.c b/cmd/zed/agents/zfs_agents.c index 0e1bcf9276..67b7951b0e 100644 --- a/cmd/zed/agents/zfs_agents.c +++ b/cmd/zed/agents/zfs_agents.c @@ -13,6 +13,7 @@ /* * Copyright (c) 2016, Intel Corporation. * Copyright (c) 2018, loli10K + * Copyright (c) 2021 Hewlett Packard Enterprise Development LP */ #include @@ -211,12 +212,18 @@ zfs_agent_post_event(const char *class, const char *subclass, nvlist_t *nvl) * For multipath, spare and l2arc devices ZFS_EV_VDEV_GUID or * ZFS_EV_POOL_GUID may be missing so find them. */ - (void) nvlist_lookup_string(nvl, DEV_IDENTIFIER, - &search.gs_devid); - (void) zpool_iter(g_zfs_hdl, zfs_agent_iter_pool, &search); - pool_guid = search.gs_pool_guid; - vdev_guid = search.gs_vdev_guid; - devtype = search.gs_vdev_type; + if (pool_guid == 0 || vdev_guid == 0) { + if ((nvlist_lookup_string(nvl, DEV_IDENTIFIER, + &search.gs_devid) == 0) && + (zpool_iter(g_zfs_hdl, zfs_agent_iter_pool, &search) + == 1)) { + if (pool_guid == 0) + pool_guid = search.gs_pool_guid; + if (vdev_guid == 0) + vdev_guid = search.gs_vdev_guid; + devtype = search.gs_vdev_type; + } + } /* * We want to avoid reporting "remove" events coming from