Skip to content

Commit d2ee413

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
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: Trond Myklebust <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 3e6ff89 commit d2ee413

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

include/linux/sunrpc/clnt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,8 @@ struct rpc_create_args {
148148
const struct cred *cred;
149149
unsigned int max_connect;
150150
struct xprtsec_parms xprtsec;
151+
unsigned long connect_timeout;
152+
unsigned long reconnect_timeout;
151153
};
152154

153155
struct rpc_add_xprt_test {

include/linux/sunrpc/xprt.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ struct xprt_create {
351351
struct rpc_xprt_switch *bc_xps;
352352
unsigned int flags;
353353
struct xprtsec_parms xprtsec;
354+
unsigned long connect_timeout;
355+
unsigned long reconnect_timeout;
354356
};
355357

356358
struct xprt_class {

net/sunrpc/clnt.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -534,6 +534,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
534534
.servername = args->servername,
535535
.bc_xprt = args->bc_xprt,
536536
.xprtsec = args->xprtsec,
537+
.connect_timeout = args->connect_timeout,
538+
.reconnect_timeout = args->reconnect_timeout,
537539
};
538540
char servername[48];
539541
struct rpc_clnt *clnt;

net/sunrpc/xprtsock.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,8 +2290,6 @@ static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt,
22902290
unsigned long reconnect_timeout)
22912291
{
22922292
struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt);
2293-
struct rpc_timeout to;
2294-
unsigned long initval;
22952293

22962294
spin_lock(&xprt->transport_lock);
22972295
if (reconnect_timeout < xprt->max_reconnect_timeout)
@@ -3350,8 +3348,13 @@ static struct rpc_xprt *xs_setup_tcp(struct xprt_create *args)
33503348
xprt->timeout = &xs_tcp_default_timeout;
33513349

33523350
xprt->max_reconnect_timeout = xprt->timeout->to_maxval;
3351+
if (args->reconnect_timeout)
3352+
xprt->max_reconnect_timeout = args->reconnect_timeout;
3353+
33533354
xprt->connect_timeout = xprt->timeout->to_initval *
33543355
(xprt->timeout->to_retries + 1);
3356+
if (args->connect_timeout)
3357+
xs_tcp_do_set_connect_timeout(xprt, args->connect_timeout);
33553358

33563359
INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn);
33573360
INIT_WORK(&transport->error_worker, xs_error_handle);

0 commit comments

Comments
 (0)