Commit 4bbe42e8 authored by Chuck Lever's avatar Chuck Lever

NFSD: Clean up nfsd4_encode_getdeviceinfo()

Adopt the conventional XDR utility functions. Also, restructure to
make the function align more closely with the spec -- there doesn't
seem to be a performance need for speciality code, so prioritize
readability.
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent 82e93bab
...@@ -4811,59 +4811,57 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr, ...@@ -4811,59 +4811,57 @@ nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, __be32 nfserr,
#ifdef CONFIG_NFSD_PNFS #ifdef CONFIG_NFSD_PNFS
static __be32 static __be32
nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr, nfsd4_encode_device_addr4(struct xdr_stream *xdr,
union nfsd4_op_u *u) const struct nfsd4_getdeviceinfo *gdev)
{ {
struct nfsd4_getdeviceinfo *gdev = &u->getdeviceinfo; u32 needed_len, starting_len = xdr->buf->len;
struct xdr_stream *xdr = resp->xdr;
const struct nfsd4_layout_ops *ops; const struct nfsd4_layout_ops *ops;
u32 starting_len = xdr->buf->len, needed_len; __be32 status;
__be32 *p;
p = xdr_reserve_space(xdr, 4); /* da_layout_type */
if (!p) if (xdr_stream_encode_u32(xdr, gdev->gd_layout_type) != XDR_UNIT)
return nfserr_resource; return nfserr_resource;
/* da_addr_body */
*p++ = cpu_to_be32(gdev->gd_layout_type);
ops = nfsd4_layout_ops[gdev->gd_layout_type]; ops = nfsd4_layout_ops[gdev->gd_layout_type];
nfserr = ops->encode_getdeviceinfo(xdr, gdev); status = ops->encode_getdeviceinfo(xdr, gdev);
if (nfserr) { if (status != nfs_ok) {
/* /*
* We don't bother to burden the layout drivers with * Don't burden the layout drivers with enforcing
* enforcing gd_maxcount, just tell the client to * gd_maxcount. Just tell the client to come back
* come back with a bigger buffer if it's not enough. * with a bigger buffer if it's not enough.
*/ */
if (xdr->buf->len + 4 > gdev->gd_maxcount) if (xdr->buf->len + XDR_UNIT > gdev->gd_maxcount)
goto toosmall; goto toosmall;
return nfserr; return status;
} }
if (gdev->gd_notify_types) { return nfs_ok;
p = xdr_reserve_space(xdr, 4 + 4);
if (!p)
return nfserr_resource;
*p++ = cpu_to_be32(1); /* bitmap length */
*p++ = cpu_to_be32(gdev->gd_notify_types);
} else {
p = xdr_reserve_space(xdr, 4);
if (!p)
return nfserr_resource;
*p++ = 0;
}
return 0;
toosmall: toosmall:
dprintk("%s: maxcount too small\n", __func__); needed_len = xdr->buf->len + XDR_UNIT; /* notifications */
needed_len = xdr->buf->len + 4 /* notifications */;
xdr_truncate_encode(xdr, starting_len); xdr_truncate_encode(xdr, starting_len);
p = xdr_reserve_space(xdr, 4);
if (!p) status = nfsd4_encode_count4(xdr, needed_len);
return nfserr_resource; if (status != nfs_ok)
*p++ = cpu_to_be32(needed_len); return status;
return nfserr_toosmall; return nfserr_toosmall;
} }
static __be32
nfsd4_encode_getdeviceinfo(struct nfsd4_compoundres *resp, __be32 nfserr,
union nfsd4_op_u *u)
{
struct nfsd4_getdeviceinfo *gdev = &u->getdeviceinfo;
struct xdr_stream *xdr = resp->xdr;
/* gdir_device_addr */
nfserr = nfsd4_encode_device_addr4(xdr, gdev);
if (nfserr)
return nfserr;
/* gdir_notification */
return nfsd4_encode_bitmap4(xdr, gdev->gd_notify_types, 0, 0);
}
static __be32 static __be32
nfsd4_encode_layout4(struct xdr_stream *xdr, const struct nfsd4_layoutget *lgp) nfsd4_encode_layout4(struct xdr_stream *xdr, const struct nfsd4_layoutget *lgp)
{ {
......
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