* @recursive - specifies if this sub-tree is to be freed or just the single
* node.
*/
-static inline void mat_free(struct ma_topiary *mat, bool recursive)
+static inline void mas_free(struct ma_state *mas, struct maple_enode *used);
+static inline void mas_mat_free(struct ma_state *mas, struct ma_topiary *mat,
+ bool recursive)
{
struct maple_enode *next;
if (recursive)
mte_destroy_walk(mat->head, mat->mtree);
else
- mte_free(mat->head);
+ mas_free(mas, mat->head);
mat->head = next;
}
}
BUG_ON(!mas_alloc_cnt(mas));
}
+static inline void mas_free(struct ma_state *mas, struct maple_enode *used)
+{
+ if (mt_in_rcu(mas->tree))
+ mte_free(used);
+ else {
+ mas_push_node(mas, used);
+ }
+}
+
static inline void mas_node_node(struct ma_state *ms, gfp_t gfp)
{
struct maple_node *mn, *smn;
}
if (!advanced)
- mte_free(prev);
+ mas_free(mas, prev);
}
/*
if (!mte_is_leaf(mas->node))
mas_descend_adopt(mas);
- mat_free(free, false);
+ mas_mat_free(mas, free, false);
if (destroy)
- mat_free(destroy, true);
+ mas_mat_free(mas, destroy, true);
if (mte_is_leaf(mas->node))
return;
int ret = 0;
+ if (mas_is_err(mas))
+ return NULL;
+
if (mas_start(mas) || mas_is_none(mas) || mas->node == MAS_ROOT) {
ret = ma_root_ptr(mas, entry, content, overwrite);
if (mas_is_err(mas))
kmem_cache_free(maple_node_cache, node);
}
-void mt_dump(const struct maple_tree *mt);
void mte_destroy_walk(struct maple_enode *enode, struct maple_tree *mt)
{
struct maple_node *node = mte_to_node(enode);