}
}
- // Insert happens in leaf
if (attempt_insert && (cp.index <= piv)) {
if (written_piv != cp.index - 1) {
// Insert a previous entry..
return _mas_copy(mas, cp, mas->min);
}
-static inline int mas_split_data(struct ma_state *mas, struct maple_enode *left,
- struct maple_enode *right, unsigned char split,
- unsigned long r_max)
-{
-
- MA_CP(cp, mas->node, left, 0, split);
-
- mas_copy(mas, &cp);
- cp.src_start = split + 1;
-
- if (cp.src_start > mt_node_max(mas->node))
- return split;
-
- cp.src_end = mt_slot_count(mas->node) - 1;
- if (right) {
- cp.dst = right;
- cp.dst_start = 0;
- mas_copy(mas, &cp);
- if (cp.dst_start + split >= mt_pivot_count(cp.dst)) {
- unsigned char slot = cp.dst_start;
-
- if (mt_is_empty(mte_get_rcu_slot(right, slot)))
- slot--;
- mte_set_pivot(right, slot, r_max);
- }
- }
- return split;
-}
-
static inline void mte_adopt_children(struct maple_enode *parent)
{
goto update_gap;
}
+ printk("slot %u\n", slot);
if (slot > slot_cnt)
slot = old_end + 1;
if (new_end > slot_cnt) {
/* Not enough space in the node */
- unsigned char split = mas_split(mas, slot, active, new_end,
- entry);
+ mas_split(mas, slot, active, new_end, entry);
if (mas_is_err(mas))
return 0;
unsigned long *range_start)
{
unsigned long pivot = mas->min;
- unsigned long r_start = *range_start;
+ unsigned long r_start = mas->min;
unsigned char slot = mas_get_slot(mas);
unsigned char count = mt_slot_count(mas->node);
void *entry;
+ if (slot)
+ r_start = mas_get_safe_pivot(mas, slot - 1) + 1;
+
+ printk("next entry starting slot %u\n", slot);
while (slot < count) {
pivot = mas_get_safe_pivot(mas, slot);
*range_start = mas->last + 1;
while (!mas_is_none(mas)) {
-
unsigned char p_slot = 0;
+ struct maple_enode *last_node = mas->node;
+
slot = mas_get_slot(mas);
if (slot > mt_slot_count(mas->node))
goto next_node;
if (!mte_is_leaf(mas->node) || !mas_get_slot(mas)) {
*range_start = mas_first_entry(mas, limit);
- if (mas_is_none(mas))
- return NULL;
+ if (mas_is_none(mas)) {
+ mas->node = last_node;
+ goto next_node;
+ }
}
- if (mas_next_nentry(mas, limit, range_start))
+ if (mas_next_nentry(mas, limit, range_start)) {
+ printk("nentry break\n");
break;
+ }
if (*range_start > limit)
return NULL;
mas_set_slot(mas, 0);
}
done:
- printk("Set min %lu\n", min);
mas_set_slot(mas, i);
*range_max = max;
*range_min = min;
mas->alloc = NULL;
// Copy left side
+ mas_reset(&l_mas);
mas_for_each(&l_mas, entry, mas->index - 1) {
new_mas.index = l_mas.index;
- new_mas.last = mas_get_safe_pivot(&l_mas, mas_get_slot(&l_mas));
+ new_mas.last = l_mas.index;
printk("Insert %lu->%lu\n", new_mas.index, new_mas.last);
ma_inactive_insert(&new_mas, entry);
if (mas_is_err(&new_mas))