From e53a64b38c9e009e6821645980caef459ae04efa Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 17 Jul 2020 16:47:48 -0400 Subject: [PATCH] maple_tree: Comments, and also mab_mas_cp always uses 0 for the node start Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 668f2cb80477..aa80bae43718 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1552,8 +1552,6 @@ static inline int mab_calc_split(struct maple_big_node *b_node, * @mas_end: The end slot to copy (inclusively) * @b_node: The maple_big_node to place the data * @mab_start: The starting location in maple_big_node to store the data. - * - * Note, mas_end is inclusive */ static inline void mas_mab_cp(struct ma_state *mas, unsigned char mas_start, unsigned char mas_end, struct maple_big_node *b_node, @@ -1581,14 +1579,21 @@ static inline void mas_mab_cp(struct ma_state *mas, unsigned char mas_start, } b_node->b_end = j; } - +/** Private + * mab_mas_cp() - Copy data from maple_big_node to a maple encoded node. + * + * @b_node: the maple_big_node that has the data + * @mab_start: the start location in @b_node. + * @mab_end: The end location in @b_node (inclusively) + * @mas: The maple state with the maple encoded node. + */ static inline void mab_mas_cp(struct maple_big_node *b_node, unsigned char mab_start, unsigned char mab_end, - struct ma_state *mas, unsigned char mas_start) + struct ma_state *mas) { - int i, j; + int i, j = 0; - for (i = mab_start, j = mas_start; i <= mab_end; i++, j++) { + for (i = mab_start; i <= mab_end; i++, j++) { if(j && !b_node->pivot[i]) break; @@ -2058,18 +2063,18 @@ static inline void mast_cp_to_nodes(struct maple_subtree_state *mast, mast->l->min = mast->orig_l->min; mast->l->max = mast->bn->pivot[split]; - mab_mas_cp(mast->bn, 0, split, mast->l, 0); + mab_mas_cp(mast->bn, 0, split, mast->l); mast->r->max = mast->l->max; if (middle) { - mab_mas_cp(mast->bn, 1 + split, mid_split, mast->m, 0); + mab_mas_cp(mast->bn, 1 + split, mid_split, mast->m); mast->m->min = mast->bn->pivot[split] + 1; mast->m->max = mast->bn->pivot[mid_split]; split = mid_split; } if (right) { - mab_mas_cp(mast->bn, 1 + split, mast->bn->b_end, mast->r, 0); + mab_mas_cp(mast->bn, 1 + split, mast->bn->b_end, mast->r); mast->r->min = mast->bn->pivot[split] + 1; mast->r->max = mast->bn->pivot[mast->bn->b_end]; } @@ -2201,7 +2206,7 @@ static inline int mas_combine_separate(struct ma_state *mas, l_mas.node = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)), mte_node_type(mast->orig_l->node)); mast->orig_l->depth++; - mab_mas_cp(mast->bn, 0, mast->bn->b_end, &l_mas, 0); + mab_mas_cp(mast->bn, 0, mast->bn->b_end, &l_mas); mte_set_parent(left, l_mas.node, slot); if (middle) mte_set_parent(middle, l_mas.node, ++slot); @@ -2295,7 +2300,7 @@ static inline bool mas_split_final_node(struct maple_subtree_state *mast, mas->tree->ma_height++; mast->l->node = ancestor; - mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, mast->l, 0); + mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, mast->l); return true; } @@ -2364,9 +2369,9 @@ static inline int mas_split(struct ma_state *mas, l_mas.node = mas_new_ma_node(mas, b_node); r_mas.node = mas_new_ma_node(mas, b_node); split = mab_calc_split(b_node, &mid_split); - mab_mas_cp(b_node, 0, split, &l_mas, 0); + mab_mas_cp(b_node, 0, split, &l_mas); mte_set_pivot(r_mas.node, 0, r_mas.max); - mab_mas_cp(b_node, split + 1, b_node->b_end, &r_mas, 0); + mab_mas_cp(b_node, split + 1, b_node->b_end, &r_mas); mas_set_slot(&l_mas, mte_parent_slot(mas->node)); l_mas.max = b_node->pivot[split]; r_mas.min = l_mas.max + 1; @@ -2410,7 +2415,7 @@ static inline int mas_commit_b_node(struct ma_state *mas, mte_to_node(new_node)->parent = mas_mn(mas)->parent; mas->node = new_node; - mab_mas_cp(b_node, 0, b_node->b_end, mas, 0); + mab_mas_cp(b_node, 0, b_node->b_end, mas); mas_replace(mas, false); mas_update_gap(mas); return 2; -- 2.50.1