]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: use mt_wr_split_data() in split and try_rebalance
authorLiam R. Howlett <howlett@gmail.com>
Fri, 28 Feb 2025 22:27:01 +0000 (17:27 -0500)
committerLiam R. Howlett <howlett@gmail.com>
Fri, 28 Feb 2025 22:27:01 +0000 (17:27 -0500)
Signed-off-by: Liam R. Howlett <howlett@gmail.com>
lib/maple_tree.c

index 2b9a3f376fa676ef6f8b17e415b18ac3fff1831e..6f8ad90431f7d8de86359bb49e00270ac4c2f924 100644 (file)
@@ -3953,7 +3953,6 @@ static int mt_wr_split_data(struct ma_node_info *src,
                unsigned char insert, unsigned char size, unsigned char offset,
                unsigned char node_ins_end, unsigned char total_data,
                struct ma_node_state *state, int i)
-
 {
        unsigned char insert_end;
        unsigned char node_off, part_off;
@@ -4025,14 +4024,17 @@ static int mt_wr_split_data(struct ma_node_info *src,
                                }
                                printk("offset %u node_off %u\n", offset, node_off);
                        }
+                       printk("Last pivot in left is %lu\n", to->pivots[node_off - 1]);
                        printk("Switch to right\n");
-                       size = total_data - split;
+                       size = mt_slots[right->type];
+                       printk("size is %u\n", size);
                        to = right;
                        split = 255;
                }
                i++;
                printk("node off is %u vs %u\n", node_off, src->end);
        } while (node_off <= src->end);
+       printk("Last pivot in right is %lu\n", to->pivots[node_off - 1]);
 
        return i;
 }
@@ -4047,6 +4049,7 @@ static int mt_wr_split_data(struct ma_node_info *src,
  *
  * Returns: True on rebalance, false otherwise.
  */
+/* FIXME: full nodes need to create a new pivot */
 static bool mas_wr_try_rebalance(struct ma_state *mas,
                struct ma_node_info *src, unsigned char new_end,
                struct ma_node_info *left, struct ma_node_info *right,
@@ -4665,9 +4668,9 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 
        //printk("%d height is %d\n", __LINE__, height);
        while (--height) {
-               i = 0;
                printk("===================Start of loop\n");
                mas_wr_ascend_init(mas, &src_info);
+               printk("At %p\n", mas->node);
                mas->end = src_info.end;
                total = mas->end + 1;
                if (mas->end + 1 < mt_slots[src_info.type])
@@ -4683,8 +4686,14 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
 
                left.min = src_info.min;
                right.max = src_info.max;
+               printk("MIN %lu MAX %lu\n\n", left.min, right.max);
                split = (total + 1) / 2;
 
+               printk("Split data at %u\n", split);
+               i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
+                                    mas->offset, split, 0, wr_mas->offset_end,
+                                    total, state, 0);
+#if 0
                if (split >= mas->offset) {
                        unsigned char space; /* size remaining in left */
 
@@ -4748,11 +4757,14 @@ static void mas_wr_split(struct ma_wr_state *wr_mas)
                                             mas->end - wr_mas->offset_end + 1);
                        }
                }
+#endif
 
                mns_assemble(state, i);
                mni_finalise(&left);
                mni_finalise(&right);
                mni_node_part_init(&ma_part, &left, &right);
+               printk ("part size is %u\n", ma_part.size);
+               printk("part[1] = %lu\n", ma_part.pivots[1]);
                printk("End of loop\n");
        }