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 Gregor Kopka committed Jan 7, 2019
1 parent 8c5ab43 commit dc46a9c
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 dc46a9c

Please sign in to comment.