static void spanning_data_write(struct maple_copy *cp, struct ma_state *mas)
{
struct maple_node *dst, *src;
- size_t s, d;
+ unsigned char s, d;
unsigned char dst_offset;
unsigned char data, data_offset;
unsigned char src_end, s_offset;
s_offset += size;
if (s_offset > src_end) {
- printk("\t\tnext src %d / %d\n", s +1, cp->s_count);
+ printk("\t\tnext src %u / %u\n", s +1, cp->s_count);
/* This source is exhausted */
s++;
if (s >= cp->s_count) {
next_node++;
split++;
printk("inc split %u\n", split);
- if (dst_offset >= mt_pivots[d_mt])
- ma_pivots(dst, d_mt)[dst_offset - 1] = 0;
data_offset--;
+ dst_offset--;
}
node_finalise(dst, d_mt, dst_offset);
mt_dump_node(mas->tree, mt_mk_node(dst, d_mt), 0, ULONG_MAX, 1, mt_dump_hex);
cp.dst[cp.d_count].mt = mt;
cp.dst[cp.d_count++].node = ma_mnode_ptr(mas_pop_node(mas));
/* New root */
- } else if (cp.data > mt_slots[mt] * 2) {
+ } else if (cp.data >= mt_slots[mt] * 2 - 1) {
cp.split = cp.data / 3;
cp.dst[cp.d_count].mt = mt;
cp.dst[cp.d_count++].node = ma_mnode_ptr(mas_pop_node(mas));
cp.dst[cp.d_count].mt = mt;
cp.dst[cp.d_count++].node = ma_mnode_ptr(mas_pop_node(mas));
}
- printk("split = %u data %u\n", cp.split, cp.data);
+ printk("split = %u data %u d_count %u\n", cp.split, cp.data, cp.d_count);
cp.s_count = 0;
if (sib.end && sib.max < l_wr_mas->mas->min)
append_node_cp(&cp, &sib, 0, sib.end);
/* Copy left 0 - offset */
- if (l_wr_mas->mas->offset || l_wr_mas->r_min < mas->index)
- append_node_cp(&cp, l_wr_mas->mas, 0, l_wr_mas->mas->offset);
+ if (l_wr_mas->mas->offset || l_wr_mas->r_min < mas->index) {
+ unsigned long l_end = l_wr_mas->mas->offset;
+
+ if (l_wr_mas->r_min == mas->index)
+ l_end--;
+ append_node_cp(&cp, l_wr_mas->mas, 0, l_end);
+ }
if (cp.s_count)
cp.src[cp.s_count - 1].max = mas->index - 1;
cp.s_count++;
/* Copy right either from offset or offset + 1 pending on r_max */
- if (r_wr_mas->mas->end != r_wr_mas->mas->offset || r_wr_mas->r_max > mas->last)
- append_node_cp(&cp, r_wr_mas->mas, r_wr_mas->mas->offset,
- r_wr_mas->mas->end);
+ if (r_wr_mas->mas->end != r_wr_mas->mas->offset || r_wr_mas->r_max > mas->last) {
+ unsigned long r_start = r_wr_mas->mas->offset;
+
+ if (r_wr_mas->r_max == mas->last)
+ r_start++;
+
+ append_node_cp(&cp, r_wr_mas->mas, r_wr_mas->mas->offset, r_start);
+ }
if (sib.end) {
if (sib.min > r_wr_mas->mas->max) {