diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2023-09-18 17:01:28 +0300 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2023-10-16 19:44:24 +0300 |
commit | e7a5b1b2ad8515ed6a093307318ebfd3bde6a54f (patch) | |
tree | 5f8b3547850d25835cedc9a6dfc501dcb06cac5c | |
parent | 1b9097e36688a5624a8db7db575030e25dcd075c (diff) | |
download | linux-e7a5b1b2ad8515ed6a093307318ebfd3bde6a54f.tar.xz |
NFSD: Add nfsd4_encode_fattr4_fs_layout_types()
Refactor the encoder for FATTR4_FS_LAYOUT_TYPES into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index b840318beffa..36ef7b0795b1 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -3293,6 +3293,28 @@ static __be32 nfsd4_encode_fattr4_mounted_on_fileid(struct xdr_stream *xdr, return nfsd4_encode_uint64_t(xdr, ino); } +#ifdef CONFIG_NFSD_PNFS + +static __be32 nfsd4_encode_fattr4_fs_layout_types(struct xdr_stream *xdr, + const struct nfsd4_fattr_args *args) +{ + unsigned long mask = args->exp->ex_layout_types; + int i; + + /* Hamming weight of @mask is the number of layout types to return */ + if (xdr_stream_encode_u32(xdr, hweight_long(mask)) != XDR_UNIT) + return nfserr_resource; + for (i = LAYOUT_NFSV4_1_FILES; i < LAYOUT_TYPE_MAX; ++i) + if (mask & BIT(i)) { + /* layouttype4 */ + if (xdr_stream_encode_u32(xdr, i) != XDR_UNIT) + return nfserr_resource; + } + return nfs_ok; +} + +#endif + /* * Note: @fhp can be NULL; in this case, we might have to compose the filehandle * ourselves. @@ -3653,7 +3675,7 @@ nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp, } #ifdef CONFIG_NFSD_PNFS if (bmval1 & FATTR4_WORD1_FS_LAYOUT_TYPES) { - status = nfsd4_encode_layout_types(xdr, exp->ex_layout_types); + status = nfsd4_encode_fattr4_fs_layout_types(xdr, &args); if (status) goto out; } |