]> git.baikalelectronics.ru Git - kernel.git/commit
rhashtable: Fix rhashtable_remove failures
authorHerbert Xu <herbert@gondor.apana.org.au>
Sun, 15 Mar 2015 10:12:05 +0000 (21:12 +1100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 16 Mar 2015 02:22:08 +0000 (22:22 -0400)
commit969f0220b3f4ad77c09ca401ec78f354c7003256
tree6be3f18d0d0311eb84062e18d30b771b14bb9f9e
parent0062d19dc7de879c3c1033f6ea970a6f8e8e8a1f
rhashtable: Fix rhashtable_remove failures

The commit 76bff2ee499f60150ad7747903abecb0b21f1479 ("rhashtable:
Free bucket tables asynchronously after rehash") causes gratuitous
failures in rhashtable_remove.

The reason is that it inadvertently introduced multiple rehashing
from the perspective of readers.  IOW it is now possible to see
more than two tables during a single RCU critical section.

Fortunately the other reader rhashtable_lookup already deals with
this correctly thanks to 62cd523211c1e03eb4ce7e0618396a526602cbac
("rhashtable: rhashtable: Move future_tbl into struct bucket_table")
so only rhashtable_remove is broken by this change.

This patch fixes this by looping over every table from the first
one to the last or until we find the element that we were trying
to delete.

Incidentally the simple test for detecting rehashing to prevent
starting another shrinking no longer works.  Since it isn't needed
anyway (the work queue and the mutex serves as a natural barrier
to unnecessary rehashes) I've simply killed the test.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/rhashtable.c