]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
maple_tree: change rev_awalk since there are no delete or skips, etc
authorLiam R. Howlett <Liam.Howlett@Oracle.com>
Sat, 18 Jul 2020 00:57:16 +0000 (20:57 -0400)
committerLiam R. Howlett <Liam.Howlett@Oracle.com>
Fri, 30 Oct 2020 19:05:36 +0000 (15:05 -0400)
Signed-off-by: Liam R. Howlett <Liam.Howlett@Oracle.com>
lib/maple_tree.c

index eb1ad58669fa34f5c5757d385eac8fd22d73d0fe..01a488480c13d015d76960b517dad4f9c92581c5 100644 (file)
@@ -3368,20 +3368,18 @@ EXPORT_SYMBOL_GPL(mas_prev);
 static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
 {
        enum maple_type type;
-       unsigned long max, min;
-       unsigned char i, start;
+       unsigned long max, min = mas->min;
+       unsigned char i;
        bool found = false;
        unsigned long this_gap = 0;
 
        type = mte_node_type(mas->node);
        i = mas_get_slot(mas);
 
-       min = mas->min;
        max = _mas_get_safe_pivot(mas, i, type);
 
        switch (type) {
        case maple_leaf_64:
-               start = i;
                do {
                        void *entry = NULL;
 
@@ -3399,24 +3397,20 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
 
                        /* check if this slot is full */
                        entry = mas_get_rcu_slot(mas, i);
-                       if (entry) {
-                               this_gap = 0;
+                       if (entry)
                                goto next_slot;
-                       }
 
-                       if (!this_gap)
-                               start = i;
+                       this_gap = max - min + 1;
+                       if (size > this_gap)
+                               goto next_slot;
 
-                       this_gap += max - min + 1;
-                       if (this_gap >= size) {
-                               if (mas->last - min + 1 < size)
-                                       goto next_slot;
-                               mas->min = min;
-                               mas->max = min + this_gap - 1;
-                               i = start;
-                               found = true;
-                               break;
-                       }
+                       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)
@@ -3426,7 +3420,6 @@ next_slot:
                } while (i--);
                break;
        default:
-
                do {
                        min = mas_get_safe_lower_bound(mas, i);
                        /* last is too little for this range */