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

SUNRPC: Refactor and simplify connect timeout

Instead of requiring the requests to redrive the connection several
times, just let the TCP connect code manage it now that we've adjusted
the TCP_SYNCNT value.

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
3e6ff89d 3a107f07

+21 -13
+21 -13
net/sunrpc/xprtsock.c
··· 2266 2266 tcp_sock_set_syncnt(sock->sk, t - 1); 2267 2267 } 2268 2268 2269 + static void xs_tcp_do_set_connect_timeout(struct rpc_xprt *xprt, 2270 + unsigned long connect_timeout) 2271 + { 2272 + struct sock_xprt *transport = 2273 + container_of(xprt, struct sock_xprt, xprt); 2274 + struct rpc_timeout to; 2275 + unsigned long initval; 2276 + 2277 + memcpy(&to, xprt->timeout, sizeof(to)); 2278 + /* Arbitrary lower limit */ 2279 + initval = max_t(unsigned long, connect_timeout, XS_TCP_INIT_REEST_TO); 2280 + to.to_initval = initval; 2281 + to.to_maxval = initval; 2282 + to.to_retries = 0; 2283 + memcpy(&transport->tcp_timeout, &to, sizeof(transport->tcp_timeout)); 2284 + xprt->timeout = &transport->tcp_timeout; 2285 + xprt->connect_timeout = connect_timeout; 2286 + } 2287 + 2269 2288 static void xs_tcp_set_connect_timeout(struct rpc_xprt *xprt, 2270 2289 unsigned long connect_timeout, 2271 2290 unsigned long reconnect_timeout) ··· 2296 2277 spin_lock(&xprt->transport_lock); 2297 2278 if (reconnect_timeout < xprt->max_reconnect_timeout) 2298 2279 xprt->max_reconnect_timeout = reconnect_timeout; 2299 - if (connect_timeout < xprt->connect_timeout) { 2300 - memcpy(&to, xprt->timeout, sizeof(to)); 2301 - initval = DIV_ROUND_UP(connect_timeout, to.to_retries + 1); 2302 - /* Arbitrary lower limit */ 2303 - if (initval < XS_TCP_INIT_REEST_TO << 1) 2304 - initval = XS_TCP_INIT_REEST_TO << 1; 2305 - to.to_initval = initval; 2306 - to.to_maxval = initval; 2307 - memcpy(&transport->tcp_timeout, &to, 2308 - sizeof(transport->tcp_timeout)); 2309 - xprt->timeout = &transport->tcp_timeout; 2310 - xprt->connect_timeout = connect_timeout; 2311 - } 2280 + if (connect_timeout < xprt->connect_timeout) 2281 + xs_tcp_do_set_connect_timeout(xprt, connect_timeout); 2312 2282 set_bit(XPRT_SOCK_UPD_TIMEOUT, &transport->sock_state); 2313 2283 spin_unlock(&xprt->transport_lock); 2314 2284 }