maple_tree: Fix state for external mas
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Mon, 28 Sep 2020 19:22:19 +0000 (15:22 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:12:23 +0000 (15:12 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 2213dfefe5662f09749a859a5b610745124d52ef..f401b48f39021b2645a1b30797e782a076e78ef3 100644 (file)
@@ -1631,6 +1631,7 @@ static inline unsigned char mas_store_b_node(struct ma_state *mas,
        }
 
        // Insert the data.
+       mas_set_offset(mas, b_end);
        b_node->slot[b_end] = entry;
        b_node->pivot[b_end] = mas->last;
 
@@ -2412,6 +2413,7 @@ static inline bool _mas_split_final_node(struct maple_subtree_state *mast,
 
        mast->l->node = ancestor;
        mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, mast->l);
+       mas_set_offset(mas, mast->bn->b_end - 1);
        return true;
 }
 
@@ -2620,11 +2622,13 @@ static inline bool mas_reuse_node(struct ma_state *mas,
                                  unsigned char end)
 {
        int i;
+       unsigned long max = mas->max;
 
        if (mt_in_rcu(mas->tree))
                return false; // Need to be rcu safe.
 
        mab_mas_cp(bn, 0, bn->b_end, mas);
+       mas->max = max;
 
        // Zero end of node.
        if (end > bn->b_end) {
@@ -2790,6 +2794,9 @@ static inline bool mas_node_walk(struct ma_state *mas, enum maple_type type,
                goto dense;
        }
 
+       if (i)
+               min = mas_safe_min(mas, pivots, i);
+
        while(i < mt_slots[type]) {
                pivot = _mas_safe_pivot(mas, pivots, i, type);
 
@@ -3057,6 +3064,7 @@ static inline bool mas_fast_store(struct ma_state *mas, void *entry,
                if (offset + 1 < mt_pivots[mt])
                        pivots[offset + 1] = mas->last;
                slots[offset + 1] = entry;
+               mas_set_offset(mas, offset + 1);
                pivots[offset] = mas->index - 1;
                goto done;
        }