From: Liam R. Howlett Date: Tue, 27 Oct 2020 18:10:59 +0000 (-0400) Subject: maple_tree: Fix _mas_store() rmin expansion on null. X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=a0c6410a735e4a153cc54e13bf0ff7b44f6871cd;p=users%2Fjedix%2Flinux-maple.git maple_tree: Fix _mas_store() rmin expansion on null. When the offset changes on expanding null, ensure the min slot value changes as well. This avoids a fall-through to the slow path and uses the mas_node_store() instead. Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 5ee0a6d96ef4..f2035bb0e3b1 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3177,9 +3177,8 @@ static inline bool mas_node_store(struct ma_state *mas, void *entry, return false; if (!mte_is_root(mas->node) && (new_end <= mt_min_slots[mt]) && - !(mas->mas_flags & MA_STATE_ADVANCED_OP)) {// not enough data. + !(mas->mas_flags & MA_STATE_ADVANCED_OP)) // not enough data. return false; - } // set up node. if (mt_in_rcu(mas->tree)) { @@ -3260,10 +3259,10 @@ static inline bool mas_slot_store(struct ma_state *mas, void *entry, if (offset + 1 >= mt_slots[mt]) // out of room. return false; - lmax = mas_logical_pivot(mas, pivots, offset + 1, mt); if (max > mas->last) // going to split a single entry. goto try_node_store; + lmax = mas_logical_pivot(mas, pivots, offset + 1, mt); if (lmax < mas->last) // going to overwrite too many slots. goto try_node_store; @@ -3337,6 +3336,9 @@ static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite if (!entry) { unsigned long rmin, rmax; + enum maple_type mt = mte_node_type(mas->node); + unsigned long *pivots = ma_pivots(mas_mn(mas),mt); + MA_STATE(r_mas, mas->tree, mas->last, mas->last); mas_set_offset(&r_mas, offset); @@ -3346,7 +3348,8 @@ static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite mas_extend_null(mas, &r_mas); mas->last = r_mas.last; offset = mas_offset(mas); - r_max = mas_safe_pivot(mas, mas_offset(mas)); + r_min = mas_safe_min(mas, pivots, offset); + r_max = _mas_safe_pivot(mas, pivots, offset, mt); } end = mas_data_end(mas);