All of lore.kernel.org
 help / color / mirror / Atom feed
From: Weston Andros Adamson <dros@netapp.com>
To: Trond.Myklebust@netapp.com
Cc: linux-nfs@vger.kernel.org, Weston Andros Adamson <dros@netapp.com>
Subject: [PATCH 15/25] SUNRPC: remove BUG_ONs from *_reclassify_socket*
Date: Tue, 23 Oct 2012 10:43:39 -0400	[thread overview]
Message-ID: <1351003429-18887-16-git-send-email-dros@netapp.com> (raw)
In-Reply-To: <1351003429-18887-1-git-send-email-dros@netapp.com>

Replace multiple BUG_ON() calls with WARN_ON_ONCE() and early return when
sanity checking socket ownership (lock). The bind call will fail if the
socket was unsuccessfully reclassified.

Signed-off-by: Weston Andros Adamson <dros@netapp.com>
---
 net/sunrpc/svcsock.c  |    6 +++++-
 net/sunrpc/xprtsock.c |    7 ++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/net/sunrpc/svcsock.c b/net/sunrpc/svcsock.c
index 03827ce..cc3020d 100644
--- a/net/sunrpc/svcsock.c
+++ b/net/sunrpc/svcsock.c
@@ -84,7 +84,11 @@ static struct lock_class_key svc_slock_key[2];
 static void svc_reclassify_socket(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
-	BUG_ON(sock_owned_by_user(sk));
+
+	WARN_ON_ONCE(sock_owned_by_user(sk));
+	if (sock_owned_by_user(sk))
+		return;
+
 	switch (sk->sk_family) {
 	case AF_INET:
 		sock_lock_init_class_and_name(sk, "slock-AF_INET-NFSD",
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index aaaadfb..4e76d38 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -1762,7 +1762,6 @@ static inline void xs_reclassify_socketu(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BUG_ON(sock_owned_by_user(sk));
 	sock_lock_init_class_and_name(sk, "slock-AF_LOCAL-RPC",
 		&xs_slock_key[1], "sk_lock-AF_LOCAL-RPC", &xs_key[1]);
 }
@@ -1771,7 +1770,6 @@ static inline void xs_reclassify_socket4(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BUG_ON(sock_owned_by_user(sk));
 	sock_lock_init_class_and_name(sk, "slock-AF_INET-RPC",
 		&xs_slock_key[0], "sk_lock-AF_INET-RPC", &xs_key[0]);
 }
@@ -1780,13 +1778,16 @@ static inline void xs_reclassify_socket6(struct socket *sock)
 {
 	struct sock *sk = sock->sk;
 
-	BUG_ON(sock_owned_by_user(sk));
 	sock_lock_init_class_and_name(sk, "slock-AF_INET6-RPC",
 		&xs_slock_key[1], "sk_lock-AF_INET6-RPC", &xs_key[1]);
 }
 
 static inline void xs_reclassify_socket(int family, struct socket *sock)
 {
+	WARN_ON_ONCE(sock_owned_by_user(sock->sk));
+	if (sock_owned_by_user(sock->sk))
+		return;
+
 	switch (family) {
 	case AF_LOCAL:
 		xs_reclassify_socketu(sock);
-- 
1.7.9.6 (Apple Git-31.1)


  parent reply	other threads:[~2012-10-23 14:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-23 14:43 [PATCH 00/25] SUNRPC: remove many BUG_ONs Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 01/25] SUNRPC: remove BUG_ON in __rpc_clnt_handle_event Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 02/25] SUNRPC: remove BUG_ON from rpc_bind_new_program Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 03/25] SUNRPC: remove BUG_ON from rpc_run_bc_task Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 04/25] SUNRPC: remove BUG_ON from call_transmit Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 05/25] SUNRPC: remove BUG_ON from rpc_call_sync Weston Andros Adamson
2012-11-01 15:56   ` Myklebust, Trond
2012-10-23 14:43 ` [PATCH 06/25] SUNRPC: remove BUG_ON from call_bc_transmit Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 07/25] " Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 08/25] SUNRPC: remove BUG_ON from rpc_sleep_on* Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 09/25] SUNRPC: remove two BUG_ON asserts Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 10/25] SUNRPC: remove BUG_ON from xprt_destroy_backchannel Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 11/25] SUNRPC: remove BUG_ON from bc_send Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 12/25] SUNRPC: remove BUG_ON calls from cache_read Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 13/25] SUNRPC: remove BUG_ON in rpc_put_sb_net Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 14/25] SUNRPC: remove BUG_ON from svc_pool_map_set_cpumask Weston Andros Adamson
2012-10-23 14:43 ` Weston Andros Adamson [this message]
2012-10-23 14:43 ` [PATCH 16/25] SUNRPC: remove BUG_ON in svc_xprt_received Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 17/25] SUNRPC: remove BUG_ONs checking RPCSVC_MAXPAGES Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 18/25] SUNRPC: remove BUG_ON in xdr_shrink_bufhead Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 19/25] SUNRPC: remove BUG_ON from bc_malloc Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 20/25] SUNRPC: remove BUG_ON from encode_rpcb_string Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 21/25] SUNRPC: remove BUG_ON in svc_register Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 22/25] SUNRPC: remove BUG_ON from __rpc_sleep_on_priority Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 23/25] SUNRPC: remove BUG_ONs checking RPC_IS_QUEUED Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 24/25] SUNRPC: remove BUG_ON in svc_delete_xprt Weston Andros Adamson
2012-10-23 14:43 ` [PATCH 25/25] SUNRPC: remove BUG_ON in rpc_release_task Weston Andros Adamson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1351003429-18887-16-git-send-email-dros@netapp.com \
    --to=dros@netapp.com \
    --cc=Trond.Myklebust@netapp.com \
    --cc=linux-nfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.