Skip to content

Commit

Permalink
rhashtable: Still do rehash when we get EEXIST
Browse files Browse the repository at this point in the history
As it stands if a shrink is delayed because of an outstanding
rehash, we will go into a rescheduling loop without ever doing
the rehash.

This patch fixes this by still carrying out the rehash and then
rescheduling so that we can shrink after the completion of the
rehash should it still be necessary.

The return value of EEXIST captures this case and other cases
(e.g., another thread expanded/rehashed the table at the same
time) where we should still proceed with the rehash.

Fixes: da20420 ("rhashtable: Add nested tables")
Reported-by: Josh Elsasser <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
Tested-by: Josh Elsasser <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
herbertx authored and davem330 committed Mar 21, 2019
1 parent 6b70fc9 commit 408f13e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/rhashtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,12 @@ static void rht_deferred_worker(struct work_struct *work)
else if (tbl->nest)
err = rhashtable_rehash_alloc(ht, tbl, tbl->size);

if (!err)
err = rhashtable_rehash_table(ht);
if (!err || err == -EEXIST) {
int nerr;

nerr = rhashtable_rehash_table(ht);
err = err ?: nerr;
}

mutex_unlock(&ht->mutex);

Expand Down

0 comments on commit 408f13e

Please sign in to comment.