Skip to content

Commit 1545e48

Browse files
Mike SnitzerAnna Schumaker
authored andcommitted
nfs: factor out {encode,decode}_opaque_fixed to nfs_xdr.h
Eliminates duplicate functions in various files to allow for additional callers. Signed-off-by: Mike Snitzer <[email protected]> Reviewed-by: NeilBrown <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 1fcb166 commit 1545e48

File tree

3 files changed

+19
-20
lines changed

3 files changed

+19
-20
lines changed

fs/nfs/flexfilelayout/flexfilelayout.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2086,12 +2086,6 @@ static int ff_layout_encode_ioerr(struct xdr_stream *xdr,
20862086
return ff_layout_encode_ds_ioerr(xdr, &ff_args->errors);
20872087
}
20882088

2089-
static void
2090-
encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
2091-
{
2092-
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
2093-
}
2094-
20952089
static void
20962090
ff_layout_encode_ff_iostat_head(struct xdr_stream *xdr,
20972091
const nfs4_stateid *stateid,

fs/nfs/nfs4xdr.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -972,11 +972,6 @@ static __be32 *reserve_space(struct xdr_stream *xdr, size_t nbytes)
972972
return p;
973973
}
974974

975-
static void encode_opaque_fixed(struct xdr_stream *xdr, const void *buf, size_t len)
976-
{
977-
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
978-
}
979-
980975
static void encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
981976
{
982977
WARN_ON_ONCE(xdr_stream_encode_opaque(xdr, str, len) < 0);
@@ -4406,14 +4401,6 @@ static int decode_access(struct xdr_stream *xdr, u32 *supported, u32 *access)
44064401
return 0;
44074402
}
44084403

4409-
static int decode_opaque_fixed(struct xdr_stream *xdr, void *buf, size_t len)
4410-
{
4411-
ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
4412-
if (unlikely(ret < 0))
4413-
return -EIO;
4414-
return 0;
4415-
}
4416-
44174404
static int decode_stateid(struct xdr_stream *xdr, nfs4_stateid *stateid)
44184405
{
44194406
return decode_opaque_fixed(xdr, stateid, NFS4_STATEID_SIZE);

include/linux/nfs_xdr.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1853,6 +1853,24 @@ struct nfs_rpc_ops {
18531853
void (*disable_swap)(struct inode *inode);
18541854
};
18551855

1856+
/*
1857+
* Helper functions used by NFS client and/or server
1858+
*/
1859+
static inline void encode_opaque_fixed(struct xdr_stream *xdr,
1860+
const void *buf, size_t len)
1861+
{
1862+
WARN_ON_ONCE(xdr_stream_encode_opaque_fixed(xdr, buf, len) < 0);
1863+
}
1864+
1865+
static inline int decode_opaque_fixed(struct xdr_stream *xdr,
1866+
void *buf, size_t len)
1867+
{
1868+
ssize_t ret = xdr_stream_decode_opaque_fixed(xdr, buf, len);
1869+
if (unlikely(ret < 0))
1870+
return -EIO;
1871+
return 0;
1872+
}
1873+
18561874
/*
18571875
* Function vectors etc. for the NFS client
18581876
*/
@@ -1866,4 +1884,4 @@ extern const struct rpc_version nfs_version4;
18661884
extern const struct rpc_version nfsacl_version3;
18671885
extern const struct rpc_program nfsacl_program;
18681886

1869-
#endif
1887+
#endif /* _LINUX_NFS_XDR_H */

0 commit comments

Comments
 (0)