Commit caabea8a authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Use soft connect semantics when performing RPC ping

Currently, if a remote RPC service is unreachable, an RPC ping will
hang until the underlying transport connect attempt times out.  A more
desirable behavior might be to have the ping fail immediately so upper
layers can recover appropriately.

In the case of an NFS mount, for instance, this would mean the
mount(2) system call could fail immediately if the server isn't
listening, rather than hanging uninterruptibly for more than 3
minutes.

Change rpc_ping() so that it fails immediately for connection-oriented
transports.  rpc_create() will then fail immediately for such
transports if an RPC ping was requested.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 012da158
...@@ -79,7 +79,7 @@ static void call_connect_status(struct rpc_task *task); ...@@ -79,7 +79,7 @@ static void call_connect_status(struct rpc_task *task);
static __be32 *rpc_encode_header(struct rpc_task *task); static __be32 *rpc_encode_header(struct rpc_task *task);
static __be32 *rpc_verify_header(struct rpc_task *task); static __be32 *rpc_verify_header(struct rpc_task *task);
static int rpc_ping(struct rpc_clnt *clnt, int flags); static int rpc_ping(struct rpc_clnt *clnt);
static void rpc_register_client(struct rpc_clnt *clnt) static void rpc_register_client(struct rpc_clnt *clnt)
{ {
...@@ -340,7 +340,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) ...@@ -340,7 +340,7 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
return clnt; return clnt;
if (!(args->flags & RPC_CLNT_CREATE_NOPING)) { if (!(args->flags & RPC_CLNT_CREATE_NOPING)) {
int err = rpc_ping(clnt, RPC_TASK_SOFT); int err = rpc_ping(clnt);
if (err != 0) { if (err != 0) {
rpc_shutdown_client(clnt); rpc_shutdown_client(clnt);
return ERR_PTR(err); return ERR_PTR(err);
...@@ -528,7 +528,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old, ...@@ -528,7 +528,7 @@ struct rpc_clnt *rpc_bind_new_program(struct rpc_clnt *old,
clnt->cl_prog = program->number; clnt->cl_prog = program->number;
clnt->cl_vers = version->number; clnt->cl_vers = version->number;
clnt->cl_stats = program->stats; clnt->cl_stats = program->stats;
err = rpc_ping(clnt, RPC_TASK_SOFT); err = rpc_ping(clnt);
if (err != 0) { if (err != 0) {
rpc_shutdown_client(clnt); rpc_shutdown_client(clnt);
clnt = ERR_PTR(err); clnt = ERR_PTR(err);
...@@ -1709,14 +1709,14 @@ static struct rpc_procinfo rpcproc_null = { ...@@ -1709,14 +1709,14 @@ static struct rpc_procinfo rpcproc_null = {
.p_decode = rpcproc_decode_null, .p_decode = rpcproc_decode_null,
}; };
static int rpc_ping(struct rpc_clnt *clnt, int flags) static int rpc_ping(struct rpc_clnt *clnt)
{ {
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = &rpcproc_null, .rpc_proc = &rpcproc_null,
}; };
int err; int err;
msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0); msg.rpc_cred = authnull_ops.lookup_cred(NULL, NULL, 0);
err = rpc_call_sync(clnt, &msg, flags); err = rpc_call_sync(clnt, &msg, RPC_TASK_SOFT | RPC_TASK_SOFTCONN);
put_rpccred(msg.rpc_cred); put_rpccred(msg.rpc_cred);
return err; return err;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment