Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <Trond.Myklebust@netapp.com>

+6 -2
+2 -1
include/linux/sunrpc/sched.h
··· 128 128 #define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ 129 129 #define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */ 130 130 #define RPC_TASK_SENT 0x0800 /* message was sent */ 131 + #define RPC_TASK_TIMEOUT 0x1000 /* fail with ETIMEDOUT on timeout */ 131 132 132 133 #define RPC_IS_ASYNC(t) ((t)->tk_flags & RPC_TASK_ASYNC) 133 134 #define RPC_IS_SWAPPER(t) ((t)->tk_flags & RPC_TASK_SWAPPER) 134 135 #define RPC_DO_ROOTOVERRIDE(t) ((t)->tk_flags & RPC_TASK_ROOTCREDS) 135 136 #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)) 137 138 #define RPC_IS_SOFTCONN(t) ((t)->tk_flags & RPC_TASK_SOFTCONN) 138 139 #define RPC_WAS_SENT(t) ((t)->tk_flags & RPC_TASK_SENT) 139 140
+4 -1
net/sunrpc/clnt.c
··· 1508 1508 if (clnt->cl_chatty) 1509 1509 printk(KERN_NOTICE "%s: server %s not responding, timed out\n", 1510 1510 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); 1512 1515 return; 1513 1516 } 1514 1517