aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-14 15:39:59 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2008-01-30 02:05:30 -0500
commitc970aa85e71bd581726c42df843f6f129db275ac (patch)
treee7fc90ee4064196d357045fd173764e0b8fc8ca8
parent84115e1cd4a3614c4e566d4cce31381dce3dbef9 (diff)
SUNRPC: Clean up rpc_run_task
Make it use the new task initialiser structure instead of acting as a wrapper. Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4proc.c49
-rw-r--r--fs/nfs/unlink.c9
-rw-r--r--include/linux/sunrpc/sched.h3
-rw-r--r--net/sunrpc/clnt.c36
-rw-r--r--net/sunrpc/rpcb_clnt.c8
5 files changed, 67 insertions, 38 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index a51a7537f3f6..ff2c5f83ce87 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -779,12 +779,18 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
779{ 779{
780 struct nfs_server *server = NFS_SERVER(data->dir->d_inode); 780 struct nfs_server *server = NFS_SERVER(data->dir->d_inode);
781 struct rpc_task *task; 781 struct rpc_task *task;
782 struct rpc_task_setup task_setup_data = {
783 .rpc_client = server->client,
784 .callback_ops = &nfs4_open_confirm_ops,
785 .callback_data = data,
786 .flags = RPC_TASK_ASYNC,
787 };
782 int status; 788 int status;
783 789
784 kref_get(&data->kref); 790 kref_get(&data->kref);
785 data->rpc_done = 0; 791 data->rpc_done = 0;
786 data->rpc_status = 0; 792 data->rpc_status = 0;
787 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data); 793 task = rpc_run_task(&task_setup_data);
788 if (IS_ERR(task)) 794 if (IS_ERR(task))
789 return PTR_ERR(task); 795 return PTR_ERR(task);
790 status = nfs4_wait_for_completion_rpc_task(task); 796 status = nfs4_wait_for_completion_rpc_task(task);
@@ -908,13 +914,19 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
908 struct nfs_openargs *o_arg = &data->o_arg; 914 struct nfs_openargs *o_arg = &data->o_arg;
909 struct nfs_openres *o_res = &data->o_res; 915 struct nfs_openres *o_res = &data->o_res;
910 struct rpc_task *task; 916 struct rpc_task *task;
917 struct rpc_task_setup task_setup_data = {
918 .rpc_client = server->client,
919 .callback_ops = &nfs4_open_ops,
920 .callback_data = data,
921 .flags = RPC_TASK_ASYNC,
922 };
911 int status; 923 int status;
912 924
913 kref_get(&data->kref); 925 kref_get(&data->kref);
914 data->rpc_done = 0; 926 data->rpc_done = 0;
915 data->rpc_status = 0; 927 data->rpc_status = 0;
916 data->cancelled = 0; 928 data->cancelled = 0;
917 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data); 929 task = rpc_run_task(&task_setup_data);
918 if (IS_ERR(task)) 930 if (IS_ERR(task))
919 return PTR_ERR(task); 931 return PTR_ERR(task);
920 status = nfs4_wait_for_completion_rpc_task(task); 932 status = nfs4_wait_for_completion_rpc_task(task);
@@ -1309,6 +1321,11 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
1309 struct nfs4_closedata *calldata; 1321 struct nfs4_closedata *calldata;
1310 struct nfs4_state_owner *sp = state->owner; 1322 struct nfs4_state_owner *sp = state->owner;
1311 struct rpc_task *task; 1323 struct rpc_task *task;
1324 struct rpc_task_setup task_setup_data = {
1325 .rpc_client = server->client,
1326 .callback_ops = &nfs4_close_ops,
1327 .flags = RPC_TASK_ASYNC,
1328 };
1312 int status = -ENOMEM; 1329 int status = -ENOMEM;
1313 1330
1314 calldata = kmalloc(sizeof(*calldata), GFP_KERNEL); 1331 calldata = kmalloc(sizeof(*calldata), GFP_KERNEL);
@@ -1328,7 +1345,8 @@ int nfs4_do_close(struct path *path, struct nfs4_state *state, int wait)
1328 calldata->path.mnt = mntget(path->mnt); 1345 calldata->path.mnt = mntget(path->mnt);
1329 calldata->path.dentry = dget(path->dentry); 1346 calldata->path.dentry = dget(path->dentry);
1330 1347
1331 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_close_ops, calldata); 1348 task_setup_data.callback_data = calldata;
1349 task = rpc_run_task(&task_setup_data);
1332 if (IS_ERR(task)) 1350 if (IS_ERR(task))
1333 return PTR_ERR(task); 1351 return PTR_ERR(task);
1334 status = 0; 1352 status = 0;
@@ -3027,6 +3045,11 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
3027 struct nfs4_delegreturndata *data; 3045 struct nfs4_delegreturndata *data;
3028 struct nfs_server *server = NFS_SERVER(inode); 3046 struct nfs_server *server = NFS_SERVER(inode);
3029 struct rpc_task *task; 3047 struct rpc_task *task;
3048 struct rpc_task_setup task_setup_data = {
3049 .rpc_client = server->client,
3050 .callback_ops = &nfs4_delegreturn_ops,
3051 .flags = RPC_TASK_ASYNC,
3052 };
3030 int status; 3053 int status;
3031 3054
3032 data = kmalloc(sizeof(*data), GFP_KERNEL); 3055 data = kmalloc(sizeof(*data), GFP_KERNEL);
@@ -3043,7 +3066,8 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
3043 data->timestamp = jiffies; 3066 data->timestamp = jiffies;
3044 data->rpc_status = 0; 3067 data->rpc_status = 0;
3045 3068
3046 task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); 3069 task_setup_data.callback_data = data;
3070 task = rpc_run_task(&task_setup_data);
3047 if (IS_ERR(task)) 3071 if (IS_ERR(task))
3048 return PTR_ERR(task); 3072 return PTR_ERR(task);
3049 status = nfs4_wait_for_completion_rpc_task(task); 3073 status = nfs4_wait_for_completion_rpc_task(task);
@@ -3260,6 +3284,11 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3260 struct nfs_seqid *seqid) 3284 struct nfs_seqid *seqid)
3261{ 3285{
3262 struct nfs4_unlockdata *data; 3286 struct nfs4_unlockdata *data;
3287 struct rpc_task_setup task_setup_data = {
3288 .rpc_client = NFS_CLIENT(lsp->ls_state->inode),
3289 .callback_ops = &nfs4_locku_ops,
3290 .flags = RPC_TASK_ASYNC,
3291 };
3263 3292
3264 /* Ensure this is an unlock - when canceling a lock, the 3293 /* Ensure this is an unlock - when canceling a lock, the
3265 * canceled lock is passed in, and it won't be an unlock. 3294 * canceled lock is passed in, and it won't be an unlock.
@@ -3272,7 +3301,8 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3272 return ERR_PTR(-ENOMEM); 3301 return ERR_PTR(-ENOMEM);
3273 } 3302 }
3274 3303
3275 return rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data); 3304 task_setup_data.callback_data = data;
3305 return rpc_run_task(&task_setup_data);
3276} 3306}
3277 3307
3278static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) 3308static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
@@ -3438,6 +3468,11 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3438{ 3468{
3439 struct nfs4_lockdata *data; 3469 struct nfs4_lockdata *data;
3440 struct rpc_task *task; 3470 struct rpc_task *task;
3471 struct rpc_task_setup task_setup_data = {
3472 .rpc_client = NFS_CLIENT(state->inode),
3473 .callback_ops = &nfs4_lock_ops,
3474 .flags = RPC_TASK_ASYNC,
3475 };
3441 int ret; 3476 int ret;
3442 3477
3443 dprintk("%s: begin!\n", __FUNCTION__); 3478 dprintk("%s: begin!\n", __FUNCTION__);
@@ -3449,8 +3484,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3449 data->arg.block = 1; 3484 data->arg.block = 1;
3450 if (reclaim != 0) 3485 if (reclaim != 0)
3451 data->arg.reclaim = 1; 3486 data->arg.reclaim = 1;
3452 task = rpc_run_task(NFS_CLIENT(state->inode), RPC_TASK_ASYNC, 3487 task_setup_data.callback_data = data;
3453 &nfs4_lock_ops, data); 3488 task = rpc_run_task(&task_setup_data);
3454 if (IS_ERR(task)) 3489 if (IS_ERR(task))
3455 return PTR_ERR(task); 3490 return PTR_ERR(task);
3456 ret = nfs4_wait_for_completion_rpc_task(task); 3491 ret = nfs4_wait_for_completion_rpc_task(task);
diff --git a/fs/nfs/unlink.c b/fs/nfs/unlink.c
index 8e5428e0b86f..6660d9a53345 100644
--- a/fs/nfs/unlink.c
+++ b/fs/nfs/unlink.c
@@ -127,6 +127,11 @@ static const struct rpc_call_ops nfs_unlink_ops = {
127 127
128static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct nfs_unlinkdata *data) 128static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct nfs_unlinkdata *data)
129{ 129{
130 struct rpc_task_setup task_setup_data = {
131 .callback_ops = &nfs_unlink_ops,
132 .callback_data = data,
133 .flags = RPC_TASK_ASYNC,
134 };
130 struct rpc_task *task; 135 struct rpc_task *task;
131 struct dentry *alias; 136 struct dentry *alias;
132 137
@@ -160,7 +165,9 @@ static int nfs_do_call_unlink(struct dentry *parent, struct inode *dir, struct n
160 data->args.fh = NFS_FH(dir); 165 data->args.fh = NFS_FH(dir);
161 nfs_fattr_init(&data->res.dir_attr); 166 nfs_fattr_init(&data->res.dir_attr);
162 167
163 task = rpc_run_task(NFS_CLIENT(dir), RPC_TASK_ASYNC, &nfs_unlink_ops, data); 168 task_setup_data.rpc_client = NFS_CLIENT(dir);
169
170 task = rpc_run_task(&task_setup_data);
164 if (!IS_ERR(task)) 171 if (!IS_ERR(task))
165 rpc_put_task(task); 172 rpc_put_task(task);
166 return 1; 173 return 1;
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 9efe045fc376..d974421d7647 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -244,8 +244,7 @@ struct rpc_wait_queue {
244 * Function prototypes 244 * Function prototypes
245 */ 245 */
246struct rpc_task *rpc_new_task(const struct rpc_task_setup *); 246struct rpc_task *rpc_new_task(const struct rpc_task_setup *);
247struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags, 247struct rpc_task *rpc_run_task(const struct rpc_task_setup *);
248 const struct rpc_call_ops *ops, void *data);
249void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *); 248void rpc_init_task(struct rpc_task *task, const struct rpc_task_setup *);
250void rpc_put_task(struct rpc_task *); 249void rpc_put_task(struct rpc_task *);
251void rpc_exit_task(struct rpc_task *); 250void rpc_exit_task(struct rpc_task *);
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 7c80abd9263f..9aad45946d32 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -523,8 +523,11 @@ void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset)
523} 523}
524EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask); 524EXPORT_SYMBOL_GPL(rpc_clnt_sigunmask);
525 525
526static 526/**
527struct rpc_task *rpc_do_run_task(const struct rpc_task_setup *task_setup_data) 527 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
528 * @task_setup_data: pointer to task initialisation data
529 */
530struct rpc_task *rpc_run_task(const struct rpc_task_setup *task_setup_data)
528{ 531{
529 struct rpc_task *task, *ret; 532 struct rpc_task *task, *ret;
530 sigset_t oldset; 533 sigset_t oldset;
@@ -553,6 +556,7 @@ out:
553 rpc_restore_sigmask(&oldset); 556 rpc_restore_sigmask(&oldset);
554 return ret; 557 return ret;
555} 558}
559EXPORT_SYMBOL_GPL(rpc_run_task);
556 560
557/** 561/**
558 * rpc_call_sync - Perform a synchronous RPC call 562 * rpc_call_sync - Perform a synchronous RPC call
@@ -573,7 +577,7 @@ int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
573 577
574 BUG_ON(flags & RPC_TASK_ASYNC); 578 BUG_ON(flags & RPC_TASK_ASYNC);
575 579
576 task = rpc_do_run_task(&task_setup_data); 580 task = rpc_run_task(&task_setup_data);
577 if (IS_ERR(task)) 581 if (IS_ERR(task))
578 return PTR_ERR(task); 582 return PTR_ERR(task);
579 status = task->tk_status; 583 status = task->tk_status;
@@ -603,7 +607,7 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
603 .flags = flags|RPC_TASK_ASYNC, 607 .flags = flags|RPC_TASK_ASYNC,
604 }; 608 };
605 609
606 task = rpc_do_run_task(&task_setup_data); 610 task = rpc_run_task(&task_setup_data);
607 if (IS_ERR(task)) 611 if (IS_ERR(task))
608 return PTR_ERR(task); 612 return PTR_ERR(task);
609 rpc_put_task(task); 613 rpc_put_task(task);
@@ -611,28 +615,6 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
611} 615}
612EXPORT_SYMBOL_GPL(rpc_call_async); 616EXPORT_SYMBOL_GPL(rpc_call_async);
613 617
614/**
615 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
616 * @clnt: pointer to RPC client
617 * @flags: RPC flags
618 * @ops: RPC call ops
619 * @data: user call data
620 */
621struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
622 const struct rpc_call_ops *tk_ops,
623 void *data)
624{
625 struct rpc_task_setup task_setup_data = {
626 .rpc_client = clnt,
627 .callback_ops = tk_ops,
628 .callback_data = data,
629 .flags = flags,
630 };
631
632 return rpc_do_run_task(&task_setup_data);
633}
634EXPORT_SYMBOL_GPL(rpc_run_task);
635
636void 618void
637rpc_call_setup(struct rpc_task *task, const struct rpc_message *msg, int flags) 619rpc_call_setup(struct rpc_task *task, const struct rpc_message *msg, int flags)
638{ 620{
@@ -1550,7 +1532,7 @@ struct rpc_task *rpc_call_null(struct rpc_clnt *clnt, struct rpc_cred *cred, int
1550 .callback_ops = &rpc_default_ops, 1532 .callback_ops = &rpc_default_ops,
1551 .flags = flags, 1533 .flags = flags,
1552 }; 1534 };
1553 return rpc_do_run_task(&task_setup_data); 1535 return rpc_run_task(&task_setup_data);
1554} 1536}
1555EXPORT_SYMBOL_GPL(rpc_call_null); 1537EXPORT_SYMBOL_GPL(rpc_call_null);
1556 1538
diff --git a/net/sunrpc/rpcb_clnt.c b/net/sunrpc/rpcb_clnt.c
index a05493aedb68..7c362e5f6e1b 100644
--- a/net/sunrpc/rpcb_clnt.c
+++ b/net/sunrpc/rpcb_clnt.c
@@ -310,6 +310,10 @@ void rpcb_getport_async(struct rpc_task *task)
310 struct rpc_clnt *rpcb_clnt; 310 struct rpc_clnt *rpcb_clnt;
311 static struct rpcbind_args *map; 311 static struct rpcbind_args *map;
312 struct rpc_task *child; 312 struct rpc_task *child;
313 struct rpc_task_setup task_setup_data = {
314 .callback_ops = &rpcb_getport_ops,
315 .flags = RPC_TASK_ASYNC,
316 };
313 struct sockaddr addr; 317 struct sockaddr addr;
314 int status; 318 int status;
315 struct rpcb_info *info; 319 struct rpcb_info *info;
@@ -395,7 +399,9 @@ void rpcb_getport_async(struct rpc_task *task)
395 sizeof(map->r_addr)); 399 sizeof(map->r_addr));
396 map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */ 400 map->r_owner = RPCB_OWNER_STRING; /* ignored for GETADDR */
397 401
398 child = rpc_run_task(rpcb_clnt, RPC_TASK_ASYNC, &rpcb_getport_ops, map); 402 task_setup_data.rpc_client = rpcb_clnt;
403 task_setup_data.callback_data = map;
404 child = rpc_run_task(&task_setup_data);
399 rpc_release_client(rpcb_clnt); 405 rpc_release_client(rpcb_clnt);
400 if (IS_ERR(child)) { 406 if (IS_ERR(child)) {
401 status = -EIO; 407 status = -EIO;