Commit e1ec78928b4d5a31b7a847e65c6009f4229f7c0f

Authored by Chuck Lever
Committed by Trond Myklebust
1 parent c2866763b4

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: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

Showing 2 changed files with 44 additions and 47 deletions Side-by-side Diff

... ... @@ -166,7 +166,6 @@
166 166 nlm_bind_host(struct nlm_host *host)
167 167 {
168 168 struct rpc_clnt *clnt;
169   - struct rpc_xprt *xprt;
170 169  
171 170 dprintk("lockd: nlm_bind_host(%08x)\n",
172 171 (unsigned)ntohl(host->h_addr.sin_addr.s_addr));
... ... @@ -178,7 +177,6 @@
178 177 * RPC rebind is required
179 178 */
180 179 if ((clnt = host->h_rpcclnt) != NULL) {
181   - xprt = clnt->cl_xprt;
182 180 if (time_after_eq(jiffies, host->h_nextrebind)) {
183 181 rpc_force_rebind(clnt);
184 182 host->h_nextrebind = jiffies + NLM_HOST_REBIND;
185 183  
186 184  
... ... @@ -186,31 +184,37 @@
186 184 host->h_nextrebind - jiffies);
187 185 }
188 186 } else {
189   - xprt = xprt_create_proto(host->h_proto, &host->h_addr, NULL);
190   - if (IS_ERR(xprt))
191   - goto forgetit;
  187 + unsigned long increment = nlmsvc_timeout * HZ;
  188 + struct rpc_timeout timeparms = {
  189 + .to_initval = increment,
  190 + .to_increment = increment,
  191 + .to_maxval = increment * 6UL,
  192 + .to_retries = 5U,
  193 + };
  194 + struct rpc_create_args args = {
  195 + .protocol = host->h_proto,
  196 + .address = (struct sockaddr *)&host->h_addr,
  197 + .addrsize = sizeof(host->h_addr),
  198 + .timeout = &timeparms,
  199 + .servername = host->h_name,
  200 + .program = &nlm_program,
  201 + .version = host->h_version,
  202 + .authflavor = RPC_AUTH_UNIX,
  203 + .flags = (RPC_CLNT_CREATE_HARDRTRY |
  204 + RPC_CLNT_CREATE_AUTOBIND),
  205 + };
192 206  
193   - xprt_set_timeout(&xprt->timeout, 5, nlmsvc_timeout);
194   - xprt->resvport = 1; /* NLM requires a reserved port */
195   -
196   - /* Existing NLM servers accept AUTH_UNIX only */
197   - clnt = rpc_new_client(xprt, host->h_name, &nlm_program,
198   - host->h_version, RPC_AUTH_UNIX);
199   - if (IS_ERR(clnt))
200   - goto forgetit;
201   - clnt->cl_autobind = 1; /* turn on pmap queries */
202   - clnt->cl_softrtry = 1; /* All queries are soft */
203   -
204   - host->h_rpcclnt = clnt;
  207 + clnt = rpc_create(&args);
  208 + if (!IS_ERR(clnt))
  209 + host->h_rpcclnt = clnt;
  210 + else {
  211 + printk("lockd: couldn't create RPC handle for %s\n", host->h_name);
  212 + clnt = NULL;
  213 + }
205 214 }
206 215  
207 216 mutex_unlock(&host->h_mutex);
208 217 return clnt;
209   -
210   -forgetit:
211   - printk("lockd: couldn't create RPC handle for %s\n", host->h_name);
212   - mutex_unlock(&host->h_mutex);
213   - return NULL;
214 218 }
215 219  
216 220 /*
... ... @@ -109,30 +109,23 @@
109 109 static struct rpc_clnt *
110 110 nsm_create(void)
111 111 {
112   - struct rpc_xprt *xprt;
113   - struct rpc_clnt *clnt;
114   - struct sockaddr_in sin;
  112 + struct sockaddr_in sin = {
  113 + .sin_family = AF_INET,
  114 + .sin_addr.s_addr = htonl(INADDR_LOOPBACK),
  115 + .sin_port = 0,
  116 + };
  117 + struct rpc_create_args args = {
  118 + .protocol = IPPROTO_UDP,
  119 + .address = (struct sockaddr *)&sin,
  120 + .addrsize = sizeof(sin),
  121 + .servername = "localhost",
  122 + .program = &nsm_program,
  123 + .version = SM_VERSION,
  124 + .authflavor = RPC_AUTH_NULL,
  125 + .flags = (RPC_CLNT_CREATE_ONESHOT),
  126 + };
115 127  
116   - sin.sin_family = AF_INET;
117   - sin.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
118   - sin.sin_port = 0;
119   -
120   - xprt = xprt_create_proto(IPPROTO_UDP, &sin, NULL);
121   - if (IS_ERR(xprt))
122   - return (struct rpc_clnt *)xprt;
123   - xprt->resvport = 1; /* NSM requires a reserved port */
124   -
125   - clnt = rpc_create_client(xprt, "localhost",
126   - &nsm_program, SM_VERSION,
127   - RPC_AUTH_NULL);
128   - if (IS_ERR(clnt))
129   - goto out_err;
130   - clnt->cl_softrtry = 1;
131   - clnt->cl_oneshot = 1;
132   - return clnt;
133   -
134   -out_err:
135   - return clnt;
  128 + return rpc_create(&args);
136 129 }
137 130  
138 131 /*