sunrpc: Pass lockdep expression to RCU lists
authorAmol Grover <frextrite@gmail.com>
Wed, 19 Feb 2020 09:35:05 +0000 (15:05 +0530)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 16 Mar 2020 16:04:31 +0000 (12:04 -0400)
detail->hash_table[] is traversed using hlist_for_each_entry_rcu
outside an RCU read-side critical section but under the protection
of detail->hash_lock.

Hence, add corresponding lockdep expression to silence false-positive
warnings, and harden RCU lists.

Signed-off-by: Amol Grover <frextrite@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
net/sunrpc/cache.c

index bd843a81afa0b2e537ce1abf20453867117e5486..8a8e3528293c8fda47b6af4e748b7ea5270a1b44 100644 (file)
@@ -113,7 +113,8 @@ static struct cache_head *sunrpc_cache_add_entry(struct cache_detail *detail,
        spin_lock(&detail->hash_lock);
 
        /* check if entry appeared while we slept */
-       hlist_for_each_entry_rcu(tmp, head, cache_list) {
+       hlist_for_each_entry_rcu(tmp, head, cache_list,
+                                lockdep_is_held(&detail->hash_lock)) {
                if (detail->match(tmp, key)) {
                        if (cache_is_expired(detail, tmp)) {
                                sunrpc_begin_cache_remove_entry(tmp, detail);