Commit 2118071d authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Report connection error values to rpc_tasks on the pending queue

Currently we only report EAGAIN, which is not descriptive enough for
softconn tasks.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent df277270
...@@ -257,6 +257,7 @@ struct sock_xprt { ...@@ -257,6 +257,7 @@ struct sock_xprt {
void (*old_data_ready)(struct sock *, int); void (*old_data_ready)(struct sock *, int);
void (*old_state_change)(struct sock *); void (*old_state_change)(struct sock *);
void (*old_write_space)(struct sock *); void (*old_write_space)(struct sock *);
void (*old_error_report)(struct sock *);
}; };
/* /*
...@@ -274,6 +275,11 @@ struct sock_xprt { ...@@ -274,6 +275,11 @@ struct sock_xprt {
*/ */
#define TCP_RPC_REPLY (1UL << 6) #define TCP_RPC_REPLY (1UL << 6)
static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
{
return (struct rpc_xprt *) sk->sk_user_data;
}
static inline struct sockaddr *xs_addr(struct rpc_xprt *xprt) static inline struct sockaddr *xs_addr(struct rpc_xprt *xprt)
{ {
return (struct sockaddr *) &xprt->addr; return (struct sockaddr *) &xprt->addr;
...@@ -799,6 +805,7 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk) ...@@ -799,6 +805,7 @@ static void xs_save_old_callbacks(struct sock_xprt *transport, struct sock *sk)
transport->old_data_ready = sk->sk_data_ready; transport->old_data_ready = sk->sk_data_ready;
transport->old_state_change = sk->sk_state_change; transport->old_state_change = sk->sk_state_change;
transport->old_write_space = sk->sk_write_space; transport->old_write_space = sk->sk_write_space;
transport->old_error_report = sk->sk_error_report;
} }
static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk) static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *sk)
...@@ -806,6 +813,33 @@ static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *s ...@@ -806,6 +813,33 @@ static void xs_restore_old_callbacks(struct sock_xprt *transport, struct sock *s
sk->sk_data_ready = transport->old_data_ready; sk->sk_data_ready = transport->old_data_ready;
sk->sk_state_change = transport->old_state_change; sk->sk_state_change = transport->old_state_change;
sk->sk_write_space = transport->old_write_space; sk->sk_write_space = transport->old_write_space;
sk->sk_error_report = transport->old_error_report;
}
/**
* xs_error_report - callback to handle TCP socket state errors
* @sk: socket
*
* Note: we don't call sock_error() since there may be a rpc_task
* using the socket, and so we don't want to clear sk->sk_err.
*/
static void xs_error_report(struct sock *sk)
{
struct rpc_xprt *xprt;
int err;
read_lock_bh(&sk->sk_callback_lock);
if (!(xprt = xprt_from_sock(sk)))
goto out;
err = -sk->sk_err;
if (err == 0)
goto out;
dprintk("RPC: xs_error_report client %p, error=%d...\n",
xprt, -err);
xprt_wake_pending_tasks(xprt, err);
out:
read_unlock_bh(&sk->sk_callback_lock);
} }
static void xs_reset_transport(struct sock_xprt *transport) static void xs_reset_transport(struct sock_xprt *transport)
...@@ -885,11 +919,6 @@ static void xs_destroy(struct rpc_xprt *xprt) ...@@ -885,11 +919,6 @@ static void xs_destroy(struct rpc_xprt *xprt)
module_put(THIS_MODULE); module_put(THIS_MODULE);
} }
static inline struct rpc_xprt *xprt_from_sock(struct sock *sk)
{
return (struct rpc_xprt *) sk->sk_user_data;
}
static int xs_local_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb) static int xs_local_copy_to_xdr(struct xdr_buf *xdr, struct sk_buff *skb)
{ {
struct xdr_skb_reader desc = { struct xdr_skb_reader desc = {
...@@ -1869,6 +1898,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt, ...@@ -1869,6 +1898,7 @@ static int xs_local_finish_connecting(struct rpc_xprt *xprt,
sk->sk_user_data = xprt; sk->sk_user_data = xprt;
sk->sk_data_ready = xs_local_data_ready; sk->sk_data_ready = xs_local_data_ready;
sk->sk_write_space = xs_udp_write_space; sk->sk_write_space = xs_udp_write_space;
sk->sk_error_report = xs_error_report;
sk->sk_allocation = GFP_ATOMIC; sk->sk_allocation = GFP_ATOMIC;
xprt_clear_connected(xprt); xprt_clear_connected(xprt);
...@@ -2146,6 +2176,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock) ...@@ -2146,6 +2176,7 @@ static int xs_tcp_finish_connecting(struct rpc_xprt *xprt, struct socket *sock)
sk->sk_data_ready = xs_tcp_data_ready; sk->sk_data_ready = xs_tcp_data_ready;
sk->sk_state_change = xs_tcp_state_change; sk->sk_state_change = xs_tcp_state_change;
sk->sk_write_space = xs_tcp_write_space; sk->sk_write_space = xs_tcp_write_space;
sk->sk_error_report = xs_error_report;
sk->sk_allocation = GFP_ATOMIC; sk->sk_allocation = GFP_ATOMIC;
/* socket options */ /* socket options */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment