unsigned long gap[MAPLE_BIG_NODE_GAPS];
};
};
- unsigned long min;
unsigned char b_end;
enum maple_type type;
};
* Return: The first split location. The middle split is set in @mid_split.
*/
static inline int mab_calc_split(struct ma_state *mas,
- struct maple_big_node *bn,
- unsigned char *mid_split)
+ struct maple_big_node *bn, unsigned char *mid_split, unsigned long min)
{
unsigned char b_end = bn->b_end;
int split = b_end / 2; /* Assume equal split. */
- unsigned char min, slot_count = mt_slots[bn->type];
+ unsigned char slot_min, slot_count = mt_slots[bn->type];
/*
* To support gap tracking, all NULL entries are kept together and a node cannot
if (unlikely((mas->mas_flags & MA_STATE_BULK))) {
*mid_split = 0;
if (ma_is_leaf(bn->type))
- min = 2;
+ slot_min = 2;
else
return b_end - mt_min_slots[bn->type];
- split = b_end - min;
+ split = b_end - slot_min;
mas->mas_flags |= MA_STATE_REBALANCE;
if (!bn->slot[split])
split--;
split = b_end / 3;
*mid_split = split * 2;
} else {
- min = mt_min_slots[bn->type];
+ slot_min = mt_min_slots[bn->type];
*mid_split = 0;
/*
* causes one node to be deficient.
* NOTE: mt_min_slots is 1 based, b_end and split are zero.
*/
- while (((bn->pivot[split] - bn->min) < slot_count - 1) &&
- (split < slot_count - 1) && (b_end - split > min))
+ while (((bn->pivot[split] - min) < slot_count - 1) &&
+ (split < slot_count - 1) && (b_end - split > slot_min))
split++;
}
* Return: the split of left.
*/
static inline unsigned char mas_mab_to_node(struct ma_state *mas,
- struct maple_big_node *b_node,
- struct maple_enode **left,
- struct maple_enode **right,
- struct maple_enode **middle,
- unsigned char *mid_split)
+ struct maple_big_node *b_node, struct maple_enode **left,
+ struct maple_enode **right, struct maple_enode **middle,
+ unsigned char *mid_split, unsigned long min)
{
unsigned char split = 0;
unsigned char slot_count = mt_slots[b_node->type];
if (b_node->b_end < slot_count) {
split = b_node->b_end;
} else {
- split = mab_calc_split(mas, b_node, mid_split);
+ split = mab_calc_split(mas, b_node, mid_split, min);
*right = mas_new_ma_node(mas, b_node);
}
return false;
}
-/*
- * mast_setup_bnode_for_split() - Prepare the subtree state big node for
- * splitting
- * @mast: The maple subtree state
- */
-static inline void mast_setup_bnode_for_split(struct maple_subtree_state *mast)
-{
- mast->bn->b_end--;
- mast->bn->min = mast->orig_l->min;
- mast->bn->type = mte_node_type(mast->orig_l->node);
-}
-
static inline void *mtree_range_walk(struct ma_state *mas)
{
unsigned long *pivots;
* See mas_descend_adopt() for more information..
*/
while (count--) {
- mast_setup_bnode_for_split(mast);
+ mast->bn->b_end--;
+ mast->bn->type = mte_node_type(mast->orig_l->node);
split = mas_mab_to_node(mas, mast->bn, &left, &right, &middle,
- &mid_split);
+ &mid_split, mast->orig_l->min);
mast_set_split_parents(mast, left, middle, right, split,
mid_split);
mast_cp_to_nodes(mast, left, middle, right, split, mid_split);
mas->offset = mte_parent_slot(mas->node);
}
- mast->bn->min = mas->min;
if (cp && mast->l->offset)
mas_mab_cp(mas, 0, mast->l->offset - 1, mast->bn, 0);
if (mas_push_data(mas, height, &mast, false))
break;
- split = mab_calc_split(mas, b_node, &mid_split);
+ split = mab_calc_split(mas, b_node, &mid_split, prev_l_mas.min);
mast_split_data(&mast, mas, split);
/*
* Usually correct, mab_mas_cp in the above call overwrites
slow_path:
b_node.b_end = mas_store_b_node(wr_mas, &b_node, wr_mas->offset_end);
- b_node.min = mas->min;
zero = MAPLE_BIG_NODE_SLOTS - b_node.b_end - 1;
memset(b_node.slot + b_node.b_end + 1, 0, sizeof(void *) * zero--);
memset(b_node.pivot + b_node.b_end + 1, 0,