]> 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)
commitc975c273b923267847c5f478d35aeb35501b7d0e
tree6be3f18d0d0311eb84062e18d30b771b14bb9f9e
parent1f91ca809713f36012d073e2ae3c2bbbc2302c77
rhashtable: Fix rhashtable_remove failures

The commit 71d933c33d87bf91c8329328b8271a5918cbe61f ("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 0fd051d500cc7ad31ec6ef98b81fb940710171a8
("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