return new_end;
}
-static void mas_wr_split_no_null(struct ma_node_info *src,
- struct ma_node_info *left, struct ma_node_info *right,
- unsigned char total, struct ma_node_part *ma_part)
-{
- if (!ma_is_leaf(src->type))
- return;
-
- if (!left->slots[left->offset - 1]) {
- unsigned char min;
- unsigned char end;
-
- end = total - left->offset;
- min = mt_min_slots[right->type];
- if ((end - 1 > min) &&
- (left->offset < mt_slots[left->type])) {
- if (ma_part->unfinished ||
- src->insert_off == src->offset) {
- ma_part->dst_max_off = src->offset;
- mni_insert_part(ma_part, left);
- } else {
- mni_cp(src, left, 1);
- }
- } else {
- left->offset--;
- right->offset++;
- right->slots[0] = NULL;
- if (left->offset < mt_pivots[left->type]) {
- right->pivots[0] = left->pivots[left->offset];
- left->pivots[left->offset] = 0;
- } else {
- right->pivots[0] = left->max;
- }
- left->max = left->pivots[left->offset - 1];
- }
- }
-
- right->min = left->max + 1;
-}
-
/*
* mas_wr_rebalance_calc() - Try to calculate a rebalance that will work
* @data_size: The total data to be written
trace_ma_op(__func__, mas);
- printk("\t\t%s\n", __func__);
- //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;
goto rebalanced;
split = (total + 1) / 2;
- printk("\t\tSplitting leaf at %u store at %u\n", split, mas->offset);
left.min = mas->min;
right.max = mas->max;
- //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_part_init(&ma_part, &left, &right);
if (height == 1) {
- printk("src parent is %p\n", src_info.node->parent);
- printk("New root\n");
goto new_root;
}
//printk("%d height is %d\n", __LINE__, height);
while (--height) {
- printk("===================Start of loop\n");
mas_wr_ascend_init(mas, &src_info);
- printk("At %p\n", mas->node);
mas->end = src_info.end;
total = mas->end + 1;
if (mas->end + 1 < mt_slots[src_info.type])
goto converged;
- //printk("\tConsume %p type %u\n", src.node, src.type);
mni_node_init(&left, mas_pop_node(mas), src_info.type);
mni_node_init(&right, mas_pop_node(mas), src_info.type);
if ((height > 1) &&
left.min = src_info.min;
right.max = src_info.max;
- printk("MIN %lu MAX %lu\n\n", left.min, right.max);
split = (total + 1) / 2;
- 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, mas->offset,
total, state, 0);
mni_finalise(&left);
mni_finalise(&right);
mni_node_part_init(&ma_part, &left, &right);
- printk ("part size is %u\n", ma_part.size);
- printk("part[1] = %lu\n", ma_part.pivots[1]);
- printk("End of loop\n");
}
new_root:
rebalanced:
mas_wmb_replace(mas, src_info.enode);
mtree_range_walk(mas);
- //mt_dump(wr_mas->mas->tree, mt_dump_dec);
}
/*
trace_ma_write(__func__, mas, 0, wr_mas->entry);
mas_update_gap(mas);
mas->end = new_end;
- //mt_dump(mas->tree, mt_dump_hex);
return;
}
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;
}
MA_WR_STATE(wr_mas, mas, entry);
int ret = 0;
- printk("store %lu-%lu\n", index, last);
retry:
mas_wr_preallocate(&wr_mas, entry);
if (unlikely(mas_nomem(mas, gfp))) {
MT_BUG_ON(mas->tree, max_gap > mas->max);
if (ma_gaps(p_mn, mas_parent_type(mas, mte))[p_slot] != max_gap) {
pr_err("gap " PTR_FMT "[%u] != %lu\n", p_mn, p_slot, max_gap);
- mt_dump(mas->tree, mt_dump_hex);
MT_BUG_ON(mas->tree, 1);
}
}
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);
}
MT_BUG_ON(mt, mt_height(mt) >= 4);
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);
}
if (!MAPLE_32BIT)
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. */
- 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);
}