]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
mas_wr_rebalance: rebalancing, not reducing
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 30 Apr 2025 20:12:08 +0000 (16:12 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 30 Apr 2025 20:12:08 +0000 (16:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index d91cd5bfe5b3b54119326d5e02b6fba418798517..d9d688a887c3caf8ea3c532bb7c5fd279a2c0f99 100644 (file)
@@ -4104,7 +4104,7 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
        src.end = mas->end;
 
        mns_node_part_leaf_init(&part, wr_mas, &src);
-       sd.new_end = mas->end + part.size; /* - skip + 1 */
+       sd.new_end = mas->end + part.size - part.skip + 1;
        sd.src_ins_end = wr_mas->offset_end;
        sd.len = 0;
 
@@ -4175,9 +4175,19 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
 
        mt_wr_split_data(&src, &left, &right, &part, &sd);
        if (left_store) {
+               char len;
+
+               sd.split = (sd.new_end + 1) / 2;
+               printk("sd is at offset %u splut %u\n", sd.offset, sd.split);
+               len = sd.split - sd.offset;
+               sd.states[sd.len].info = &src2;
+               printk("cp right %u + %u to left\n", 0, len);
+               mns_mni_init(&sd.states[sd.len], &left, 0, len);
+               sd.len++;
+               printk("cp the right to right %u + %u\n", len, src2.end + 1);
                /* Stored to the left, copy the last of the right in src2 */
                sd.states[sd.len].info = &src2;
-               mns_mni_init(&sd.states[sd.len], &right, 0, src2.end + 1);
+               mns_mni_init(&sd.states[sd.len], &right, len, src2.end + 1 - len);
                sd.len++;
        }