]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: fix setting parent during split.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 14 Jan 2020 17:34:47 +0000 (12:34 -0500)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 18:57:00 +0000 (14:57 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 19946237dd873368439caf014f30cc5899d07009..7cb11bb4521ce4da3543fa57034621517ba6f064 100644 (file)
@@ -2155,8 +2155,8 @@ static inline int mas_split(struct ma_state *mas, unsigned char slot,
        left.node = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)), type);
        right.node  = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)), type);
 
-       mte_set_parent(left.node, new_parent, p_slot);
-       mte_set_parent(right.node, new_parent, p_slot+1);
+       mte_set_parent(left.node, mte_to_node(new_parent), p_slot);
+       mte_set_parent(right.node, mte_to_node(new_parent), p_slot+1);
        // split the data into left & right and do the insert.
        split = mas_ma_cp(mas, p_slot, &left, &right, NULL, type, 0, entry_cnt,
                        entry, 0);
@@ -4094,6 +4094,8 @@ skip_right:
 error:
        if (new_mas.tree)
                mte_destroy_walk(new_mas.tree->ma_root);
+       printk("Failed on %lu-%lu\n", mas->index, mas->last);
+       mt_dump(mas->tree);
        BUG_ON(1);
        return 0;
 }
@@ -4645,15 +4647,15 @@ void *mtree_load(struct maple_tree *mt, unsigned long index)
 }
 EXPORT_SYMBOL(mtree_load);
 
-int mtree_store_range(struct maple_tree *mt, unsigned long first,
+int mtree_store_range(struct maple_tree *mt, unsigned long index,
                unsigned long last, void *entry, gfp_t gfp)
 {
-       MA_STATE(mas, mt, first, last);
+       MA_STATE(mas, mt, index, last);
 
        if (WARN_ON_ONCE(mt_is_advanced(entry)))
                return -EINVAL;
 
-       if (first > last)
+       if (index > last)
                return -EINVAL;
 
        mas_lock(&mas);