Commit 802e1913 authored by Chuck Lever's avatar Chuck Lever

NFSD: Add nfsd4_encode_open_delegation4()

To better align our implementation with the XDR specification,
refactor the part of nfsd4_encode_open() that encodes delegation
metadata.

As part of that refactor, remove an unnecessary BUG() call site and
a comment that appears to be stale.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 6dd43c6d
......@@ -4174,13 +4174,43 @@ nfsd4_encode_open_none_delegation4(struct xdr_stream *xdr,
return status;
}
static __be32
nfsd4_encode_open_delegation4(struct xdr_stream *xdr, struct nfsd4_open *open)
{
__be32 status;
/* delegation_type */
if (xdr_stream_encode_u32(xdr, open->op_delegate_type) != XDR_UNIT)
return nfserr_resource;
switch (open->op_delegate_type) {
case NFS4_OPEN_DELEGATE_NONE:
status = nfs_ok;
break;
case NFS4_OPEN_DELEGATE_READ:
/* read */
status = nfsd4_encode_open_read_delegation4(xdr, open);
break;
case NFS4_OPEN_DELEGATE_WRITE:
/* write */
status = nfsd4_encode_open_write_delegation4(xdr, open);
break;
case NFS4_OPEN_DELEGATE_NONE_EXT:
/* od_whynone */
status = nfsd4_encode_open_none_delegation4(xdr, open);
break;
default:
status = nfserr_serverfault;
}
return status;
}
static __be32
nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr,
union nfsd4_op_u *u)
{
struct nfsd4_open *open = &u->open;
struct xdr_stream *xdr = resp->xdr;
__be32 *p;
nfserr = nfsd4_encode_stateid4(xdr, &open->op_stateid);
if (nfserr)
......@@ -4196,28 +4226,8 @@ nfsd4_encode_open(struct nfsd4_compoundres *resp, __be32 nfserr,
if (nfserr)
return nfserr;
p = xdr_reserve_space(xdr, 4);
if (!p)
return nfserr_resource;
*p++ = cpu_to_be32(open->op_delegate_type);
switch (open->op_delegate_type) {
case NFS4_OPEN_DELEGATE_NONE:
break;
case NFS4_OPEN_DELEGATE_READ:
/* read */
return nfsd4_encode_open_read_delegation4(xdr, open);
case NFS4_OPEN_DELEGATE_WRITE:
/* write */
return nfsd4_encode_open_write_delegation4(xdr, open);
case NFS4_OPEN_DELEGATE_NONE_EXT:
/* od_whynone */
return nfsd4_encode_open_none_delegation4(xdr, open);
default:
BUG();
}
/* XXX save filehandle here */
return 0;
/* delegation */
return nfsd4_encode_open_delegation4(xdr, open);
}
static __be32
......
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