Skip to content

Commit 7494d00

Browse files
Trond MyklebustTrond Myklebust
authored andcommitted
SUNRPC: Allow RPC calls to return ETIMEDOUT instead of EIO
On occasion, it is useful for the NFS layer to distinguish between soft timeouts and other EIO errors due to (say) encoding errors, or authentication errors. The following patch ensures that the default behaviour of the RPC layer remains to return EIO on soft timeouts (until we have audited all the callers). Signed-off-by: Trond Myklebust <[email protected]>
1 parent fd954ae commit 7494d00

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

include/linux/sunrpc/sched.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,12 +128,13 @@ struct rpc_task_setup {
128128
#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
129129
#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */
130130
#define RPC_TASK_SENT 0x0800 /* message was sent */
131+
#define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */
131132

132133
#define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC)
133134
#define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER)
134135
#define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS)
135136
#define RPC_ASSASSINATED(t) ((t)->tk_flags & RPC_TASK_KILLED)
136-
#define RPC_IS_SOFT(t) ((t)->tk_flags & RPC_TASK_SOFT)
137+
#define RPC_IS_SOFT(t) ((t)->tk_flags & (RPC_TASK_SOFT|RPC_TASK_TIMEOUT))
137138
#define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN)
138139
#define RPC_WAS_SENT(t) ((t)->tk_flags & RPC_TASK_SENT)
139140

net/sunrpc/clnt.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,10 @@ call_timeout(struct rpc_task *task)
15081508
if (clnt->cl_chatty)
15091509
printk(KERN_NOTICE "%s: server %s not responding, timed out\n",
15101510
clnt->cl_protname, clnt->cl_server);
1511-
rpc_exit(task, -EIO);
1511+
if (task->tk_flags & RPC_TASK_TIMEOUT)
1512+
rpc_exit(task, -ETIMEDOUT);
1513+
else
1514+
rpc_exit(task, -EIO);
15121515
return;
15131516
}
15141517

0 commit comments

Comments
 (0)