return;
}
-/*
- * mas_rebalance() - Rebalance a given node.
- * @mas: The maple state
- * @b_node: The big maple node.
- *
- * Rebalance two nodes into a single node or two new nodes that are sufficient.
- * Continue upwards until tree is sufficient.
- */
-static inline void mas_rebalance(struct ma_state *mas,
- struct maple_big_node *b_node)
-{
- char empty_count = mas_mt_height(mas);
- struct maple_subtree_state mast;
- unsigned char shift, b_end = ++b_node->b_end;
-
- MA_STATE(l_mas, mas->tree, mas->index, mas->last);
- MA_STATE(r_mas, mas->tree, mas->index, mas->last);
-
- trace_ma_op(__func__, mas);
-
- /*
- * Rebalancing occurs if a node is insufficient. Data is rebalanced
- * against the node to the right if it exists, otherwise the node to the
- * left of this node is rebalanced against this node. If rebalancing
- * causes just one node to be produced instead of two, then the parent
- * is also examined and rebalanced if it is insufficient. Every level
- * tries to combine the data in the same way. If one node contains the
- * entire range of the tree, then that node is used as a new root node.
- */
-
- mast.orig_l = &l_mas;
- mast.orig_r = &r_mas;
- mast.bn = b_node;
- mast.bn->type = mte_node_type(mas->node);
-
- l_mas = r_mas = *mas;
-
- if (mas_next_sibling(&r_mas)) {
- mas_mab_cp(&r_mas, 0, mt_slot_count(r_mas.node), b_node, b_end);
- r_mas.last = r_mas.index = r_mas.max;
- } else {
- mas_prev_sibling(&l_mas);
- shift = mas_data_end(&l_mas) + 1;
- mab_shift_right(b_node, shift);
- mas->offset += shift;
- mas_mab_cp(&l_mas, 0, shift - 1, b_node, 0);
- b_node->b_end = shift + b_end;
- l_mas.index = l_mas.last = l_mas.min;
- }
-
- return mas_spanning_rebalance(mas, &mast, empty_count);
-}
/*
* mas_destroy_rebalance() - Rebalance left-most node while destroying the maple
mni_set_end(mni);
}
-static inline
-void mns_mas_init(struct ma_node_state *mns, struct ma_node_info *mni,
- struct ma_state *mas)
-{
- mni->node = mte_to_node(mas->node);
- mni->type = mte_node_type(mas->node);
- _mni_node_init(mni, mni->node, mni->type);
- mni->enode = mas->node;
- mni->end = mas->end;
- mni->max = mas->max;
- mni->min = mas->min;
-
- mns->info = mni;
- mns->start = 0;
- mns->size = 0;
- mns->dst = NULL;
- mns->use_part = false;
-}
-
static inline
void mns_mni_init(struct ma_node_state *mns, struct ma_node_info *dst,
unsigned char start, unsigned char len)
return true;
}
-/* FIXME: This comment.
- * Parent ma_node_state init
- */
-static inline
-void mni_pmni_init(struct ma_node_info *mni, struct ma_node_info *pmni,
- unsigned char p_off, struct maple_tree *mt)
-{
- if (p_off == pmni->end) {
- mni->max = pmni->max;
- mni->min = pmni->pivots[p_off - 1];
- } else {
- mni->max = pmni->pivots[p_off];
- if (p_off)
- mni->min = pmni->pivots[p_off - 1];
- else
- mni->min = pmni->min;
- }
-
- mni->enode = mt_slot_locked(mt, pmni->slots, p_off);
- mni->insert_off = p_off;
- _mni_node_init(mni, mte_to_node(mni->enode),
- mte_node_type(mni->enode));
-}
-
/*
* @src: The maple node state of the source
* @dst: The maple node state of the destination
mtree_range_walk(mas);
}
-/*
- * mas_commit_b_node() - Commit the big node into the tree.
- * @wr_mas: The maple write state
- * @b_node: The maple big node
- */
-static noinline_for_kasan void mas_commit_b_node(struct ma_wr_state *wr_mas,
- struct maple_big_node *b_node)
-{
- enum store_type type = wr_mas->mas->store_type;
-
- WARN_ON_ONCE(type != wr_rebalance && type != wr_split_store);
-
- return mas_rebalance(wr_mas->mas, b_node);
-}
-
/*
* mas_root_expand() - Expand a root to a node
* @mas: The maple state