Fix race in vdev_initialize_thread

Before allowing new allocations to the metaslab we need to ensure
that any issued initializing writes have been synced.  Otherwise,
it's possible for metaslab_block_alloc() to allocate a range which
is about to be overwritten by an initializing IO.

Serapheim Dimitropoulos <serapheim@delphix.com>
Reviewed-by: Richard Elling <Richard.Elling@RichardElling.com>
Reviewed-by: Tim Chase <tim@chase2k.com>
Reviewed-by: George Wilson <george.wilson@delphix.com>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #8461
This commit is contained in:
Brian Behlendorf 2019-03-06 09:17:53 -08:00 committed by GitHub
parent 762f9ef3d9
commit 96ebc5a1a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -628,6 +628,13 @@ vdev_initialize_thread(void *arg)
spa_config_exit(spa, SCL_CONFIG, FTAG);
error = vdev_initialize_ranges(vd, deadbeef);
/*
* Wait for the outstanding IO to be synced to prevent
* newly allocated blocks from being overwritten.
*/
txg_wait_synced(spa_get_dsl(spa), 0);
vdev_initialize_ms_unmark(msp);
spa_config_enter(spa, SCL_CONFIG, FTAG, RW_READER);