From: Liam R. Howlett Date: Fri, 28 Feb 2025 22:27:01 +0000 (-0500) Subject: maple_tree: use mt_wr_split_data() in split and try_rebalance X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a4e3dda4daadcdad43a568a8609d592490cf73a9;p=users%2Fjedix%2Flinux-maple.git maple_tree: use mt_wr_split_data() in split and try_rebalance Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2b9a3f376fa6..6f8ad90431f7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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"); }