Commit 5a0c257f authored by NeilBrown's avatar NeilBrown Committed by Trond Myklebust

NFS: send state management on a single connection.

With NFSv4.1, different network connections need to be explicitly
bound to a session.  During session startup, this is not possible
so only a single connection must be used for session startup.

So add a task flag to disable the default round-robin choice of
connections (when nconnect > 1) and force the use of a single
connection.
Then use that flag on all requests for session management - for
consistence, include NFSv4.0 management (SETCLIENTID) and session
destruction
Reported-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 53c32630
...@@ -5992,7 +5992,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program, ...@@ -5992,7 +5992,7 @@ int nfs4_proc_setclientid(struct nfs_client *clp, u32 program,
.rpc_message = &msg, .rpc_message = &msg,
.callback_ops = &nfs4_setclientid_ops, .callback_ops = &nfs4_setclientid_ops,
.callback_data = &setclientid, .callback_data = &setclientid,
.flags = RPC_TASK_TIMEOUT, .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN,
}; };
int status; int status;
...@@ -6058,7 +6058,8 @@ int nfs4_proc_setclientid_confirm(struct nfs_client *clp, ...@@ -6058,7 +6058,8 @@ int nfs4_proc_setclientid_confirm(struct nfs_client *clp,
dprintk("NFS call setclientid_confirm auth=%s, (client ID %llx)\n", dprintk("NFS call setclientid_confirm auth=%s, (client ID %llx)\n",
clp->cl_rpcclient->cl_auth->au_ops->au_name, clp->cl_rpcclient->cl_auth->au_ops->au_name,
clp->cl_clientid); clp->cl_clientid);
status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); status = rpc_call_sync(clp->cl_rpcclient, &msg,
RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN);
trace_nfs4_setclientid_confirm(clp, status); trace_nfs4_setclientid_confirm(clp, status);
dprintk("NFS reply setclientid_confirm: %d\n", status); dprintk("NFS reply setclientid_confirm: %d\n", status);
return status; return status;
...@@ -7639,7 +7640,7 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct ...@@ -7639,7 +7640,7 @@ static int _nfs4_proc_secinfo(struct inode *dir, const struct qstr *name, struct
NFS_SP4_MACH_CRED_SECINFO, &clnt, &msg); NFS_SP4_MACH_CRED_SECINFO, &clnt, &msg);
status = nfs4_call_sync(clnt, NFS_SERVER(dir), &msg, &args.seq_args, status = nfs4_call_sync(clnt, NFS_SERVER(dir), &msg, &args.seq_args,
&res.seq_res, 0); &res.seq_res, RPC_TASK_NO_ROUND_ROBIN);
dprintk("NFS reply secinfo: %d\n", status); dprintk("NFS reply secinfo: %d\n", status);
put_cred(cred); put_cred(cred);
...@@ -7977,7 +7978,7 @@ nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred, ...@@ -7977,7 +7978,7 @@ nfs4_run_exchange_id(struct nfs_client *clp, const struct cred *cred,
.rpc_client = clp->cl_rpcclient, .rpc_client = clp->cl_rpcclient,
.callback_ops = &nfs4_exchange_id_call_ops, .callback_ops = &nfs4_exchange_id_call_ops,
.rpc_message = &msg, .rpc_message = &msg,
.flags = RPC_TASK_TIMEOUT, .flags = RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN,
}; };
struct nfs41_exchange_id_data *calldata; struct nfs41_exchange_id_data *calldata;
int status; int status;
...@@ -8202,7 +8203,8 @@ static int _nfs4_proc_destroy_clientid(struct nfs_client *clp, ...@@ -8202,7 +8203,8 @@ static int _nfs4_proc_destroy_clientid(struct nfs_client *clp,
}; };
int status; int status;
status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); status = rpc_call_sync(clp->cl_rpcclient, &msg,
RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN);
trace_nfs4_destroy_clientid(clp, status); trace_nfs4_destroy_clientid(clp, status);
if (status) if (status)
dprintk("NFS: Got error %d from the server %s on " dprintk("NFS: Got error %d from the server %s on "
...@@ -8481,7 +8483,8 @@ static int _nfs4_proc_create_session(struct nfs_client *clp, ...@@ -8481,7 +8483,8 @@ static int _nfs4_proc_create_session(struct nfs_client *clp,
nfs4_init_channel_attrs(&args, clp->cl_rpcclient); nfs4_init_channel_attrs(&args, clp->cl_rpcclient);
args.flags = (SESSION4_PERSIST | SESSION4_BACK_CHAN); args.flags = (SESSION4_PERSIST | SESSION4_BACK_CHAN);
status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); status = rpc_call_sync(session->clp->cl_rpcclient, &msg,
RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN);
trace_nfs4_create_session(clp, status); trace_nfs4_create_session(clp, status);
switch (status) { switch (status) {
...@@ -8557,7 +8560,8 @@ int nfs4_proc_destroy_session(struct nfs4_session *session, ...@@ -8557,7 +8560,8 @@ int nfs4_proc_destroy_session(struct nfs4_session *session,
if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state)) if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state))
return 0; return 0;
status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); status = rpc_call_sync(session->clp->cl_rpcclient, &msg,
RPC_TASK_TIMEOUT | RPC_TASK_NO_ROUND_ROBIN);
trace_nfs4_destroy_session(session->clp, status); trace_nfs4_destroy_session(session->clp, status);
if (status) if (status)
...@@ -8811,7 +8815,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp, ...@@ -8811,7 +8815,7 @@ static int nfs41_proc_reclaim_complete(struct nfs_client *clp,
.rpc_client = clp->cl_rpcclient, .rpc_client = clp->cl_rpcclient,
.rpc_message = &msg, .rpc_message = &msg,
.callback_ops = &nfs4_reclaim_complete_call_ops, .callback_ops = &nfs4_reclaim_complete_call_ops,
.flags = RPC_TASK_ASYNC, .flags = RPC_TASK_ASYNC | RPC_TASK_NO_ROUND_ROBIN,
}; };
int status = -ENOMEM; int status = -ENOMEM;
...@@ -9330,7 +9334,7 @@ _nfs41_proc_secinfo_no_name(struct nfs_server *server, struct nfs_fh *fhandle, ...@@ -9330,7 +9334,7 @@ _nfs41_proc_secinfo_no_name(struct nfs_server *server, struct nfs_fh *fhandle,
dprintk("--> %s\n", __func__); dprintk("--> %s\n", __func__);
status = nfs4_call_sync(clnt, server, &msg, &args.seq_args, status = nfs4_call_sync(clnt, server, &msg, &args.seq_args,
&res.seq_res, 0); &res.seq_res, RPC_TASK_NO_ROUND_ROBIN);
dprintk("<-- %s status=%d\n", __func__, status); dprintk("<-- %s status=%d\n", __func__, status);
put_cred(cred); put_cred(cred);
......
...@@ -126,6 +126,7 @@ struct rpc_task_setup { ...@@ -126,6 +126,7 @@ struct rpc_task_setup {
#define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */ #define RPC_CALL_MAJORSEEN 0x0020 /* major timeout seen */
#define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */ #define RPC_TASK_ROOTCREDS 0x0040 /* force root creds */
#define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */ #define RPC_TASK_DYNAMIC 0x0080 /* task was kmalloc'ed */
#define RPC_TASK_NO_ROUND_ROBIN 0x0100 /* send requests on "main" xprt */
#define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */ #define RPC_TASK_SOFT 0x0200 /* Use soft timeouts */
#define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */ #define RPC_TASK_SOFTCONN 0x0400 /* Fail if can't connect */
#define RPC_TASK_SENT 0x0800 /* message was sent */ #define RPC_TASK_SENT 0x0800 /* message was sent */
......
...@@ -995,6 +995,24 @@ rpc_task_get_xprt(struct rpc_clnt *clnt) ...@@ -995,6 +995,24 @@ rpc_task_get_xprt(struct rpc_clnt *clnt)
return xprt; return xprt;
} }
static struct rpc_xprt *
rpc_task_get_first_xprt(struct rpc_clnt *clnt)
{
struct rpc_xprt_switch *xps;
struct rpc_xprt *xprt;
rcu_read_lock();
xprt = xprt_get(rcu_dereference(clnt->cl_xprt));
if (xprt) {
atomic_long_inc(&xprt->queuelen);
xps = rcu_dereference(clnt->cl_xpi.xpi_xpswitch);
atomic_long_inc(&xps->xps_queuelen);
}
rcu_read_unlock();
return xprt;
}
static void static void
rpc_task_release_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt) rpc_task_release_xprt(struct rpc_clnt *clnt, struct rpc_xprt *xprt)
{ {
...@@ -1042,7 +1060,11 @@ void rpc_task_release_client(struct rpc_task *task) ...@@ -1042,7 +1060,11 @@ void rpc_task_release_client(struct rpc_task *task)
static static
void rpc_task_set_transport(struct rpc_task *task, struct rpc_clnt *clnt) void rpc_task_set_transport(struct rpc_task *task, struct rpc_clnt *clnt)
{ {
if (!task->tk_xprt) if (task->tk_xprt)
return;
if (task->tk_flags & RPC_TASK_NO_ROUND_ROBIN)
task->tk_xprt = rpc_task_get_first_xprt(clnt);
else
task->tk_xprt = rpc_task_get_xprt(clnt); task->tk_xprt = rpc_task_get_xprt(clnt);
} }
......
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