}
/*
- * mte_set_parent() - Set the parent node and encode the slot
+ * mas_set_parent() - Set the parent node and encode the slot
* @enode: The encoded maple node.
* @parent: The encoded maple node that is the parent of @enode.
* @slot: The slot that @enode resides in @parent.
* parent type.
*/
static inline
-void mte_set_parent(struct maple_enode *enode, const struct maple_enode *parent,
- unsigned char slot)
+void mas_set_parent(struct ma_state *mas, struct maple_enode *enode,
+ const struct maple_enode *parent, unsigned char slot)
{
unsigned long val = (unsigned long) parent;
unsigned long shift;
unsigned long type;
enum maple_type p_type = mte_node_type(parent);
- BUG_ON(p_type == maple_dense);
- BUG_ON(p_type == maple_leaf_64);
+ if (MT_WARN_ON(mas->tree, p_type == maple_dense))
+ pr_err("Dense node %p cannot be parent\n", parent);
+
+ if (MT_WARN_ON(mas->tree, p_type == maple_leaf_64))
+ pr_err("Leaf node %p cannot be parent\n", parent);
switch (p_type) {
case maple_range_64:
offset = ma_data_end(node, type, pivots, mas->max);
do {
child = mas_slot_locked(mas, slots, offset);
- mte_set_parent(child, parent, offset);
+ mas_set_parent(mas, child, parent, offset);
} while (offset--);
}
}
/*
- * mte_set_split_parent() - combine_then_separate helper function. Sets the parent
+ * mas_set_split_parent() - combine_then_separate helper function. Sets the parent
* of @mas->node to either @left or @right, depending on @slot and @split
*
* @mas - the maple state with the node that needs a parent
* @slot - the slot the mas->node was placed
* @split - the split location between @left and @right
*/
-static inline void mte_set_split_parent(struct maple_enode *enode,
- struct maple_enode *left,
- struct maple_enode *right,
- unsigned char *slot, unsigned char split)
+static inline void mas_set_split_parent(struct ma_state *mas,
+ struct maple_enode *enode, struct maple_enode *left,
+ struct maple_enode *right, unsigned char *slot, unsigned char split)
{
if (enode == MAS_NONE)
return;
if ((*slot) <= split)
- mte_set_parent(enode, left, *slot);
+ mas_set_parent(mas, enode, left, *slot);
else if (right)
- mte_set_parent(enode, right, (*slot) - split - 1);
+ mas_set_parent(mas, enode, right, (*slot) - split - 1);
(*slot)++;
}
slot = mast->l->offset;
mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- mte_set_split_parent(mast->l->node, l, r, &slot, split);
+ mas_set_split_parent(mast->l, mast->l->node, l, r, &slot, split);
mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- mte_set_split_parent(mast->m->node, l, r, &slot, split);
+ mas_set_split_parent(mast->m, mast->m->node, l, r, &slot, split);
mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- mte_set_split_parent(mast->r->node, l, r, &slot, split);
+ mas_set_split_parent(mast->r, mast->r->node, l, r, &slot, split);
}
/*
mte_node_type(mast->orig_l->node));
mast->orig_l->depth++;
mab_mas_cp(mast->bn, 0, mt_slots[mast->bn->type] - 1, &l_mas, true);
- mte_set_parent(left, l_mas.node, slot);
+ mas_set_parent(mas, left, l_mas.node, slot);
if (middle)
- mte_set_parent(middle, l_mas.node, ++slot);
+ mas_set_parent(mas, middle, l_mas.node, ++slot);
if (right)
- mte_set_parent(right, l_mas.node, ++slot);
+ mas_set_parent(mas, right, l_mas.node, ++slot);
if (mas_is_root_limits(mast->l)) {
new_root:
* The Big_node data should just fit in a single node.
*/
ancestor = mas_new_ma_node(mas, mss->bn);
- mte_set_parent(mss->l->node, ancestor, mss->l->offset);
- mte_set_parent(mss->r->node, ancestor, mss->r->offset);
+ mas_set_parent(mas, mss->l->node, ancestor, mss->l->offset);
+ mas_set_parent(mas, mss->r->node, ancestor, mss->r->offset);
mte_to_node(ancestor)->parent = mas_mn(mas)->parent;
mss->l->node = ancestor;
return;
p_slot = mss->offset;
- mte_set_split_parent(mss->l_node, mss->l->node, mss->r->node,
+ mas_set_split_parent(mas, mss->l_node, mss->l->node, mss->r->node,
&p_slot, split);
- mte_set_split_parent(mss->r_node, mss->l->node, mss->r->node,
+ mas_set_split_parent(mas, mss->r_node, mss->l->node, mss->r->node,
&p_slot, split);
}