return mte_parent_range_enum(parent);
}
-/*
+/* Private
* mte_set_parent() - Set the parent node and encode the slot.
*
* Type is encoded in the node->parent
mte_free(mn);
}
-/*
+/* Private
* mat_add() - Add a @dead_enode to the ma_topiary of a list of dead nodes.
*
* Add the %dead_enode to the linked list in %mat.
return ma_enode_ptr(MAS_NONE);
}
-/*
+/* Private
* mast_topiary() - Add the portions of the tree to the removal list; either to
* be freed or discarded (destroy walk).
*
b_node->pivot[b_node->b_end++] = mas->max;
}
-/*
+/* Private
* mas_set_split_parent() - combine_then_separate helper function. Sets the parent
* of @mas->node to either @left or @right, depending on @slot and @split
*
unsigned char mid_split)
{
unsigned char slot;
- struct maple_enode *l = left;
- struct maple_enode *r = right;
if (mas_is_none(mast->l))
return;
- if (middle)
- r = middle;
-
slot = mas_get_slot(mast->l);
-
- mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- // Set left parent.
- mas_set_split_parent(mast->l, l, r, &slot, split);
-
- mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- // Set middle parent.
- mas_set_split_parent(mast->m, l, r, &slot, split);
-
- mte_mid_split_check(&l, &r, right, slot, &split, mid_split);
- // Set right parent.
- mas_set_split_parent(mast->r, l, r, &slot, split);
+ mas_set_split_parent(mast->l, left, right, &slot, split);
+ mas_set_split_parent(mast->m, left, right, &slot, split);
+ mas_set_split_parent(mast->r, left, right, &slot, split);
}
static inline void mas_wmb_replace(struct ma_state *mas,
struct ma_topiary *free,
mast->bn->type = mte_node_type(mast->orig_l->node);
}
-/*
+/* Private
*
- * mas_spanning_rebalance() - Rebalance across two nodes which may not be peers.
+ * mas_combine_then_separate() - Combine two nodes and then separate them as
+ * needed.
* @mas: The starting maple state
* @mast: The maple_subtree_state, keeps track of 4 maple states.
* @count: The estimated count of iterations needed.
*
* Returns the number of elements in b_node during the last loop.
*/
-static inline int mas_spanning_rebalance(struct ma_state *mas,
+static inline int mas_combine_then_separate(struct ma_state *mas,
struct maple_subtree_state *mast,
unsigned char count)
{
mast->destroy = &destroy;
l_mas.node = r_mas.node = m_mas.node = MAS_NONE;
- if (mast->orig_l->depth != mast->orig_r->depth) {
- printk("Error: %d != %d\n",
- mast->orig_l->depth, mast->orig_r->depth);
- }
- MT_BUG_ON(mas->tree, mast->orig_l->depth != mast->orig_r->depth);
- mast->orig_l->depth = 0;
mast_topiary(mast);
while (count--) {
mast_setup_bnode_for_split(mast);
return mast->bn->b_end;
}
-/*
+/* Private
* mas_rebalance() - Rebalance a given node.
*
* @mas: The maple state
l_mas.index = l_mas.last = l_mas.min;
}
- return mas_spanning_rebalance(mas, &mast, empty_cnt);
+ return mas_combine_then_separate(mas, &mast, empty_cnt);
}
static inline bool mas_split_final_node(struct maple_subtree_state *mast,
count = mas_cnt_positive(mas) + mas->tree->ma_height - mas->depth + 1;
// Combine l_mas and r_mas and split them up evenly again.
- return mas_spanning_rebalance(mas, &mast, count);
+ l_mas.depth = 0;
+ return mas_combine_then_separate(mas, &mast, count);
}
static inline void *_mas_store(struct ma_state *mas, void *entry, bool overwrite)