return ms->node == MAS_START;
}
+void mas_reset(struct ma_state *mas)
+{
+ mas->node = MAS_START;
+}
+
static inline struct maple_node *mt_to_node(const struct maple_enode *entry)
{
return (struct maple_node *)((unsigned long)entry & ~127);
static inline struct maple_enode *mas_start(struct ma_state *mas)
{
if (mas->node == MAS_START) {
+ mas->min = 0;
if (!xa_is_node(mas->tree->ma_root)) {
if (mas->index > 0)
return NULL;
ma_set_slot(mas, MAPLE_NODE_SLOTS);
return NULL;
} else {
- return mt_safe_root(mas->tree->ma_root);
+ struct maple_enode *root = mt_safe_root(
+ mas->tree->ma_root);
+ mas->max = mt_node_max(root);
+ return root;
}
}
return mas->node;
static noinline void check_find(struct maple_tree *mt)
{
- unsigned long val = 1;
+ unsigned long val = 0;
unsigned long count = 20;
void *entry;
MA_STATE(mas, mt, 0, 0);
// Insert 0.
- MT_BUG_ON(mt, mtree_insert_index(mt, 0, GFP_KERNEL));
+ MT_BUG_ON(mt, mtree_insert_index(mt, val++, GFP_KERNEL));
for (int i = 0; i <= count; i++) {
if (val != 64)
val <<= 2;
}
- mas.node = MAS_START;
val = 0;
+ mas_reset(&mas);
+ mas.index = val;
+
while ( (entry = mas_find(&mas, 268435456)) != NULL) {
if (val != 64)
MT_BUG_ON(mt, xa_mk_value(val) != entry);
val = 1;
}
+ val = 0;
+ mas_reset(&mas);
+ mas.index = val;
+ mas_for_each(&mas, entry, ULONG_MAX) {
+ if (val != 64)
+ MT_BUG_ON(mt, xa_mk_value(val) != entry);
+ else
+ MT_BUG_ON(mt, entry != XA_ZERO_ENTRY);
+ val <<= 2;
+ // For zero check.
+ if (!val)
+ val = 1;
+ }
+
}
static noinline void check_alloc_rev_range(struct maple_tree *mt)
{