From: Liam R. Howlett Date: Wed, 2 Mar 2022 02:35:31 +0000 (-0500) Subject: maple_tree: Fix spanning store to a single root node X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4010ab32a99c2c42681f303ca863ccb9caaeab66;p=users%2Fjedix%2Flinux-maple.git maple_tree: Fix spanning store to a single root node Signed-off-by: Liam R. Howlett --- 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);