Rename emap_split_prepare_t -> emap_prepare_t.
Both the split and merge functions use it.
This commit is contained in:
parent
0586a56f39
commit
231d1477e5
@ -70,8 +70,8 @@ void emap_deregister_boundary(tsdn_t *tsdn, emap_t *emap,
|
||||
void emap_deregister_interior(tsdn_t *tsdn, emap_t *emap,
|
||||
rtree_ctx_t *rtree_ctx, edata_t *edata);
|
||||
|
||||
typedef struct emap_split_prepare_s emap_split_prepare_t;
|
||||
struct emap_split_prepare_s {
|
||||
typedef struct emap_prepare_s emap_prepare_t;
|
||||
struct emap_prepare_s {
|
||||
rtree_leaf_elm_t *lead_elm_a;
|
||||
rtree_leaf_elm_t *lead_elm_b;
|
||||
rtree_leaf_elm_t *trail_elm_a;
|
||||
@ -79,16 +79,14 @@ struct emap_split_prepare_s {
|
||||
};
|
||||
|
||||
bool emap_split_prepare(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
emap_split_prepare_t *split_prepare, edata_t *edata, size_t size_a,
|
||||
szind_t szind_a, bool slab_a, edata_t *trail, size_t size_b,
|
||||
szind_t szind_b, bool slab_b);
|
||||
void emap_split_commit(tsdn_t *tsdn, emap_t *emap,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, size_t size_a,
|
||||
szind_t szind_a, bool slab_a, edata_t *trail, size_t size_b,
|
||||
szind_t szind_b, bool slab_b);
|
||||
emap_prepare_t *prepare, edata_t *edata, size_t size_a, szind_t szind_a,
|
||||
bool slab_a, edata_t *trail, size_t size_b, szind_t szind_b, bool slab_b);
|
||||
void emap_split_commit(tsdn_t *tsdn, emap_t *emap, emap_prepare_t *prepare,
|
||||
edata_t *lead, size_t size_a, szind_t szind_a, bool slab_a, edata_t *trail,
|
||||
size_t size_b, szind_t szind_b, bool slab_b);
|
||||
void emap_merge_prepare(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, edata_t *trail);
|
||||
void emap_merge_commit(tsdn_t *tsdn, emap_t *emap,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, edata_t *trail);
|
||||
emap_prepare_t *prepare, edata_t *lead, edata_t *trail);
|
||||
void emap_merge_commit(tsdn_t *tsdn, emap_t *emap, emap_prepare_t *prepare,
|
||||
edata_t *lead, edata_t *trail);
|
||||
|
||||
#endif /* JEMALLOC_INTERNAL_EMAP_H */
|
||||
|
56
src/emap.c
56
src/emap.c
@ -186,9 +186,8 @@ emap_deregister_interior(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
|
||||
bool
|
||||
emap_split_prepare(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
emap_split_prepare_t *split_prepare, edata_t *edata, size_t size_a,
|
||||
szind_t szind_a, bool slab_a, edata_t *trail, size_t size_b,
|
||||
szind_t szind_b, bool slab_b) {
|
||||
emap_prepare_t *prepare, edata_t *edata, size_t size_a, szind_t szind_a,
|
||||
bool slab_a, edata_t *trail, size_t size_b, szind_t szind_b, bool slab_b) {
|
||||
/*
|
||||
* Note that while the trail mostly inherits its attributes from the
|
||||
* extent to be split, it maintains its own arena ind -- this allows
|
||||
@ -210,57 +209,54 @@ emap_split_prepare(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
extent_state_active, false, false, false, EXTENT_NOT_HEAD);
|
||||
|
||||
emap_rtree_leaf_elms_lookup(tsdn, emap, rtree_ctx, &lead, false, true,
|
||||
&split_prepare->lead_elm_a, &split_prepare->lead_elm_b);
|
||||
&prepare->lead_elm_a, &prepare->lead_elm_b);
|
||||
emap_rtree_leaf_elms_lookup(tsdn, emap, rtree_ctx, trail, false, true,
|
||||
&split_prepare->trail_elm_a, &split_prepare->trail_elm_b);
|
||||
&prepare->trail_elm_a, &prepare->trail_elm_b);
|
||||
|
||||
if (split_prepare->lead_elm_a == NULL
|
||||
|| split_prepare->lead_elm_b == NULL
|
||||
|| split_prepare->trail_elm_a == NULL
|
||||
|| split_prepare->trail_elm_b == NULL) {
|
||||
if (prepare->lead_elm_a == NULL || prepare->lead_elm_b == NULL
|
||||
|| prepare->trail_elm_a == NULL || prepare->trail_elm_b == NULL) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
emap_split_commit(tsdn_t *tsdn, emap_t *emap,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, size_t size_a,
|
||||
szind_t szind_a, bool slab_a, edata_t *trail, size_t size_b,
|
||||
szind_t szind_b, bool slab_b) {
|
||||
emap_split_commit(tsdn_t *tsdn, emap_t *emap, emap_prepare_t *prepare,
|
||||
edata_t *lead, size_t size_a, szind_t szind_a, bool slab_a, edata_t *trail,
|
||||
size_t size_b, szind_t szind_b, bool slab_b) {
|
||||
edata_size_set(lead, size_a);
|
||||
edata_szind_set(lead, szind_a);
|
||||
|
||||
emap_rtree_write_acquired(tsdn, emap, split_prepare->lead_elm_a,
|
||||
split_prepare->lead_elm_b, lead, szind_a, slab_a);
|
||||
emap_rtree_write_acquired(tsdn, emap, split_prepare->trail_elm_a,
|
||||
split_prepare->trail_elm_b, trail, szind_b, slab_b);
|
||||
emap_rtree_write_acquired(tsdn, emap, prepare->lead_elm_a,
|
||||
prepare->lead_elm_b, lead, szind_a, slab_a);
|
||||
emap_rtree_write_acquired(tsdn, emap, prepare->trail_elm_a,
|
||||
prepare->trail_elm_b, trail, szind_b, slab_b);
|
||||
}
|
||||
|
||||
void
|
||||
emap_merge_prepare(tsdn_t *tsdn, emap_t *emap, rtree_ctx_t *rtree_ctx,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, edata_t *trail) {
|
||||
emap_prepare_t *prepare, edata_t *lead, edata_t *trail) {
|
||||
emap_rtree_leaf_elms_lookup(tsdn, emap, rtree_ctx, lead, true, false,
|
||||
&split_prepare->lead_elm_a, &split_prepare->lead_elm_b);
|
||||
&prepare->lead_elm_a, &prepare->lead_elm_b);
|
||||
emap_rtree_leaf_elms_lookup(tsdn, emap, rtree_ctx, trail, true, false,
|
||||
&split_prepare->trail_elm_a, &split_prepare->trail_elm_b);
|
||||
&prepare->trail_elm_a, &prepare->trail_elm_b);
|
||||
}
|
||||
|
||||
void
|
||||
emap_merge_commit(tsdn_t *tsdn, emap_t *emap,
|
||||
emap_split_prepare_t *split_prepare, edata_t *lead, edata_t *trail) {
|
||||
if (split_prepare->lead_elm_b != NULL) {
|
||||
emap_merge_commit(tsdn_t *tsdn, emap_t *emap, emap_prepare_t *prepare,
|
||||
edata_t *lead, edata_t *trail) {
|
||||
if (prepare->lead_elm_b != NULL) {
|
||||
rtree_leaf_elm_write(tsdn, &emap->rtree,
|
||||
split_prepare->lead_elm_b, NULL, SC_NSIZES, false);
|
||||
prepare->lead_elm_b, NULL, SC_NSIZES, false);
|
||||
}
|
||||
|
||||
rtree_leaf_elm_t *merged_b;
|
||||
if (split_prepare->trail_elm_b != NULL) {
|
||||
if (prepare->trail_elm_b != NULL) {
|
||||
rtree_leaf_elm_write(tsdn, &emap->rtree,
|
||||
split_prepare->trail_elm_a, NULL, SC_NSIZES, false);
|
||||
merged_b = split_prepare->trail_elm_b;
|
||||
prepare->trail_elm_a, NULL, SC_NSIZES, false);
|
||||
merged_b = prepare->trail_elm_b;
|
||||
} else {
|
||||
merged_b = split_prepare->trail_elm_a;
|
||||
merged_b = prepare->trail_elm_a;
|
||||
}
|
||||
|
||||
edata_size_set(lead, edata_size_get(lead) + edata_size_get(trail));
|
||||
@ -270,6 +266,6 @@ emap_merge_commit(tsdn_t *tsdn, emap_t *emap,
|
||||
edata_zeroed_set(lead, edata_zeroed_get(lead)
|
||||
&& edata_zeroed_get(trail));
|
||||
|
||||
emap_rtree_write_acquired(tsdn, emap, split_prepare->lead_elm_a,
|
||||
merged_b, lead, SC_NSIZES, false);
|
||||
emap_rtree_write_acquired(tsdn, emap, prepare->lead_elm_a, merged_b,
|
||||
lead, SC_NSIZES, false);
|
||||
}
|
||||
|
20
src/extent.c
20
src/extent.c
@ -1278,10 +1278,9 @@ extent_split_impl(tsdn_t *tsdn, edata_cache_t *edata_cache, ehooks_t *ehooks,
|
||||
|
||||
rtree_ctx_t rtree_ctx_fallback;
|
||||
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
|
||||
emap_split_prepare_t split_prepare;
|
||||
bool err = emap_split_prepare(tsdn, &emap_global, rtree_ctx,
|
||||
&split_prepare, edata, size_a, szind_a, slab_a, trail, size_b,
|
||||
szind_b, slab_b);
|
||||
emap_prepare_t prepare;
|
||||
bool err = emap_split_prepare(tsdn, &emap_global, rtree_ctx, &prepare,
|
||||
edata, size_a, szind_a, slab_a, trail, size_b, szind_b, slab_b);
|
||||
if (err) {
|
||||
goto label_error_b;
|
||||
}
|
||||
@ -1295,8 +1294,8 @@ extent_split_impl(tsdn_t *tsdn, edata_cache_t *edata_cache, ehooks_t *ehooks,
|
||||
goto label_error_c;
|
||||
}
|
||||
|
||||
emap_split_commit(tsdn, &emap_global, &split_prepare, edata, size_a,
|
||||
szind_a, slab_a, trail, size_b, szind_b, slab_b);
|
||||
emap_split_commit(tsdn, &emap_global, &prepare, edata, size_a, szind_a,
|
||||
slab_a, trail, size_b, szind_b, slab_b);
|
||||
|
||||
emap_unlock_edata2(tsdn, &emap_global, edata, trail);
|
||||
|
||||
@ -1342,12 +1341,11 @@ extent_merge_impl(tsdn_t *tsdn, ehooks_t *ehooks, edata_cache_t *edata_cache,
|
||||
*/
|
||||
rtree_ctx_t rtree_ctx_fallback;
|
||||
rtree_ctx_t *rtree_ctx = tsdn_rtree_ctx(tsdn, &rtree_ctx_fallback);
|
||||
emap_split_prepare_t split_prepare;
|
||||
emap_merge_prepare(tsdn, &emap_global, rtree_ctx, &split_prepare, a, b);
|
||||
emap_prepare_t prepare;
|
||||
emap_merge_prepare(tsdn, &emap_global, rtree_ctx, &prepare, a, b);
|
||||
|
||||
emap_lock_edata2(tsdn, &emap_global, a, b);
|
||||
|
||||
emap_merge_commit(tsdn, &emap_global, &split_prepare, a, b);
|
||||
|
||||
emap_merge_commit(tsdn, &emap_global, &prepare, a, b);
|
||||
emap_unlock_edata2(tsdn, &emap_global, a, b);
|
||||
|
||||
edata_cache_put(tsdn, edata_cache, b);
|
||||
|
Loading…
Reference in New Issue
Block a user