return true;
}
+static inline
+void copy_tree_location(const struct ma_state *src, struct ma_state *dst)
+{
+ dst->node = src->node;
+ dst->offset = src->offset;
+ dst->min = src->min;
+ dst->max = src->max;
+ dst->end = src->end;
+ dst->depth = src->depth;
+}
+
/*
* rebalance_ascend() - Ascend the tree and set up for the next loop - if
* necessary
struct ma_state *parent)
{
struct ma_state *mas;
- unsigned long min;
- struct ma_state *r;
+ unsigned long min, max;
mas = wr_mas->mas;
if (!sib->end) {
min = mas->min;
- r = mas;
+ max = mas->max;
} else if (sib->min > mas->max) { /* Move right succeeded */
min = mas->min;
- r = sib;
+ max = sib->max;
+ wr_mas->offset_end = parent->offset + 1;
} else {
min = sib->min;
- r = mas;
+ max = mas->max;
+ wr_mas->offset_end = parent->offset;
+ parent->offset--;
}
- cp_dst_to_slots(cp, min, r->max, mas);
+ cp_dst_to_slots(cp, min, max, mas);
if (cp_is_new_root(cp, mas))
return false;
return false;
cp->height++;
- parent->alloc = mas->alloc;
- *mas = *parent;
+ copy_tree_location(parent, mas);
wr_mas_setup(wr_mas, mas);
- wr_mas->offset_end = mas->offset;
- if (r == sib)
- wr_mas->offset_end++;
- else
- wr_mas->mas->offset--;
-
return true;
}
-
-
/*
* mas_destroy_rebalance() - Rebalance left-most node while destroying the maple
* state.
mas = wr_mas->mas;
min = mas->min; /* push right, or normal split */
max = mas->max;
+ wr_mas->offset_end = parent->offset;
if (sib->end) {
- if (sib->max < mas->min)
+ if (sib->max < mas->min) {
min = sib->min; /* push left */
- else
+ parent->offset--;
+ } else {
max = sib->max; /* push right */
+ wr_mas->offset_end++;
+ }
}
cp_dst_to_slots(cp, min, max, mas);
cp->height++;
BUG_ON(mas->node == parent->node);
- parent->alloc = mas->alloc;
- *mas = *parent;
+ copy_tree_location(parent, mas);
wr_mas_setup(wr_mas, mas);
- wr_mas->offset_end = mas->offset;
- if (sib->end) {
- if (sib->min == min)
- wr_mas->mas->offset--;
- else
- wr_mas->offset_end++;
- }
-
return true;
}
*/
static void mas_wr_split(struct ma_wr_state *wr_mas)
{
+ struct ma_state parent;
struct ma_state *mas;
struct maple_copy cp;
struct ma_state sib;
- struct ma_state parent;
mas = wr_mas->mas;
- parent = *mas;
trace_ma_op(__func__, mas);
+ parent = *mas;
cp_leaf_init(&cp, mas, wr_mas, wr_mas);
do {
if (!mte_is_root(parent.node)) {
*/
static void mas_wr_rebalance(struct ma_wr_state *wr_mas)
{
+ struct ma_state parent;
struct ma_state *mas;
struct maple_copy cp;
struct ma_state sib;
- struct ma_state parent;
/*
* Rebalancing occurs if a node is insufficient. Data is rebalanced