NFSv4.1: fix handling of backchannel binding in BIND_CONN_TO_SESSION
Subsystems (2)
PATCH 1/1 NFSv4.1: fix handling of backchannel binding in BIND_CONN_TO_SESSION
Currently, if the client sends BIND_CONN_TO_SESSION with NFS4_CDFC4_FORE_OR_BOTH but only gets NFS4_CDFS4_FORE back it ignores that it wasn't able to enable a backchannel.
To make sure, the client sends BIND_CONN_TO_SESSION as the first operation on the connections (ie., no other session compounds haven't been sent before), and if the client's request to bind the backchannel is not satisfied, then reset the connection and retry.
--- fs/nfs/nfs4proc.c | 6 ++++++ include/linux/sunrpc/clnt.h | 5 +++++ 2 files changed, 11 insertions(+)
fs/nfs/nfs4proc.c +6 -0
@@ -7891,6 +7891,7 @@ static int nfs4_check_cl_exchange_flags(u32 flags) nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata) { struct nfs41_bind_conn_to_session_args *args = task->tk_msg.rpc_argp; +struct nfs41_bind_conn_to_session_res *res = task->tk_msg.rpc_resp;struct nfs_client *clp = args->client;switch (task->tk_status) {
@@ -7899,6 +7900,11 @@ static int nfs4_check_cl_exchange_flags(u32 flags)nfs4_schedule_session_recovery (clp->cl_session, task->tk_status); } +if (args->dir ==NFS4_CDFC4_FORE_OR_BOTH && + res->dir !=NFS4_CDFS4_BOTH ) { +rpc_task_close_connection (task); + task->tk_status = -NFS4ERR_DELAY ; + } }static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = {
include/linux/sunrpc/clnt.h +5 -0
@@ -236,4 +236,9 @@ static inline int rpc_reply_expected(struct rpc_task *task) (task->tk_msg.rpc_proc->p_decode != NULL); } +static inline void rpc_task_close_connection (struct rpc_task *task) +{ +if (task->tk_xprt) +xprt_force_disconnect (task->tk_xprt); +}#endif /* _LINUX_SUNRPC_CLNT_H */
Signature · 1 line
1.8.3.1
Hi Olga
Quoted 34 lines · Olga Kornievskaia
Currently, if the client sends
BIND_CONN_TO_SESSIONwithNFS4_CDFC4_FORE_OR_BOTHbut only getsNFS4_CDFS4_FOREback it ignores that it wasn't able to enable a backchannel.To make sure, the client sends
BIND_CONN_TO_SESSIONas the first operation on the connections (ie., no other session compounds haven't been sent before), and if the client's request to bind the backchannel
is not satisfied, then reset the connection and retry.Signed-off-by Olga Kornievskaia <[email protected]>--- fs/nfs/nfs4proc.c | 6 ++++++ include/linux/sunrpc/clnt.h | 5 +++++ 2 files changed, 11 insertions(+)fs/nfs/nfs4proc.c +1
-0@@ -7891,6 +7891,7 @@ static int nfs4_check_cl_exchange_flags(u32 flags)nfs4_bind_one_conn_to_session_done (struct rpc_task *task,void *calldata) {struct nfs41_bind_conn_to_session_args *args = task- >tk_msg.rpc_argp; + struct nfs41_bind_conn_to_session_res *res = task-Quoted 1 line
tk_msg.rpc_resp;
fs/nfs/nfs4proc.c +0
-0struct nfs_client *clp = args->client;switch (task->tk_status) {
fs/nfs/nfs4proc.c static int nfs4_check_cl_exchange_flags(u32 · line 7907
Quoted 8 lines
fs/nfs/nfs4proc.c +4
-0@@ -7899,6 +7900,11 @@ static int nfs4_check_cl_exchange_flags(u32 flags) nfs4_schedule_session_recovery(clp->cl_session, task->tk_status); } +if (args->dir ==NFS4_CDFC4_FORE_OR_BOTH && + res->dir !=NFS4_CDFS4_BOTH ) { +rpc_task_close_connection (task); + task->tk_status = -NFS4ERR_DELAY ;
We don't have any error handling for NFS4ERR_DELAY in this function, so if your intention is to replay the RPC call, then maybe you want to replace this line with a call to rpc_restart_call()?
However it would be good to ensure that we only do this once or twice so that we don't loop forever. Maybe also add a variable to the struct nfs41_bind_conn_to_session_args that can set the number of retries remaining?
Quoted 20 lines
fs/nfs/nfs4proc.c +1
-0+ } }static const struct
rpc_call_opsnfs4_bind_one_conn_to_session_ops=
{include/linux/sunrpc/clnt.h +5
-0@@ -236,4 +236,9 @@ static inline int rpc_reply_expected(struct rpc_task *task) (task->tk_msg.rpc_proc->p_decode != NULL); } +static inline void rpc_task_close_connection (struct rpc_task *task) +{ +if (task->tk_xprt) +xprt_force_disconnect (task->tk_xprt); +}
Quoted 1 line
#endif /*
_LINUX_SUNRPC_CLNT_H*/
Thanks
Trond
Signature · 3 lines
Trond Myklebust Linux NFS client maintainer, Hammerspace [email protected]
Quoted 36 lines · Trond Myklebust
Hi Olga
Quoted 32 lines · Olga Kornievskaia
Currently, if the client sends
BIND_CONN_TO_SESSIONwithNFS4_CDFC4_FORE_OR_BOTHbut only getsNFS4_CDFS4_FOREback it ignores that it wasn't able to enable a backchannel.To make sure, the client sends
BIND_CONN_TO_SESSIONas the first operation on the connections (ie., no other session compounds haven't been sent before), and if the client's request to bind the backchannel
is not satisfied, then reset the connection and retry.Signed-off-by Olga Kornievskaia <[email protected]>--- fs/nfs/nfs4proc.c | 6 ++++++ include/linux/sunrpc/clnt.h | 5 +++++ 2 files changed, 11 insertions(+)fs/nfs/nfs4proc.c +1
-0@@ -7891,6 +7891,7 @@ static int nfs4_check_cl_exchange_flags(u32 flags)nfs4_bind_one_conn_to_session_done (struct rpc_task *task,void *calldata) {struct nfs41_bind_conn_to_session_args *args = task- >tk_msg.rpc_argp; + struct nfs41_bind_conn_to_session_res *res = task-Quoted 1 line
tk_msg.rpc_resp;
struct nfs_client *clp = args->client;
Quoted 14 lines
fs/nfs/nfs4proc.c static int nfs4_check_cl_exchange_flags(u32 · line 7907
Quoted 10 lines
switch (task->tk_status) {fs/nfs/nfs4proc.c +4
-0@@ -7899,6 +7900,11 @@ static int nfs4_check_cl_exchange_flags(u32 flags) nfs4_schedule_session_recovery(clp->cl_session, task->tk_status); } +if (args->dir ==NFS4_CDFC4_FORE_OR_BOTH && + res->dir !=NFS4_CDFS4_BOTH ) { +rpc_task_close_connection (task); + task->tk_status = -NFS4ERR_DELAY ;We don't have any error handling for
NFS4ERR_DELAYin this function, so if your intention is to replay the RPC call, then maybe you want to replace this line with a call torpc_restart_call()?
What happens is nfs4_proc_bind_conn_to_session() is errored with ERR_DELAY which goes back into nfs4state.c which has a case for ERR_DELAY which resets the bit and does the call again. But I can try the rpc_restart_call().
Quoted 4 lines
However it would be good to ensure that we only do this once or twice so that we don't loop forever. Maybe also add a variable to the struct
nfs41_bind_conn_to_session_argsthat can set the number of retries remaining?
If I recode using rpc_restart_call, then I can add something to the args. Otherwise, number of retries would need to be handled some other way that I'd need to think of.
Thank you for all the help.
Quoted 32 lines
Quoted 21 lines
fs/nfs/nfs4proc.c +1
-0+ } }static const struct
rpc_call_opsnfs4_bind_one_conn_to_session_ops=
{include/linux/sunrpc/clnt.h +5
-0@@ -236,4 +236,9 @@ static inline int rpc_reply_expected(struct rpc_task *task) (task->tk_msg.rpc_proc->p_decode != NULL); } +static inline void rpc_task_close_connection (struct rpc_task *task) +{ +if (task->tk_xprt) +xprt_force_disconnect (task->tk_xprt); +}Quoted 1 line
#endif /*
_LINUX_SUNRPC_CLNT_H*/Thanks
Trond--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]