From: Liam R. Howlett <Liam.Howlett@oracle.com> Date: Tue, 8 Apr 2025 17:50:28 +0000 (-0400) Subject: wip, cleanup X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2fa8f843d749e9eada1a7899ffb21eb6e5ef2ba9;p=users%2Fjedix%2Flinux-maple.git wip, cleanup Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com> --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index edc2ebcb2eb2..227de1e9808f 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3827,11 +3827,12 @@ static inline void mas_wr_converged(struct ma_node_info *src, * @left: The node information of the left destination * @right: The node information of the right destination * @ma_part: The node part being inserted - * @split: The split location referenced by the destination size + * @split: The split location referenced by the destination data * @insert: The location of the insert start for @ma_part * @size: The targeted size of the left node - * @offset: The starting offset into the destination - * @node_ins_end: The offset in the source the insert ends + * @offset: The starting offset into the destination data (may be larger than + * the node) + * @node_ins_end: The offset in the node data that the insert ends * @total_data: The total size of the data being stored * @state: The maple node state array * @i: The number of existing states @@ -3847,6 +3848,7 @@ static int mt_wr_split_data(struct ma_node_info *src, unsigned char node_off, part_off; struct ma_node_info *to; + /* Offset into the destination data where the insert ends */ insert_end = insert + ma_part->size - 1; to = left; node_off = 0; /* src */ @@ -4000,13 +4002,6 @@ try_right: i++; } - - /* - * Offset indexed into new data - * split indexed into new data - * size is the remainder of the data requested to this node - */ - /* * There are two splits of src, at insert and insert_end. * There can also be a split between nodes that may happen at these @@ -4225,36 +4220,34 @@ static void mas_wr_split(struct ma_wr_state *wr_mas) mas->depth = height; /* First split the leaves */ + mni_mas_init(&src, mas); mni_node_init(&left, mas_pop_node(mas), wr_mas->type); mni_node_init(&right, mas_pop_node(mas), wr_mas->type); - mni_mas_init(&src, mas); - mns_node_part_leaf_init(&ma_part, wr_mas, &src); - total = mas->end + ma_part.size; if (mt_is_alloc(mas->tree)) right.alloc = left.alloc = true; + mns_node_part_leaf_init(&ma_part, wr_mas, &src); + total = mas->end + ma_part.size; /* - skip + 1 */ if (height > 1 && mas_wr_try_rebalance(mas, &src, total, &left, &right, &ma_part, wr_mas->offset_end)) goto rebalanced; split = (total + 1) / 2; - left.min = mas->min; - right.max = mas->max; + left.min = src.min; + right.max = src.max; i = mt_wr_split_data(&src, &left, &right, &ma_part, split, mas->offset, split, 0, wr_mas->offset_end, total, state, 0); mns_assemble(state, i); mni_finalise(&left); mni_finalise(&right); - mni_node_part_init(&ma_part, &left, &right); - if (height == 1) { + if (height == 1) goto new_root; - } - //printk("%d height is %d\n", __LINE__, height); while (--height) { + mni_node_part_init(&ma_part, &left, &right); mas_wr_ascend_init(mas, &src); mas->end = src.end; total = mas->end + 1; @@ -4278,10 +4271,10 @@ static void mas_wr_split(struct ma_wr_state *wr_mas) mns_assemble(state, i); mni_finalise(&left); mni_finalise(&right); - mni_node_part_init(&ma_part, &left, &right); } new_root: + mni_node_part_init(&ma_part, &left, &right); /* Converged on new root */ mas->depth++; src.insert_off = mas->offset = 0;