unsigned char *mid_split)
{
int split = b_node->b_end / 2; // Assume equal split.
- unsigned char slot_count = mt_slots[b_node->type];
+ unsigned char min, slot_count = mt_slots[b_node->type];
+
+ if (unlikely((mas->mas_flags & MA_STATE_BULK))) {
+ *mid_split = 0;
+ if (ma_is_leaf(b_node->type))
+ min = 2;
+ else
+ return b_node->b_end - mt_min_slots[b_node->type];
- if (mab_middle_node(b_node, split, slot_count)) {
+ split = b_node->b_end - min;
+ mas->mas_flags |= MA_STATE_REBALANCE;
+ if (!b_node->slot[split])
+ split--;
+ return split;
+ }
+
+ if (unlikely(mab_middle_node(b_node, split, slot_count))) {
split = b_node->b_end / 3;
*mid_split = split * 2;
} else {
- unsigned char min = mt_min_slots[b_node->type] - 1;
+ min = mt_min_slots[b_node->type];
*mid_split = 0;
- if ((mas->mas_flags & MA_STATE_BULK) &&
- ma_is_leaf(b_node->type)) {
- min = 2;
- split = mt_slots[b_node->type] - min;
- mas->mas_flags |= MA_STATE_REBALANCE;
- }
/* Avoid having a range less than the slot count unless it
* causes one node to be deficient.
* NOTE: mt_min_slots is 1 based, b_end and split are zero.
unsigned long seq100[] = {
/* 0-5 */
- 78, 79, 80,
+ 74, 75, 76,
50, 100, 2,
/* 6-12 */
count++;
mas_dfs_preorder(&mas);
} while (!mas_is_none(&mas));
- // 68 + MAS_START = 69 + 1 for no jitter
//printk("count %lu\n", count);
- MT_BUG_ON(mt, count != 70);
+ MT_BUG_ON(mt, count != 74);
mtree_destroy(mt);
mtree_init(mt, MAPLE_ALLOC_RANGE);
mas_dfs_preorder(&mas);
} while (!mas_is_none(&mas));
//printk("count %lu\n", count);
- // 71 + MAS_START = 72 + 1 for no jitter
- MT_BUG_ON(mt, count != 72);
+ MT_BUG_ON(mt, count != 77);
mtree_destroy(mt);
mtree_init(mt, MAPLE_ALLOC_RANGE);
count++;
mas_dfs_preorder(&mas);
} while (!mas_is_none(&mas));
- // 71 + MAS_START = 72
//printk("count %lu\n", count);
MT_BUG_ON(mt, count != 77);
mtree_destroy(mt);