return true;
}
/* Private
- * Find the range in which index resides and erase the entire range
+ * ma_erase() - Find the range in which index resides and erase the entire
+ * range.
+ *
* Any previous pivots with no value will be set to the same pivot value.
- * returns the number of slots that have been erased.
+ * Return: the number of concurrent slots that are NULL or XA_RETRY_ENTRY.
*/
static inline int ma_erase(struct ma_state *mas)
{
slot = ma_get_slot(mas);
- ma_update_rcu_slot(mas->node, slot, NULL);
+ ma_update_rcu_slot(mas->node, slot, XA_RETRY_ENTRY);
if ((slot >= slot_cnt - 1))
return ret;
}
/* Walk down and set all the previous pivots with NULLs to piv_val */
- while (--slot >= 0 && ma_get_rcu_slot(mas->node, slot) == NULL) {
+ while (--slot >= 0) {
+ void *entry = ma_get_rcu_slot(mas->node, slot);
+
+ if (entry && entry != XA_RETRY_ENTRY)
+ break;
+
ma_set_pivot(mas->node, slot, piv_val);
ret++;
}
/* The error on allocation failure can be ignored */
mas_coalesce(mas, ++slot);
-
return ret;
}