From: Liam R. Howlett Date: Fri, 17 Jul 2020 02:49:01 +0000 (-0400) Subject: maple_tree: Cleaner check in combine_separate X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=69c5aa87e892b089b17eee0342f447a7f7574815;p=users%2Fjedix%2Flinux-maple.git maple_tree: Cleaner check in combine_separate Signed-off-by: Liam R. Howlett --- diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 43f3497cb2813..c423fe7bd5c72 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 */