From 7735c9addf0fbcf6df2fae98a6af31c7e241b61c Mon Sep 17 00:00:00 2001 From: Ryan Moeller Date: Wed, 2 Dec 2020 13:20:02 -0500 Subject: [PATCH] FreeBSD: notify userspace when a vdev is removed This is needed for zfsd to autoreplace vdevs. Reviewed-by: Brian Behlendorf Reviewed-by: Alexander Motin Signed-off-by: Ryan Moeller Closes #11260 --- cmd/zed/agents/zfs_agents.c | 2 ++ module/zfs/spa.c | 3 +++ 2 files changed, 5 insertions(+) diff --git a/cmd/zed/agents/zfs_agents.c b/cmd/zed/agents/zfs_agents.c index 6c40470e8..0e1bcf927 100644 --- a/cmd/zed/agents/zfs_agents.c +++ b/cmd/zed/agents/zfs_agents.c @@ -181,6 +181,8 @@ zfs_agent_post_event(const char *class, const char *subclass, nvlist_t *nvl) * from the vdev_disk layer after a hot unplug. Fortunately we do * get an EC_DEV_REMOVE from our disk monitor and it is a suitable * proxy so we remap it here for the benefit of the diagnosis engine. + * Starting in OpenZFS 2.0, we do get FM_RESOURCE_REMOVED from the spa + * layer. Processing multiple FM_RESOURCE_REMOVED events is not harmful. */ if ((strcmp(class, EC_DEV_REMOVE) == 0) && (strcmp(subclass, ESC_DISK) == 0) && diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 9d1d4e0cc..758710dc9 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -7903,6 +7903,9 @@ spa_async_remove(spa_t *spa, vdev_t *vd) vd->vdev_stat.vs_checksum_errors = 0; vdev_state_dirty(vd->vdev_top); + + /* Tell userspace that the vdev is gone. */ + zfs_post_remove(spa, vd); } for (int c = 0; c < vd->vdev_children; c++)