]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
more cleanup
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 May 2025 15:47:46 +0000 (11:47 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 6 May 2025 15:47:46 +0000 (11:47 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 795fa2128b6df0ffa5a79bb7071097b5ccbd3aee..8aa08127aa6477e375eaee3e66200a498755ea45 100644 (file)
@@ -3674,35 +3674,41 @@ static void split_state_setup(struct ma_node_info *src,
                struct split_data *sd)
 {
        struct ma_node_state *state;
-       unsigned char copied;
+       unsigned char size;
+       unsigned char max_copy;
 
        /* Configure one state */
        state = &sd->states[sd->len];
+       size = sd->space;
        if (sd->offset >= sd->insert && sd->offset <= sd->insert_end) {
-               copied = min(part->size - part->pos, sd->space);
+               max_copy = part->size - part->pos;
+               if (max_copy < size)
+                       size = max_copy;
+
                state->part = part;
-               mns_mni_init(state, dst, part->pos , copied);
+               mns_mni_init(state, dst, part->pos, size);
                state->use_part = true;
-               part->pos += copied;
+               part->pos += size;
                src->offset = sd->src_ins_end + 1;
        } else {
+
                state->info = src;
-               if (sd->offset < sd->insert_end) {
-                       /*
-                        * First part of node, may split across node
-                        * boundaries though
-                        */
-                       copied = min(sd->space, sd->insert - sd->offset);
-               } else {
-                       copied = min(sd->space, (src->end - src->offset + 1));
-               }
-               BUG_ON(copied == 0);
-               mns_mni_init(state, dst, src->offset, copied);
-               src->offset += copied;
+               /* First part of node, may split across node boundaries though */
+               if (sd->offset < sd->insert_end)
+                       max_copy = sd->insert - sd->offset;
+               else
+                       max_copy = src->end - src->offset + 1;
+
+               if (max_copy < size)
+                       size = max_copy;
+
+               BUG_ON(size == 0);
+               mns_mni_init(state, dst, src->offset, size);
+               src->offset += size;
        }
 
-       sd->offset += copied;
-       sd->space -= copied;
+       sd->offset += size;
+       sd->space -= size;
 }
 
 /*
@@ -3736,8 +3742,6 @@ static void mt_wr_split_data(struct ma_node_info *src,
                struct ma_node_info *left, struct ma_node_info *right,
                struct ma_node_part *part, struct split_data *sd)
 {
-       unsigned char insert_end;
-       unsigned char node_off;
        struct ma_node_info *to;
        struct ma_node_state *state;
 
@@ -4046,7 +4050,7 @@ static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
        struct ma_node_info src, src2, left, right;
        struct split_data sd;
        struct ma_node_part part;
-       unsigned char max, height;
+       unsigned char height;
        bool left_store = false;
 
        mas = wr_mas->mas;
@@ -4897,22 +4901,6 @@ static inline void mas_wr_append(struct ma_wr_state *wr_mas,
        return;
 }
 
-/*
- * mas_wr_bnode() - Slow path for a modification.
- * @wr_mas: The write maple state
- *
- * This is where split, rebalance end up.
- */
-static void mas_wr_bnode(struct ma_wr_state *wr_mas)
-{
-       struct maple_big_node b_node;
-
-       trace_ma_write(__func__, wr_mas->mas, 0, wr_mas->entry);
-       memset(&b_node, 0, sizeof(struct maple_big_node));
-       mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
-       mas_commit_b_node(wr_mas, &b_node);
-}
-
 /*
  * mas_wr_store_entry() - Internal call to store a value
  * @wr_mas: The maple write state
@@ -4933,7 +4921,6 @@ static inline void mas_wr_store_entry(struct ma_wr_state *wr_mas)
                mas_wr_split(wr_mas);
                break;
        case wr_rebalance:
-               //mas_wr_bnode(wr_mas);
                mas_wr_rebalance(wr_mas);
                break;
        case wr_exact_fit: