Skip to content

Commit

Permalink
Fix vdev removal finishing race
Browse files Browse the repository at this point in the history
This patch fixes a race condition where the end of
vdev_remove_replace_with_indirect(), which holds
svr_lock, would race against spa_vdev_removal_destroy(),
which destroys the same lock and is called asynchronously
via dsl_sync_task_nowait().

Signed-off-by: Tom Caputi <tcaputi@datto.com>
  • Loading branch information
Tom Caputi committed Oct 31, 2018
1 parent 6459492 commit c693cc6
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions module/zfs/vdev_removal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1115,19 +1115,16 @@ vdev_remove_replace_with_indirect(vdev_t *vd, uint64_t txg)

ASSERT(!list_link_active(&vd->vdev_state_dirty_node));

tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_remove_complete_sync, svr,
0, ZFS_SPACE_CHECK_NONE, tx);
dmu_tx_commit(tx);

/*
* Indicate that this thread has exited.
* After this, we can not use svr.
*/
mutex_enter(&svr->svr_lock);
svr->svr_thread = NULL;
cv_broadcast(&svr->svr_cv);
mutex_exit(&svr->svr_lock);

/* After this, we can not use svr. */
tx = dmu_tx_create_assigned(spa->spa_dsl_pool, txg);
dsl_sync_task_nowait(spa->spa_dsl_pool, vdev_remove_complete_sync, svr,
0, ZFS_SPACE_CHECK_NONE, tx);
dmu_tx_commit(tx);
}

/*
Expand Down

0 comments on commit c693cc6

Please sign in to comment.