Fix the extent state checking on the merge error path.

With DSS as primary, the default merge impl will (correctly) decline to merge
when one of the extent is non-dss.  The error path should tolerate the
not-merged extent being in a merging state.
This commit is contained in:
Qi Wang 2022-01-07 11:41:24 -08:00 committed by Qi Wang
parent c9946fa7e6
commit d66162e032

View File

@ -245,11 +245,10 @@ extents_abandon_vm(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, ecache_t *ecache,
} }
static void static void
extent_deactivate_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache, extent_deactivate_locked_impl(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache,
edata_t *edata) { edata_t *edata) {
malloc_mutex_assert_owner(tsdn, &ecache->mtx); malloc_mutex_assert_owner(tsdn, &ecache->mtx);
assert(edata_arena_ind_get(edata) == ecache_ind_get(ecache)); assert(edata_arena_ind_get(edata) == ecache_ind_get(ecache));
assert(edata_state_get(edata) == extent_state_active);
emap_update_edata_state(tsdn, pac->emap, edata, ecache->state); emap_update_edata_state(tsdn, pac->emap, edata, ecache->state);
eset_t *eset = edata_guarded_get(edata) ? &ecache->guarded_eset : eset_t *eset = edata_guarded_get(edata) ? &ecache->guarded_eset :
@ -257,6 +256,20 @@ extent_deactivate_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache,
eset_insert(eset, edata); eset_insert(eset, edata);
} }
static void
extent_deactivate_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache,
edata_t *edata) {
assert(edata_state_get(edata) == extent_state_active);
extent_deactivate_locked_impl(tsdn, pac, ecache, edata);
}
static void
extent_deactivate_check_state_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache,
edata_t *edata, extent_state_t expected_state) {
assert(edata_state_get(edata) == expected_state);
extent_deactivate_locked_impl(tsdn, pac, ecache, edata);
}
static void static void
extent_activate_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache, eset_t *eset, extent_activate_locked(tsdn_t *tsdn, pac_t *pac, ecache_t *ecache, eset_t *eset,
edata_t *edata) { edata_t *edata) {
@ -796,7 +809,8 @@ extent_coalesce(tsdn_t *tsdn, pac_t *pac, ehooks_t *ehooks, ecache_t *ecache,
forward ? inner : outer, forward ? outer : inner, forward ? inner : outer, forward ? outer : inner,
/* holding_core_locks */ true); /* holding_core_locks */ true);
if (err) { if (err) {
extent_deactivate_locked(tsdn, pac, ecache, outer); extent_deactivate_check_state_locked(tsdn, pac, ecache, outer,
extent_state_merging);
} }
return err; return err;