rhashtable: future table needs to be traversed when remove an object
authorYing Xue <ying.xue@windriver.com>
Wed, 7 Jan 2015 05:41:55 +0000 (13:41 +0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Jan 2015 03:47:11 +0000 (19:47 -0800)
When remove an object from hash table, we currently only traverse old
bucket table to check whether the object exists. If the object is not
found in it, we will try again. But in the second search loop, we still
search the object from the old table instead of future table. As a
result, the object may be not removed from hash table especially when
resizing is currently in progress and the object is just saved in the
future table.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Cc: Thomas Graf <tgraf@suug.ch>
Acked-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
lib/rhashtable.c

index 4430233c4e11705fd12979a4d0f5c896e91e93d2..1aef942976fe7b2420d9877fc2d3e0f44b0d152f 100644 (file)
@@ -608,10 +608,10 @@ restart:
                return true;
        }
 
-       if (tbl != rht_dereference_rcu(ht->tbl, ht)) {
+       if (tbl != rht_dereference_rcu(ht->future_tbl, ht)) {
                spin_unlock_bh(lock);
 
-               tbl = rht_dereference_rcu(ht->tbl, ht);
+               tbl = rht_dereference_rcu(ht->future_tbl, ht);
                hash = head_hashfn(ht, tbl, obj);
 
                lock = bucket_lock(tbl, hash);