SUNRPC: use different lock keys for INET6 and LOCAL
authorNeilBrown <neilb@suse.de>
Mon, 22 Nov 2021 22:40:35 +0000 (09:40 +1100)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Mon, 22 Nov 2021 22:44:49 +0000 (17:44 -0500)
xprtsock.c reclassifies sock locks based on the protocol.
However there are 3 protocols and only 2 classification keys.
The same key is used for both INET6 and LOCAL.

This causes lockdep complaints.  The complaints started since Commit
ea9afca88bbe ("SUNRPC: Replace use of socket sk_callback_lock with
sock_lock") which resulted in the sock locks beings used more.

So add another key, and renumber them slightly.

Fixes: ea9afca88bbe ("SUNRPC: Replace use of socket sk_callback_lock with sock_lock")
Fixes: 176e21ee2ec8 ("SUNRPC: Support for RPC over AF_LOCAL transports")
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
net/sunrpc/xprtsock.c

index ae48c9c..d8ee06a 100644 (file)
@@ -1720,15 +1720,15 @@ static void xs_local_set_port(struct rpc_xprt *xprt, unsigned short port)
 }
 
 #ifdef CONFIG_DEBUG_LOCK_ALLOC
-static struct lock_class_key xs_key[2];
-static struct lock_class_key xs_slock_key[2];
+static struct lock_class_key xs_key[3];
+static struct lock_class_key xs_slock_key[3];
 
 static inline void xs_reclassify_socketu(struct socket *sock)
 {
        struct sock *sk = sock->sk;
 
        sock_lock_init_class_and_name(sk, "slock-AF_LOCAL-RPC",
-               &xs_slock_key[1], "sk_lock-AF_LOCAL-RPC", &xs_key[1]);
+               &xs_slock_key[0], "sk_lock-AF_LOCAL-RPC", &xs_key[0]);
 }
 
 static inline void xs_reclassify_socket4(struct socket *sock)
@@ -1736,7 +1736,7 @@ static inline void xs_reclassify_socket4(struct socket *sock)
        struct sock *sk = sock->sk;
 
        sock_lock_init_class_and_name(sk, "slock-AF_INET-RPC",
-               &xs_slock_key[0], "sk_lock-AF_INET-RPC", &xs_key[0]);
+               &xs_slock_key[1], "sk_lock-AF_INET-RPC", &xs_key[1]);
 }
 
 static inline void xs_reclassify_socket6(struct socket *sock)
@@ -1744,7 +1744,7 @@ static inline void xs_reclassify_socket6(struct socket *sock)
        struct sock *sk = sock->sk;
 
        sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC",
-               &xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]);
+               &xs_slock_key[2], "sk_lock-AF_INET6-RPC", &xs_key[2]);
 }
 
 static inline void xs_reclassify_socket(int family, struct socket *sock)