From ddbfc592ca9b411e64f042a302e1f822bc79cb3b Mon Sep 17 00:00:00 2001 From: "Liam R. Howlett" Date: Fri, 17 Jul 2020 21:11:59 -0400 Subject: [PATCH] maple_tree: rev_awalk i->slot and this_gap -> gap Signed-off-by: Liam R. Howlett --- lib/maple_tree.c | 41 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 23 deletions(-) diff --git a/lib/maple_tree.c b/lib/maple_tree.c index 4622312be91a..92374037d4ad 100644 --- a/lib/maple_tree.c +++ b/lib/maple_tree.c @@ -3367,22 +3367,18 @@ EXPORT_SYMBOL_GPL(mas_prev); static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size) { - enum maple_type type; + enum maple_type type = mte_node_type(mas->node); + unsigned char slot = mas_get_slot(mas); unsigned long max, min = mas->min; - unsigned char i; + unsigned long gap = 0; bool found = false; - unsigned long this_gap = 0; - - type = mte_node_type(mas->node); - i = mas_get_slot(mas); - - max = _mas_get_safe_pivot(mas, i, type); + max = _mas_get_safe_pivot(mas, slot, type); switch (type) { case maple_leaf_64: default: do { - min = mas_get_safe_lower_bound(mas, i); + min = mas_get_safe_lower_bound(mas, slot); /* last is below this range */ if (mas->last < min) goto next_slot; @@ -3394,38 +3390,37 @@ static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size) } if (ma_is_leaf(type)) { - if (mas_get_rcu_slot(mas, i)) + if (mas_get_rcu_slot(mas, slot)) goto next_slot; - this_gap = max - min + 1; - + gap = max - min + 1; } else { - this_gap = mte_get_gap(mas->node, i); + gap = mte_get_gap(mas->node, slot); } - if (mas->last - min + 1 < size) + if (size > mas->last - min + 1) goto next_slot; - if (size > this_gap) + if (size > gap) goto next_slot; if (ma_is_leaf(type)) { mas->min = min; - mas->max = min + this_gap - 1; + mas->max = min + gap - 1; found = true; } break; next_slot: - if (!i) + if (!slot) goto ascend; max = min - 1; - } while (i--); + } while (slot--); break; case maple_dense: - i = mas->index - mas->min; + slot = mas->index - mas->min; found = true; break; } @@ -3433,23 +3428,23 @@ next_slot: if (!ma_is_leaf(type)) { //descend struct maple_enode *next; - next = mas_get_rcu_slot(mas, i); + next = mas_get_rcu_slot(mas, slot); mas->min = min; mas->max = max; if (mt_is_empty(next)) goto ascend; mas->node = next; - i = _mas_data_end(mas, mte_node_type(next), &max); + slot = _mas_data_end(mas, mte_node_type(next), &max); } - mas_set_slot(mas, i); + mas_set_slot(mas, slot); return found; ascend: if (mte_is_root(mas->node)) mas_set_err(mas, -EBUSY); - mas_set_slot(mas, i); + mas_set_slot(mas, slot); return found; } -- 2.50.1