From: Tom Caputi Date: Mon, 22 Oct 2018 13:54:01 +0000 (-0400) Subject: Fix waiting in ztest_device_removal() X-Git-Tag: zfs-0.8.0~328 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=7d658d29cf4b6b037156dfc29d298a7abb8afc86;p=mirror_zfs.git Fix waiting in ztest_device_removal() spa->spa_vdev_removal is created in a sync task that is initiated via dsl_sync_task_nowait(). Since the task may not run before spa_vdev_remove() returns, we must wait at least 1 txg to ensure that the removal struct has been created. Reviewed-by: Brian Behlendorf Reviewed-by: Serapheim Dimitropoulos Reviewed-by: Matthew Ahrens Signed-off-by: Tom Caputi Closes #8010 --- diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c index 983bc0dfe..14e8a5e27 100644 --- a/cmd/ztest/ztest.c +++ b/cmd/ztest/ztest.c @@ -3549,6 +3549,15 @@ ztest_device_removal(ztest_ds_t *zd, uint64_t id) ztest_device_removal_active = B_TRUE; mutex_exit(&ztest_vdev_lock); + /* + * spa->spa_vdev_removal is created in a sync task that + * is initiated via dsl_sync_task_nowait(). Since the + * task may not run before spa_vdev_remove() returns, we + * must wait at least 1 txg to ensure that the removal + * struct has been created. + */ + txg_wait_synced(spa_get_dsl(spa), 0); + while (spa->spa_vdev_removal != NULL) txg_wait_synced(spa_get_dsl(spa), 0); } else {