rhashtable: key_hashfn() must return full hash value
authorThomas Graf <tgraf@suug.ch>
Thu, 5 Feb 2015 01:03:31 +0000 (02:03 +0100)
committerDavid S. Miller <davem@davemloft.net>
Fri, 6 Feb 2015 23:18:34 +0000 (15:18 -0800)
The value computed by key_hashfn() is used by rhashtable_lookup_compare()
to traverse both tables during a resize. key_hashfn() must therefore
return the hash value without the buckets mask applied so it can be
masked to the size of each individual table.

Fixes: 97defe1ecf86 ("rhashtable: Per bucket locks & deferred expansion/shrinking")
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/rhashtable.c

index 057919164e23d7ecc3f6e4258e541eb064a2dd73..71fd0dd45ce35a219dbeb7edfc17833f577ce973 100644 (file)
@@ -94,13 +94,7 @@ static u32 obj_raw_hashfn(const struct rhashtable *ht, const void *ptr)
 
 static u32 key_hashfn(struct rhashtable *ht, const void *key, u32 len)
 {
-       struct bucket_table *tbl = rht_dereference_rcu(ht->tbl, ht);
-       u32 hash;
-
-       hash = ht->p.hashfn(key, len, ht->p.hash_rnd);
-       hash >>= HASH_RESERVED_SPACE;
-
-       return rht_bucket_index(tbl, hash);
+       return ht->p.hashfn(key, len, ht->p.hash_rnd) >> HASH_RESERVED_SPACE;
 }
 
 static u32 head_hashfn(const struct rhashtable *ht,