Skip to content

Commit

Permalink
3552 condensing one space map burns 3 seconds of CPU in spa_sync() th…
Browse files Browse the repository at this point in the history
…read (fix race condition)
  • Loading branch information
grwilson authored and Christopher Siden committed Feb 21, 2013
1 parent c61ea56 commit 03f8c36
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions usr/src/uts/common/fs/zfs/metaslab.c
Expand Up @@ -1383,6 +1383,13 @@ metaslab_group_alloc(metaslab_group_t *mg, uint64_t psize, uint64_t asize,
mutex_exit(&mg->mg_lock);
return (-1ULL);
}

/*
* If the selected metaslab is condensing, skip it.
*/
if (msp->ms_map->sm_condensing)
continue;

was_active = msp->ms_weight & METASLAB_ACTIVE_MASK;
if (activation_weight == METASLAB_WEIGHT_PRIMARY)
break;
Expand Down Expand Up @@ -1422,16 +1429,6 @@ metaslab_group_alloc(metaslab_group_t *mg, uint64_t psize, uint64_t asize,

mutex_enter(&msp->ms_lock);

/*
* If this metaslab is currently condensing then pick again as
* we can't manipulate this metaslab until it's committed
* to disk.
*/
if (msp->ms_map->sm_condensing) {
mutex_exit(&msp->ms_lock);
continue;
}

/*
* Ensure that the metaslab we have selected is still
* capable of handling our request. It's possible that
Expand All @@ -1458,6 +1455,16 @@ metaslab_group_alloc(metaslab_group_t *mg, uint64_t psize, uint64_t asize,
continue;
}

/*
* If this metaslab is currently condensing then pick again as
* we can't manipulate this metaslab until it's committed
* to disk.
*/
if (msp->ms_map->sm_condensing) {
mutex_exit(&msp->ms_lock);
continue;
}

if ((offset = space_map_alloc(msp->ms_map, asize)) != -1ULL)
break;

Expand Down

0 comments on commit 03f8c36

Please sign in to comment.