switch (type) {
case maple_leaf_64:
+ default:
do {
- void *entry = NULL;
-
min = mas_get_safe_lower_bound(mas, i);
-
/* last is below this range */
if (mas->last < min)
goto next_slot;
return false;
}
- /* check if this slot is full */
- entry = mas_get_rcu_slot(mas, i);
- if (entry)
- goto next_slot;
+ if (ma_is_leaf(type)) {
+ if (mas_get_rcu_slot(mas, i))
+ goto next_slot;
- this_gap = max - min + 1;
- if (size > this_gap)
- goto next_slot;
+ this_gap = max - min + 1;
+
+ } else {
+ this_gap = mte_get_gap(mas->node, i);
+ }
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)
- goto ascend;
-
- max = min - 1;
- } while (i--);
- break;
- default:
- do {
- min = mas_get_safe_lower_bound(mas, i);
- /* last is too little for this range */
- if (mas->last < min)
- goto next;
-
- /* index is too large for this range */
- if (mas->index > max) {
- mas_set_err(mas, -EBUSY);
- return false;
- }
-
- this_gap = mte_get_gap(mas->node, i);
- /* Not big enough */
if (size > this_gap)
- goto next;
+ goto next_slot;
+ if (ma_is_leaf(type)) {
+ mas->min = min;
+ mas->max = min + this_gap - 1;
+ found = true;
+ }
break;
-next:
+next_slot:
if (!i)
goto ascend;
max = min - 1;
- if (mas->index > max) {
- mas_set_err(mas, -EBUSY);
- return false;
- }
} while (i--);
break;