diff options
author | NeilBrown <neilb@suse.com> | 2019-04-11 21:52:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2019-04-12 20:34:45 -0400 |
commit | e4edbe3c1f44c84f319149aeb998e7e36b3b897f (patch) | |
tree | 147388b269b9b7d4418235592ecfabb4c092d262 | |
parent | c252aa3e8ed3ac54060b1838f6a47f29799a133d (diff) |
rhashtable: fix some __rcu annotation errors
With these annotations, the rhashtable now gets no
warnings when compiled with "C=1" for sparse checking.
Signed-off-by: NeilBrown <neilb@suse.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/linux/rhashtable.h | 11 | ||||
-rw-r--r-- | lib/rhashtable.c | 4 |
2 files changed, 8 insertions, 7 deletions
diff --git a/include/linux/rhashtable.h b/include/linux/rhashtable.h index 460c0eaf6b96..2711cbf01b64 100644 --- a/include/linux/rhashtable.h +++ b/include/linux/rhashtable.h | |||
@@ -40,7 +40,7 @@ | |||
40 | * the chain. To avoid dereferencing this pointer without clearing | 40 | * the chain. To avoid dereferencing this pointer without clearing |
41 | * the bit first, we use an opaque 'struct rhash_lock_head *' for the | 41 | * the bit first, we use an opaque 'struct rhash_lock_head *' for the |
42 | * pointer stored in the bucket. This struct needs to be defined so | 42 | * pointer stored in the bucket. This struct needs to be defined so |
43 | * that rcu_derefernce() works on it, but it has no content so a | 43 | * that rcu_dereference() works on it, but it has no content so a |
44 | * cast is needed for it to be useful. This ensures it isn't | 44 | * cast is needed for it to be useful. This ensures it isn't |
45 | * used by mistake with clearing the lock bit first. | 45 | * used by mistake with clearing the lock bit first. |
46 | */ | 46 | */ |
@@ -130,10 +130,10 @@ static inline void rht_unlock(struct bucket_table *tbl, | |||
130 | } | 130 | } |
131 | 131 | ||
132 | static inline void rht_assign_unlock(struct bucket_table *tbl, | 132 | static inline void rht_assign_unlock(struct bucket_table *tbl, |
133 | struct rhash_lock_head **bkt, | 133 | struct rhash_lock_head __rcu **bkt, |
134 | struct rhash_head *obj) | 134 | struct rhash_head *obj) |
135 | { | 135 | { |
136 | struct rhash_head **p = (struct rhash_head **)bkt; | 136 | struct rhash_head __rcu **p = (struct rhash_head __rcu **)bkt; |
137 | 137 | ||
138 | lock_map_release(&tbl->dep_map); | 138 | lock_map_release(&tbl->dep_map); |
139 | rcu_assign_pointer(*p, obj); | 139 | rcu_assign_pointer(*p, obj); |
@@ -556,6 +556,7 @@ static inline struct rhash_head *__rhashtable_lookup( | |||
556 | }; | 556 | }; |
557 | struct rhash_lock_head __rcu * const *bkt; | 557 | struct rhash_lock_head __rcu * const *bkt; |
558 | struct bucket_table *tbl; | 558 | struct bucket_table *tbl; |
559 | struct rhash_head __rcu *head; | ||
559 | struct rhash_head *he; | 560 | struct rhash_head *he; |
560 | unsigned int hash; | 561 | unsigned int hash; |
561 | 562 | ||
@@ -564,8 +565,8 @@ restart: | |||
564 | hash = rht_key_hashfn(ht, tbl, key, params); | 565 | hash = rht_key_hashfn(ht, tbl, key, params); |
565 | bkt = rht_bucket(tbl, hash); | 566 | bkt = rht_bucket(tbl, hash); |
566 | do { | 567 | do { |
567 | he = rht_ptr(rht_dereference_bucket_rcu(*bkt, tbl, hash)); | 568 | head = rht_ptr(rht_dereference_bucket_rcu(*bkt, tbl, hash)); |
568 | rht_for_each_rcu_from(he, he, tbl, hash) { | 569 | rht_for_each_rcu_from(he, head, tbl, hash) { |
569 | if (params.obj_cmpfn ? | 570 | if (params.obj_cmpfn ? |
570 | params.obj_cmpfn(&arg, rht_obj(ht, he)) : | 571 | params.obj_cmpfn(&arg, rht_obj(ht, he)) : |
571 | rhashtable_compare(&arg, rht_obj(ht, he))) | 572 | rhashtable_compare(&arg, rht_obj(ht, he))) |
diff --git a/lib/rhashtable.c b/lib/rhashtable.c index 9c84f5cef69c..e387ceb00e86 100644 --- a/lib/rhashtable.c +++ b/lib/rhashtable.c | |||
@@ -223,7 +223,7 @@ static int rhashtable_rehash_one(struct rhashtable *ht, | |||
223 | struct bucket_table *new_tbl = rhashtable_last_table(ht, old_tbl); | 223 | struct bucket_table *new_tbl = rhashtable_last_table(ht, old_tbl); |
224 | int err = -EAGAIN; | 224 | int err = -EAGAIN; |
225 | struct rhash_head *head, *next, *entry; | 225 | struct rhash_head *head, *next, *entry; |
226 | struct rhash_head **pprev = NULL; | 226 | struct rhash_head __rcu **pprev = NULL; |
227 | unsigned int new_hash; | 227 | unsigned int new_hash; |
228 | 228 | ||
229 | if (new_tbl->nest) | 229 | if (new_tbl->nest) |
@@ -486,7 +486,7 @@ static void *rhashtable_lookup_one(struct rhashtable *ht, | |||
486 | .ht = ht, | 486 | .ht = ht, |
487 | .key = key, | 487 | .key = key, |
488 | }; | 488 | }; |
489 | struct rhash_head **pprev = NULL; | 489 | struct rhash_head __rcu **pprev = NULL; |
490 | struct rhash_head *head; | 490 | struct rhash_head *head; |
491 | int elasticity; | 491 | int elasticity; |
492 | 492 | ||