Commit 3851f1cd authored by Trond Myklebust's avatar Trond Myklebust

SUNRPC: Limit the reconnect backoff timer to the max RPC message timeout

...and ensure that we propagate it to new transports on the same
client.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 02910177
...@@ -218,7 +218,8 @@ struct rpc_xprt { ...@@ -218,7 +218,8 @@ struct rpc_xprt {
struct work_struct task_cleanup; struct work_struct task_cleanup;
struct timer_list timer; struct timer_list timer;
unsigned long last_used, unsigned long last_used,
idle_timeout; idle_timeout,
max_reconnect_timeout;
/* /*
* Send stuff * Send stuff
......
...@@ -2638,6 +2638,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, ...@@ -2638,6 +2638,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
{ {
struct rpc_xprt_switch *xps; struct rpc_xprt_switch *xps;
struct rpc_xprt *xprt; struct rpc_xprt *xprt;
unsigned long reconnect_timeout;
unsigned char resvport; unsigned char resvport;
int ret = 0; int ret = 0;
...@@ -2649,6 +2650,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, ...@@ -2649,6 +2650,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
return -EAGAIN; return -EAGAIN;
} }
resvport = xprt->resvport; resvport = xprt->resvport;
reconnect_timeout = xprt->max_reconnect_timeout;
rcu_read_unlock(); rcu_read_unlock();
xprt = xprt_create_transport(xprtargs); xprt = xprt_create_transport(xprtargs);
...@@ -2657,6 +2659,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt, ...@@ -2657,6 +2659,7 @@ int rpc_clnt_add_xprt(struct rpc_clnt *clnt,
goto out_put_switch; goto out_put_switch;
} }
xprt->resvport = resvport; xprt->resvport = resvport;
xprt->max_reconnect_timeout = reconnect_timeout;
rpc_xprt_switch_set_roundrobin(xps); rpc_xprt_switch_set_roundrobin(xps);
if (setup) { if (setup) {
......
...@@ -177,7 +177,6 @@ static struct ctl_table sunrpc_table[] = { ...@@ -177,7 +177,6 @@ static struct ctl_table sunrpc_table[] = {
* increase over time if the server is down or not responding. * increase over time if the server is down or not responding.
*/ */
#define XS_TCP_INIT_REEST_TO (3U * HZ) #define XS_TCP_INIT_REEST_TO (3U * HZ)
#define XS_TCP_MAX_REEST_TO (5U * 60 * HZ)
/* /*
* TCP idle timeout; client drops the transport socket if it is idle * TCP idle timeout; client drops the transport socket if it is idle
...@@ -2396,6 +2395,15 @@ static unsigned long xs_reconnect_delay(const struct rpc_xprt *xprt) ...@@ -2396,6 +2395,15 @@ static unsigned long xs_reconnect_delay(const struct rpc_xprt *xprt)
return 0; return 0;
} }
static void xs_reconnect_backoff(struct rpc_xprt *xprt)
{
xprt->reestablish_timeout <<= 1;
if (xprt->reestablish_timeout > xprt->max_reconnect_timeout)
xprt->reestablish_timeout = xprt->max_reconnect_timeout;
if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO)
xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
}
/** /**
* xs_connect - connect a socket to a remote endpoint * xs_connect - connect a socket to a remote endpoint
* @xprt: pointer to transport structure * @xprt: pointer to transport structure
...@@ -2426,12 +2434,8 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task) ...@@ -2426,12 +2434,8 @@ static void xs_connect(struct rpc_xprt *xprt, struct rpc_task *task)
xs_reset_transport(transport); xs_reset_transport(transport);
delay = xs_reconnect_delay(xprt); delay = xs_reconnect_delay(xprt);
xs_reconnect_backoff(xprt);
xprt->reestablish_timeout <<= 1;
if (xprt->reestablish_timeout < XS_TCP_INIT_REEST_TO)
xprt->reestablish_timeout = XS_TCP_INIT_REEST_TO;
if (xprt->reestablish_timeout > XS_TCP_MAX_REEST_TO)
xprt->reestablish_timeout = XS_TCP_MAX_REEST_TO;
} else } else
dprintk("RPC: xs_connect scheduled xprt %p\n", xprt); dprintk("RPC: xs_connect scheduled xprt %p\n", xprt);
...@@ -2989,6 +2993,8 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) ...@@ -2989,6 +2993,8 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
xprt->ops = &xs_tcp_ops; xprt->ops = &xs_tcp_ops;
xprt->timeout = &xs_tcp_default_timeout; xprt->timeout = &xs_tcp_default_timeout;
xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn); INIT_WORK(&transport->recv_worker, xs_tcp_data_receive_workfn);
INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket); INIT_DELAYED_WORK(&transport->connect_worker, xs_tcp_setup_socket);
......
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