From c30cda63cf6d1a3da80fb9d83474abffa315eec6 Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Thu, 16 Jul 2020 22:49:01 -0400 Subject: [PATCH] maple_tree: Cleaner check in combine_separate Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 43f3497cb281..c423fe7bd5c7 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -1965,10 +1965,12 @@ static inline void mas_wmb_replace(struct ma_state *mas, if (mt_is_alloc(mas->tree)) mas_update_gap(mas, false); } -static inline void mast_new_root(struct maple_subtree_state *mast, +static inline bool mast_new_root(struct maple_subtree_state *mast, struct ma_state *mas) { unsigned long range_min, range_max; + if (mast->l->min || mast->l->max != ULONG_MAX) + return false; mas_mn(mast->l)->parent = ma_parent_ptr(((unsigned long)mas->tree | MA_ROOT_PARENT)); @@ -1991,8 +1993,10 @@ static inline void mast_new_root(struct maple_subtree_state *mast, mast_consume(mast); } while (!mte_is_root(mast->orig_l->node)); } + mat_add(mast->free, mast->orig_l->node); mas_dup_state(mast->orig_l, mast->l); + return true; } /* Private * @@ -2073,10 +2077,8 @@ static inline int mas_combine_separate(struct ma_state *mas, memset(mast->bn, 0, sizeof(struct maple_big_node)); mast->orig_l->depth++; - if (!l_mas.min && l_mas.max == ULONG_MAX) { - mast_new_root(mast, mas); + if (mast_new_root(mast, mas)) goto new_root; - } mast_ascend_free(mast); /* Set up the right side of things */ -- 2.50.1