Skip to content

Commit

Permalink
Fix waiting in ztest_device_removal()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Serapheim Dimitropoulos <[email protected]>
Reviewed-by: Matthew Ahrens <[email protected]>
Signed-off-by: Tom Caputi <[email protected]>
Closes openzfs#8010
  • Loading branch information
Tom Caputi authored and ghfields committed Oct 29, 2018
1 parent d286d28 commit 55a49fa
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 55a49fa

Please sign in to comment.