void mas_pause(struct ma_state *mas);
void maple_tree_init(void);
+/**
+ * mas_for_each() - Iterate over a range of the maple tree.
+ * @mas: Maple Tree operation state (maple_state)
+ * @entry: Entry retrieved from the tree
+ * @max: maximum index to retrieve from the tree
+ *
+ * When returned, mas->index and mas->last will hold the entire range for the
+ * entry.
+ *
+ * Note: may return the zero entry.
+ *
+ */
+#define mas_for_each(mas, entry, max) \
+ while ((entry = mas_find(mas, max)) != NULL)
+
+/**
+ * mt_for_each - Searches for an entry starting at index until max.
+ *
+ *
+ *
+ * Note: Will not return the zero entry.
+ *
+ *
+ */
+#define mt_for_each(tree, entry, index, max) \
+ for (entry = mt_find(mt, index, max); \
+ entry; entry = mt_find_after(mt, &index, max))
+ /**
+ * mas_set_range() - Set up Maple Tree operation state for a different index.
+ * @xas: Maple Tree operation state.
+ * @start: New start of range in the Maple Tree.
+ * @last: New end of range in the Maple Tree.
+ *
+ * Move the operation state to refer to a different range. This will
+ * have the effect of starting a walk from the top; see mas_next()
+ * to move to an adjacent index.
+ */
+ static inline void mas_set_range(struct ma_state *mas, unsigned long start,
+ unsigned long last)
+ {
+ mas->index = start;
+ mas->last = last;
+ mas->node = MAS_START;
+ }
+
+ /**
+ * mas_set() - Set up Maple Tree operation state for a different index.
+ * @xas: Maple Tree operation state.
+ * @index: New index into the Maple Tree.
+ *
+ * Move the operation state to refer to a different index. This will
+ * have the effect of starting a walk from the top; see mas_next()
+ * to move to an adjacent index.
+ */
+ static inline void mas_set(struct ma_state *mas, unsigned long index)
+ {
+ mas_set_range(mas, index, index);
+ }
#endif
}
}
- ma_set_slot(mas, i);
+ mas_set_slot(mas, i);
return found;
ascend:
- if (ma_is_root(mas->node))
+ if (mte_is_root(mas->node))
found = true;
- ma_set_slot(mas, i);
+ mas_set_slot(mas, i);
return found;
}
+
/*
* Private: Returns true if mas->node is a leaf
*/
mas->node = next;
}
done:
- ma_set_slot(mas, i);
+ mas_set_slot(mas, i);
return ret;
}
+
static inline bool _mas_walk(struct ma_state *mas)
{
mas->node = mas_start(mas);
}
return false;
}
+
static inline int mas_dead_node(struct ma_state *mas, unsigned long index)
{
- if (!mt_dead_node(mas->node))
+ if (!mas->node)
+ return 0;
+ if (!mte_dead_node(mas->node))
return 0;
mas->index = index;
if (first > last)
return -EINVAL;
- mtree_lock(mas.tree);
+ mas_lock(&mas);
retry:
- ma_add(&mas, entry, true, true);
+ mas_add(&mas, entry, true, true);
if (mas_nomem(&mas, gfp))
goto retry;