From e1fd8cd14cce49b94b5a6caa601b8ea3ce56caeb Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 19 Dec 2019 13:32:39 -0800 Subject: [PATCH] Cancel initialize and TRIM before vdev_metaslab_fini() Any running 'zpool initialize' or TRIM must be cancelled prior to the vdev_metaslab_fini() call in spa_vdev_remove_log() which will unload the metaslabs and set ms->ms_group == NULL. TEST_ZTEST_TIMEOUT=7200 Signed-off-by: Brian Behlendorf Issue #8602 --- module/zfs/vdev_removal.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/module/zfs/vdev_removal.c b/module/zfs/vdev_removal.c index 614f70efcc1c..a6b0e9660564 100644 --- a/module/zfs/vdev_removal.c +++ b/module/zfs/vdev_removal.c @@ -1889,11 +1889,16 @@ spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) ASSERT0(vd->vdev_stat.vs_alloc); /* - * The evacuation succeeded. Remove any remaining MOS metadata - * associated with this vdev, and wait for these changes to sync. + * The evacuation succeeded. Cancel any initialize or TRIM which + * was in progress, remove any remaining MOS metadata associated + * with this vdev, and wait for these changes to sync. */ vd->vdev_removing = B_TRUE; + vdev_initialize_stop_all(vd, VDEV_INITIALIZE_CANCELED); + vdev_trim_stop_all(vd, VDEV_TRIM_CANCELED); + vdev_autotrim_stop_wait(vd); + vdev_dirty_leaves(vd, VDD_DTL, *txg); vdev_config_dirty(vd); @@ -1922,11 +1927,6 @@ spa_vdev_remove_log(vdev_t *vd, uint64_t *txg) spa_vdev_config_exit(spa, NULL, *txg, 0, FTAG); - /* Stop initializing and TRIM */ - vdev_initialize_stop_all(vd, VDEV_INITIALIZE_CANCELED); - vdev_trim_stop_all(vd, VDEV_TRIM_CANCELED); - vdev_autotrim_stop_wait(vd); - *txg = spa_vdev_config_enter(spa); sysevent_t *ev = spa_event_create(spa, vd, NULL,