printk("%p is root?\n", mas->node);
if (mte_is_root(mas->node)) {
+ printk("yes\n");
mas_mn(mas)->parent = ma_parent_ptr(mas_tree_parent(mas));
rcu_assign_pointer(mas->tree->ma_root, mte_mk_root(mas->node));
mas_set_height(mas);
} else {
+ printk("no\n");
offset = mte_parent_slot(mas->node);
slots = ma_slots(mte_parent(mas->node),
mast->r = &r_mas;
l_mas.status = r_mas.status = m_mas.status = ma_none;
+ printk("%d\n", __LINE__);
/* Check if this is not root and has sufficient data. */
if (((mast->orig_l->min != 0) || (mast->orig_r->max != ULONG_MAX)) &&
- unlikely(mast->bn->b_end <= mt_min_slots[mast->bn->type]))
+ unlikely(mast->bn->b_end <= mt_min_slots[mast->bn->type])) {
mast_spanning_rebalance(mast);
+ printk("%d\n", __LINE__);
+ }
l_mas.depth = 0;
mast->bn->type = mte_node_type(left);
l_mas.depth++;
+ printk("%d\n", __LINE__);
/* Root already stored in l->node. */
if (mas_is_root_limits(mast->l))
goto new_root;
+ printk("%d\n", __LINE__);
mast_ascend(mast);
mast_combine_cp_left(mast);
l_mas.offset = mast->bn->b_end;
if (!count)
count++;
}
+ printk("%d\n", __LINE__);
l_mas.node = mt_mk_node(ma_mnode_ptr(mas_pop_node(mas)),
mte_node_type(mast->orig_l->node));
if (mas_is_root_limits(mast->l)) {
new_root:
+ printk("%d\n", __LINE__);
mas_mn(mast->l)->parent = ma_parent_ptr(mas_tree_parent(mas));
while (!mte_is_root(mast->orig_l->node))
mast_ascend(mast);
};
unsigned char start; /* The start offset into the source*/
unsigned char size; /* The size to copy or insert */
- bool use_part;
+ bool use_part; /* ma_node_part, not a real node */
struct ma_node_info *dst; /* The destination node */
};
printk("pivot 0 is %lu\n", left->max);
ma_part->gaps[0] = left->max_gap;
+ printk("set slot 1 to %p\n", right->enode);
ma_part->slots[1] = right->enode;
ma_part->pivots[1] = right->max;
+ printk("pivot 1 is %lu\n", right->max);
ma_part->gaps[1] = right->max_gap;
ma_part->pos = 0;
mns->start = start;
mns->size = len;
mns->use_part = false;
- printk("Dst %p <= [%u] + %u\n", dst, start, len);
+ printk("Dst %p <= [%u] + %u\n", dst->node, start, len);
}
static inline
printk("%u: dst %p [%u] size %lu\n", i, ns->dst, ns->dst->offset, size);
if (ns->use_part) {
+ printk("Use part\n");
s_slots = ns->part->slots + ns->start;
s_piv = ns->part->pivots + ns->start;
s_gap = ns->part->gaps + ns->start;
if (!ns->part->leaf) {
int j = 0;
+ /* Set parent of _new_ children */
printk("not a leaf\n");
do {
struct maple_enode *child;
}
ns->dst->offset += size;
+ printk("offset advances by %u to %u\n", size, ns->dst->offset);
ns->dst->end = ns->dst->offset - 1;
printk("\t\t set %p end to %u\n", ns->dst->node, ns->dst->end);
size -= piv_overflow;
do {
unsigned char copied = 0;
- if (offset >= insert && offset < insert_end) {
+ printk("offset is %u insert %u - %u\n", insert, insert_end);
+ if (offset >= insert && offset <= insert_end) {
copied = min(ma_part->size - part_off, size);
- printk("B: Insert at %u/%u size %u (out of %u)\n", offset, total_data, copied,
+ printk("B: (part) Insert at %u/%u size %u (out of %u)\n", offset, total_data, copied,
ma_part->size);
state[i].part = ma_part;
mns_mni_init(&state[i], to, part_off, copied);
state[i].use_part = true;
part_off += copied;
+ printk("copy part size %u\n", copied);
+ printk("node_off is %u insert end is %u\n", node_off, node_ins_end);
node_off = node_ins_end + 1;
} else {
state[i].info = src;
*/
printk("A: min of %u and %u (%u - %u)\n", size, insert - offset, insert, offset);
copied = min(size, insert - offset);
+ printk("\tcopied = %u\n", copied);
} else {
printk("C: min of %u and %u\n", size, src->end - node_off + 1);
copied = min(size, (src->end - node_off + 1));
+ printk("\tcopied = %u\n", copied);
}
+ BUG_ON(copied == 0);
printk("size is %u split %u\n", size, split);
printk("cp at %u/%u size %u\n", offset, total_data, copied);
size -= copied;
printk("next offset %u\n", offset);
if ((to == left) && (offset >= split)) {
- printk("Check null\n");
- if (mns_ends_in_null(&state[i])) {
- printk("null split, adjust - 1\n");
+ if (ma_is_leaf(src->type) &&
+ mns_ends_in_null(&state[i])) {
+ printk("Check null\n");
if (!state[i].use_part && offset != insert) {
- printk("\tuse_part\n");
+ /* Setting up a copy from a normal node */
+ printk("\t!use_part: expand cp a space\n");
+ printk("offset %u insert %u\n", offset, insert);
state[i].size++;
split++;
offset++;
size--;
node_off++;
} else {
- printk("\tregular\n");
- state[i].size--;
+ printk("\tuse_part!!\n");
+ printk("\t\t split (%u) - 1\n", split);
+ printk("\t\t offset (%u) - 1\n", offset);
+ printk("\t\t size (%u) + 1\n", size);
split--;
offset--;
size++;
- part_off--;
- if (!state[i].use_part)
+ if (state[i].use_part) {
+ printk("\t\t part_off (%u) - 1\n", part_off);
+ part_off--;
+ } else {
+ printk("\t\t node_off %u --\n", node_off);
node_off--;
+ }
+ printk("\t\t state size (%u) - 1\n", state[i].size);
+ if (state[i].size == 1)
+ i--;
+ else
+ state[i].size--;
}
printk("offset %u node_off %u\n", offset, node_off);
}
- printk("Last pivot in left is %lu\n", to->pivots[node_off - 1]);
+ //printk("Last pivot in left is %lu\n", to->pivots[node_off - 1]);
printk("Switch to right\n");
size = mt_slots[right->type];
printk("size is %u\n", size);
split = 255;
}
i++;
- printk("node off is %u vs %u\n", node_off, src->end);
+ printk("\tnode %p off is %u vs %u\n", src->node, node_off, src->end);
} while (node_off <= src->end);
printk("Last pivot in right is %lu\n", to->pivots[node_off - 1]);
left->min = src->min;
right->max = src2.max;
printk("right will be rebalanced against this one.\n");
+ printk("ma part %p and %p\n", ma_part->slots[0], ma_part->slots[1]);
}
/* The rebalance operation will succeed. */
printk("\t\t%s\n", __func__);
- mt_dump(mas->tree, mt_dump_dec);
+ //mt_dump(mas->tree, mt_dump_dec);
i = 0;
offset = 0;
printk("left store at %u\n", insert);
size = split;
} else {
- printk("right store\n");
+ printk("right store (into %p)\n", src2.node);
/* Right pushes data left */
insert = mas->offset + src2.end + 1;
offset += src2.end + 1;
+ printk("insert %u offset %u\n", insert, offset);
size = split - src2.end;
printk("size is %u = %u - %u\n", size, split, src2.end);
* There can also be a split between nodes that may happen at these
* boundaries, or elsewhere.
*/
- printk("do the splitting of data\n");
+ printk("do the splitting of data %u - node ins end %u\n", offset, node_ins_end);
i = mt_wr_split_data(src, left, right, ma_part, split, insert, size,
offset, node_ins_end, total_data, state, i);
if (left_store) {
trace_ma_op(__func__, mas);
printk("\t\t%s\n", __func__);
- mt_dump(mas->tree, mt_dump_dec);
+ //mt_dump(mas->tree, mt_dump_dec);
printk ("Store %lu - %lu => %p\n", mas->index, mas->last, wr_mas->entry);
height = mas_mt_height(mas);
mas->depth = height;
left.min = mas->min;
right.max = mas->max;
- mt_dump(wr_mas->mas->tree, mt_dump_dec);
+ //mt_dump(wr_mas->mas->tree, mt_dump_dec);
i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
mas->offset, split, 0, wr_mas->offset_end,
total, state, 0);
mni_node_init(&right, mas_pop_node(mas), src_info.type);
if ((height > 1) &&
(mas_wr_try_rebalance(mas, &src_info, mas->end + 1, &left,
- &right, &ma_part, src_info.insert_off + 1)))
+ &right, &ma_part, src_info.insert_off)))
goto rebalanced;
left.min = src_info.min;
printk("MIN %lu MAX %lu\n\n", left.min, right.max);
split = (total + 1) / 2;
- printk("Split data at %u\n", split);
+ printk("Split data at %u offset %u\n", split, mas->offset);
i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
- mas->offset, split, 0, wr_mas->offset_end,
+ mas->offset, split, 0, mas->offset,
total, state, 0);
mns_assemble(state, i);
mni_finalise(&left);
rebalanced:
mas_wmb_replace(mas, src_info.enode);
mtree_range_walk(mas);
- mt_dump(wr_mas->mas->tree, mt_dump_dec);
+ //mt_dump(wr_mas->mas->tree, mt_dump_dec);
}
/*
switch (mas->store_type) {
case wr_slot_store:
+ printk("%d\n", __LINE__);
mas_wr_slot_store(wr_mas);
break;
case wr_node_store:
+ printk("%d\n", __LINE__);
mas_wr_node_store(wr_mas, new_end);
break;
case wr_split_store:
+ printk("%d\n", __LINE__);
mas_wr_split(wr_mas);
break;
case wr_rebalance:
mas_wr_bnode(wr_mas);
+ printk("%d\n", __LINE__);
//mas_wr_rebalance(wr_mas);
break;
case wr_exact_fit:
+ printk("%d\n", __LINE__);
rcu_assign_pointer(wr_mas->slots[mas->offset], wr_mas->entry);
if (!!wr_mas->entry ^ !!wr_mas->content)
mas_update_gap(mas);
break;
case wr_new_root:
+ printk("%d\n", __LINE__);
mas_new_root(mas, wr_mas->entry);
break;
case wr_store_root:
+ printk("%d\n", __LINE__);
mas_store_root(mas, wr_mas->entry);
break;
case wr_spanning_store:
+ printk("%d\n", __LINE__);
mas_wr_spanning_store(wr_mas);
break;
case wr_append:
+ printk("%d\n", __LINE__);
mas_wr_append(wr_mas, new_end);
break;
case wr_invalid:
+ printk("%d\n", __LINE__);
MT_BUG_ON(mas->tree, 1);
return;
}
val = i*10;
val2 = (i+1)*10;
check_store_range(mt, val, val2, xa_mk_value(val), 0);
+ if (val > 11700)
+ check_load(mt, 11700, xa_mk_value(11700));
MT_BUG_ON(mt, mt_height(mt) >= 4);
}
+ check_load(mt, 11700, xa_mk_value(11700 & LONG_MAX));
/* Cause a 3 child split all the way up the tree. */
for (i = 5; i < 215; i += 10) {
+ printk("\n\n: START %lu (%lu)\n", 11450 + i, i);
check_store_range(mt, 11450 + i, 11450 + i + 1, NULL, 0);
+ printk("store %lu-%lu => %p\n", 11450 + i, 11450 + i +1);
+ check_load(mt, 11700, xa_mk_value(11700));
mt_validate(mt);
mt_dump(mt, mt_dump_dec);
}
for (i = 5; i < 65; i += 10) {
+ check_load(mt, 11700, xa_mk_value(11700 & LONG_MAX));
check_store_range(mt, 11770 + i, 11770 + i + 1, NULL, 0);
+ check_load(mt, 11700, xa_mk_value(11700 & LONG_MAX));
mt_validate(mt);
mt_dump(mt, mt_dump_dec);
MT_BUG_ON(mt, mt_height(mt) >= 4);
MT_BUG_ON(mt, mt_height(mt) >= 4);
for (i = 5; i < 45; i += 10) {
check_store_range(mt, 11700 + i, 11700 + i + 1, NULL, 0);
+ check_load(mt, 11700, xa_mk_value(11700 & LONG_MAX));
mt_validate(mt);
mt_dump(mt, mt_dump_dec);
}
}
check_store_range(mt, 8001, 8001, xa_mk_value(8001), 0);
check_store_range(mt, 8002, 8002, xa_mk_value(8002), 0);
+
check_store_range(mt, 8081, 8081, xa_mk_value(8081), 0);
check_store_range(mt, 8082, 8082, xa_mk_value(8082), 0);
+ check_store_range(mt, 8083, 8083, xa_mk_value(8083), 0);
+ check_store_range(mt, 8084, 8084, xa_mk_value(8084), 0);
+ check_store_range(mt, 8085, 8085, xa_mk_value(8085), 0);
/* triple split across multiple levels. */
- check_store_range(mt, 8099, 8100, xa_mk_value(8100), 0);
+ mt_dump(mt, mt_dump_dec);
+ check_store_range(mt, 8099, 8100, xa_mk_value(1), 0);
+ mt_dump(mt, mt_dump_dec);
if (!MAPLE_32BIT)
MT_BUG_ON(mt, mt_height(mt) != 4);
}