max_gap = mas_max_gap(mas);
penode = mas->node;
+ printk("penode is %p\n", penode);
do {
/* Ascend */
pnode = mte_parent(penode);
if (r_mas.node != mas->node) {
sd.new_end += r_mas.end + 1;
}
- if (r_wr_mas.offset_end < r_mas.end) {
+
+ if (r_mas.offset < r_mas.end) {
printk("offset_end %u < %u\n", r_wr_mas.offset_end, r_mas.end);
max_s++;
}
printk("Looks like there is a left sibling\n");
printk("mas is now %p[%u]\n", mas_mn(mas), mas->offset);
} else if (r_parent.max < ULONG_MAX) {
- printk("%d: set src %u\n", __LINE__, 2);
src[++max_s] = &other;
printk("%d: set src %u\n", __LINE__, max_s);
+ printk("r_parent %p[%u]\n", r_parent.node, r_parent.insert_off);
mas_next_node(&r_mas, r_parent.node, ULONG_MAX);
- mni_mas_init(&other, &r_mas);
- //r_parent.insert_off++;
+ r_mas.offset = 0;
+ mni_mas_init(&r_parent, &r_mas);
+ other = r_parent;
printk("Looks like there is a right cousin\n");
- BUG_ON(1);
- } else {
+ printk("r_parent is %p[%u] %lu-%lu\n", r_parent.node,
+ r_parent.insert_off, r_parent.min, r_parent.max);
fflush(stdout);
+ } else {
BUG_ON(!parent.min);
printk("%d: set src %u\n", __LINE__, s);
src[0] = &other;
s++;
max_s++;
+ printk("parent is %p[%u] %lu-%lu\n", parent.node,
+ parent.insert_off, parent.min, parent.max);
mas_prev_node(mas, 0);
- mni_mas_init(&other, &r_mas);
- //parent.insert_off--;
+ mas->offset = mas->end;
+ mni_mas_init(&parent, mas);
+ other = parent;
printk("Looks like there is a left cousin\n");
- BUG_ON(1);
+ printk("parent is %p[%u] %lu-%lu\n", parent.node,
+ parent.insert_off, parent.min, parent.max);
+ fflush(stdout);
}
mni_descend(&other);
- printk("descended other into %p with end %u\n", other.node, other.end);
+ printk("descended other into %p with end %u (%lu-%lu\n",
+ other.node, other.end, other.min, other.max);
sd.new_end += other.end + 1;
printk("new end is now %u\n", sd.new_end);
} else {
mni_mas_init(&left, mas);
mni_mas_init(&right, &r_mas);
printk("again\n\n");
- printk("parent %p and r %p\n",
- parent.node, r_parent.node);
- printk("next size is %u (%u - %u + %u)\n",
- mas->end - part.skip + part.size,
- mas->end, part.skip, part.size);
+ printk("parent %p[%u] and r %p[%u]\n",
+ parent.node, parent.insert_off, r_parent.node, r_parent.insert_off);
new_end = mas->end - part.skip + part.size;
if (parent.node != r_parent.node)
new_end += r_mas.end + 1;
+ printk("next size is %u (%u - %u + %u)\n",
+ new_end,
+ mas->end, part.skip, part.size);
printk("new end is %u\n", new_end);
if (!parent.min && r_parent.max == ULONG_MAX) {
if (new_end < mt_slots[parent.type]) {
- printk("break\n");
- break;
+ unsigned char size;
+ printk("break, parent insert is %u\n", parent.insert_off);
+ mas->depth = height + 1;
+ mas_set_height(mas);
+ mni_node_init(&new_parent, mas_pop_node(mas), parent.type);
+ printk("new parent is %p\n", new_parent.node);
+ printk("type %u enode %p\n", parent.type, new_parent.enode);
+ sd.len = 0;
+ size = parent.insert_off;
+ if (size) {
+ printk("cp parent 0 - %u\n", size);
+ mns_mni_init(&sd.states[0], &new_parent, 0, size);
+ sd.states[0].info = &parent;
+ sd.len++;
+ }
+ printk("insert new at %u\n", size);
+ mns_mni_init(&sd.states[sd.len], &new_parent, 0, part.size);
+ sd.states[sd.len].part = ∂
+ sd.states[sd.len].use_part = true;
+ sd.len++;
+ if (r_parent.insert_off < r_parent.end) {
+ size = r_parent.end - r_parent.insert_off;
+ printk("cp r parent %u - %u\n", r_parent.insert_off + 1, size);
+ mns_mni_init(&sd.states[sd.len], &new_parent, r_parent.insert_off + 1, size);
+ sd.states[sd.len].info = &r_parent;
+ sd.len++;
+ }
+ mns_assemble(sd.states, sd.len);
+ mni_finalise(&new_parent, &sd);
+ left.enode = mas_root_locked(mas);
+ new_parent.node->parent = mte_to_node(left.enode)->parent;
+ mas->node = new_parent.enode;
+ goto new_root;
}
printk("root detected, but too big\n");
}
mas_wmb_replace(mas, left.enode);
mtree_range_walk(mas);
mt_dump(mas->tree, mt_dump_dec);
+ fflush(stdout);
mt_validate(mas->tree);
}
#if 0