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 add 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 Feb 20, 2017
1 parent d39653e commit c7654b5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions module/zfs/metaslab.c
Expand Up @@ -1531,6 +1531,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 c7654b5

Please sign in to comment.