]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
fix destination max setting
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 22 Aug 2025 15:51:24 +0000 (11:51 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Fri, 22 Aug 2025 15:51:24 +0000 (11:51 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index 3b59c77cf9e3fe7b4858121436535cd2876de9c1..f4ae08ef63ebc04faa49cabb1ed4bf0c0700ae92 100644 (file)
@@ -2865,7 +2865,7 @@ dead_node:
 
 /* Direct node to node copy */
 static inline
-unsigned char node_copy(struct maple_node *src, unsigned char start,
+unsigned long node_copy(struct maple_node *src, unsigned char start,
        unsigned char size, unsigned long s_max, enum maple_type s_mt,
        struct maple_node *dst, unsigned char d_start, enum maple_type d_mt)
 {
@@ -2874,6 +2874,7 @@ unsigned char node_copy(struct maple_node *src, unsigned char start,
        unsigned long *s_pivots, *d_pivots;
        unsigned long *s_gaps, *d_gaps;
        bool set_last_piv = true;
+       unsigned long d_max;
 
        s_slots = ma_slots(src, s_mt) + start;
        d_slots = ma_slots(dst, d_mt) + d_start;
@@ -2905,6 +2906,9 @@ unsigned char node_copy(struct maple_node *src, unsigned char start,
                set_last_piv = false;
                size--;
                d_pivots[size] = s_max;
+               d_max = s_max;
+       } else {
+               d_max = *(s_pivots + size - 1);
        }
 
        if (size)
@@ -2913,7 +2917,7 @@ unsigned char node_copy(struct maple_node *src, unsigned char start,
        if (set_last_piv)
                d_pivots[size] = s_max;
 
-       return size;
+       return d_max;
 }
 
 static inline
@@ -3113,6 +3117,8 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
        data_offset = 0;
        next_node = split;
        do {
+               unsigned long d_max;
+
                do {
                        size = next_node - data_offset;
                        printk("try to use size %d\n", size);
@@ -3132,7 +3138,7 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
                        printk("%d: size %u\n", __LINE__, size);
 
                        size++;
-                       node_copy(src, s_offset, size, s_max, s_mt,
+                       d_max = node_copy(src, s_offset, size, s_max, s_mt,
                                  dst, dst_offset, d_mt);
 
                        data_offset += size;
@@ -3144,6 +3150,7 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
                                /* This source is exhausted */
                                s++;
                                if (s >= cp->s_count) {
+                                       cp->dst[d].max = d_max;
                                        node_finalise(dst, d_mt, dst_offset);
                                        return;
                                }
@@ -3185,6 +3192,7 @@ void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
                        data_offset--;
                        dst_offset--;
                }
+               cp->dst[d].max = d_max;
                node_finalise(dst, d_mt, dst_offset);
                mt_dump_node(mas->tree, mt_mk_node(dst, d_mt), 0, ULONG_MAX, 1, mt_dump_hex);
                if (d >= cp->d_count) {