SUNRPC: Don't wake tasks during connection abort
authorBenjamin Coddington <bcodding@redhat.com>
Tue, 23 Sep 2014 16:26:19 +0000 (12:26 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Thu, 25 Sep 2014 03:06:56 +0000 (23:06 -0400)
When aborting a connection to preserve source ports, don't wake the task in
xs_error_report.  This allows tasks with RPC_TASK_SOFTCONN to succeed if the
connection needs to be re-established since it preserves the task's status
instead of setting it to the status of the aborting kernel_connect().

This may also avoid a potential conflict on the socket's lock.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Cc: stable@vger.kernel.org # 3.14+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
include/linux/sunrpc/xprt.h
net/sunrpc/xprtsock.c

index fcbfe8783243bb66c65c440a02104a0041ccec4b..cf391eef2e6de9ab46e73ebb42e93dd5dbbbaf47 100644 (file)
@@ -357,6 +357,7 @@ int                 xs_swapper(struct rpc_xprt *xprt, int enable);
 #define XPRT_CONNECTION_ABORT  (7)
 #define XPRT_CONNECTION_CLOSE  (8)
 #define XPRT_CONGESTED         (9)
+#define XPRT_CONNECTION_REUSE  (10)
 
 static inline void xprt_set_connected(struct rpc_xprt *xprt)
 {
index 7ed47b4943da8c988e0ad06acb422b219d74a22d..bffba4e4bfc635379cd983636e075a19b300e692 100644 (file)
@@ -845,6 +845,8 @@ static void xs_error_report(struct sock *sk)
        dprintk("RPC:       xs_error_report client %p, error=%d...\n",
                        xprt, -err);
        trace_rpc_socket_error(xprt, sk->sk_socket, err);
+       if (test_bit(XPRT_CONNECTION_REUSE, &xprt->state))
+               goto out;
        xprt_wake_pending_tasks(xprt, err);
  out:
        read_unlock_bh(&sk->sk_callback_lock);
@@ -2261,7 +2263,9 @@ static void xs_tcp_setup_socket(struct work_struct *work)
                abort_and_exit = test_and_clear_bit(XPRT_CONNECTION_ABORT,
                                &xprt->state);
                /* "close" the socket, preserving the local port */
+               set_bit(XPRT_CONNECTION_REUSE, &xprt->state);
                xs_tcp_reuse_connection(transport);
+               clear_bit(XPRT_CONNECTION_REUSE, &xprt->state);
 
                if (abort_and_exit)
                        goto out_eagain;