Skip to content

Commit

Permalink
sunrpc: fix loss of task->tk_status after rpc_delay call in xprt_allo…
Browse files Browse the repository at this point in the history
…c_slot

xprt_alloc_slot will call rpc_delay() to make the task wait a bit before
retrying when it gets back an -ENOMEM error from xprt_dynamic_alloc_slot.
The problem is that rpc_delay will clear the task->tk_status, causing
call_reserveresult to abort the task.

The solution is simply to let call_reserveresult handle the ENOMEM error
directly.

Reported-by: Jeff Layton <jlayton@redhat.com>
Cc: stable@vger.kernel.org [>= 3.1]
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed May 19, 2012
1 parent 6b34309 commit 1afeaf5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions net/sunrpc/clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1288,6 +1288,8 @@ call_reserveresult(struct rpc_task *task)
}

switch (status) {
case -ENOMEM:
rpc_delay(task, HZ >> 2);
case -EAGAIN: /* woken up; retry */
task->tk_action = call_reserve;
return;
Expand Down
5 changes: 3 additions & 2 deletions net/sunrpc/xprt.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,15 +984,16 @@ static void xprt_alloc_slot(struct rpc_task *task)
goto out_init_req;
switch (PTR_ERR(req)) {
case -ENOMEM:
rpc_delay(task, HZ >> 2);
dprintk("RPC: dynamic allocation of request slot "
"failed! Retrying\n");
task->tk_status = -ENOMEM;
break;
case -EAGAIN:
rpc_sleep_on(&xprt->backlog, task, NULL);
dprintk("RPC: waiting for request slot\n");
default:
task->tk_status = -EAGAIN;
}
task->tk_status = -EAGAIN;
return;
out_init_req:
task->tk_status = 0;
Expand Down

0 comments on commit 1afeaf5

Please sign in to comment.