]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
add dummy loop
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 21 Aug 2025 21:02:43 +0000 (17:02 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 21 Aug 2025 21:02:43 +0000 (17:02 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 9663c02738684efa4ad66d5774fc7c5554fc0b89..3b59c77cf9e3fe7b4858121436535cd2876de9c1 100644 (file)
@@ -3084,7 +3084,9 @@ void spanning_split_src_setup(struct maple_copy *cp, struct ma_state *mas,
                }
        }
 }
-static void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
+
+static inline
+void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
 {
        struct maple_node *dst, *src;
        unsigned char s, d;
@@ -3197,6 +3199,16 @@ static void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
        } while (data_offset <= data);
 }
 
+static bool spanning_ascend(struct maple_copy *cp, struct ma_state *mas,
+               struct ma_wr_state *l_wr_mas, struct ma_wr_state *r_wr_mas)
+{
+       return false; /* for now */
+
+       if (cp->d_count == 1) /* Converged to one node */
+               return false;
+
+}
+
 static void mas_spanning_rebalance_loop(struct ma_state *mas,
                struct maple_subtree_state *mast, unsigned char count)
 {
@@ -3394,12 +3406,12 @@ static noinline void mas_wr_spanning_rebalance(struct ma_state *mas,
 
        mt_dump(mas->tree, mt_dump_hex);
 
-       spanning_data_calc(&cp, mas, l_wr_mas, r_wr_mas, &sib);
-       spanning_split_dest_setup(&cp, mas, l_wr_mas->type);
-       spanning_split_src_setup(&cp, mas, l_wr_mas, r_wr_mas, &sib);
-
-
-       spanning_data_write(&cp, mas);
+       do {
+               spanning_data_calc(&cp, mas, l_wr_mas, r_wr_mas, &sib);
+               spanning_split_dest_setup(&cp, mas, l_wr_mas->type);
+               spanning_split_src_setup(&cp, mas, l_wr_mas, r_wr_mas, &sib);
+               spanning_data_write(&cp, mas);
+       } while (spanning_ascend(&cp, mas, l_wr_mas, r_wr_mas));
 
        memset(&b_node, 0, sizeof(struct maple_big_node));
        /* Copy l_mas and store the value in b_node. */
@@ -3411,10 +3423,10 @@ static noinline void mas_wr_spanning_rebalance(struct ma_state *mas,
        if (mast->orig_r->max > mast->orig_r->last) {
                mas_mab_cp(mast->orig_r, mast->orig_r->offset,
                           mast->orig_r->end, &b_node, b_node.b_end + 1);
-       printk("big node end %u\n", b_node.b_end);
+               printk("big node end %u\n", b_node.b_end);
        } else {
                b_node.b_end++;
-       printk("big node ++ end %u\n", b_node.b_end);
+               printk("big node ++ end %u\n", b_node.b_end);
        }
 
 
@@ -3446,7 +3458,7 @@ static noinline void mas_wr_spanning_rebalance(struct ma_state *mas,
 #endif
                mast_spanning_rebalance(mast);
 #if 0
-       printk("big node end sib %u\n", b_node.b_end);
+               printk("big node end sib %u\n", b_node.b_end);
                if (mast->orig_l->node == sib.node)
                        printk("left\n");
                else if (mast->orig_r->node == sib.node)
@@ -3471,13 +3483,13 @@ static noinline void mas_wr_spanning_rebalance(struct ma_state *mas,
        {
                unsigned long min = mas->min;
                printk("Count is %u\n", cp.d_count);
-       for (int i = 0; i < cp.d_count; i++) {
-               printk("dump %p %lu - %lu\n", cp.dst[i].node, min, cp.dst[i].max);
-               mt_dump_node(mas->tree, mt_mk_node(cp.dst[i].node, cp.dst[i].mt),
-                            min, cp.dst[i].max, height, mt_dump_hex);
-               min = cp.dst[i].max + 1;
-       }
-       printk ("VS\n");
+               for (int i = 0; i < cp.d_count; i++) {
+                       printk("dump %p %lu - %lu\n", cp.dst[i].node, min, cp.dst[i].max);
+                       mt_dump_node(mas->tree, mt_mk_node(cp.dst[i].node, cp.dst[i].mt),
+                                    min, cp.dst[i].max, height, mt_dump_hex);
+                       min = cp.dst[i].max + 1;
+               }
+               printk ("VS\n");
        }
 #endif
        mas_spanning_rebalance_loop(mas, mast, height);