From d7cd7d52c5a4471ad0ffba3b9046051ed583c19e Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 17 Jul 2020 20:57:16 -0400 Subject: [PATCH] maple_tree: change rev_awalk since there are no delete or skips, etc Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index eb1ad58669fa..01a488480c13 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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 */ -- 2.50.1