]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
tests are failing
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Wed, 27 Aug 2025 14:41:38 +0000 (10:41 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 2 Oct 2025 17:28:03 +0000 (13:28 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index a32ed19b09788d62cd0d861fca5823d2e55d66ce..6a78f293951416676f6b28f65ae44636fbe39d3d 100644 (file)
@@ -1741,7 +1741,7 @@ static inline void mas_adopt_children(struct ma_state *mas,
 
        offset = ma_data_end(node, type, pivots, mas->max);
        WARN_ON_ONCE(offset == 0);
-       printk("Adopt %p 0 - %u\n", node, offset);
+       //printk("Adopt %p 0 - %u\n", node, offset);
        do {
                child = mas_slot_locked(mas, slots, offset);
                mas_set_parent(mas, child, parent, offset);
@@ -2932,12 +2932,15 @@ unsigned long node_copy(struct ma_state *mas, struct maple_node *src,
        if (start + size < mt_pivots[s_mt])
                d_max = s_pivots[size - 1];
 
-       size--;
-       if (d_start + size < mt_pivots[d_mt])
-               d_pivots[size] = d_max;
+       if (d_start + size  - 1 < mt_pivots[d_mt])
+               d_pivots[size - 1] = d_max;
 
-       if (size)
+       printk("cp from %p -> %p %u\n", d_pivots, s_pivots, size);
+       fflush(stdout);
+       if (size) {
+               size--;
                memcpy(d_pivots, s_pivots, size * sizeof(unsigned long));
+       }
 
        return d_max;
 }
@@ -2991,6 +2994,7 @@ static inline void spanning_leaf_init(struct maple_copy *cp,
                struct ma_wr_state *r_wr_mas)
 {
        unsigned char end = 0;
+
        /* Create entries to insert including split entries to left and right */
        if (l_wr_mas->r_min < mas->index) {
                cp->slot[0] = l_wr_mas->content;
@@ -3008,6 +3012,8 @@ static inline void spanning_leaf_init(struct maple_copy *cp,
        else
                cp->gap[end] = mas->last - mas->index + 1;
 
+       printk("r_wr_mas->r_max %lx mas last %lx offset %u",
+              r_wr_mas->r_max, mas->last, r_wr_mas->mas->offset);
        if (r_wr_mas->r_max > mas->last) {
                end++;
                cp->slot[end] = r_wr_mas->content;
@@ -3064,12 +3070,12 @@ void spanning_split_dest_setup(struct maple_copy *cp, struct ma_state *mas,
        if (cp->data <= mt_slots[mt]) {
                cp->split = cp->data;
                cp->d_count = 1;
-       } else if (cp->data >= mt_slots[mt] * 2 - 1) {
-               cp->split = cp->data / 3;
-               cp->d_count = 3;
-       }  else {
+       } else if (cp->data < mt_slots[mt] * 2 - 1) {
                cp->split = (cp->data + 1) / 2;
                cp->d_count = 2;
+       }  else {
+               cp->split = (cp->data + 2) / 3;
+               cp->d_count = 3;
        }
 
        for (int i = 0; i < cp->d_count; i++) {
@@ -3149,6 +3155,7 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
        unsigned char split, next_node, size;
        unsigned long s_max;
        enum maple_type s_mt, d_mt;
+       int debug = 0;
 
        s = d = 0;
        /* Readability help */
@@ -3171,6 +3178,8 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
         */
        do {
                do {
+                       debug++;
+                       BUG_ON(debug > 8);
                        size = next_node - data_offset;
                        printk("try to use size %d\n", size);
                        /* Fill the destination */
@@ -3547,7 +3556,7 @@ static void mas_wr_spanning_rebalance(struct ma_state *mas,
                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);
-#if 1
+#if 0
                if (debug < 2)
        {
                unsigned long min = l_wr_mas->mas->min;
@@ -4226,8 +4235,8 @@ static inline void mas_extend_spanning_null(struct ma_wr_state *l_wr_mas,
        }
 
        if (!r_wr_mas->content) {
-               if (r_mas->last < r_wr_mas->r_max)
-                       r_mas->offset++;
+               //if (r_mas->last < r_wr_mas->r_max)
+               //      r_mas->offset++;
                r_mas->last = r_wr_mas->r_max;
                printk("Extend end pivot\n");
        }