aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <trond.myklebust@primarydata.com>2015-02-18 12:27:18 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2015-02-18 16:11:09 -0500
commit71a097c6de9a49afd0f96b3ecef70c4eb04efde7 (patch)
tree0f465c7c79d4e8f2978ba036ac8be02ca32ed6e8
parent7e9f07388779ccc5067f206357d9791aeef38864 (diff)
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: Trond Myklebust <trond.myklebust@primarydata.com>
-rw-r--r--fs/nfs/nfs4proc.c28
-rw-r--r--fs/nfs/nfs4xdr.c16
-rw-r--r--include/linux/nfs_xdr.h9
3 files changed, 30 insertions, 23 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 59853797825c..88180ac5ea0e 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -6648,47 +6648,47 @@ nfs41_same_server_scope(struct nfs41_server_scope *a,
6648int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred) 6648int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred)
6649{ 6649{
6650 int status; 6650 int status;
6651 struct nfs41_bind_conn_to_session_args args = {
6652 .client = clp,
6653 .dir = NFS4_CDFC4_FORE_OR_BOTH,
6654 };
6651 struct nfs41_bind_conn_to_session_res res; 6655 struct nfs41_bind_conn_to_session_res res;
6652 struct rpc_message msg = { 6656 struct rpc_message msg = {
6653 .rpc_proc = 6657 .rpc_proc =
6654 &nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION], 6658 &nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION],
6655 .rpc_argp = clp, 6659 .rpc_argp = &args,
6656 .rpc_resp = &res, 6660 .rpc_resp = &res,
6657 .rpc_cred = cred, 6661 .rpc_cred = cred,
6658 }; 6662 };
6659 6663
6660 dprintk("--> %s\n", __func__); 6664 dprintk("--> %s\n", __func__);
6661 6665
6662 res.session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS); 6666 nfs4_copy_sessionid(&args.sessionid, &clp->cl_session->sess_id);
6663 if (unlikely(res.session == NULL)) { 6667 if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
6664 status = -ENOMEM; 6668 args.dir = NFS4_CDFC4_FORE;
6665 goto out;
6666 }
6667 6669
6668 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT); 6670 status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
6669 trace_nfs4_bind_conn_to_session(clp, status); 6671 trace_nfs4_bind_conn_to_session(clp, status);
6670 if (status == 0) { 6672 if (status == 0) {
6671 if (memcmp(res.session->sess_id.data, 6673 if (memcmp(res.sessionid.data,
6672 clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) { 6674 clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) {
6673 dprintk("NFS: %s: Session ID mismatch\n", __func__); 6675 dprintk("NFS: %s: Session ID mismatch\n", __func__);
6674 status = -EIO; 6676 status = -EIO;
6675 goto out_session; 6677 goto out;
6676 } 6678 }
6677 if (res.dir != NFS4_CDFS4_BOTH) { 6679 if ((res.dir & args.dir) != res.dir || res.dir == 0) {
6678 dprintk("NFS: %s: Unexpected direction from server\n", 6680 dprintk("NFS: %s: Unexpected direction from server\n",
6679 __func__); 6681 __func__);
6680 status = -EIO; 6682 status = -EIO;
6681 goto out_session; 6683 goto out;
6682 } 6684 }
6683 if (res.use_conn_in_rdma_mode) { 6685 if (res.use_conn_in_rdma_mode != args.use_conn_in_rdma_mode) {
6684 dprintk("NFS: %s: Server returned RDMA mode = true\n", 6686 dprintk("NFS: %s: Server returned RDMA mode = true\n",
6685 __func__); 6687 __func__);
6686 status = -EIO; 6688 status = -EIO;
6687 goto out_session; 6689 goto out;
6688 } 6690 }
6689 } 6691 }
6690out_session:
6691 kfree(res.session);
6692out: 6692out:
6693 dprintk("<-- %s status= %d\n", __func__, status); 6693 dprintk("<-- %s status= %d\n", __func__, status);
6694 return status; 6694 return status;
diff --git a/fs/nfs/nfs4xdr.c b/fs/nfs/nfs4xdr.c
index 97d4bdf53541..5c399ec41079 100644
--- a/fs/nfs/nfs4xdr.c
+++ b/fs/nfs/nfs4xdr.c
@@ -1715,17 +1715,17 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru
1715#if defined(CONFIG_NFS_V4_1) 1715#if defined(CONFIG_NFS_V4_1)
1716/* NFSv4.1 operations */ 1716/* NFSv4.1 operations */
1717static void encode_bind_conn_to_session(struct xdr_stream *xdr, 1717static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1718 struct nfs4_session *session, 1718 struct nfs41_bind_conn_to_session_args *args,
1719 struct compound_hdr *hdr) 1719 struct compound_hdr *hdr)
1720{ 1720{
1721 __be32 *p; 1721 __be32 *p;
1722 1722
1723 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION, 1723 encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
1724 decode_bind_conn_to_session_maxsz, hdr); 1724 decode_bind_conn_to_session_maxsz, hdr);
1725 encode_opaque_fixed(xdr, session->sess_id.data, NFS4_MAX_SESSIONID_LEN); 1725 encode_opaque_fixed(xdr, args->sessionid.data, NFS4_MAX_SESSIONID_LEN);
1726 p = xdr_reserve_space(xdr, 8); 1726 p = xdr_reserve_space(xdr, 8);
1727 *p++ = cpu_to_be32(NFS4_CDFC4_FORE_OR_BOTH); 1727 *p++ = cpu_to_be32(args->dir);
1728 *p = 0; /* use_conn_in_rdma_mode = False */ 1728 *p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
1729} 1729}
1730 1730
1731static void encode_op_map(struct xdr_stream *xdr, struct nfs4_op_map *op_map) 1731static 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 */ 2734 */
2735static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req, 2735static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
2736 struct xdr_stream *xdr, 2736 struct xdr_stream *xdr,
2737 struct nfs_client *clp) 2737 struct nfs41_bind_conn_to_session_args *args)
2738{ 2738{
2739 struct compound_hdr hdr = { 2739 struct compound_hdr hdr = {
2740 .minorversion = clp->cl_mvops->minor_version, 2740 .minorversion = args->client->cl_mvops->minor_version,
2741 }; 2741 };
2742 2742
2743 encode_compound_hdr(xdr, req, &hdr); 2743 encode_compound_hdr(xdr, req, &hdr);
2744 encode_bind_conn_to_session(xdr, clp->cl_session, &hdr); 2744 encode_bind_conn_to_session(xdr, args, &hdr);
2745 encode_nops(&hdr); 2745 encode_nops(&hdr);
2746} 2746}
2747 2747
@@ -5613,7 +5613,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr,
5613 5613
5614 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION); 5614 status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
5615 if (!status) 5615 if (!status)
5616 status = decode_sessionid(xdr, &res->session->sess_id); 5616 status = decode_sessionid(xdr, &res->sessionid);
5617 if (unlikely(status)) 5617 if (unlikely(status))
5618 return status; 5618 return status;
5619 5619
diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h
index 1af12fc16e98..4cb3eaa89cf7 100644
--- a/include/linux/nfs_xdr.h
+++ b/include/linux/nfs_xdr.h
@@ -1167,8 +1167,15 @@ struct nfs41_impl_id {
1167 struct nfstime4 date; 1167 struct nfstime4 date;
1168}; 1168};
1169 1169
1170struct nfs41_bind_conn_to_session_args {
1171 struct nfs_client *client;
1172 struct nfs4_sessionid sessionid;
1173 u32 dir;
1174 bool use_conn_in_rdma_mode;
1175};
1176
1170struct nfs41_bind_conn_to_session_res { 1177struct nfs41_bind_conn_to_session_res {
1171 struct nfs4_session *session; 1178 struct nfs4_sessionid sessionid;
1172 u32 dir; 1179 u32 dir;
1173 bool use_conn_in_rdma_mode; 1180 bool use_conn_in_rdma_mode;
1174}; 1181};