Skip to content

Commit 65baa60

Browse files
committed
NFSD: Add a utility function for encoding sessionid4 objects
There is more than one NFSv4 operation that needs to encode a sessionid4, so extract that data type into a separate helper. Reviewed-by: Jeff Layton <jlayton@kernel.org> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 841735b commit 65baa60

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

fs/nfsd/nfs4xdr.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3885,6 +3885,14 @@ nfsd4_encode_stateid4(struct xdr_stream *xdr, const stateid_t *sid)
38853885
return nfs_ok;
38863886
}
38873887

3888+
static __be32
3889+
nfsd4_encode_sessionid4(struct xdr_stream *xdr,
3890+
const struct nfs4_sessionid *sessionid)
3891+
{
3892+
return nfsd4_encode_opaque_fixed(xdr, sessionid->data,
3893+
NFS4_MAX_SESSIONID_LEN);
3894+
}
3895+
38883896
static __be32
38893897
nfsd4_encode_access(struct nfsd4_compoundres *resp, __be32 nfserr,
38903898
union nfsd4_op_u *u)
@@ -3906,17 +3914,16 @@ static __be32 nfsd4_encode_bind_conn_to_session(struct nfsd4_compoundres *resp,
39063914
{
39073915
struct nfsd4_bind_conn_to_session *bcts = &u->bind_conn_to_session;
39083916
struct xdr_stream *xdr = resp->xdr;
3909-
__be32 *p;
39103917

3911-
p = xdr_reserve_space(xdr, NFS4_MAX_SESSIONID_LEN + 8);
3912-
if (!p)
3918+
/* bctsr_sessid */
3919+
nfserr = nfsd4_encode_sessionid4(xdr, &bcts->sessionid);
3920+
if (nfserr != nfs_ok)
3921+
return nfserr;
3922+
/* bctsr_dir */
3923+
if (xdr_stream_encode_u32(xdr, bcts->dir) != XDR_UNIT)
39133924
return nfserr_resource;
3914-
p = xdr_encode_opaque_fixed(p, bcts->sessionid.data,
3915-
NFS4_MAX_SESSIONID_LEN);
3916-
*p++ = cpu_to_be32(bcts->dir);
3917-
/* Upshifting from TCP to RDMA is not supported */
3918-
*p++ = cpu_to_be32(0);
3919-
return 0;
3925+
/* bctsr_use_conn_in_rdma_mode */
3926+
return nfsd4_encode_bool(xdr, false);
39203927
}
39213928

39223929
static __be32

0 commit comments

Comments
 (0)