aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/svcproc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/lockd/svcproc.c')
-rw-r--r--fs/lockd/svcproc.c151
1 files changed, 53 insertions, 98 deletions
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 35681d9cf1fc..d210cf304e92 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -22,10 +22,6 @@
22 22
23#define NLMDBG_FACILITY NLMDBG_CLIENT 23#define NLMDBG_FACILITY NLMDBG_CLIENT
24 24
25static u32 nlmsvc_callback(struct svc_rqst *, u32, struct nlm_res *);
26
27static const struct rpc_call_ops nlmsvc_callback_ops;
28
29#ifdef CONFIG_LOCKD_V4 25#ifdef CONFIG_LOCKD_V4
30static u32 26static u32
31cast_to_nlm(u32 status, u32 vers) 27cast_to_nlm(u32 status, u32 vers)
@@ -262,83 +258,91 @@ nlmsvc_proc_granted(struct svc_rqst *rqstp, struct nlm_args *argp,
262} 258}
263 259
264/* 260/*
261 * This is the generic lockd callback for async RPC calls
262 */
263static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
264{
265 dprintk("lockd: %4d callback returned %d\n", task->tk_pid,
266 -task->tk_status);
267}
268
269static void nlmsvc_callback_release(void *data)
270{
271 nlm_release_call(data);
272}
273
274static const struct rpc_call_ops nlmsvc_callback_ops = {
275 .rpc_call_done = nlmsvc_callback_exit,
276 .rpc_release = nlmsvc_callback_release,
277};
278
279/*
265 * `Async' versions of the above service routines. They aren't really, 280 * `Async' versions of the above service routines. They aren't really,
266 * because we send the callback before the reply proper. I hope this 281 * because we send the callback before the reply proper. I hope this
267 * doesn't break any clients. 282 * doesn't break any clients.
268 */ 283 */
269static int 284static int nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_args *argp,
270nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 285 int (*func)(struct svc_rqst *, struct nlm_args *, struct nlm_res *))
271 void *resp)
272{ 286{
273 struct nlm_res res; 287 struct nlm_host *host;
274 u32 stat; 288 struct nlm_rqst *call;
289 int stat;
275 290
276 dprintk("lockd: TEST_MSG called\n"); 291 host = nlmsvc_lookup_host(rqstp);
277 memset(&res, 0, sizeof(res)); 292 if (host == NULL)
293 return rpc_system_err;
278 294
279 if ((stat = nlmsvc_proc_test(rqstp, argp, &res)) == 0) 295 call = nlm_alloc_call(host);
280 stat = nlmsvc_callback(rqstp, NLMPROC_TEST_RES, &res); 296 if (call == NULL)
281 return stat; 297 return rpc_system_err;
298
299 stat = func(rqstp, argp, &call->a_res);
300 if (stat != 0) {
301 nlm_release_call(call);
302 return stat;
303 }
304
305 call->a_flags = RPC_TASK_ASYNC;
306 if (nlm_async_reply(call, proc, &nlmsvc_callback_ops) < 0)
307 return rpc_system_err;
308 return rpc_success;
282} 309}
283 310
284static int 311static int nlmsvc_proc_test_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
285nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
286 void *resp) 312 void *resp)
287{ 313{
288 struct nlm_res res; 314 dprintk("lockd: TEST_MSG called\n");
289 u32 stat; 315 return nlmsvc_callback(rqstp, NLMPROC_TEST_RES, argp, nlmsvc_proc_test);
316}
290 317
318static int nlmsvc_proc_lock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
319 void *resp)
320{
291 dprintk("lockd: LOCK_MSG called\n"); 321 dprintk("lockd: LOCK_MSG called\n");
292 memset(&res, 0, sizeof(res)); 322 return nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, argp, nlmsvc_proc_lock);
293
294 if ((stat = nlmsvc_proc_lock(rqstp, argp, &res)) == 0)
295 stat = nlmsvc_callback(rqstp, NLMPROC_LOCK_RES, &res);
296 return stat;
297} 323}
298 324
299static int 325static int nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
300nlmsvc_proc_cancel_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
301 void *resp) 326 void *resp)
302{ 327{
303 struct nlm_res res;
304 u32 stat;
305
306 dprintk("lockd: CANCEL_MSG called\n"); 328 dprintk("lockd: CANCEL_MSG called\n");
307 memset(&res, 0, sizeof(res)); 329 return nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, argp, nlmsvc_proc_cancel);
308
309 if ((stat = nlmsvc_proc_cancel(rqstp, argp, &res)) == 0)
310 stat = nlmsvc_callback(rqstp, NLMPROC_CANCEL_RES, &res);
311 return stat;
312} 330}
313 331
314static int 332static int
315nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 333nlmsvc_proc_unlock_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
316 void *resp) 334 void *resp)
317{ 335{
318 struct nlm_res res;
319 u32 stat;
320
321 dprintk("lockd: UNLOCK_MSG called\n"); 336 dprintk("lockd: UNLOCK_MSG called\n");
322 memset(&res, 0, sizeof(res)); 337 return nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, argp, nlmsvc_proc_unlock);
323
324 if ((stat = nlmsvc_proc_unlock(rqstp, argp, &res)) == 0)
325 stat = nlmsvc_callback(rqstp, NLMPROC_UNLOCK_RES, &res);
326 return stat;
327} 338}
328 339
329static int 340static int
330nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp, 341nlmsvc_proc_granted_msg(struct svc_rqst *rqstp, struct nlm_args *argp,
331 void *resp) 342 void *resp)
332{ 343{
333 struct nlm_res res;
334 u32 stat;
335
336 dprintk("lockd: GRANTED_MSG called\n"); 344 dprintk("lockd: GRANTED_MSG called\n");
337 memset(&res, 0, sizeof(res)); 345 return nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, argp, nlmsvc_proc_granted);
338
339 if ((stat = nlmsvc_proc_granted(rqstp, argp, &res)) == 0)
340 stat = nlmsvc_callback(rqstp, NLMPROC_GRANTED_RES, &res);
341 return stat;
342} 346}
343 347
344/* 348/*
@@ -497,55 +501,6 @@ nlmsvc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
497} 501}
498 502
499/* 503/*
500 * This is the generic lockd callback for async RPC calls
501 */
502static u32
503nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
504{
505 struct nlm_host *host;
506 struct nlm_rqst *call;
507
508 if (!(call = nlmclnt_alloc_call()))
509 return rpc_system_err;
510
511 host = nlmclnt_lookup_host(&rqstp->rq_addr,
512 rqstp->rq_prot, rqstp->rq_vers);
513 if (!host) {
514 kfree(call);
515 return rpc_system_err;
516 }
517
518 call->a_flags = RPC_TASK_ASYNC;
519 call->a_host = host;
520 memcpy(&call->a_args, resp, sizeof(*resp));
521
522 if (nlmsvc_async_call(call, proc, &nlmsvc_callback_ops) < 0)
523 goto error;
524
525 return rpc_success;
526 error:
527 nlm_release_host(host);
528 kfree(call);
529 return rpc_system_err;
530}
531
532static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
533{
534 struct nlm_rqst *call = data;
535
536 if (task->tk_status < 0) {
537 dprintk("lockd: %4d callback failed (errno = %d)\n",
538 task->tk_pid, -task->tk_status);
539 }
540 nlm_release_host(call->a_host);
541 kfree(call);
542}
543
544static const struct rpc_call_ops nlmsvc_callback_ops = {
545 .rpc_call_done = nlmsvc_callback_exit,
546};
547
548/*
549 * NLM Server procedures. 504 * NLM Server procedures.
550 */ 505 */
551 506