aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-03 03:55:04 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-01-06 14:58:39 -0500
commit963d8fe53339128ee46a7701f2e36305f0ccff8c (patch)
tree426736c70a8e05cb1d945d5c7f44ea6475edd113 /fs/lockd
parentabbcf28f23d53e8ec56a91f3528743913fa2694a (diff)
RPC: Clean up RPC task structure
Shrink the RPC task structure. Instead of storing separate pointers for task->tk_exit and task->tk_release, put them in a structure. Also pass the user data pointer as a parameter instead of passing it via task->tk_calldata. This enables us to nest callbacks. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd')
-rw-r--r--fs/lockd/clntproc.c38
-rw-r--r--fs/lockd/svc4proc.c15
-rw-r--r--fs/lockd/svclock.c14
-rw-r--r--fs/lockd/svcproc.c14
4 files changed, 48 insertions, 33 deletions
diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
index c5a33648e9fd..816333cd377b 100644
--- a/fs/lockd/clntproc.c
+++ b/fs/lockd/clntproc.c
@@ -26,11 +26,12 @@
26static int nlmclnt_test(struct nlm_rqst *, struct file_lock *); 26static int nlmclnt_test(struct nlm_rqst *, struct file_lock *);
27static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *); 27static int nlmclnt_lock(struct nlm_rqst *, struct file_lock *);
28static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *); 28static int nlmclnt_unlock(struct nlm_rqst *, struct file_lock *);
29static void nlmclnt_unlock_callback(struct rpc_task *);
30static void nlmclnt_cancel_callback(struct rpc_task *);
31static int nlm_stat_to_errno(u32 stat); 29static int nlm_stat_to_errno(u32 stat);
32static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host); 30static void nlmclnt_locks_init_private(struct file_lock *fl, struct nlm_host *host);
33 31
32static const struct rpc_call_ops nlmclnt_unlock_ops;
33static const struct rpc_call_ops nlmclnt_cancel_ops;
34
34/* 35/*
35 * Cookie counter for NLM requests 36 * Cookie counter for NLM requests
36 */ 37 */
@@ -399,8 +400,7 @@ in_grace_period:
399/* 400/*
400 * Generic NLM call, async version. 401 * Generic NLM call, async version.
401 */ 402 */
402int 403int nlmsvc_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops)
403nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
404{ 404{
405 struct nlm_host *host = req->a_host; 405 struct nlm_host *host = req->a_host;
406 struct rpc_clnt *clnt; 406 struct rpc_clnt *clnt;
@@ -419,13 +419,12 @@ nlmsvc_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
419 msg.rpc_proc = &clnt->cl_procinfo[proc]; 419 msg.rpc_proc = &clnt->cl_procinfo[proc];
420 420
421 /* bootstrap and kick off the async RPC call */ 421 /* bootstrap and kick off the async RPC call */
422 status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); 422 status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, tk_ops, req);
423 423
424 return status; 424 return status;
425} 425}
426 426
427static int 427static int nlmclnt_async_call(struct nlm_rqst *req, u32 proc, const struct rpc_call_ops *tk_ops)
428nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
429{ 428{
430 struct nlm_host *host = req->a_host; 429 struct nlm_host *host = req->a_host;
431 struct rpc_clnt *clnt; 430 struct rpc_clnt *clnt;
@@ -448,7 +447,7 @@ nlmclnt_async_call(struct nlm_rqst *req, u32 proc, rpc_action callback)
448 /* Increment host refcount */ 447 /* Increment host refcount */
449 nlm_get_host(host); 448 nlm_get_host(host);
450 /* bootstrap and kick off the async RPC call */ 449 /* bootstrap and kick off the async RPC call */
451 status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, callback, req); 450 status = rpc_call_async(clnt, &msg, RPC_TASK_ASYNC, tk_ops, req);
452 if (status < 0) 451 if (status < 0)
453 nlm_release_host(host); 452 nlm_release_host(host);
454 return status; 453 return status;
@@ -664,7 +663,7 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
664 663
665 if (req->a_flags & RPC_TASK_ASYNC) { 664 if (req->a_flags & RPC_TASK_ASYNC) {
666 status = nlmclnt_async_call(req, NLMPROC_UNLOCK, 665 status = nlmclnt_async_call(req, NLMPROC_UNLOCK,
667 nlmclnt_unlock_callback); 666 &nlmclnt_unlock_ops);
668 /* Hrmf... Do the unlock early since locks_remove_posix() 667 /* Hrmf... Do the unlock early since locks_remove_posix()
669 * really expects us to free the lock synchronously */ 668 * really expects us to free the lock synchronously */
670 do_vfs_lock(fl); 669 do_vfs_lock(fl);
@@ -692,10 +691,9 @@ nlmclnt_unlock(struct nlm_rqst *req, struct file_lock *fl)
692 return -ENOLCK; 691 return -ENOLCK;
693} 692}
694 693
695static void 694static void nlmclnt_unlock_callback(struct rpc_task *task, void *data)
696nlmclnt_unlock_callback(struct rpc_task *task)
697{ 695{
698 struct nlm_rqst *req = (struct nlm_rqst *) task->tk_calldata; 696 struct nlm_rqst *req = data;
699 int status = req->a_res.status; 697 int status = req->a_res.status;
700 698
701 if (RPC_ASSASSINATED(task)) 699 if (RPC_ASSASSINATED(task))
@@ -722,6 +720,10 @@ die:
722 rpc_restart_call(task); 720 rpc_restart_call(task);
723} 721}
724 722
723static const struct rpc_call_ops nlmclnt_unlock_ops = {
724 .rpc_call_done = nlmclnt_unlock_callback,
725};
726
725/* 727/*
726 * Cancel a blocked lock request. 728 * Cancel a blocked lock request.
727 * We always use an async RPC call for this in order not to hang a 729 * We always use an async RPC call for this in order not to hang a
@@ -750,8 +752,7 @@ nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl)
750 752
751 nlmclnt_setlockargs(req, fl); 753 nlmclnt_setlockargs(req, fl);
752 754
753 status = nlmclnt_async_call(req, NLMPROC_CANCEL, 755 status = nlmclnt_async_call(req, NLMPROC_CANCEL, &nlmclnt_cancel_ops);
754 nlmclnt_cancel_callback);
755 if (status < 0) { 756 if (status < 0) {
756 nlmclnt_release_lockargs(req); 757 nlmclnt_release_lockargs(req);
757 kfree(req); 758 kfree(req);
@@ -765,10 +766,9 @@ nlmclnt_cancel(struct nlm_host *host, struct file_lock *fl)
765 return status; 766 return status;
766} 767}
767 768
768static void 769static void nlmclnt_cancel_callback(struct rpc_task *task, void *data)
769nlmclnt_cancel_callback(struct rpc_task *task)
770{ 770{
771 struct nlm_rqst *req = (struct nlm_rqst *) task->tk_calldata; 771 struct nlm_rqst *req = data;
772 772
773 if (RPC_ASSASSINATED(task)) 773 if (RPC_ASSASSINATED(task))
774 goto die; 774 goto die;
@@ -807,6 +807,10 @@ retry_cancel:
807 rpc_delay(task, 30 * HZ); 807 rpc_delay(task, 30 * HZ);
808} 808}
809 809
810static const struct rpc_call_ops nlmclnt_cancel_ops = {
811 .rpc_call_done = nlmclnt_cancel_callback,
812};
813
810/* 814/*
811 * Convert an NLM status code to a generic kernel errno 815 * Convert an NLM status code to a generic kernel errno
812 */ 816 */
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index 489670e21769..4063095d849e 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -22,7 +22,8 @@
22#define NLMDBG_FACILITY NLMDBG_CLIENT 22#define NLMDBG_FACILITY NLMDBG_CLIENT
23 23
24static u32 nlm4svc_callback(struct svc_rqst *, u32, struct nlm_res *); 24static u32 nlm4svc_callback(struct svc_rqst *, u32, struct nlm_res *);
25static void nlm4svc_callback_exit(struct rpc_task *); 25
26static const struct rpc_call_ops nlm4svc_callback_ops;
26 27
27/* 28/*
28 * Obtain client and file from arguments 29 * Obtain client and file from arguments
@@ -470,7 +471,6 @@ nlm4svc_proc_granted_res(struct svc_rqst *rqstp, struct nlm_res *argp,
470} 471}
471 472
472 473
473
474/* 474/*
475 * This is the generic lockd callback for async RPC calls 475 * This is the generic lockd callback for async RPC calls
476 */ 476 */
@@ -494,7 +494,7 @@ nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
494 call->a_host = host; 494 call->a_host = host;
495 memcpy(&call->a_args, resp, sizeof(*resp)); 495 memcpy(&call->a_args, resp, sizeof(*resp));
496 496
497 if (nlmsvc_async_call(call, proc, nlm4svc_callback_exit) < 0) 497 if (nlmsvc_async_call(call, proc, &nlm4svc_callback_ops) < 0)
498 goto error; 498 goto error;
499 499
500 return rpc_success; 500 return rpc_success;
@@ -504,10 +504,9 @@ nlm4svc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
504 return rpc_system_err; 504 return rpc_system_err;
505} 505}
506 506
507static void 507static void nlm4svc_callback_exit(struct rpc_task *task, void *data)
508nlm4svc_callback_exit(struct rpc_task *task)
509{ 508{
510 struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; 509 struct nlm_rqst *call = data;
511 510
512 if (task->tk_status < 0) { 511 if (task->tk_status < 0) {
513 dprintk("lockd: %4d callback failed (errno = %d)\n", 512 dprintk("lockd: %4d callback failed (errno = %d)\n",
@@ -517,6 +516,10 @@ nlm4svc_callback_exit(struct rpc_task *task)
517 kfree(call); 516 kfree(call);
518} 517}
519 518
519static const struct rpc_call_ops nlm4svc_callback_ops = {
520 .rpc_call_done = nlm4svc_callback_exit,
521};
522
520/* 523/*
521 * NLM Server procedures. 524 * NLM Server procedures.
522 */ 525 */
diff --git a/fs/lockd/svclock.c b/fs/lockd/svclock.c
index 49f959796b66..87d09a0d8f64 100644
--- a/fs/lockd/svclock.c
+++ b/fs/lockd/svclock.c
@@ -41,7 +41,8 @@
41 41
42static void nlmsvc_insert_block(struct nlm_block *block, unsigned long); 42static void nlmsvc_insert_block(struct nlm_block *block, unsigned long);
43static int nlmsvc_remove_block(struct nlm_block *block); 43static int nlmsvc_remove_block(struct nlm_block *block);
44static void nlmsvc_grant_callback(struct rpc_task *task); 44
45static const struct rpc_call_ops nlmsvc_grant_ops;
45 46
46/* 47/*
47 * The list of blocked locks to retry 48 * The list of blocked locks to retry
@@ -562,7 +563,7 @@ callback:
562 /* Call the client */ 563 /* Call the client */
563 nlm_get_host(block->b_call.a_host); 564 nlm_get_host(block->b_call.a_host);
564 if (nlmsvc_async_call(&block->b_call, NLMPROC_GRANTED_MSG, 565 if (nlmsvc_async_call(&block->b_call, NLMPROC_GRANTED_MSG,
565 nlmsvc_grant_callback) < 0) 566 &nlmsvc_grant_ops) < 0)
566 nlm_release_host(block->b_call.a_host); 567 nlm_release_host(block->b_call.a_host);
567 up(&file->f_sema); 568 up(&file->f_sema);
568} 569}
@@ -575,10 +576,9 @@ callback:
575 * chain once more in order to have it removed by lockd itself (which can 576 * chain once more in order to have it removed by lockd itself (which can
576 * then sleep on the file semaphore without disrupting e.g. the nfs client). 577 * then sleep on the file semaphore without disrupting e.g. the nfs client).
577 */ 578 */
578static void 579static void nlmsvc_grant_callback(struct rpc_task *task, void *data)
579nlmsvc_grant_callback(struct rpc_task *task)
580{ 580{
581 struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; 581 struct nlm_rqst *call = data;
582 struct nlm_block *block; 582 struct nlm_block *block;
583 unsigned long timeout; 583 unsigned long timeout;
584 struct sockaddr_in *peer_addr = RPC_PEERADDR(task->tk_client); 584 struct sockaddr_in *peer_addr = RPC_PEERADDR(task->tk_client);
@@ -614,6 +614,10 @@ nlmsvc_grant_callback(struct rpc_task *task)
614 nlm_release_host(call->a_host); 614 nlm_release_host(call->a_host);
615} 615}
616 616
617static const struct rpc_call_ops nlmsvc_grant_ops = {
618 .rpc_call_done = nlmsvc_grant_callback,
619};
620
617/* 621/*
618 * We received a GRANT_RES callback. Try to find the corresponding 622 * We received a GRANT_RES callback. Try to find the corresponding
619 * block. 623 * block.
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index 757e344cf200..3bc437e0cf5b 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -23,7 +23,8 @@
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 *); 25static u32 nlmsvc_callback(struct svc_rqst *, u32, struct nlm_res *);
26static void nlmsvc_callback_exit(struct rpc_task *); 26
27static const struct rpc_call_ops nlmsvc_callback_ops;
27 28
28#ifdef CONFIG_LOCKD_V4 29#ifdef CONFIG_LOCKD_V4
29static u32 30static u32
@@ -518,7 +519,7 @@ nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
518 call->a_host = host; 519 call->a_host = host;
519 memcpy(&call->a_args, resp, sizeof(*resp)); 520 memcpy(&call->a_args, resp, sizeof(*resp));
520 521
521 if (nlmsvc_async_call(call, proc, nlmsvc_callback_exit) < 0) 522 if (nlmsvc_async_call(call, proc, &nlmsvc_callback_ops) < 0)
522 goto error; 523 goto error;
523 524
524 return rpc_success; 525 return rpc_success;
@@ -528,10 +529,9 @@ nlmsvc_callback(struct svc_rqst *rqstp, u32 proc, struct nlm_res *resp)
528 return rpc_system_err; 529 return rpc_system_err;
529} 530}
530 531
531static void 532static void nlmsvc_callback_exit(struct rpc_task *task, void *data)
532nlmsvc_callback_exit(struct rpc_task *task)
533{ 533{
534 struct nlm_rqst *call = (struct nlm_rqst *) task->tk_calldata; 534 struct nlm_rqst *call = data;
535 535
536 if (task->tk_status < 0) { 536 if (task->tk_status < 0) {
537 dprintk("lockd: %4d callback failed (errno = %d)\n", 537 dprintk("lockd: %4d callback failed (errno = %d)\n",
@@ -541,6 +541,10 @@ nlmsvc_callback_exit(struct rpc_task *task)
541 kfree(call); 541 kfree(call);
542} 542}
543 543
544static const struct rpc_call_ops nlmsvc_callback_ops = {
545 .rpc_call_done = nlmsvc_callback_exit,
546};
547
544/* 548/*
545 * NLM Server procedures. 549 * NLM Server procedures.
546 */ 550 */