mt_init_flags(mt, 0);
}
+static inline bool mt_in_rcu(struct maple_tree *mt)
+{
+ return mt->ma_flags & MAPLE_USE_RCU;
+}
/**
* mt_clear_in_rcu() - Switch the tree to non-RCU mode.
*/
static inline void mt_clear_in_rcu(struct maple_tree *mt)
{
- if ((mt->ma_flags & MAPLE_USE_RCU) == 0)
+ if (!mt_in_rcu(mt))
return;
mtree_lock(mt);
- mt->ma_flags &= ~(1 <<MAPLE_USE_RCU);
+ mt->ma_flags &= ~MAPLE_USE_RCU;
mtree_unlock(mt);
}
*/
static inline void mt_set_in_rcu(struct maple_tree *mt)
{
- if (mt->ma_flags & MAPLE_USE_RCU)
+ if (mt_in_rcu(mt))
return;
mtree_lock(mt);
- mt->ma_flags |= (1 << MAPLE_USE_RCU);
+ mt->ma_flags |= MAPLE_USE_RCU;
mtree_unlock(mt);
}
return (mt->ma_flags & MAPLE_HEIGHT_MASK) >> MAPLE_HEIGHT_OFFSET;
}
-static bool mas_in_rcu(struct ma_state *mas)
-{
- return mas->tree->ma_flags & (1 << MAPLE_USE_RCU);
-}
static void mas_set_height(struct ma_state *mas)
{
{
int i;
- if (mas_in_rcu(mas))
+ if (mt_in_rcu(mas->tree))
return false; // Need to be rcu safe.
mab_mas_cp(bn, 0, bn->b_end, mas);
+ // Zero end of node.
if (end > bn->b_end) {
for (i = bn->b_end + 1; i < mt_slot_count(mas->node); i++) {
mte_set_rcu_slot(mas->node, i, NULL);
if (i < mt_pivot_count(mas->node))
mte_set_pivot(mas->node, i, 0);
- //if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree))
- // mte_set_gap(mas->node, j, b_node->gap[i]);
+ // if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree))
+ // mte_set_gap(mas->node, i, 0);
}
}
node->type = mte_node_type(enode);
node->mt.ma_flags = mt->ma_flags;
mte_set_node_dead(enode);
- call_rcu(&node->rcu, mt_destroy_walk);
+ if (mt_in_rcu(mt))
+ call_rcu(&node->rcu, mt_destroy_walk);
+ else
+ mt_destroy_walk(&node->rcu);
}
/* Interface */
void __init maple_tree_init(void)
}
EXPORT_SYMBOL(mtree_erase);
-void mtree_direct_destroy(struct maple_tree *mt)
-{
- mtree_lock(mt);
- if (xa_is_node(mt->ma_root)) {
- struct maple_node *node = mte_to_node(mt->ma_root);
-
- node->type = mte_node_type(mt->ma_root);
- node->mt.ma_flags = mt->ma_flags;
- mte_set_node_dead(mt->ma_root);
- mt_destroy_walk(&node->rcu);
- }
-
- mt->ma_flags = 0;
- mt->ma_root = NULL;
- mtree_unlock(mt);
-}
-/* mtree_direct_destroy is unsafe to export as it is not rcu safe. */
-
void mtree_destroy(struct maple_tree *mt)
{
mtree_lock(mt);