Skip to content

Commit

Permalink
Wait for trimming to finish in metaslab_fini
Browse files Browse the repository at this point in the history
The new spa_unload() code added as part of "OpenZFS 7303 - dynamic
metaslab selection" (4e21fd0) would cause in-flight trim zio to fail.
This patch makes sure each metaslab is finished trimming before removing
it during metaslab shutdown.
  • Loading branch information
dweeezil committed Apr 9, 2017
1 parent 03f6f65 commit f1c9cd8
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions module/zfs/metaslab.c
Original file line number Diff line number Diff line change
Expand Up @@ -1538,6 +1538,12 @@ metaslab_fini(metaslab_t *msp)

metaslab_group_t *mg = msp->ms_group;

/* Wait for trimming to finish */
mutex_enter(&msp->ms_lock);
while (msp->ms_trimming_ts != NULL)
cv_wait(&msp->ms_trim_cv, &msp->ms_lock);
mutex_exit(&msp->ms_lock);

metaslab_group_remove(mg, msp);

mutex_enter(&msp->ms_lock);
Expand Down

0 comments on commit f1c9cd8

Please sign in to comment.