]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Fix _mas_store() rmin expansion on null.
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Tue, 27 Oct 2020 18:10:59 +0000 (14:10 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:13:37 +0000 (15:13 -0400)
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 <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 5ee0a6d96ef4df7463b688737193957d3eb4de4e..f2035bb0e3b15a07190d281f9cb31d2c7345377a 100644 (file)
@@ -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);