mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-27 17:11:46 +00:00
NFSv4: Replace ad-hoc xdr encode/decode helpers with xdr_stream_* generics
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com> Reviewed-by: Chuck Lever <chuck.lever@oracle.com> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
This commit is contained in:
parent
0ae060ca2b
commit
ab6e9aaf16
3 changed files with 12 additions and 34 deletions
|
@ -582,12 +582,8 @@ out:
|
||||||
|
|
||||||
static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
|
static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
if (unlikely(xdr_stream_encode_opaque(xdr, str, len) < 0))
|
||||||
|
return cpu_to_be32(NFS4ERR_RESOURCE);
|
||||||
p = xdr_reserve_space(xdr, 4 + len);
|
|
||||||
if (unlikely(p == NULL))
|
|
||||||
return htonl(NFS4ERR_RESOURCE);
|
|
||||||
xdr_encode_opaque(p, str, len);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1949,10 +1949,7 @@ static int ff_layout_encode_ioerr(struct xdr_stream *xdr,
|
||||||
static void
|
static void
|
||||||
encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
|
encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
|
||||||
|
|
||||||
p = xdr_reserve_space(xdr, len);
|
|
||||||
xdr_encode_opaque_fixed(p, buf, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -924,34 +924,22 @@ static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
|
||||||
|
|
||||||
static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
|
static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
|
||||||
|
|
||||||
p = xdr_reserve_space(xdr, len);
|
|
||||||
xdr_encode_opaque_fixed(p, buf, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
|
static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
|
||||||
|
|
||||||
p = reserve_space(xdr, 4 + len);
|
|
||||||
xdr_encode_opaque(p, str, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void encode_uint32(struct xdr_stream *xdr, u32 n)
|
static void encode_uint32(struct xdr_stream *xdr, u32 n)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
WARN_ON_ONCE(xdr_stream_encode_u32(xdr, n) < 0);
|
||||||
|
|
||||||
p = reserve_space(xdr, 4);
|
|
||||||
*p = cpu_to_be32(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void encode_uint64(struct xdr_stream *xdr, u64 n)
|
static void encode_uint64(struct xdr_stream *xdr, u64 n)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
WARN_ON_ONCE(xdr_stream_encode_u64(xdr, n) < 0);
|
||||||
|
|
||||||
p = reserve_space(xdr, 8);
|
|
||||||
xdr_encode_hyper(p, n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void encode_nfs4_seqid(struct xdr_stream *xdr,
|
static void encode_nfs4_seqid(struct xdr_stream *xdr,
|
||||||
|
@ -4294,15 +4282,12 @@ out_overflow:
|
||||||
|
|
||||||
static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
|
static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
|
||||||
{
|
{
|
||||||
__be32 *p;
|
ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
|
||||||
|
if (unlikely(ret < 0)) {
|
||||||
p = xdr_inline_decode(xdr, len);
|
print_overflow_msg(__func__, xdr);
|
||||||
if (likely(p)) {
|
return -EIO;
|
||||||
memcpy(buf, p, len);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
print_overflow_msg(__func__, xdr);
|
return 0;
|
||||||
return -EIO;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
|
static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue