aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2019-03-06 09:17:53 -0800
committerGitHub <[email protected]>2019-03-06 09:17:53 -0800
commit96ebc5a1a4cc57806882e4e9b38c49ba8a5bdfda (patch)
treebadaa649b8d8bc6a2040692ee3e94c260a99614b /module/zfs
parent762f9ef3d9d897b5baf7c91d6e8a7bf371a9b02f (diff)
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 <[email protected]> Reviewed-by: Richard Elling <[email protected]> Reviewed-by: Tim Chase <[email protected]> Reviewed-by: George Wilson <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #8461
Diffstat (limited to 'module/zfs')
-rw-r--r--module/zfs/vdev_initialize.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/module/zfs/vdev_initialize.c b/module/zfs/vdev_initialize.c
index a69eca354..bec89a28e 100644
--- a/module/zfs/vdev_initialize.c
+++ b/module/zfs/vdev_initialize.c
@@ -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);