]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: change rev_awalk to more common code
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 18 Jul 2020 01:09:52 +0000 (21:09 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:05:37 +0000 (15:05 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index 01a488480c13d015d76960b517dad4f9c92581c5..4622312be91ab756e22bfaef4334fbf833be5cd1 100644 (file)
@@ -3380,11 +3380,9 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
 
        switch (type) {
        case maple_leaf_64:
+       default:
                do {
-                       void *entry = NULL;
-
                        min = mas_get_safe_lower_bound(mas, i);
-
                        /* last is below this range */
                        if (mas->last < min)
                                goto next_slot;
@@ -3395,59 +3393,34 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
                                return false;
                        }
 
-                       /* check if this slot is full */
-                       entry = mas_get_rcu_slot(mas, i);
-                       if (entry)
-                               goto next_slot;
+                       if (ma_is_leaf(type)) {
+                               if (mas_get_rcu_slot(mas, i))
+                                       goto next_slot;
 
-                       this_gap = max - min + 1;
-                       if (size > this_gap)
-                               goto next_slot;
+                               this_gap = max - min + 1;
+
+                       } else {
+                               this_gap = mte_get_gap(mas->node, i);
+                       }
 
                        if (mas->last - min + 1 < size)
                                goto next_slot;
 
-                       mas->min = min;
-                       mas->max = min + this_gap - 1;
-                       found = true;
-                       break;
-
-next_slot:
-                       if (!i)
-                               goto ascend;
-
-                       max = min - 1;
-               } while (i--);
-               break;
-       default:
-               do {
-                       min = mas_get_safe_lower_bound(mas, i);
-                       /* last is too little for this range */
-                       if (mas->last < min)
-                               goto next;
-
-                       /* index is too large for this range */
-                       if (mas->index > max) {
-                               mas_set_err(mas, -EBUSY);
-                               return false;
-                       }
-
-                       this_gap = mte_get_gap(mas->node, i);
-                       /* Not big enough */
                        if (size > this_gap)
-                               goto next;
+                               goto next_slot;
 
+                       if (ma_is_leaf(type)) {
+                               mas->min = min;
+                               mas->max = min + this_gap - 1;
+                               found = true;
+                       }
                        break;
 
-next:
+next_slot:
                        if (!i)
                                goto ascend;
 
                        max = min - 1;
-                       if (mas->index > max) {
-                               mas_set_err(mas, -EBUSY);
-                               return false;
-                       }
                } while (i--);
                break;