/*
* mas_extend_spanning_null() - Extend a store of a %NULL to include surrounding %NULLs.
- * @l_mas: The left maple state
- * @r_mas: The right maple state
+ * @l_wr_mas: The left maple write state
+ * @r_wr_mas: The right maple write state
*/
static inline void mas_extend_spanning_null(struct ma_wr_state *l_wr_mas,
struct ma_wr_state *r_wr_mas)
struct ma_state *l_mas = l_wr_mas->mas;
unsigned char l_slot;
-
l_slot = l_mas->offset;
if (!l_wr_mas->content)
l_mas->index = l_wr_mas->r_min;
* and new nodes where necessary, then place the sub-tree in the actual tree.
* Note that mas is expected to point to the node which caused the store to
* span.
- * @mas: The maple state
- * @entry: The entry to store.
+ * @wr_mas: The maple write state
*
* Return: 0 on error, positive on success.
*/
-static inline int mas_spanning_store(struct ma_wr_state *wr_mas, void *entry)
+static inline int mas_spanning_store(struct ma_wr_state *wr_mas)
{
struct ma_wr_state r_wr_mas, l_wr_mas;
struct maple_subtree_state mast;
trace_ma_op(__func__, mas);
if (unlikely(!mas->index && mas->last == ULONG_MAX))
- return mas_new_root(mas, entry);
+ return mas_new_root(mas, wr_mas->entry);
/*
* Node rebalancing may occur due to this store, so there may be two new
* entries per level plus a new root.
/* Set up right side. */
r_mas = *mas;
- /* Avoid overflow. */
+ /* Avoid overflow, walk to next slot in the tree. */
if (r_mas.last + 1)
r_mas.last++;
/* Set up left side. */
l_mas = *mas;
l_wr_mas.mas = &l_mas;
+ /* Stop detection of spanning store on write walk */
l_mas.last = l_mas.index;
mas_wr_walk(&l_wr_mas);
- if (!entry) {
+ if (!wr_mas->entry) {
mas_extend_spanning_null(&l_wr_mas, &r_wr_mas);
mas->offset = l_mas.offset;
mas->index = l_mas.index;
b_node.type = wr_mas->type;
/* Copy l_mas and store the value in b_node. */
- b_node.b_end = mas_store_b_node(&l_mas, &b_node, entry,
+ b_node.b_end = mas_store_b_node(&l_mas, &b_node, wr_mas->entry,
l_wr_mas.node_end, l_wr_mas.node_end,
l_wr_mas.content);
/* Copy r_mas into b_node. */
return;
slow_path:
- b_node.type = mte_node_type(mas->node);
+ b_node.type = wr_mas->type;
b_node.b_end = mas_store_b_node(mas, &b_node, wr_mas->entry, wr_mas->node_end,
wr_mas->offset_end, wr_mas->content);
b_node.min = mas->min;
wr_mas.mas = mas;
wr_mas.entry = entry;
if (!mas_wr_walk(&wr_mas)) {
- mas_spanning_store(&wr_mas, entry);
+ mas_spanning_store(&wr_mas);
return wr_mas.content;
}