static inline bool _mas_rev_awalk(struct ma_state *mas, unsigned long size)
{
enum maple_type type;
- unsigned long max, min;
- unsigned char i, start;
+ unsigned long max, min = mas->min;
+ unsigned char i;
bool found = false;
unsigned long this_gap = 0;
type = mte_node_type(mas->node);
i = mas_get_slot(mas);
- min = mas->min;
max = _mas_get_safe_pivot(mas, i, type);
switch (type) {
case maple_leaf_64:
- start = i;
do {
void *entry = NULL;
/* check if this slot is full */
entry = mas_get_rcu_slot(mas, i);
- if (entry) {
- this_gap = 0;
+ if (entry)
goto next_slot;
- }
- if (!this_gap)
- start = i;
+ this_gap = max - min + 1;
+ if (size > this_gap)
+ goto next_slot;
- this_gap += max - min + 1;
- if (this_gap >= size) {
- if (mas->last - min + 1 < size)
- goto next_slot;
- mas->min = min;
- mas->max = min + this_gap - 1;
- i = start;
- found = true;
- break;
- }
+ if (mas->last - min + 1 < size)
+ goto next_slot;
+
+ mas->min = min;
+ mas->max = min + this_gap - 1;
+ found = true;
+ break;
next_slot:
if (!i)
} while (i--);
break;
default:
-
do {
min = mas_get_safe_lower_bound(mas, i);
/* last is too little for this range */