Skip to content

Commit 7b3fef8

Browse files
author
Trond Myklebust
committed
SUNRPC: Respect RPC call timeouts when retrying transmission
Fix a regression where soft and softconn requests are not timing out as expected. Fixes: 89f90fe ("SUNRPC: Allow calls to xprt_transmit() to drain...") Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 477687e commit 7b3fef8

File tree

1 file changed

+24
-18
lines changed

1 file changed

+24
-18
lines changed

net/sunrpc/clnt.c

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ static int rpc_encode_header(struct rpc_task *task,
7979
static int rpc_decode_header(struct rpc_task *task,
8080
struct xdr_stream *xdr);
8181
static int rpc_ping(struct rpc_clnt *clnt);
82+
static void rpc_check_timeout(struct rpc_task *task);
8283

8384
static void rpc_register_client(struct rpc_clnt *clnt)
8485
{
@@ -1962,8 +1963,7 @@ call_connect_status(struct rpc_task *task)
19621963
break;
19631964
if (clnt->cl_autobind) {
19641965
rpc_force_rebind(clnt);
1965-
task->tk_action = call_bind;
1966-
return;
1966+
goto out_retry;
19671967
}
19681968
/* fall through */
19691969
case -ECONNRESET:
@@ -1983,16 +1983,19 @@ call_connect_status(struct rpc_task *task)
19831983
/* fall through */
19841984
case -ENOTCONN:
19851985
case -EAGAIN:
1986-
/* Check for timeouts before looping back to call_bind */
19871986
case -ETIMEDOUT:
1988-
task->tk_action = call_timeout;
1989-
return;
1987+
goto out_retry;
19901988
case 0:
19911989
clnt->cl_stats->netreconn++;
19921990
task->tk_action = call_transmit;
19931991
return;
19941992
}
19951993
rpc_exit(task, status);
1994+
return;
1995+
out_retry:
1996+
/* Check for timeouts before looping back to call_bind */
1997+
task->tk_action = call_bind;
1998+
rpc_check_timeout(task);
19961999
}
19972000

19982001
/*
@@ -2069,7 +2072,7 @@ call_transmit_status(struct rpc_task *task)
20692072
trace_xprt_ping(task->tk_xprt,
20702073
task->tk_status);
20712074
rpc_exit(task, task->tk_status);
2072-
break;
2075+
return;
20732076
}
20742077
/* fall through */
20752078
case -ECONNRESET:
@@ -2081,6 +2084,7 @@ call_transmit_status(struct rpc_task *task)
20812084
task->tk_status = 0;
20822085
break;
20832086
}
2087+
rpc_check_timeout(task);
20842088
}
20852089

20862090
#if defined(CONFIG_SUNRPC_BACKCHANNEL)
@@ -2217,7 +2221,7 @@ call_status(struct rpc_task *task)
22172221
case -EPIPE:
22182222
case -ENOTCONN:
22192223
case -EAGAIN:
2220-
task->tk_action = call_encode;
2224+
task->tk_action = call_timeout;
22212225
break;
22222226
case -EIO:
22232227
/* shutdown or soft timeout */
@@ -2231,20 +2235,13 @@ call_status(struct rpc_task *task)
22312235
}
22322236
}
22332237

2234-
/*
2235-
* 6a. Handle RPC timeout
2236-
* We do not release the request slot, so we keep using the
2237-
* same XID for all retransmits.
2238-
*/
22392238
static void
2240-
call_timeout(struct rpc_task *task)
2239+
rpc_check_timeout(struct rpc_task *task)
22412240
{
22422241
struct rpc_clnt *clnt = task->tk_client;
22432242

2244-
if (xprt_adjust_timeout(task->tk_rqstp) == 0) {
2245-
dprintk("RPC: %5u call_timeout (minor)\n", task->tk_pid);
2246-
goto retry;
2247-
}
2243+
if (xprt_adjust_timeout(task->tk_rqstp) == 0)
2244+
return;
22482245

22492246
dprintk("RPC: %5u call_timeout (major)\n", task->tk_pid);
22502247
task->tk_timeouts++;
@@ -2280,10 +2277,19 @@ call_timeout(struct rpc_task *task)
22802277
* event? RFC2203 requires the server to drop all such requests.
22812278
*/
22822279
rpcauth_invalcred(task);
2280+
}
22832281

2284-
retry:
2282+
/*
2283+
* 6a. Handle RPC timeout
2284+
* We do not release the request slot, so we keep using the
2285+
* same XID for all retransmits.
2286+
*/
2287+
static void
2288+
call_timeout(struct rpc_task *task)
2289+
{
22852290
task->tk_action = call_encode;
22862291
task->tk_status = 0;
2292+
rpc_check_timeout(task);
22872293
}
22882294

22892295
/*

0 commit comments

Comments
 (0)