}
/* Private
- * mas_data_end() - Find the end of the data (slot +1). Sets the value of the
+ * mas_data_end() - Find the end of the data (slot). Sets the value of the
* last pivot to @last_piv, sets @coalesce to the number of slots that can be
* removed by coalescing.
*/
unsigned char *coalesce)
{
struct maple_enode *mn = mas->node;
- unsigned long piv = mas->min, prev_piv = mas->min;
+ unsigned long piv = mas->min, prev_piv = mas->min - 1;
unsigned char slot;
unsigned char counted_null = 0;
void *entry;
piv = _mas_get_safe_pivot(mas, slot, type);
- if (!piv && slot) { // Past the end of data.
+ if ((piv == 0 && slot != 0) ||
+ (piv > mas->max)) {
+ // Past the end of data.
slot--;
piv = prev_piv;
// At this point, we are saying the previous slot is
entry = _mte_get_rcu_slot(mn, slot, type, mas->tree);
if (mt_will_coalesce(entry)) {
- if (piv == prev_piv || !slot)
+ if (piv == prev_piv)
(*coalesce)++;
} else if (entry == NULL) {
if (!piv && slot)
return ret;
+ if (piv > mas->max) // possibly a retry.
+ return ret;
+
range = piv - mas->min;
if (range >= 8) {
if (slot > half)
if (!pend && i)
pend = mas->max;
+ if (pend > mas->max) // possibly a retry.
+ break;
+
gap = pend - pstart + 1;
entry = mas_get_rcu_slot(mas, i);
if (!this_piv && this_slot)
break;
+ if (this_piv > mas->max) // possibly a retry.
+ break;
+
if (this_piv == prev_piv && this_slot)
goto skip_slot;
if (!piv)
break;
+ if (piv > r_mas.max) // possibly a retry.
+ break;
+
if (piv > r_mas.last)
break;
while (slot < count) {
pivot = mas_get_safe_pivot(mas, slot);
+ if (pivot > mas->max) // possibly a retry.
+ goto no_entry;
+
if (slot != 0 && pivot == 0)
goto no_entry;
entry = mas_get_rcu_slot(mas, i);
if (prev_piv > piv) {
if (!mt_will_coalesce(entry)) {
- pr_err(MA_PTR"[%u] %lu < %lu\n", mas_mn(mas), i,
- piv, prev_piv);
+ pr_err(MA_PTR"[%u] piv %lu < prev_piv %lu\n",
+ mas_mn(mas), i, piv, prev_piv);
mt_dump(mas->tree);
MT_BUG_ON(mas->tree, piv < prev_piv);
}
MT_BUG_ON(mas->tree, piv < mas->min);
}
}
- if ((piv > mas->max) && !xa_is_retry(entry)) {
- pr_err(MA_PTR"[%u] %lu > %lu\n", mas_mn(mas), i, piv,
- mas->max);
- mt_dump(mas->tree);
- MT_BUG_ON(mas->tree, piv > mas->max);
+ if (!xa_is_retry(entry)) {
+ if ((piv > mas->max)) {
+ pr_err(MA_PTR"[%u] %lu > %lu\n", mas_mn(mas), i,
+ piv, mas->max);
+ mt_dump(mas->tree);
+ MT_BUG_ON(mas->tree, piv > mas->max);
+ }
+ prev_piv = piv;
}
- prev_piv = piv;
}
}