Remove some duplicated code by moving the restart label up a few
lines. Also use rcu_access_pointer() for the pointer comparison
instead of rht_dereference_rcu().
Signed-off-by: Patrick McHardy <redacted>
---
lib/rhashtable.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/lib/rhashtable.c b/lib/rhashtable.c
index aca6998..5f079f7 100644
--- a/lib/rhashtable.c
+++ b/lib/rhashtable.c
@@ -588,12 +588,12 @@ bool rhashtable_remove(struct rhashtable *ht, struct rhash_head *obj)
rcu_read_lock();
tbl = rht_dereference_rcu(ht->tbl, ht);
+restart:
hash = head_hashfn(ht, tbl, obj);
lock = bucket_lock(tbl, hash);
spin_lock_bh(lock);
-restart:
pprev = &tbl->buckets[hash];
rht_for_each(he, tbl, hash) {
if (he != obj) {@@ -613,14 +613,10 @@ restart:
return true;
}
- if (tbl != rht_dereference_rcu(ht->future_tbl, ht)) {
+ if (tbl != rcu_access_pointer(ht->future_tbl)) {
spin_unlock_bh(lock);
tbl = rht_dereference_rcu(ht->future_tbl, ht);
- hash = head_hashfn(ht, tbl, obj);
-
- lock = bucket_lock(tbl, hash);
- spin_lock_bh(lock);
goto restart;
}
--
2.1.0