]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
node_finalise was a mess
authorLiam R. Howlett <Liam.Howlett@oracle.com>
Tue, 26 Aug 2025 17:02:34 +0000 (13:02 -0400)
committerLiam R. Howlett <Liam.Howlett@oracle.com>
Thu, 2 Oct 2025 17:28:02 +0000 (13:28 -0400)
meta needs to be set regardless for arange

Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
lib/maple_tree.c

index eaa0f724cc10cf37694d9b9dd4af0c4528c3b68e..8552768380153539cc7bc4270f43d7eb4fd90c6f 100644 (file)
@@ -2950,21 +2950,23 @@ void node_finalise(struct maple_node *node, enum maple_type mt, unsigned char en
        unsigned char size;
        unsigned long *gaps;
 
-       if (end >= max_end - 1)
-               return;
-
-       size = max_end - end;
-       memset(ma_slots(node, mt) + end, 0, size * sizeof(void*));
+       printk("Finalise %p end %u max end %u\n", node, end, max_end);
+       if (end < max_end - 1) {
+               size = max_end - end;
+               memset(ma_slots(node, mt) + end, 0, size * sizeof(void*));
 
-       gaps = ma_gaps(node, mt);
-       if (gaps)
-               memset(gaps + end, 0, size * sizeof(unsigned long));
+               gaps = ma_gaps(node, mt);
+               if (gaps)
+                       memset(gaps + end, 0, size * sizeof(unsigned long));
 
-       if (--size) {
-               ma_set_meta(node, mt, 0, end - 1);
                if (--size)
                        memset(ma_pivots(node, mt) + end, 0, size * sizeof(unsigned long));
        }
+
+       if (mt == maple_arange_64)
+               ma_set_meta(node, mt, 0, end - 1);
+       else if (end <= max_end - 1)
+               ma_set_meta(node, mt, 0, end - 1);
 }
 
 static inline void append_node_cp(struct maple_copy *cp,