aboutsummaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorPeter Zijlstra <a.p.zijlstra@chello.nl>2006-12-06 23:35:24 -0500
committerLinus Torvalds <torvalds@woody.osdl.org>2006-12-07 11:39:30 -0500
commited07536ed6731775219c1df7fa26a7588753e693 (patch)
treec539d80fe50f28d4e294850bb33be810f46fd515 /net/sunrpc/xprtsock.c
parentb9d85b08c689dbf54b9943a02f73cb54c2b0fccf (diff)
[PATCH] lockdep: annotate nfs/nfsd in-kernel sockets
Stick NFS sockets in their own class to avoid some lockdep warnings. NFS sockets are never exposed to user-space, and will hence not trigger certain code paths that would otherwise pose deadlock scenarios. [akpm@osdl.org: cleanups] Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl> Signed-off-by: Steven Dickson <SteveD@redhat.com> Acked-by: Ingo Molnar <mingo@elte.hu> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Acked-by: Neil Brown <neilb@suse.de> Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Andrew Morton <akpm@osdl.org> [ Fixed patch corruption by quilt, pointed out by Peter Zijlstra ] Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index cfe3c15be948..2fc4a3123261 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1058,6 +1058,35 @@ static int xs_bindresvport(struct rpc_xprt *xprt, struct socket *sock)
1058 return err; 1058 return err;
1059} 1059}
1060 1060
1061#ifdef CONFIG_DEBUG_LOCK_ALLOC
1062static struct lock_class_key xs_key[2];
1063static struct lock_class_key xs_slock_key[2];
1064
1065static inline void xs_reclassify_socket(struct socket *sock)
1066{
1067 struct sock *sk = sock->sk;
1068 BUG_ON(sk->sk_lock.owner != NULL);
1069 switch (sk->sk_family) {
1070 case AF_INET:
1071 sock_lock_init_class_and_name(sk, "slock-AF_INET-NFS",
1072 &xs_slock_key[0], "sk_lock-AF_INET-NFS", &xs_key[0]);
1073 break;
1074
1075 case AF_INET6:
1076 sock_lock_init_class_and_name(sk, "slock-AF_INET6-NFS",
1077 &xs_slock_key[1], "sk_lock-AF_INET6-NFS", &xs_key[1]);
1078 break;
1079
1080 default:
1081 BUG();
1082 }
1083}
1084#else
1085static inline void xs_reclassify_socket(struct socket *sock)
1086{
1087}
1088#endif
1089
1061/** 1090/**
1062 * xs_udp_connect_worker - set up a UDP socket 1091 * xs_udp_connect_worker - set up a UDP socket
1063 * @work: RPC transport to connect 1092 * @work: RPC transport to connect
@@ -1081,6 +1110,7 @@ static void xs_udp_connect_worker(struct work_struct *work)
1081 dprintk("RPC: can't create UDP transport socket (%d).\n", -err); 1110 dprintk("RPC: can't create UDP transport socket (%d).\n", -err);
1082 goto out; 1111 goto out;
1083 } 1112 }
1113 xs_reclassify_socket(sock);
1084 1114
1085 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) { 1115 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
1086 sock_release(sock); 1116 sock_release(sock);
@@ -1165,6 +1195,7 @@ static void xs_tcp_connect_worker(struct work_struct *work)
1165 dprintk("RPC: can't create TCP transport socket (%d).\n", -err); 1195 dprintk("RPC: can't create TCP transport socket (%d).\n", -err);
1166 goto out; 1196 goto out;
1167 } 1197 }
1198 xs_reclassify_socket(sock);
1168 1199
1169 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) { 1200 if (xprt->resvport && xs_bindresvport(xprt, sock) < 0) {
1170 sock_release(sock); 1201 sock_release(sock);