enum maple_type mt = mte_node_type(mas->node);
struct maple_node *node = mte_to_node(mas->node);
void **slots = ma_slots(node, mt);
+ unsigned long *pivots = ma_pivots(node, mt);
unsigned long *gaps = NULL;
int i, j;
for (i = mas_start, j = mab_start; i <= mas_end; i++, j++) {
b_node->slot[j] = mas_slot_protected(mas, slots, i);
+ b_node->pivot[j] = _mas_safe_pivot(mas, pivots, i, mt);
if (gaps)
b_node->gap[j] = gaps[i];
- if (i < mt_pivots[mt])
- b_node->pivot[j] = mas_safe_pivot(mas, i);
- else
- b_node->pivot[j] = mas->max;
-
if ((mas->max == b_node->pivot[j]) ||
(j && !b_node->pivot[j])) { // end of node.
j++;
/*
* mab_mas_cp() - Copy data from maple_big_node to a maple encoded node.
- *
* @b_node: the maple_big_node that has the data
* @mab_start: the start location in @b_node.
* @mab_end: The end location in @b_node (inclusively)
struct ma_state *mas)
{
int i, j = 0;
+ enum maple_type mt = mte_node_type(mas->node);
+ struct maple_node *node = mte_to_node(mas->node);
+ void **slots = ma_slots(node, mt);
+ unsigned long *pivots = ma_pivots(node, mt);
+ unsigned long *gaps = NULL;
+
+ if (!ma_is_leaf(mt) && mt_is_alloc(mas->tree))
+ gaps = ma_gaps(mas_mn(mas), mt);
for (i = mab_start; i <= mab_end; i++, j++) {
if (j && !b_node->pivot[i])
break;
- mas->max = b_node->pivot[i];
- mte_set_slot(mas->node, j, b_node->slot[i]);
+ rcu_assign_pointer(slots[j], b_node->slot[i]);
+ if (j < mt_pivots[mt])
+ pivots[j] = b_node->pivot[i];
- if (j < mt_pivot_count(mas->node))
- mte_set_pivot(mas->node, j, b_node->pivot[i]);
-
- if (!mte_is_leaf(mas->node) && mt_is_alloc(mas->tree))
- mte_set_gap(mas->node, j, b_node->gap[i]);
+ if (gaps)
+ gaps[j] = b_node->gap[i];
}
+ mas->max = b_node->pivot[--i];
}
/*
static inline bool mas_split_final_node(struct maple_subtree_state *mast,
struct ma_state *mas, int height)
{
- if (height <= mas->full_cnt)
+ if (mt_slots[mast->bn->type] <= mast->bn->b_end)
return false;
return _mas_split_final_node(mast, mas, height);