Commit d2ee4138 authored by Trond Myklebust's avatar Trond Myklebust Committed by Anna Schumaker

SUNRPC: Allow specification of TCP client connect timeout at setup

When we create a TCP transport, the connect timeout parameters are
currently fixed to be 90s. This is problematic in the pNFS flexfiles
case, where we may have multiple mirrors, and we would like to fail over
quickly to the next mirror if a data server is down.

This patch adds the ability to specify the connection parameters at RPC
client creation time.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
Signed-off-by: default avatarAnna Schumaker <Anna.Schumaker@Netapp.com>
parent 3e6ff89d
...@@ -148,6 +148,8 @@ struct rpc_create_args { ...@@ -148,6 +148,8 @@ struct rpc_create_args {
const struct cred *cred; const struct cred *cred;
unsigned int max_connect; unsigned int max_connect;
struct xprtsec_parms xprtsec; struct xprtsec_parms xprtsec;
unsigned long connect_timeout;
unsigned long reconnect_timeout;
}; };
struct rpc_add_xprt_test { struct rpc_add_xprt_test {
......
...@@ -351,6 +351,8 @@ struct xprt_create { ...@@ -351,6 +351,8 @@ struct xprt_create {
struct rpc_xprt_switch *bc_xps; struct rpc_xprt_switch *bc_xps;
unsigned int flags; unsigned int flags;
struct xprtsec_parms xprtsec; struct xprtsec_parms xprtsec;
unsigned long connect_timeout;
unsigned long reconnect_timeout;
}; };
struct xprt_class { struct xprt_class {
......
...@@ -534,6 +534,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) ...@@ -534,6 +534,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
.servername = args->servername, .servername = args->servername,
.bc_xprt = args->bc_xprt, .bc_xprt = args->bc_xprt,
.xprtsec = args->xprtsec, .xprtsec = args->xprtsec,
.connect_timeout = args->connect_timeout,
.reconnect_timeout = args->reconnect_timeout,
}; };
char servername[48]; char servername[48];
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
......
...@@ -2290,8 +2290,6 @@ static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, ...@@ -2290,8 +2290,6 @@ static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt,
unsigned long reconnect_timeout) unsigned long reconnect_timeout)
{ {
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
struct rpc_timeout to;
unsigned long initval;
spin_lock(&xprt->transport_lock); spin_lock(&xprt->transport_lock);
if (reconnect_timeout < xprt->max_reconnect_timeout) if (reconnect_timeout < xprt->max_reconnect_timeout)
...@@ -3350,8 +3348,13 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args) ...@@ -3350,8 +3348,13 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
xprt->timeout = &xs_tcp_default_timeout; xprt->timeout = &xs_tcp_default_timeout;
xprt->max_reconnect_timeout = xprt->timeout->to_maxval; xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
if (args->reconnect_timeout)
xprt->max_reconnect_timeout = args->reconnect_timeout;
xprt->connect_timeout = xprt->timeout->to_initval * xprt->connect_timeout = xprt->timeout->to_initval *
(xprt->timeout->to_retries + 1); (xprt->timeout->to_retries + 1);
if (args->connect_timeout)
xs_tcp_do_set_connect_timeout(xprt, args->connect_timeout);
INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn);
INIT_WORK(&transport->error_worker, xs_error_handle); INIT_WORK(&transport->error_worker, xs_error_handle);
......
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