aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 18:11:10 -0500
committerTrond Myklebust <Trond.Myklebust@netapp.com>2006-03-20 18:11:10 -0500
commit7a1218a277c45cba1fb8d7089407a1769c645c43 (patch)
treec59634979c53606696993ef06297045015791d6e
parent43ac3f2961b8616da26114ec6dc76ac2a61f76ad (diff)
SUNRPC: Ensure rpc_call_async() always calls tk_ops->rpc_release()
Currently this will not happen if we exit before rpc_new_task() was called. Also fix up rpc_run_task() to do the same (for consistency). Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
-rw-r--r--fs/nfs/nfs4proc.c32
-rw-r--r--net/sunrpc/clnt.c10
-rw-r--r--net/sunrpc/sched.c5
3 files changed, 26 insertions, 21 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 02c7d8c04c58..4aba15ad1d27 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -605,11 +605,14 @@ static int _nfs4_proc_open_confirm(struct nfs4_opendata *data)
605 int status; 605 int status;
606 606
607 atomic_inc(&data->count); 607 atomic_inc(&data->count);
608 /*
609 * If rpc_run_task() ends up calling ->rpc_release(), we
610 * want to ensure that it takes the 'error' code path.
611 */
612 data->rpc_status = -ENOMEM;
608 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data); 613 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_confirm_ops, data);
609 if (IS_ERR(task)) { 614 if (IS_ERR(task))
610 nfs4_opendata_free(data);
611 return PTR_ERR(task); 615 return PTR_ERR(task);
612 }
613 status = nfs4_wait_for_completion_rpc_task(task); 616 status = nfs4_wait_for_completion_rpc_task(task);
614 if (status != 0) { 617 if (status != 0) {
615 data->cancelled = 1; 618 data->cancelled = 1;
@@ -708,11 +711,14 @@ static int _nfs4_proc_open(struct nfs4_opendata *data)
708 int status; 711 int status;
709 712
710 atomic_inc(&data->count); 713 atomic_inc(&data->count);
714 /*
715 * If rpc_run_task() ends up calling ->rpc_release(), we
716 * want to ensure that it takes the 'error' code path.
717 */
718 data->rpc_status = -ENOMEM;
711 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data); 719 task = rpc_run_task(server->client, RPC_TASK_ASYNC, &nfs4_open_ops, data);
712 if (IS_ERR(task)) { 720 if (IS_ERR(task))
713 nfs4_opendata_free(data);
714 return PTR_ERR(task); 721 return PTR_ERR(task);
715 }
716 status = nfs4_wait_for_completion_rpc_task(task); 722 status = nfs4_wait_for_completion_rpc_task(task);
717 if (status != 0) { 723 if (status != 0) {
718 data->cancelled = 1; 724 data->cancelled = 1;
@@ -2959,10 +2965,8 @@ static int _nfs4_proc_delegreturn(struct inode *inode, struct rpc_cred *cred, co
2959 data->rpc_status = 0; 2965 data->rpc_status = 0;
2960 2966
2961 task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data); 2967 task = rpc_run_task(NFS_CLIENT(inode), RPC_TASK_ASYNC, &nfs4_delegreturn_ops, data);
2962 if (IS_ERR(task)) { 2968 if (IS_ERR(task))
2963 nfs4_delegreturn_release(data);
2964 return PTR_ERR(task); 2969 return PTR_ERR(task);
2965 }
2966 status = nfs4_wait_for_completion_rpc_task(task); 2970 status = nfs4_wait_for_completion_rpc_task(task);
2967 if (status == 0) { 2971 if (status == 0) {
2968 status = data->rpc_status; 2972 status = data->rpc_status;
@@ -3182,7 +3186,6 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3182 struct nfs_seqid *seqid) 3186 struct nfs_seqid *seqid)
3183{ 3187{
3184 struct nfs4_unlockdata *data; 3188 struct nfs4_unlockdata *data;
3185 struct rpc_task *task;
3186 3189
3187 data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid); 3190 data = nfs4_alloc_unlockdata(fl, ctx, lsp, seqid);
3188 if (data == NULL) { 3191 if (data == NULL) {
@@ -3192,10 +3195,7 @@ static struct rpc_task *nfs4_do_unlck(struct file_lock *fl,
3192 3195
3193 /* Unlock _before_ we do the RPC call */ 3196 /* Unlock _before_ we do the RPC call */
3194 do_vfs_lock(fl->fl_file, fl); 3197 do_vfs_lock(fl->fl_file, fl);
3195 task = rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data); 3198 return rpc_run_task(NFS_CLIENT(lsp->ls_state->inode), RPC_TASK_ASYNC, &nfs4_locku_ops, data);
3196 if (IS_ERR(task))
3197 nfs4_locku_release_calldata(data);
3198 return task;
3199} 3199}
3200 3200
3201static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request) 3201static int nfs4_proc_unlck(struct nfs4_state *state, int cmd, struct file_lock *request)
@@ -3376,10 +3376,8 @@ static int _nfs4_do_setlk(struct nfs4_state *state, int cmd, struct file_lock *f
3376 data->arg.reclaim = 1; 3376 data->arg.reclaim = 1;
3377 task = rpc_run_task(NFS_CLIENT(state->inode), RPC_TASK_ASYNC, 3377 task = rpc_run_task(NFS_CLIENT(state->inode), RPC_TASK_ASYNC,
3378 &nfs4_lock_ops, data); 3378 &nfs4_lock_ops, data);
3379 if (IS_ERR(task)) { 3379 if (IS_ERR(task))
3380 nfs4_lock_release(data);
3381 return PTR_ERR(task); 3380 return PTR_ERR(task);
3382 }
3383 ret = nfs4_wait_for_completion_rpc_task(task); 3381 ret = nfs4_wait_for_completion_rpc_task(task);
3384 if (ret == 0) { 3382 if (ret == 0) {
3385 ret = data->rpc_status; 3383 ret = data->rpc_status;
diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
index 6e71d6ace5a3..aa8965e9d307 100644
--- a/net/sunrpc/clnt.c
+++ b/net/sunrpc/clnt.c
@@ -495,15 +495,16 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
495 int status; 495 int status;
496 496
497 /* If this client is slain all further I/O fails */ 497 /* If this client is slain all further I/O fails */
498 status = -EIO;
498 if (clnt->cl_dead) 499 if (clnt->cl_dead)
499 return -EIO; 500 goto out_release;
500 501
501 flags |= RPC_TASK_ASYNC; 502 flags |= RPC_TASK_ASYNC;
502 503
503 /* Create/initialize a new RPC task */ 504 /* Create/initialize a new RPC task */
504 status = -ENOMEM; 505 status = -ENOMEM;
505 if (!(task = rpc_new_task(clnt, flags, tk_ops, data))) 506 if (!(task = rpc_new_task(clnt, flags, tk_ops, data)))
506 goto out; 507 goto out_release;
507 508
508 /* Mask signals on GSS_AUTH upcalls */ 509 /* Mask signals on GSS_AUTH upcalls */
509 rpc_task_sigmask(task, &oldset); 510 rpc_task_sigmask(task, &oldset);
@@ -518,7 +519,10 @@ rpc_call_async(struct rpc_clnt *clnt, struct rpc_message *msg, int flags,
518 rpc_release_task(task); 519 rpc_release_task(task);
519 520
520 rpc_restore_sigmask(&oldset); 521 rpc_restore_sigmask(&oldset);
521out: 522 return status;
523out_release:
524 if (tk_ops->rpc_release != NULL)
525 tk_ops->rpc_release(data);
522 return status; 526 return status;
523} 527}
524 528
diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
index cd51b5468332..3fc13bea302d 100644
--- a/net/sunrpc/sched.c
+++ b/net/sunrpc/sched.c
@@ -921,8 +921,11 @@ struct rpc_task *rpc_run_task(struct rpc_clnt *clnt, int flags,
921{ 921{
922 struct rpc_task *task; 922 struct rpc_task *task;
923 task = rpc_new_task(clnt, flags, ops, data); 923 task = rpc_new_task(clnt, flags, ops, data);
924 if (task == NULL) 924 if (task == NULL) {
925 if (ops->rpc_release != NULL)
926 ops->rpc_release(data);
925 return ERR_PTR(-ENOMEM); 927 return ERR_PTR(-ENOMEM);
928 }
926 atomic_inc(&task->tk_count); 929 atomic_inc(&task->tk_count);
927 rpc_execute(task); 930 rpc_execute(task);
928 return task; 931 return task;