* @p: Configuration parameters
* @run_work: Deferred worker to expand/shrink asynchronously
* @mutex: Mutex to protect current/future table swapping
+ * @lock: Spin lock to protect walker list
* @being_destroyed: True if table is set up for destruction
*/
struct rhashtable {
struct rhashtable_params p;
struct work_struct run_work;
struct mutex mutex;
+ spinlock_t lock;
};
/**
/* Publish the new table pointer. */
rcu_assign_pointer(ht->tbl, new_tbl);
+ spin_lock(&ht->lock);
list_for_each_entry(walker, &old_tbl->walkers, list)
walker->tbl = NULL;
+ spin_unlock(&ht->lock);
/* Wait for readers. All new readers will see the new
* table, and thus no references to the old table will
ht = iter->ht;
- mutex_lock(&ht->mutex);
+ spin_lock(&ht->lock);
if (tbl->rehash < tbl->size)
list_add(&iter->walker->list, &tbl->walkers);
else
iter->walker->tbl = NULL;
- mutex_unlock(&ht->mutex);
+ spin_unlock(&ht->lock);
iter->p = NULL;
memset(ht, 0, sizeof(*ht));
mutex_init(&ht->mutex);
+ spin_lock_init(&ht->lock);
memcpy(&ht->p, params, sizeof(*params));
if (params->min_size)