/* Private
* Combine nulls with the same pivot value
*/
-static void *mas_coalesce(struct ma_state *mas)
+static int mas_coalesce(struct ma_state *mas)
{
struct maple_range_64 *src = &mt_to_node(mas->node)->mr64;
+ unsigned char s_slot, d_slot = 0;
unsigned long last = mas->max;
struct maple_range_64 *dst;
struct maple_node *mn;
- unsigned char s_slot, d_slot = 0;
/* Allocate a new node */
mas_node_cnt(mas, 1);
if (mas_is_err(mas))
- return NULL;
+ return 0;
mn = ma_next_alloc(mas);
dst = &mn->mr64;
+ mas->node = mt_mk_node(mn, maple_leaf_64);
- for (s_slot = 0; s_slot < MAPLE_RANGE64_SLOTS - 1; s_slot++) {
- if (last == src->pivot[s_slot])
- continue;
-
+ for (s_slot = 0; s_slot < MAPLE_RANGE64_SLOTS; s_slot++) {
if (s_slot < MAPLE_RANGE64_SLOTS - 1) {
+ if (last == src->pivot[s_slot])
+ continue;
+
if (s_slot != 0 && src->pivot[s_slot] == 0)
break;
RCU_INIT_POINTER(dst->slot[d_slot], src->slot[s_slot]);
last = dst->pivot[d_slot++];
}
- return mn;
+ return s_slot - d_slot;
}
static void ma_adopt_children(struct maple_node *parent)
{
void *p_entry; // Previous entry.
unsigned char slot = MAPLE_NODE_SLOTS;
- struct maple_node *mn;
bool leaf;
}
}
- mn = mas_coalesce(mas);
+ p_entry = mas->node;
+ mas_coalesce(mas);
if (mas_is_err(mas))
goto error;
- p_entry = mas->node;
-
- mas->node = mt_mk_node(mn, maple_leaf_64);
/* Do the insert */
_ma_insert(mas, entry, slot);
if (mas_is_err(mas))
unsigned long piv_val;
int cnt = -EINVAL;
void *p_entry; // Previous entry.
- struct maple_node *mn;
if (slot == MAPLE_NODE_SLOTS)
return cnt;
mr64->pivot[slot] = piv_val;
cnt++;
}
-
- mn = mas_coalesce(mas);
+ p_entry = mas->node;
+ mas_coalesce(mas);
if (mas_is_err(mas))
goto error;
- p_entry = mas->node;
- mas->node = mt_mk_node(mn, maple_leaf_64);
mt_replace(mas, p_entry, leaf);
error: