}
/*
- * ma_set_pivot() - Set a pivot to a value.
- * @mn: The maple node
+ * mte_set_pivot() - Set a pivot to a value in an encoded maple node.
+ * @mn: The encoded maple node
* @piv: The pivot offset
- * @type: The maple node type
* @val: The value of the pivot
*/
-static inline void ma_set_pivot(struct maple_node *mn, unsigned char piv,
- enum maple_type type, unsigned long val)
+static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
+ unsigned long val)
{
- BUG_ON(piv >= mt_pivots[type]);
+ struct maple_node *node = mte_to_node(mn);
+ enum maple_type type = mte_node_type(mn);
+ BUG_ON(piv >= mt_pivots[type]);
switch (type) {
default:
case maple_range_64:
case maple_leaf_64:
- (&mn->mr64)->pivot[piv] = val;
+ (&node->mr64)->pivot[piv] = val;
break;
case maple_arange_64:
- (&mn->ma64)->pivot[piv] = val;
+ (&node->ma64)->pivot[piv] = val;
case maple_dense:
break;
}
-}
-/*
- * mte_set_pivot() - Set a pivot to a value in an encoded maple node.
- * @mn: The encoded maple node
- * @piv: The pivot offset
- * @val: The value of the pivot
- */
-static inline void mte_set_pivot(struct maple_enode *mn, unsigned char piv,
- unsigned long val)
-{
- return ma_set_pivot(mte_to_node(mn), piv, mte_node_type(mn), val);
}
/*
/*
* mas_mat_free() - Free all nodes in a dead list.
+ * @mas - the maple state
* @mat - the ma_topiary linked list of dead nodes to free.
*
* Free walk a dead list.
/*
* mas_mat_destroy() - Free all nodes and subtrees in a dead list.
+ * @mas - the maple state
* @mat - the ma_topiary linked list of dead nodes to free.
*
* Destroy walk a dead list.
return entry;
}
+/*
+ * ma_data_end() - Find the end of the data in a node.
+ * @node: The maple node
+ * @type: The maple node type
+ * @pivots: The array of pivots in the node
+ * @max: The maximum value in the node
+ *
+ * Uses metadata to find the end of the data when possible.
+ * Return: The zero indexed last slot with data (may be null).
+ */
static inline unsigned char ma_data_end(struct maple_node *node,
enum maple_type type,
unsigned long *pivots,
return mt_pivots[type];
}
+
/*
* mas_data_end() - Find the end of the data (slot).
* @mas: the maple state
struct maple_enode *parent)
{
enum maple_type type = mte_node_type(parent);
- void __rcu **slots = ma_slots(mte_to_node(mas->node), type);
+ struct maple_node *node = mas_mn(mas);
+ void __rcu **slots = ma_slots(node, type);
+ unsigned long *pivots = ma_pivots(node, type);
struct maple_enode *child;
unsigned char offset;
- offset = mas_data_end(mas);
+ offset = ma_data_end(node, type, pivots, mas->max);
do {
child = mas_slot_locked(mas, slots, offset);
mte_set_parent(child, parent, offset);
enum maple_type mt;
unsigned char offset;
unsigned char end;
+ unsigned long *pivots;
struct maple_enode *entry;
struct maple_node *node;
void __rcu **slots;
mt = mte_node_type(mas->node);
node = mas_mn(mas);
slots = ma_slots(node, mt);
- end = mas_data_end(mas);
+ pivots = ma_pivots(node, mt);
+ end = ma_data_end(node, mt, pivots, mas->max);
for (offset = mas->offset; offset <= end; offset++) {
entry = mas_slot_locked(mas, slots, offset);
if (mte_parent(entry) == node) {
offset = mas->offset;
level++;
node = mas_mn(mas);
- } while (unlikely(offset == mas_data_end(mas)));
+ mt = mte_node_type(mas->node);
+ pivots = ma_pivots(node, mt);
+ } while (unlikely(offset == ma_data_end(node, mt, pivots, mas->max)));
- mt = mte_node_type(mas->node);
slots = ma_slots(node, mt);
- pivots = ma_pivots(node, mt);
pivot = mas_safe_pivot(mas, pivots, ++offset, mt);
while (unlikely(level > 1)) {
/* Descend, if necessary */