]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: Cleaner check in combine_separate
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 17 Jul 2020 02:49:01 +0000 (22:49 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:05:18 +0000 (15:05 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 43f3497cb28138646d0ba4ef16c1a32dc0d73b65..c423fe7bd5c72602c4206d72a0f8374c73ffb5a6 100644 (file)
@@ -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 */