]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Comments, and also mab_mas_cp always uses 0 for the node start
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 17 Jul 2020 20:47:48 +0000 (16:47 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:05:27 +0000 (15:05 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 668f2cb804774461ad6e89020bce5db89f416948..aa80bae437180967d14c7d5b43c88accd8c0d4fe 100644 (file)
@@ -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;