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
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);