aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2007-06-12 10:02:37 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2007-07-10 23:40:30 -0400
commit6e5b70e9d1e712d8dad5514e0ab5240ac4b5fb57 (patch)
treecb6c293dd5adf1b966dcd5681649fafc690fd053
parent188fef11db219f13f32d055ba59985e7d1a349fe (diff)
SUNRPC: clean up rpc_call_async/rpc_call_sync/rpc_run_task
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--net/sunrpc/clnt.c115
-rw-r--r--net/sunrpc/sched.c23
2 files changed, 69 insertions, 69 deletions
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 4f39ab1b04d6..76eef19cf995 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -474,73 +474,96 @@ void rpc_clnt_sigunmask(struct rpc_clnt *clnt, sigset_t *oldset)
474 rpc_restore_sigmask(oldset); 474 rpc_restore_sigmask(oldset);
475} 475}
476 476
477/* 477static
478 * New rpc_call implementation 478struct rpc_task *rpc_do_run_task(struct rpc_clnt *clnt,
479 struct rpc_message *msg,
480 int flags,
481 const struct rpc_call_ops *ops,
482 void *data)
483{
484 struct rpc_task *task, *ret;
485 sigset_t oldset;
486
487 task = rpc_new_task(clnt, flags, ops, data);
488 if (task == NULL) {
489 rpc_release_calldata(ops, data);
490 return ERR_PTR(-ENOMEM);
491 }
492
493 /* Mask signals on synchronous RPC calls and RPCSEC_GSS upcalls */
494 rpc_task_sigmask(task, &oldset);
495 if (msg != NULL) {
496 rpc_call_setup(task, msg, 0);
497 if (task->tk_status != 0) {
498 ret = ERR_PTR(task->tk_status);
499 rpc_put_task(task);
500 goto out;
501 }
502 }
503 atomic_inc(&task->tk_count);
504 rpc_execute(task);
505 ret = task;
506out:
507 rpc_restore_sigmask(&oldset);
508 return ret;
509}
510
511/**
512 * rpc_call_sync - Perform a synchronous RPC call
513 * @clnt: pointer to RPC client
514 * @msg: RPC call parameters
515 * @flags: RPC call flags
479 */ 516 */
480int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags) 517int rpc_call_sync(struct rpc_clnt *clnt, struct rpc_message *msg, int flags)
481{ 518{
482 struct rpc_task *task; 519 struct rpc_task *task;
483 sigset_t oldset; 520 int status;
484 int status;
485 521
486 BUG_ON(flags & RPC_TASK_ASYNC); 522 BUG_ON(flags & RPC_TASK_ASYNC);
487 523
488 task = rpc_new_task(clnt, flags, &rpc_default_ops, NULL); 524 task = rpc_do_run_task(clnt, msg, flags, &rpc_default_ops, NULL);
489 if (task == NULL) 525 if (IS_ERR(task))
490 return -ENOMEM; 526 return PTR_ERR(task);
491
492 /* Mask signals on RPC calls _and_ GSS_AUTH upcalls */
493 rpc_task_sigmask(task, &oldset);
494
495 /* Set up the call info struct and execute the task */
496 rpc_call_setup(task, msg, 0);
497 if (task->tk_status == 0) {
498 atomic_inc(&task->tk_count);
499 rpc_execute(task);
500 }
501 status = task->tk_status; 527 status = task->tk_status;
502 rpc_put_task(task); 528 rpc_put_task(task);
503 rpc_restore_sigmask(&oldset);
504 return status; 529 return status;
505} 530}
506 531
507/* 532/**
508 * New rpc_call implementation 533 * rpc_call_async - Perform an asynchronous RPC call
534 * @clnt: pointer to RPC client
535 * @msg: RPC call parameters
536 * @flags: RPC call flags
537 * @ops: RPC call ops
538 * @data: user call data
509 */ 539 */
510int 540int
511rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags, 541rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
512 const struct rpc_call_ops *tk_ops, void *data) 542 const struct rpc_call_ops *tk_ops, void *data)
513{ 543{
514 struct rpc_task *task; 544 struct rpc_task *task;
515 sigset_t oldset;
516 int status;
517
518 flags |= RPC_TASK_ASYNC;
519
520 /* Create/initialize a new RPC task */
521 status = -ENOMEM;
522 if (!(task = rpc_new_task(clnt, flags, tk_ops, data)))
523 goto out_release;
524
525 /* Mask signals on GSS_AUTH upcalls */
526 rpc_task_sigmask(task, &oldset);
527
528 rpc_call_setup(task, msg, 0);
529
530 /* Set up the call info struct and execute the task */
531 status = task->tk_status;
532 if (status == 0)
533 rpc_execute(task);
534 else
535 rpc_put_task(task);
536 545
537 rpc_restore_sigmask(&oldset); 546 task = rpc_do_run_task(clnt, msg, flags|RPC_TASK_ASYNC, tk_ops, data);
538 return status; 547 if (IS_ERR(task))
539out_release: 548 return PTR_ERR(task);
540 rpc_release_calldata(tk_ops, data); 549 rpc_put_task(task);
541 return status; 550 return 0;
542} 551}
543 552
553/**
554 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
555 * @clnt: pointer to RPC client
556 * @flags: RPC flags
557 * @ops: RPC call ops
558 * @data: user call data
559 */
560struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
561 const struct rpc_call_ops *tk_ops,
562 void *data)
563{
564 return rpc_do_run_task(clnt, NULL, flags, tk_ops, data);
565}
566EXPORT_SYMBOL(rpc_run_task);
544 567
545void 568void
546rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags) 569rpc_call_setup(struct rpc_task *task, struct rpc_message *msg, int flags)
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index c0f8d25caf57..2ac43c41c3a9 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -933,29 +933,6 @@ static void rpc_release_task(struct rpc_task *task)
933 rpc_put_task(task); 933 rpc_put_task(task);
934} 934}
935 935
936/**
937 * rpc_run_task - Allocate a new RPC task, then run rpc_execute against it
938 * @clnt: pointer to RPC client
939 * @flags: RPC flags
940 * @ops: RPC call ops
941 * @data: user call data
942 */
943struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
944 const struct rpc_call_ops *ops,
945 void *data)
946{
947 struct rpc_task *task;
948 task = rpc_new_task(clnt, flags, ops, data);
949 if (task == NULL) {
950 rpc_release_calldata(ops, data);
951 return ERR_PTR(-ENOMEM);
952 }
953 atomic_inc(&task->tk_count);
954 rpc_execute(task);
955 return task;
956}
957EXPORT_SYMBOL(rpc_run_task);
958
959/* 936/*
960 * Kill all tasks for the given client. 937 * Kill all tasks for the given client.
961 * XXX: kill their descendants as well? 938 * XXX: kill their descendants as well?