aboutsummaryrefslogtreecommitdiffstats
path: root/fs/lockd/clntproc.c
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/clntproc.c
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/clntproc.c')
-rw-r--r--fs/lockd/clntproc.c38
1 files changed, 21 insertions, 17 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 */