diff mbox series

[v1,46/52] NFSD: Add nfsd4_encode_fattr4_layout_blksize()

Message ID 169504570088.133720.70116052510788365.stgit@manet.1015granger.net (mailing list archive)
State New, archived
Headers show
Series Modernize nfsd4_encode_fattr() | expand

Commit Message

Chuck Lever Sept. 18, 2023, 2:01 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

Refactor the encoder for FATTR4_LAYOUT_BLKSIZE into a helper. In a
subsequent patch, this helper will be called from a bitmask loop.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 fs/nfsd/nfs4xdr.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index bc0b5bc3e655..aca0301dc949 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -3311,6 +3311,12 @@  static __be32 nfsd4_encode_fattr4_layout_types(struct xdr_stream *xdr,
 	return nfs_ok;
 }
 
+static __be32 nfsd4_encode_fattr4_layout_blksize(struct xdr_stream *xdr,
+						 const struct nfsd4_fattr_args *args)
+{
+	return nfsd4_encode_uint32_t(xdr, args->stat.blksize);
+}
+
 #endif
 
 /*
@@ -3680,10 +3686,9 @@  nfsd4_encode_fattr(struct xdr_stream *xdr, struct svc_fh *fhp,
 	}
 
 	if (bmval2 & FATTR4_WORD2_LAYOUT_BLKSIZE) {
-		p = xdr_reserve_space(xdr, 4);
-		if (!p)
-			goto out_resource;
-		*p++ = cpu_to_be32(args.stat.blksize);
+		status = nfsd4_encode_fattr4_layout_blksize(xdr, &args);
+		if (status != nfs_ok)
+			goto out;
 	}
 #endif /* CONFIG_NFSD_PNFS */
 	if (bmval2 & FATTR4_WORD2_SUPPATTR_EXCLCREAT) {