Commit 71a097c6 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4.1: Clean up bind_conn_to_session

We don't need to fake up an entire session in order retrieve the arguments.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 7e9f0738
...@@ -6648,47 +6648,47 @@ nfs41_same_server_scope(struct nfs41_server_scope *a, ...@@ -6648,47 +6648,47 @@ nfs41_same_server_scope(struct nfs41_server_scope *a,
int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred) int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred)
{ {
int status; int status;
struct nfs41_bind_conn_to_session_args args = {
.client = clp,
.dir = NFS4_CDFC4_FORE_OR_BOTH,
};
struct nfs41_bind_conn_to_session_res res; struct nfs41_bind_conn_to_session_res res;
struct rpc_message msg = { struct rpc_message msg = {
.rpc_proc = .rpc_proc =
&nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION], &nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION],
.rpc_argp = clp, .rpc_argp = &args,
.rpc_resp = &res, .rpc_resp = &res,
.rpc_cred = cred, .rpc_cred = cred,
}; };
dprintk("--> %s\n", __func__); dprintk("--> %s\n", __func__);
res.session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); nfs4_copy_sessionid(&args.sessionid, &clp->cl_session->sess_id);
if (unlikely(res.session == NULL)) { if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
status = -ENOMEM; args.dir = NFS4_CDFC4_FORE;
goto out;
}
status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
trace_nfs4_bind_conn_to_session(clp, status); trace_nfs4_bind_conn_to_session(clp, status);
if (status == 0) { if (status == 0) {
if (memcmp(res.session->sess_id.data, if (memcmp(res.sessionid.data,
clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) { clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) {
dprintk("NFS: %s: Session ID mismatch\n", __func__); dprintk("NFS: %s: Session ID mismatch\n", __func__);
status = -EIO; status = -EIO;
goto out_session; goto out;
} }
if (res.dir != NFS4_CDFS4_BOTH) { if ((res.dir & args.dir) != res.dir || res.dir == 0) {
dprintk("NFS: %s: Unexpected direction from server\n", dprintk("NFS: %s: Unexpected direction from server\n",
__func__); __func__);
status = -EIO; status = -EIO;
goto out_session; goto out;
} }
if (res.use_conn_in_rdma_mode) { if (res.use_conn_in_rdma_mode != args.use_conn_in_rdma_mode) {
dprintk("NFS: %s: Server returned RDMA mode = true\n", dprintk("NFS: %s: Server returned RDMA mode = true\n",
__func__); __func__);
status = -EIO; status = -EIO;
goto out_session; goto out;
} }
} }
out_session:
kfree(res.session);
out: out:
dprintk("<-- %s status= %d\n", __func__, status); dprintk("<-- %s status= %d\n", __func__, status);
return status; return status;
......
...@@ -1715,17 +1715,17 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru ...@@ -1715,17 +1715,17 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru
#if defined(CONFIG_NFS_V4_1) #if defined(CONFIG_NFS_V4_1)
/* NFSv4.1 operations */ /* NFSv4.1 operations */
static void encode_bind_conn_to_session(struct xdr_stream *xdr, static void encode_bind_conn_to_session(struct xdr_stream *xdr,
struct nfs4_session *session, struct nfs41_bind_conn_to_session_args *args,
struct compound_hdr *hdr) struct compound_hdr *hdr)
{ {
__be32 *p; __be32 *p;
encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
decode_bind_conn_to_session_maxsz, hdr); decode_bind_conn_to_session_maxsz, hdr);
encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
p = xdr_reserve_space(xdr, 8); p = xdr_reserve_space(xdr, 8);
*p++ = cpu_to_be32(NFS4_CDFC4_FORE_OR_BOTH); *p++ = cpu_to_be32(args->dir);
*p = 0; /* use_conn_in_rdma_mode = False */ *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
} }
static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map)
...@@ -2734,14 +2734,14 @@ static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req, ...@@ -2734,14 +2734,14 @@ static void nfs4_xdr_enc_fsid_present(struct rpc_rqst *req,
*/ */
static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
struct xdr_stream *xdr, struct xdr_stream *xdr,
struct nfs_client *clp) struct nfs41_bind_conn_to_session_args *args)
{ {
struct compound_hdr hdr = { struct compound_hdr hdr = {
.minorversion = clp->cl_mvops->minor_version, .minorversion = args->client->cl_mvops->minor_version,
}; };
encode_compound_hdr(xdr, req, &hdr); encode_compound_hdr(xdr, req, &hdr);
encode_bind_conn_to_session(xdr, clp->cl_session, &hdr); encode_bind_conn_to_session(xdr, args, &hdr);
encode_nops(&hdr); encode_nops(&hdr);
} }
...@@ -5613,7 +5613,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr, ...@@ -5613,7 +5613,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr,
status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
if (!status) if (!status)
status = decode_sessionid(xdr, &res->session->sess_id); status = decode_sessionid(xdr, &res->sessionid);
if (unlikely(status)) if (unlikely(status))
return status; return status;
......
...@@ -1167,8 +1167,15 @@ struct nfs41_impl_id { ...@@ -1167,8 +1167,15 @@ struct nfs41_impl_id {
struct nfstime4 date; struct nfstime4 date;
}; };
struct nfs41_bind_conn_to_session_args {
struct nfs_client *client;
struct nfs4_sessionid sessionid;
u32 dir;
bool use_conn_in_rdma_mode;
};
struct nfs41_bind_conn_to_session_res { struct nfs41_bind_conn_to_session_res {
struct nfs4_session *session; struct nfs4_sessionid sessionid;
u32 dir; u32 dir;
bool use_conn_in_rdma_mode; bool use_conn_in_rdma_mode;
}; };
......
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