bool mas_nomem(struct ma_state *mas, gfp_t gfp);
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))
+
#endif
mas->node = MAS_NONE;
}
+static inline void* mas_prev_entry(struct ma_state *mas, unsigned long min)
+{
+ if (mas->node == MAS_NONE)
+ return NULL;
+
+ mas_prev_node(mas, min);
+ if (mas->node == MAS_NONE)
+ return NULL;
+
+ return mte_get_rcu_slot(mas->node, mas_get_slot(mas));
+}
/*
* Find the next non-null entry at the same level in the tree. The next value
* will be mas->node[mas_get_slot(mas)] or MAS_NONE.
return 1;
}
+void *mas_load(struct ma_state *mas)
+{
+ void *entry = mas_walk(&mas);
+ if (xa_is_zero(entry) || mt_is_empty(entry))
+ return NULL;
+
+ return entry;
+}
/**
* mas_find - Find the first entry that overlaps the range.
* If mas->node is root, finds mas->index and returns the value. If the
MA_STATE(mas, mt, index, index);
rcu_read_lock();
- entry = mas_walk(&mas);
+ entry = mas_load(mas);
rcu_read_unlock();
-
- if (xa_is_zero(entry) || mt_is_empty(entry))
- return NULL;
-
- return entry;
+ return mas_load(mas);
}
EXPORT_SYMBOL(mtree_load);