mni_finalise(dst);
}
+/*
+ *
+ * @src: The node information of the source
+ * @left: The node information of the left destination
+ * @right: The node information of the right destination
+ * @ma_part: The node part being inserted
+ * @split: The split location referenced by the destination size
+ * @insert: The location of the insert start for @ma_part
+ * @size: The targeted size of the left node
+ * @offset: The starting offset into the destination
+ * @node_ins_end: The offset in the source the insert ends
+ * @total_data: The total size of the data being stored
+ * @state: The maple node state array
+ * @i: The number of existing states
+ */
static int mt_wr_split_data(struct ma_node_info *src,
struct ma_node_info *left, struct ma_node_info *right,
struct ma_node_part *ma_part, unsigned char split,
}
#if 0
+static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
+{
+ struct ma_node_info src_info, parent, left, right;
+ struct ma_node_state src;
+ struct ma_node_part ma_part;
+
+ mni_node_init(&left, mas_pop_node(mas), wr_mas->type);
+ if (mt_is_alloc(mas->tree))
+ right.alloc = left.alloc = true;
+}
+
/*
* There is insufficient data in the node after a store.
* This rebalance will succeed, not like the split variant that will attempt
struct ma_state *mas = wr_mas->mas;
struct ma_node_state state[4];
unsigned char i = 0;
- struct ma_node_info src_info, parent, left, right;
- struct ma_node_state src;
+ struct ma_node_info src, parent, left, right;
struct ma_node_part ma_part;
int height;
unsigned char split, total;
/* First split the leaves */
mni_node_init(&left, mas_pop_node(mas), wr_mas->type);
mni_node_init(&right, mas_pop_node(mas), wr_mas->type);
- mns_mas_init(&src, &src_info, mas);
- mns_node_part_leaf_init(&ma_part, wr_mas, &src_info);
+ mni_mas_init(&src, mas);
+ mns_node_part_leaf_init(&ma_part, wr_mas, &src);
total = mas->end + ma_part.size;
- if (mt_is_alloc(mas->tree)) {
+ if (mt_is_alloc(mas->tree))
right.alloc = left.alloc = true;
- }
- if (height > 1 &&
- mas_wr_try_rebalance(mas, &src_info, total, &left,
- &right, &ma_part, wr_mas->offset_end))
+ if (height > 1 && mas_wr_try_rebalance(mas, &src, total, &left,
+ &right, &ma_part, wr_mas->offset_end))
goto rebalanced;
split = (total + 1) / 2;
left.min = mas->min;
right.max = mas->max;
-
- i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
+ i = mt_wr_split_data(&src, &left, &right, &ma_part, split,
mas->offset, split, 0, wr_mas->offset_end,
total, state, 0);
mns_assemble(state, i);
//printk("%d height is %d\n", __LINE__, height);
while (--height) {
- mas_wr_ascend_init(mas, &src_info);
- mas->end = src_info.end;
+ mas_wr_ascend_init(mas, &src);
+ mas->end = src.end;
total = mas->end + 1;
- if (mas->end + 1 < mt_slots[src_info.type])
+ if (mas->end + 1 < mt_slots[src.type])
goto converged;
- mni_node_init(&left, mas_pop_node(mas), src_info.type);
- mni_node_init(&right, mas_pop_node(mas), src_info.type);
+ mni_node_init(&left, mas_pop_node(mas), src.type);
+ mni_node_init(&right, mas_pop_node(mas), src.type);
if ((height > 1) &&
- (mas_wr_try_rebalance(mas, &src_info, mas->end + 1, &left,
- &right, &ma_part, src_info.insert_off)))
+ (mas_wr_try_rebalance(mas, &src, mas->end + 1, &left,
+ &right, &ma_part, src.insert_off)))
goto rebalanced;
- left.min = src_info.min;
- right.max = src_info.max;
+ left.min = src.min;
+ right.max = src.max;
split = (total + 1) / 2;
- i = mt_wr_split_data(&src_info, &left, &right, &ma_part, split,
+ i = mt_wr_split_data(&src, &left, &right, &ma_part, split,
mas->offset, split, 0, mas->offset,
total, state, 0);
mns_assemble(state, i);
new_root:
/* Converged on new root */
mas->depth++;
- src_info.insert_off = mas->offset = 0;
+ src.insert_off = mas->offset = 0;
mas->end = 0;
mas_set_height(mas);
if (mt_is_alloc(mas->tree))
- src_info.type = maple_arange_64;
+ src.type = maple_arange_64;
else
- src_info.type = maple_range_64;
- src_info.end = 0; /* Empty node */
+ src.type = maple_range_64;
+ src.end = 0; /* Empty node */
/*
* src can only really provide the parent
* set the skip to high enough to avoid using any data
*/
converged:
- mas_wr_converged(&src_info, &parent, &ma_part, mas);
+ mas_wr_converged(&src, &parent, &ma_part, mas);
mas->node = parent.enode;
rebalanced:
- mas_wmb_replace(mas, src_info.enode);
+ mas_wmb_replace(mas, src.enode);
mtree_range_walk(mas);
}