NFSD: Replace READ* macros in nfsd4_decode_layoutreturn()

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Chuck Lever 2020-11-04 10:42:25 -05:00
parent c8e88e3aa7
commit 645fcad371

View File

@ -660,6 +660,43 @@ nfsd4_decode_layoutupdate4(struct nfsd4_compoundargs *argp,
return nfs_ok;
}
static __be32
nfsd4_decode_layoutreturn4(struct nfsd4_compoundargs *argp,
struct nfsd4_layoutreturn *lrp)
{
__be32 status;
if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_return_type) < 0)
return nfserr_bad_xdr;
switch (lrp->lr_return_type) {
case RETURN_FILE:
if (xdr_stream_decode_u64(argp->xdr, &lrp->lr_seg.offset) < 0)
return nfserr_bad_xdr;
if (xdr_stream_decode_u64(argp->xdr, &lrp->lr_seg.length) < 0)
return nfserr_bad_xdr;
status = nfsd4_decode_stateid4(argp, &lrp->lr_sid);
if (status)
return status;
if (xdr_stream_decode_u32(argp->xdr, &lrp->lrf_body_len) < 0)
return nfserr_bad_xdr;
if (lrp->lrf_body_len > 0) {
lrp->lrf_body = xdr_inline_decode(argp->xdr, lrp->lrf_body_len);
if (!lrp->lrf_body)
return nfserr_bad_xdr;
}
break;
case RETURN_FSID:
case RETURN_ALL:
lrp->lr_seg.offset = 0;
lrp->lr_seg.length = NFS4_MAX_UINT64;
break;
default:
return nfserr_bad_xdr;
}
return nfs_ok;
}
#endif /* CONFIG_NFSD_PNFS */
static __be32
@ -1871,34 +1908,13 @@ static __be32
nfsd4_decode_layoutreturn(struct nfsd4_compoundargs *argp,
struct nfsd4_layoutreturn *lrp)
{
DECODE_HEAD;
READ_BUF(16);
lrp->lr_reclaim = be32_to_cpup(p++);
lrp->lr_layout_type = be32_to_cpup(p++);
lrp->lr_seg.iomode = be32_to_cpup(p++);
lrp->lr_return_type = be32_to_cpup(p++);
if (lrp->lr_return_type == RETURN_FILE) {
READ_BUF(16);
p = xdr_decode_hyper(p, &lrp->lr_seg.offset);
p = xdr_decode_hyper(p, &lrp->lr_seg.length);
status = nfsd4_decode_stateid(argp, &lrp->lr_sid);
if (status)
return status;
READ_BUF(4);
lrp->lrf_body_len = be32_to_cpup(p++);
if (lrp->lrf_body_len > 0) {
READ_BUF(lrp->lrf_body_len);
READMEM(lrp->lrf_body, lrp->lrf_body_len);
}
} else {
lrp->lr_seg.offset = 0;
lrp->lr_seg.length = NFS4_MAX_UINT64;
}
DECODE_TAIL;
if (xdr_stream_decode_bool(argp->xdr, &lrp->lr_reclaim) < 0)
return nfserr_bad_xdr;
if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_layout_type) < 0)
return nfserr_bad_xdr;
if (xdr_stream_decode_u32(argp->xdr, &lrp->lr_seg.iomode) < 0)
return nfserr_bad_xdr;
return nfsd4_decode_layoutreturn4(argp, lrp);
}
#endif /* CONFIG_NFSD_PNFS */