#define ma_enode_ptr(x) ((struct maple_enode *)(x))
static struct kmem_cache *maple_node_cache;
-unsigned long mt_max[] = {
+static const unsigned long mt_max[] = {
[maple_dense] = MAPLE_NODE_SLOTS,
[maple_leaf_64] = ULONG_MAX,
[maple_range_64] = ULONG_MAX,
};
#define mt_node_max(x) mt_max[mte_node_type(x)]
-unsigned char mt_slots[] = {
+static const unsigned char mt_slots[] = {
[maple_dense] = MAPLE_NODE_SLOTS,
[maple_leaf_64] = MAPLE_RANGE64_SLOTS,
[maple_range_64] = MAPLE_RANGE64_SLOTS,
};
#define mt_slot_count(x) mt_slots[mte_node_type(x)]
-unsigned char mt_pivots[] = {
+static const unsigned char mt_pivots[] = {
[maple_dense] = 0,
[maple_leaf_64] = MAPLE_RANGE64_SLOTS - 1,
[maple_range_64] = MAPLE_RANGE64_SLOTS - 1,
};
#define mt_pivot_count(x) mt_pivots[mte_node_type(x)]
-unsigned char mt_min_slots[] = {
+static const unsigned char mt_min_slots[] = {
[maple_dense] = MAPLE_NODE_SLOTS / 2,
[maple_leaf_64] = (MAPLE_RANGE64_SLOTS / 2) - 2,
[maple_range_64] = (MAPLE_RANGE64_SLOTS / 2) - 2,
unsigned char max_piv;
if (ma_is_dense(mt)) {
- for (i = 0; i < mt_slot_count(mas->node); i++) {
+ for (i = 0; i < mt_slots[mt]; i++) {
if (slots[i]) {
if (gap > max_gap)
max_gap = gap;
if (slots[i])
goto next;
-
gap = pend - pstart + 1;
if (gap > max_gap)
max_gap = gap;
pivot = _mas_safe_pivot(mas, pivots, mas->offset, type);
if (!pivot && mas->offset) {
- if (mas->max < mas->index) {
- mas->offset = MAPLE_NODE_SLOTS;
- return false;
- }
pivot = mas->max;
break;
}
struct maple_node *node = mas_mn(mas);
void **slots = ma_slots(node, mt);
unsigned long *pivots = ma_pivots(node, mt);
- unsigned long offset = mas->offset, lmax; // Logical max.
+ unsigned long lmax; // Logical max.
+ unsigned char offset = mas->offset;
if (min == mas->index && max == mas->last) { // exact fit.
slots[offset] = entry;
if (lmax <= mas->last) // overwriting two or more ranges with one.
goto try_node_store;
+ // Overwriting a portion of offset + 1.
slots[offset] = entry;
pivots[offset] = mas->last;
goto done;
pivots[offset + 1] = mas->last;
slots[offset + 1] = entry;
pivots[offset] = mas->index - 1;
+ mas->offset++; // Keep mas accurate.
goto done;
}