]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix spanning store to a single root node
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 2 Mar 2022 02:35:31 +0000 (21:35 -0500)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 8 Mar 2022 18:19:15 +0000 (13:19 -0500)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index b2defca4a0b9136a8d1d481602c09942635a21c0..521d1e63d77c3055fd43481df378b7672138c09c 100644 (file)
@@ -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);