{
unsigned char p_slot = MAPLE_NODE_SLOTS; // parent slot.
+ MA_STATE(prev_piv, mas->tree, 0, 0);
+
if (slot > 0)
return mas_get_safe_pivot(mas, slot - 1);
if (mas->min == 0)
return 0;
- MA_STATE(prev_piv, mas->tree, 0, 0);
prev_piv.node = mas->node;
prev_piv.min = mas->min;
unsigned long max_gap = 0;
unsigned long gap = 0;
unsigned long pstart, pend;
+ int i;
if (ma_is_dense(mt)) {
- for (int i = 0; i < mt_slot_count(mas->node); i++) {
+ for (i = 0; i < mt_slot_count(mas->node); i++) {
if (!mt_is_empty(mte_get_rcu_slot(mas->node, i))) {
if (gap > max_gap)
max_gap = gap;
}
pstart = mas->min;
- for (int i = 0; i < mt_slots[mt]; i++) {
+ for (i = 0; i < mt_slots[mt]; i++) {
pend = mas_get_safe_pivot(mas, i);
gap = pend - pstart + 1;
if (!mte_is_root(full)) {
unsigned long c_max = mas->max;
- mas->max = p_max;
// Copy the parent data except p_slot, which will later be
// replaced.
MA_CP(cp, old_parent, new_parent, 0, p_slot - 1);
+
+ mas->max = p_max;
if (p_slot)
mas_copy(mas, &cp);
/* Skip possible duplicate entry that contains a NULL */
if (!append) {
+ MA_CP(cp, prev_enode, mas->node, old_end, slot_cnt - 1);
if (mas->last >= last_piv)
goto complete;
}
/* Copy remainder of node if this isn't an append */
- MA_CP(cp, prev_enode, mas->node, old_end, slot_cnt - 1);
cp.dst_start = slot;
cp.dst_end = mt_slot_count(cp.dst) - 1;
+ cp.src_start = old_end;
cp.start_piv = mas->last;
cp.src_end = mt_slot_count(cp.src) - 1; // copy to the end to collapse last slot null.
mas_copy(mas, &cp);
enum maple_type new_type;
bool p_coalesce = false; // coalesce parent.
+ MA_CP(cp, this_enode, NULL, 0, end);
+
if (coalesce)
coalesce--;
mas->max = this_max;
mas->min = this_min;
// Coalesce this_enode into a new node.
- MA_CP(cp, mas->node, NULL, 0, end);
cp.dst_end = l_slot_cnt - trimmed;
mas_copy(mas, &cp); // cp.dst now has coalesced this_enode.
struct maple_enode *r_node = NULL, *last = NULL;
unsigned char r_slot = 0, slot;
+ // Create a new tree.
+ DEFINE_MTREE(new_tree);
+ MA_STATE(new_mas, &new_tree, 0, 0);
+
+
MA_STATE(r_mas, mas->tree, mas->last + 1, mas->last + 1);
slot_cnt = 1 + mas_get_slot(mas);
mas_set_slot(mas, mte_parent_slot(mas->node));
if (mas_is_err(mas))
return 0;
- // Create a new tree.
- DEFINE_MTREE(new_tree);
-
- MA_STATE(new_mas, &new_tree, 0, 0);
-
new_mas.alloc = mas->alloc;
mas->alloc = NULL;
unsigned long max, gfp_t gfp)
{
int ret = 0;
+ MA_STATE(mas, mt, min, max - size);
if (!mt_is_alloc(mt))
return -EINVAL;
if (!size)
return -EINVAL;
- MA_STATE(mas, mt, min, max - size);
-
mtree_lock(mas.tree);
retry:
mas.index = min;
unsigned long max, gfp_t gfp)
{
int ret = 0;
+ MA_STATE(mas, mt, min, max - size);
if (!mt_is_alloc(mt))
return -EINVAL;
if (!size)
return -EINVAL;
- MA_STATE(mas, mt, min, max - size);
-
mtree_lock(mas.tree);
retry:
mas.index = min;