return kmem_cache_nr_allocated(maple_node_cache);
}
+/*
+ * mas_dead_node() - Check if the maple state is pointing to a dead node.
+ * @mas: The maple state
+ * @index: The index to restore in @mas.
+ *
+ * Used in test code.
+ * Return: 1 if @mas has been reset to MAS_START, 0 otherwise.
+ */
+static inline int mas_dead_node(struct ma_state *mas, unsigned long index)
+{
+ if (unlikely(!mas_searchable(mas) || mas_is_start(mas)))
+ return 0;
+
+ if (likely(!mte_dead_node(mas->node)))
+ return 0;
+
+ mas_rewalk(mas, index);
+ return 1;
+}
+
#define MA_PTR "%p"
#else /* __KERNEL__ is defined */
#define MA_PTR "%px"
#endif
+/*
+ * mas_get_slot() - Get the entry in the maple state node stored at @offset.
+ * @mas: The maple state
+ * @offset: The offset into the slot array to fetch.
+ *
+ * Return: The entry stored at @offset.
+ */
+static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
+ unsigned char offset)
+{
+ return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)),
+ offset);
+}
+
+
#ifdef CONFIG_MAPLE_SEARCH
/* mas limits not adjusted */
static void mas_dfs_preorder(struct ma_state *mas)
mt_dump_node(mt, entry, 0, mt_max[mte_node_type(entry)], 0);
}
-/*
- * mas_get_slot() - Get the entry in the maple state node stored at @offset.
- * @mas: The maple state
- * @offset: The offset into the slot array to fetch.
- *
- * Return: The entry stored at @offset.
- */
-static inline struct maple_enode *mas_get_slot(struct ma_state *mas,
- unsigned char offset)
-{
- return mas_slot(mas, ma_slots(mas_mn(mas), mte_node_type(mas->node)),
- offset);
-}
-
/*
* Calculate the maximum gap in a node and check if that's what is reported in
* the parent (unless root).