MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / extent_rtree_leaf_elm_try_lock

Function extent_rtree_leaf_elm_try_lock

deps/jemalloc/src/extent.c:129–156  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

127} lock_result_t;
128
129static lock_result_t
130extent_rtree_leaf_elm_try_lock(tsdn_t *tsdn, rtree_leaf_elm_t *elm,
131 extent_t **result, bool inactive_only) {
132 extent_t *extent1 = rtree_leaf_elm_extent_read(tsdn, &extents_rtree,
133 elm, true);
134
135 /* Slab implies active extents and should be skipped. */
136 if (extent1 == NULL || (inactive_only && rtree_leaf_elm_slab_read(tsdn,
137 &extents_rtree, elm, true))) {
138 return lock_result_no_extent;
139 }
140
141 /*
142 * It's possible that the extent changed out from under us, and with it
143 * the leaf->extent mapping. We have to recheck while holding the lock.
144 */
145 extent_lock(tsdn, extent1);
146 extent_t *extent2 = rtree_leaf_elm_extent_read(tsdn,
147 &extents_rtree, elm, true);
148
149 if (extent1 == extent2) {
150 *result = extent1;
151 return lock_result_success;
152 } else {
153 extent_unlock(tsdn, extent1);
154 return lock_result_failure;
155 }
156}
157
158/*
159 * Returns a pool-locked extent_t * if there's one associated with the given

Callers 1

extent_lock_from_addrFunction · 0.70

Calls 4

rtree_leaf_elm_slab_readFunction · 0.50
extent_lockFunction · 0.50
extent_unlockFunction · 0.50

Tested by

no test coverage detected