diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2009-12-03 15:58:56 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2009-12-03 15:58:56 -0500 |
commit | 09a21c4102c8f7893368553273d39c0cadedf9af (patch) | |
tree | b0a051dbb02d48aa95383e39cc7ce6f503d6f33b /net/sunrpc/clnt.c | |
parent | 206a134b4d8abf57cd34dffacf993869355b9aac (diff) |
SUNRPC: Allow RPCs to fail quickly if the server is unreachable
The kernel sometimes makes RPC calls to services that aren't running.
Because the kernel's RPC client always assumes the hard retry semantic
when reconnecting a connection-oriented RPC transport, the underlying
reconnect logic takes a long while to time out, even though the remote
may have responded immediately with ECONNREFUSED.
In certain cases, like upcalls to our local rpcbind daemon, or for NFS
mount requests, we'd like the kernel to fail immediately if the remote
service isn't reachable. This allows another transport to be tried
immediately, or the pending request can be abandoned quickly.
Introduce a per-request flag which controls how call_transmit_status()
behaves when request transmission fails because the server cannot be
reached.
We don't want soft connection semantics to apply to other errors. The
default case of the switch statement in call_transmit_status() no
longer falls through; the fall through code is copied to the default
case, and a "break;" is added.
The transport's connection re-establishment timeout is also ignored for
such requests. We want the request to fail immediately, so the
reconnect delay is skipped. Additionally, we don't want a connect
failure here to further increase the reconnect timeout value, since
this request will not be retried.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'net/sunrpc/clnt.c')
-rw-r--r-- | net/sunrpc/clnt.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index 7bcd931e06ee..68a23583f44c 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c | |||
@@ -1197,6 +1197,8 @@ call_transmit_status(struct rpc_task *task) | |||
1197 | default: | 1197 | default: |
1198 | dprint_status(task); | 1198 | dprint_status(task); |
1199 | xprt_end_transmit(task); | 1199 | xprt_end_transmit(task); |
1200 | rpc_task_force_reencode(task); | ||
1201 | break; | ||
1200 | /* | 1202 | /* |
1201 | * Special cases: if we've been waiting on the | 1203 | * Special cases: if we've been waiting on the |
1202 | * socket's write_space() callback, or if the | 1204 | * socket's write_space() callback, or if the |
@@ -1204,11 +1206,16 @@ call_transmit_status(struct rpc_task *task) | |||
1204 | * then hold onto the transport lock. | 1206 | * then hold onto the transport lock. |
1205 | */ | 1207 | */ |
1206 | case -ECONNREFUSED: | 1208 | case -ECONNREFUSED: |
1207 | case -ECONNRESET: | ||
1208 | case -ENOTCONN: | ||
1209 | case -EHOSTDOWN: | 1209 | case -EHOSTDOWN: |
1210 | case -EHOSTUNREACH: | 1210 | case -EHOSTUNREACH: |
1211 | case -ENETUNREACH: | 1211 | case -ENETUNREACH: |
1212 | if (RPC_IS_SOFTCONN(task)) { | ||
1213 | xprt_end_transmit(task); | ||
1214 | rpc_exit(task, task->tk_status); | ||
1215 | break; | ||
1216 | } | ||
1217 | case -ECONNRESET: | ||
1218 | case -ENOTCONN: | ||
1212 | case -EPIPE: | 1219 | case -EPIPE: |
1213 | rpc_task_force_reencode(task); | 1220 | rpc_task_force_reencode(task); |
1214 | } | 1221 | } |