summaryrefslogtreecommitdiff
path: root/lib/maple_tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/maple_tree.c')
-rw-r--r--lib/maple_tree.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index a4a2592413b1..27f55f61d88e 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5497,7 +5497,7 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
/* At this point, we are at the leaf node that needs to be altered. */
/* Exact fit, no nodes needed. */
if (wr_mas.r_min == mas->index && wr_mas.r_max == mas->last)
- return 0;
+ goto set_flag;
mas_wr_end_piv(&wr_mas);
node_size = mas_wr_new_end(&wr_mas);
@@ -5506,10 +5506,10 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
if (node_size == wr_mas.node_end) {
/* reuse node */
if (!mt_in_rcu(mas->tree))
- return 0;
+ goto set_flag;
/* shifting boundary */
if (wr_mas.offset_end - mas->offset == 1)
- return 0;
+ goto set_flag;
}
if (node_size >= mt_slots[wr_mas.type]) {
@@ -5528,10 +5528,13 @@ int mas_preallocate(struct ma_state *mas, void *entry, gfp_t gfp)
/* node store, slot store needs one node */
ask_now:
+ mas->mas_flags &= ~MA_STATE_PREALLOC;
mas_node_count_gfp(mas, request, gfp);
- mas->mas_flags |= MA_STATE_PREALLOC;
- if (likely(!mas_is_err(mas)))
+ if (likely(!mas_is_err(mas))) {
+set_flag:
+ mas->mas_flags |= MA_STATE_PREALLOC;
return 0;
+ }
mas_set_alloc_req(mas, 0);
ret = xa_err(mas->node);