Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <trond.myklebust@hammerspace.com>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>

authored by

Trond Myklebust and committed by
Anna Schumaker
d2ee4138 3e6ff89d

+11 -2
+2
include/linux/sunrpc/clnt.h
··· 148 148 const struct cred *cred; 149 149 unsigned int max_connect; 150 150 struct xprtsec_parms xprtsec; 151 + unsigned long connect_timeout; 152 + unsigned long reconnect_timeout; 151 153 }; 152 154 153 155 struct rpc_add_xprt_test {
+2
include/linux/sunrpc/xprt.h
··· 351 351 struct rpc_xprt_switch *bc_xps; 352 352 unsigned int flags; 353 353 struct xprtsec_parms xprtsec; 354 + unsigned long connect_timeout; 355 + unsigned long reconnect_timeout; 354 356 }; 355 357 356 358 struct xprt_class {
+2
net/sunrpc/clnt.c
··· 534 534 .servername = args->servername, 535 535 .bc_xprt = args->bc_xprt, 536 536 .xprtsec = args->xprtsec, 537 + .connect_timeout = args->connect_timeout, 538 + .reconnect_timeout = args->reconnect_timeout, 537 539 }; 538 540 char servername[48]; 539 541 struct rpc_clnt *clnt;
+5 -2
net/sunrpc/xprtsock.c
··· 2290 2290 unsigned long reconnect_timeout) 2291 2291 { 2292 2292 struct sock_xprt *transport = container_of(xprt, struct sock_xprt, xprt); 2293 - struct rpc_timeout to; 2294 - unsigned long initval; 2295 2293 2296 2294 spin_lock(&xprt->transport_lock); 2297 2295 if (reconnect_timeout < xprt->max_reconnect_timeout) ··· 3348 3350 xprt->timeout = &xs_tcp_default_timeout; 3349 3351 3350 3352 xprt->max_reconnect_timeout = xprt->timeout->to_maxval; 3353 + if (args->reconnect_timeout) 3354 + xprt->max_reconnect_timeout = args->reconnect_timeout; 3355 + 3351 3356 xprt->connect_timeout = xprt->timeout->to_initval * 3352 3357 (xprt->timeout->to_retries + 1); 3358 + if (args->connect_timeout) 3359 + xs_tcp_do_set_connect_timeout(xprt, args->connect_timeout); 3353 3360 3354 3361 INIT_WORK(&transport->recv_worker, xs_stream_data_receive_workfn); 3355 3362 INIT_WORK(&transport->error_worker, xs_error_handle);