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

LOCKD: Convert to use new rpc_create() API

Replace xprt_create_proto/rpc_create_client with new rpc_create()
interface in the Network Lock Manager.

Note that the semantics of NLM transports is now "hard" instead of "soft"
to provide a better guarantee that lock requests will get to the server.

Test plan:
Repeated runs of Connectathon locking suite.  Check network trace to ensure
NLM requests are working correctly.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent c2866763
...@@ -166,7 +166,6 @@ struct rpc_clnt * ...@@ -166,7 +166,6 @@ struct rpc_clnt *
nlm_bind_host(struct nlm_host *host) nlm_bind_host(struct nlm_host *host)
{ {
struct rpc_clnt *clnt; struct rpc_clnt *clnt;
struct rpc_xprt *xprt;
dprintk("lockd: nlm_bind_host(%08x)\n", dprintk("lockd: nlm_bind_host(%08x)\n",
(unsigned)ntohl(host->h_addr.sin_addr.s_addr)); (unsigned)ntohl(host->h_addr.sin_addr.s_addr));
...@@ -178,7 +177,6 @@ nlm_bind_host(struct nlm_host *host) ...@@ -178,7 +177,6 @@ nlm_bind_host(struct nlm_host *host)
* RPC rebind is required * RPC rebind is required
*/ */
if ((clnt = host->h_rpcclnt) != NULL) { if ((clnt = host->h_rpcclnt) != NULL) {
xprt = clnt->cl_xprt;
if (time_after_eq(jiffies, host->h_nextrebind)) { if (time_after_eq(jiffies, host->h_nextrebind)) {
rpc_force_rebind(clnt); rpc_force_rebind(clnt);
host->h_nextrebind = jiffies + NLM_HOST_REBIND; host->h_nextrebind = jiffies + NLM_HOST_REBIND;
...@@ -186,31 +184,37 @@ nlm_bind_host(struct nlm_host *host) ...@@ -186,31 +184,37 @@ nlm_bind_host(struct nlm_host *host)
host->h_nextrebind - jiffies); host->h_nextrebind - jiffies);
} }
} else { } else {
xprt = xprt_create_proto(host->h_proto, &host->h_addr, NULL); unsigned long increment = nlmsvc_timeout * HZ;
if (IS_ERR(xprt)) struct rpc_timeout timeparms = {
goto forgetit; .to_initval = increment,
.to_increment = increment,
xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout); .to_maxval = increment * 6UL,
xprt->resvport = 1; /* NLM requires a reserved port */ .to_retries = 5U,
};
/* Existing NLM servers accept AUTH_UNIX only */ struct rpc_create_args args = {
clnt = rpc_new_client(xprt, host->h_name, &nlm_program, .protocol = host->h_proto,
host->h_version, RPC_AUTH_UNIX); .address = (struct sockaddr *)&host->h_addr,
if (IS_ERR(clnt)) .addrsize = sizeof(host->h_addr),
goto forgetit; .timeout = &timeparms,
clnt->cl_autobind = 1; /* turn on pmap queries */ .servername = host->h_name,
clnt->cl_softrtry = 1; /* All queries are soft */ .program = &nlm_program,
.version = host->h_version,
.authflavor = RPC_AUTH_UNIX,
.flags = (RPC_CLNT_CREATE_HARDRTRY |
RPC_CLNT_CREATE_AUTOBIND),
};
clnt = rpc_create(&args);
if (!IS_ERR(clnt))
host->h_rpcclnt = clnt; host->h_rpcclnt = clnt;
else {
printk("lockd: couldn't create RPC handle for %s\n", host->h_name);
clnt = NULL;
}
} }
mutex_unlock(&host->h_mutex); mutex_unlock(&host->h_mutex);
return clnt; return clnt;
forgetit:
printk("lockd: couldn't create RPC handle for %s\n", host->h_name);
mutex_unlock(&host->h_mutex);
return NULL;
} }
/* /*
......
...@@ -109,30 +109,23 @@ nsm_unmonitor(struct nlm_host *host) ...@@ -109,30 +109,23 @@ nsm_unmonitor(struct nlm_host *host)
static struct rpc_clnt * static struct rpc_clnt *
nsm_create(void) nsm_create(void)
{ {
struct rpc_xprt *xprt; struct sockaddr_in sin = {
struct rpc_clnt *clnt; .sin_family = AF_INET,
struct sockaddr_in sin; .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = 0,
sin.sin_family = AF_INET; };
sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK); struct rpc_create_args args = {
sin.sin_port = 0; .protocol = IPPROTO_UDP,
.address = (struct sockaddr *)&sin,
xprt = xprt_create_proto(IPPROTO_UDP, &sin, NULL); .addrsize = sizeof(sin),
if (IS_ERR(xprt)) .servername = "localhost",
return (struct rpc_clnt *)xprt; .program = &nsm_program,
xprt->resvport = 1; /* NSM requires a reserved port */ .version = SM_VERSION,
.authflavor = RPC_AUTH_NULL,
clnt = rpc_create_client(xprt, "localhost", .flags = (RPC_CLNT_CREATE_ONESHOT),
&nsm_program, SM_VERSION, };
RPC_AUTH_NULL);
if (IS_ERR(clnt)) return rpc_create(&args);
goto out_err;
clnt->cl_softrtry = 1;
clnt->cl_oneshot = 1;
return clnt;
out_err:
return clnt;
} }
/* /*
......
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