Skip to content

Commit 71a097c

Browse files
committed
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>
1 parent 7e9f073 commit 71a097c

File tree

3 files changed

+30
-23
lines changed

3 files changed

+30
-23
lines changed

fs/nfs/nfs4proc.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6648,47 +6648,47 @@ nfs41_same_server_scope(struct nfs41_server_scope *a,
66486648
int nfs4_proc_bind_conn_to_session(struct nfs_client *clp, struct rpc_cred *cred)
66496649
{
66506650
int status;
6651+
struct nfs41_bind_conn_to_session_args args = {
6652+
.client = clp,
6653+
.dir = NFS4_CDFC4_FORE_OR_BOTH,
6654+
};
66516655
struct nfs41_bind_conn_to_session_res res;
66526656
struct rpc_message msg = {
66536657
.rpc_proc =
66546658
&nfs4_procedures[NFSPROC4_CLNT_BIND_CONN_TO_SESSION],
6655-
.rpc_argp = clp,
6659+
.rpc_argp = &args,
66566660
.rpc_resp = &res,
66576661
.rpc_cred = cred,
66586662
};
66596663

66606664
dprintk("--> %s\n", __func__);
66616665

6662-
res.session = kzalloc(sizeof(struct nfs4_session), GFP_NOFS);
6663-
if (unlikely(res.session == NULL)) {
6664-
status = -ENOMEM;
6665-
goto out;
6666-
}
6666+
nfs4_copy_sessionid(&args.sessionid, &clp->cl_session->sess_id);
6667+
if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
6668+
args.dir = NFS4_CDFC4_FORE;
66676669

66686670
status = rpc_call_sync(clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
66696671
trace_nfs4_bind_conn_to_session(clp, status);
66706672
if (status == 0) {
6671-
if (memcmp(res.session->sess_id.data,
6673+
if (memcmp(res.sessionid.data,
66726674
clp->cl_session->sess_id.data, NFS4_MAX_SESSIONID_LEN)) {
66736675
dprintk("NFS: %s: Session ID mismatch\n", __func__);
66746676
status = -EIO;
6675-
goto out_session;
6677+
goto out;
66766678
}
6677-
if (res.dir != NFS4_CDFS4_BOTH) {
6679+
if ((res.dir & args.dir) != res.dir || res.dir == 0) {
66786680
dprintk("NFS: %s: Unexpected direction from server\n",
66796681
__func__);
66806682
status = -EIO;
6681-
goto out_session;
6683+
goto out;
66826684
}
6683-
if (res.use_conn_in_rdma_mode) {
6685+
if (res.use_conn_in_rdma_mode != args.use_conn_in_rdma_mode) {
66846686
dprintk("NFS: %s: Server returned RDMA mode = true\n",
66856687
__func__);
66866688
status = -EIO;
6687-
goto out_session;
6689+
goto out;
66886690
}
66896691
}
6690-
out_session:
6691-
kfree(res.session);
66926692
out:
66936693
dprintk("<-- %s status= %d\n", __func__, status);
66946694
return status;

fs/nfs/nfs4xdr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1715,17 +1715,17 @@ static void encode_secinfo(struct xdr_stream *xdr, const struct qstr *name, stru
17151715
#if defined(CONFIG_NFS_V4_1)
17161716
/* NFSv4.1 operations */
17171717
static void encode_bind_conn_to_session(struct xdr_stream *xdr,
1718-
struct nfs4_session *session,
1718+
struct nfs41_bind_conn_to_session_args *args,
17191719
struct compound_hdr *hdr)
17201720
{
17211721
__be32 *p;
17221722

17231723
encode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION,
17241724
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);
17261726
p = xdr_reserve_space(xdr, 8);
1727-
*p++ = cpu_to_be32(NFS4_CDFC4_FORE_OR_BOTH);
1728-
*p = 0; /* use_conn_in_rdma_mode = False */
1727+
*p++ = cpu_to_be32(args->dir);
1728+
*p = (args->use_conn_in_rdma_mode) ? cpu_to_be32(1) : cpu_to_be32(0);
17291729
}
17301730

17311731
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,
27342734
*/
27352735
static void nfs4_xdr_enc_bind_conn_to_session(struct rpc_rqst *req,
27362736
struct xdr_stream *xdr,
2737-
struct nfs_client *clp)
2737+
struct nfs41_bind_conn_to_session_args *args)
27382738
{
27392739
struct compound_hdr hdr = {
2740-
.minorversion = clp->cl_mvops->minor_version,
2740+
.minorversion = args->client->cl_mvops->minor_version,
27412741
};
27422742

27432743
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);
27452745
encode_nops(&hdr);
27462746
}
27472747

@@ -5613,7 +5613,7 @@ static int decode_bind_conn_to_session(struct xdr_stream *xdr,
56135613

56145614
status = decode_op_hdr(xdr, OP_BIND_CONN_TO_SESSION);
56155615
if (!status)
5616-
status = decode_sessionid(xdr, &res->session->sess_id);
5616+
status = decode_sessionid(xdr, &res->sessionid);
56175617
if (unlikely(status))
56185618
return status;
56195619

include/linux/nfs_xdr.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1167,8 +1167,15 @@ struct nfs41_impl_id {
11671167
struct nfstime4 date;
11681168
};
11691169

1170+
struct 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+
11701177
struct nfs41_bind_conn_to_session_res {
1171-
struct nfs4_session *session;
1178+
struct nfs4_sessionid sessionid;
11721179
u32 dir;
11731180
bool use_conn_in_rdma_mode;
11741181
};

0 commit comments

Comments
 (0)