return false;
}
static inline int mab_calc_split(struct maple_big_node *b_node, int size,
- unsigned char slot_cnt, unsigned long min)
+ unsigned char slot_cnt, unsigned long min,
+ enum maple_type type)
{
int split = (size - 1) / 2; // Assume equal split.
- printk("orig split %u\n", split);
if (mab_middle_node(b_node, size, slot_cnt)) {
split = (size + 1) / 3;
- printk("3 split %u\n", split);
} else {
- /* Avoid ending a node in NULL and avoid having a range less
- * than the slot count
- */
+ /* Avoid having a range less than the slot count unless it
+ * causes one node to be deficient. */
while (((b_node->pivot[split] - min) < slot_cnt - 1) &&
- (split < slot_cnt))
+ (split < slot_cnt) &&
+ (size - split > mt_min_slots[type]))
split++;
}
- printk("adjusted split %u\n", split);
+ /* Avoid ending a node on a NULL entry */
if (!b_node->slot[split]) {
printk("%u is null\n", split);
if (split < slot_cnt - 1)
else
split--;
}
- //printk("Setting split (leaf split) to %u\n", split);
+
return split;
}
split = b_end;
} else {
split = mab_calc_split(b_node, b_end, slot_cnt,
- orig_l_mas->min);
+ orig_l_mas->min,
+ mte_node_type(orig_l_mas->node));
r = mt_mk_node(ma_mnode_ptr(mas_next_alloc(mas)),
mte_node_type(orig_l_mas->node));
}
if (mte_is_leaf(mas->node)) {
printk("Splitting leaf %p\n", mas_mn(mas));
split = mab_calc_split(b_node, new_end, slot_cnt,
- mas->min);
+ mas->min, type);
printk("Splitting at %u\n", split);
if (split < slot_cnt)
i = mab_mas_cp(b_node, 0, split, &l_mas, 0);
if (contents)
mte_set_rcu_slot(mas->node, slot++, contents);
- if (!mas->index)
+ if (!mas->index && slot)
slot--;
else if (mas->index > 1)
mte_set_pivot(mas->node, slot++, mas->index - 1);
-
mte_set_rcu_slot(mas->node, slot, entry);
mte_set_pivot(mas->node, slot++, mas->last);