Commit 7a72fa16 authored by Trond Myklebust's avatar Trond Myklebust Committed by Linus Torvalds

[PATCH] Clean up the RPC socket slot allocation code [1/2]

Another patch by Chuck Lever. Fixes up some nasty logic in
call_reserveresult().
parent be6dd3ef
...@@ -419,38 +419,53 @@ call_reserveresult(struct rpc_task *task) ...@@ -419,38 +419,53 @@ call_reserveresult(struct rpc_task *task)
dprintk("RPC: %4d call_reserveresult (status %d)\n", dprintk("RPC: %4d call_reserveresult (status %d)\n",
task->tk_pid, task->tk_status); task->tk_pid, task->tk_status);
/* /*
* After a call to xprt_reserve(), we must have either * After a call to xprt_reserve(), we must have either
* a request slot or else an error status. * a request slot or else an error status.
*/ */
if ((task->tk_status >= 0 && !task->tk_rqstp) || task->tk_status = 0;
(task->tk_status < 0 && task->tk_rqstp)) if (status >= 0) {
printk(KERN_ERR "call_reserveresult: status=%d, request=%p??\n", if (task->tk_rqstp) {
task->tk_status, task->tk_rqstp); task->tk_action = call_allocate;
return;
}
if (task->tk_status >= 0) { printk(KERN_ERR "%s: status=%d, but no request slot, exiting\n",
task->tk_action = call_allocate; __FUNCTION__, status);
rpc_exit(task, -EIO);
return; return;
} }
task->tk_status = 0; /*
* Even though there was an error, we may have acquired
* a request slot somehow. Make sure not to leak it.
*/
if (task->tk_rqstp) {
printk(KERN_ERR "%s: status=%d, request allocated anyway\n",
__FUNCTION__, status);
xprt_release(task);
}
switch (status) { switch (status) {
case -EAGAIN: case -EAGAIN:
case -ENOBUFS: case -ENOBUFS:
task->tk_timeout = task->tk_client->cl_timeout.to_resrvval; task->tk_timeout = task->tk_client->cl_timeout.to_resrvval;
task->tk_action = call_reserve; task->tk_action = call_reserve;
break; return;
case -ETIMEDOUT: case -ETIMEDOUT:
dprintk("RPC: task timed out\n"); dprintk("RPC: timed out while reserving request slot\n");
task->tk_action = call_timeout; task->tk_action = call_timeout;
return;
case -EIO:
/* probably a shutdown */
break; break;
default: default:
if (!task->tk_rqstp) { printk(KERN_ERR "%s: unrecognized error %d, exiting\n",
printk(KERN_INFO "RPC: task has no request, exit EIO\n"); __FUNCTION__, status);
rpc_exit(task, -EIO); break;
} else
rpc_exit(task, status);
} }
rpc_exit(task, status);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment