From 4010ab32a99c2c42681f303ca863ccb9caaeab66 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Tue, 1 Mar 2022 21:35:31 -0500 Subject: [PATCH] maple_tree: Fix spanning store to a single root node Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index b2defca4a0b9..521d1e63d77c 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -2678,9 +2678,12 @@ static inline void mast_cp_to_nodes(struct maple_subtree_state *mast, mast->r->node = mte_node_or_none(right); mast->l->min = mast->orig_l->min; - mast->l->max = mast->bn->pivot[split]; mab_mas_cp(mast->bn, 0, split, mast->l, true); mast->r->max = mast->l->max; + if (split == mast->bn->b_end) { + mast->l->max = mast->orig_r->max; + return; + } if (middle) { mab_mas_cp(mast->bn, 1 + split, mid_split, mast->m, true); @@ -2941,11 +2944,12 @@ static int mas_spanning_rebalance(struct ma_state *mas, if (right) mte_set_parent(right, l_mas.node, ++slot); + if (mas_is_root_limits(mast->l)) { new_root: - if (mas_is_root_limits(mast->l)) mast_new_root(mast, mas); - else + } else { mas_mn(&l_mas)->parent = mas_mn(mast->orig_l)->parent; + } if (!mte_dead_node(mast->orig_l->node)) mat_add(&free, mast->orig_l->node); -- 2.50.1