From d876a3b729b8255e83bac4b8f3e8129a34f3102e Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 17 Jul 2020 21:09:52 -0400 Subject: [PATCH] maple_tree: change rev_awalk to more common code Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 59 +++++++++++++----------------------------------- 1 file changed, 16 insertions(+), 43 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 01a488480c13..4622312be91a 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -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; -- 2.50.1