]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
spanning_leaf_init: make spanning leaf safe for all rebalances
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 11 Sep 2025 14:06:16 +0000 (10:06 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 2 Oct 2025 17:28:03 +0000 (13:28 -0400)
Getting the right side of the operations content from the slot means
that the rebalance can pass the same wr_mas into this function to
correctly set up the new leaf entries.

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 0b110e6ffe81cbb0c1f7b5f9e596a281f78f46b1..e7c7468216728ed0e8883231a15ddab33f5629dc 100644 (file)
@@ -2997,7 +2997,7 @@ static inline void append_node_cp(struct maple_copy *cp,
        cp->s_count++;
 }
 
-static inline void spanning_leaf_init(struct maple_copy *cp,
+static inline void rebalance_leaf_init(struct maple_copy *cp,
                struct ma_state *mas, struct ma_wr_state *l_wr_mas,
                struct ma_wr_state *r_wr_mas)
 {
@@ -3005,9 +3005,9 @@ static inline void spanning_leaf_init(struct maple_copy *cp,
 
        /* Create entries to insert including split entries to left and right */
        if (l_wr_mas->r_min < mas->index) {
+               end++;
                cp->slot[0] = l_wr_mas->content;
                cp->pivot[0] = mas->index - 1;
-               end++;
                if (l_wr_mas->content)
                        cp->gap[0] = 0;
                else
@@ -3022,7 +3022,7 @@ static inline void spanning_leaf_init(struct maple_copy *cp,
 
        if (r_wr_mas->r_max > mas->last) {
                end++;
-               cp->slot[end] = r_wr_mas->content;
+               cp->slot[end] = r_wr_mas->slots[r_wr_mas->offset_end];
                cp->pivot[end] = r_wr_mas->r_max;
                if (r_wr_mas->content)
                        cp->gap[end] = 0;
@@ -3530,7 +3530,7 @@ static void mas_wr_spanning_rebalance(struct ma_state *mas,
         */
 
        cp.height = 1;
-       spanning_leaf_init(&cp, mas, l_wr_mas, r_wr_mas);
+       rebalance_leaf_init(&cp, mas, l_wr_mas, r_wr_mas);
        do {
                spanning_data_calc(&cp, mas, l_wr_mas, r_wr_mas, &sib);
                spanning_split_src_setup(&cp, mas, l_wr_mas, r_wr_mas, &sib);