From: Liam R. Howlett Date: Mon, 28 Sep 2020 19:22:19 +0000 (-0400) Subject: maple_tree: Fix state for external mas X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=74d6976ac5e7affea7b18f5fc97aa4b13d06f52b;p=users%2Fjedix%2Flinux-maple.git maple_tree: Fix state for external mas Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 2213dfefe566..f401b48f3902 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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; }