[PATCH 2/9] maple_tree: Make maple state reusable after mas_empty_area()

From: Peng Zhang
Date: Tue Apr 25 2023 - 07:05:37 EST


Make mas->min and mas->max point to a node range instead of a leaf entry
range. This allows mas to still be usable after mas_empty_area() returns.
This currently has no user impact because no one use mas after
mas_empty_area() now.

Fixes: 54a611b60590 ("Maple Tree: add new data structure")
Signed-off-by: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx>
---
lib/maple_tree.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/lib/maple_tree.c b/lib/maple_tree.c
index 72099b4b32169..aa55c914818a0 100644
--- a/lib/maple_tree.c
+++ b/lib/maple_tree.c
@@ -5320,14 +5320,7 @@ int mas_empty_area(struct ma_state *mas, unsigned long min,

mt = mte_node_type(mas->node);
pivots = ma_pivots(mas_mn(mas), mt);
- if (offset)
- mas->min = pivots[offset - 1] + 1;
-
- if (offset < mt_pivots[mt])
- mas->max = pivots[offset];
-
- if (mas->index < mas->min)
- mas->index = mas->min;
+ mas->index = max(mas->index, mas_safe_min(mas, pivots, offset));

mas->last = mas->index + size - 1;
return 0;
--
2.20.1