unsigned char pivot_cnt = mt_pivots[type];
if (!pivot_cnt)
- return 0;
+ return ret;
for (s_slot = 0; s_slot < slot_cnt; s_slot++) {
d_slot = s_slot;
mas_partial_copy(mas, s_slot - 1);
if (mas_is_err(mas))
- return 0;
+ goto mas_error;
dst = mas->node;
}
}
}
done:
- if (dst) {
- ret = s_slot - d_slot;
- mt_replace(mas);
- }
+ if (!dst)
+ return ret;
+
+ ret = s_slot - d_slot;
+ mt_replace(mas);
+
+mas_error: // Regardless of allocation, update gaps.
+ if (mt_is_alloc(mas->tree))
+ ma_update_gap(mas);
+
return ret;
}
unsigned char slot_cnt = mt_slots[type];
unsigned char pivot_cnt = mt_pivots[type];
unsigned long piv_val;
- int cnt = -EINVAL;
+ int ret = -EINVAL;
int slot;
_mas_walk(mas);
slot = ma_get_slot(mas);
if (slot == MAPLE_NODE_SLOTS)
- return cnt;
+ return ret;
ma_update_rcu_slot(mas->node, slot, NULL);
- cnt = 1;
+ ret = 0;
if ((slot >= slot_cnt - 1))
- return cnt;
+ return ret;
if (!pivot_cnt)
- return cnt;
+ return ret;
if ((slot < pivot_cnt) &&
((ma_get_pivot(mas->node, slot + 1) == 0) ||
}
/* Walk down and set all the previous pivots with NULLs to piv_val */
- while(--slot >= 0 && ma_get_rcu_slot(mas->node, slot) == NULL) {
+ while(--slot >= 0 && ma_get_rcu_slot(mas->node, slot) == NULL)
ma_set_pivot(mas->node, slot, piv_val);
- cnt++;
- }
mas_coalesce(mas);
/* Error may be returned, but it will be passed through anyways */
- return cnt;
+ return ret;
}
void ma_destroy_walk(struct maple_enode *mn)