All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v3 24/34] NFSD: Use xdrgen XDR functions for the NFSv3 FSINFO procedure
Date: Tue, 13 Oct 2026 08:49:39 -0400	[thread overview]
Message-ID: <20261013124944.316808-5-cel@kernel.org> (raw)
In-Reply-To: <20261013124944.316808-1-cel@kernel.org>

Replace the NFSPROC3_FSINFO entry in the nfsd_procedures3 array with
an entry that dispatches the xdrgen-generated nfs_svc_decode_FSINFO3args
and nfs_svc_encode_FSINFO3res. A wrapper structure bridges the
generated xdrgen argument type and the legacy svc_fh representation the
NFSD VFS layer still uses.

The pc_argzero field is now set to zero for the NFSv3 FSINFO
procedure. The xdrgen decoders are trusted to initialize all arguments
in the argp->xdrgen field, making the early defensive memset
unnecessary. The remaining argp fields are cleared as needed.

nfsd3_proc_fsinfo() now sets the post-op attributes directly. This
makes it straightforward to confirm that the file handle is released
during every error flow.

nfs3svc_encode_fsinfores() no longer has any callers, so it is
removed, and with it the now-orphaned svcxdr_encode_fsinfo3resok()
encode helper and the nfs3svc_time_delta constant it referenced.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfs3proc.c | 107 +++++++++++++++++++++++++++------------------
 fs/nfsd/nfs3xdr.c  |  55 -----------------------
 fs/nfsd/xdr3.h     |  14 ++----
 3 files changed, 67 insertions(+), 109 deletions(-)

diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c
index 0650bfa960e8..ff159d3a0fa6 100644
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -24,9 +24,6 @@
 
 #define NFSDDBG_FACILITY		NFSDDBG_PROC
 
-#define NFS3_FSF_DEFAULT		0x001b
-#define NFS3_FSF_BILLYBOY		0x0018
-
 /*
  * Wrapper structures combine xdrgen types with legacy structures.
  * The xdrgen field must be first so the structure can be cast
@@ -200,6 +197,13 @@ struct FSSTAT3args_wrapper {
 
 static_assert(offsetof(struct FSSTAT3args_wrapper, xdrgen) == 0);
 
+struct FSINFO3args_wrapper {
+	struct FSINFO3args	xdrgen;
+	struct svc_fh		fh;
+};
+
+static_assert(offsetof(struct FSINFO3args_wrapper, xdrgen) == 0);
+
 static int nfsd3_ftype3_to_mode(ftype3 ftype)
 {
 	switch (ftype) {
@@ -1606,47 +1610,63 @@ static __be32 nfsd3_proc_fsstat(struct svc_rqst *rqstp)
 	return rpc_success;
 }
 
-/*
- * Get file system info
+/**
+ * nfsd3_proc_fsinfo - FSINFO: Get static file system information
+ * @rqstp: RPC transaction context
+ *
+ * Return:
+ *   %rpc_success:		RPC executed successfully
+ *
+ * RPC synopsis:
+ *   FSINFO3res NFSPROC3_FSINFO(FSINFO3args) = 19;
  */
-static __be32
-nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
+static __be32 nfsd3_proc_fsinfo(struct svc_rqst *rqstp)
 {
-	struct nfsd_fhandle *argp = rqstp->rq_argp;
+	struct FSINFO3args_wrapper *argp = rqstp->rq_argp;
 	struct nfsd3_fsinfores *resp = rqstp->rq_resp;
-	u32	max_blocksize = svc_max_payload(rqstp);
+	struct svc_fh *fhp = &argp->fh;
 
-	dprintk("nfsd: FSINFO(3)   %s\n",
-				SVCFH_fmt(&argp->fh));
+	nfsd3_fh3_to_svc_fh(fhp, &argp->xdrgen.fsroot);
 
-	resp->f_rtmax  = max_blocksize;
-	resp->f_rtpref = max_blocksize;
-	resp->f_rtmult = PAGE_SIZE;
-	resp->f_wtmax  = max_blocksize;
-	resp->f_wtpref = max_blocksize;
-	resp->f_wtmult = PAGE_SIZE;
-	resp->f_dtpref = max_blocksize;
-	resp->f_maxfilesize = ~(u32) 0;
-	resp->f_properties = NFS3_FSF_DEFAULT;
+	resp->xdrgen.status = fh_verify(rqstp, fhp, 0, NFSD_MAY_NOP |
+					NFSD_MAY_BYPASS_GSS_ON_ROOT);
 
-	resp->status = fh_verify(rqstp, &argp->fh, 0,
-				 NFSD_MAY_NOP | NFSD_MAY_BYPASS_GSS_ON_ROOT);
+	if (resp->xdrgen.status == nfs_ok) {
+		struct FSINFO3resok *resok = &resp->xdrgen.u.resok;
+		struct super_block *sb = fhp->fh_dentry->d_sb;
+		u32 max_blocksize = svc_max_payload(rqstp);
 
-	/* Check special features of the file system. May request
-	 * different read/write sizes for file systems known to have
-	 * problems with large blocks */
-	if (resp->status == nfs_ok) {
-		struct super_block *sb = argp->fh.fh_dentry->d_sb;
+		resok->obj_attributes.attributes_follow = false;
+		resok->rtmax = max_blocksize;
+		resok->rtpref = max_blocksize;
+		resok->rtmult = PAGE_SIZE;
+		resok->wtmax = max_blocksize;
+		resok->wtpref = max_blocksize;
+		resok->wtmult = PAGE_SIZE;
+		resok->dtpref = max_blocksize;
+		resok->maxfilesize = ~(u32)0;
+		/* NFSD is accurate to the nearest second. */
+		resok->time_delta.seconds = 1;
+		resok->time_delta.nseconds = 0;
+		resok->properties = FSF3_LINK | FSF3_SYMLINK |
+				    FSF3_HOMOGENEOUS | FSF3_CANSETTIME;
 
-		/* Note that we don't care for remote fs's here */
-		if (sb->s_magic == MSDOS_SUPER_MAGIC) {
-			resp->f_properties = NFS3_FSF_BILLYBOY;
-		}
-		resp->f_maxfilesize = sb->s_maxbytes;
+		/*
+		 * Check special features of the file system. May
+		 * request different read/write sizes for file systems
+		 * known to have problems with large blocks.
+		 */
+		if (sb->s_magic == MSDOS_SUPER_MAGIC)
+			resok->properties = FSF3_HOMOGENEOUS | FSF3_CANSETTIME;
+		resok->maxfilesize = sb->s_maxbytes;
+	} else {
+		struct FSINFO3resfail *resfail = &resp->xdrgen.u.resfail;
+
+		resp->xdrgen.status = nfsd3_map_status(resp->xdrgen.status);
+		resfail->obj_attributes.attributes_follow = false;
 	}
 
-	fh_put(&argp->fh);
-	resp->status = nfsd3_map_status(resp->status);
+	fh_put(fhp);
 	return rpc_success;
 }
 
@@ -1971,15 +1991,15 @@ static const struct svc_procedure nfsd_procedures3[22] = {
 		.pc_name	= "FSSTAT",
 	},
 	[NFSPROC3_FSINFO] = {
-		.pc_func = nfsd3_proc_fsinfo,
-		.pc_decode = nfs3svc_decode_fhandleargs,
-		.pc_encode = nfs3svc_encode_fsinfores,
-		.pc_argsize = sizeof(struct nfsd3_fhandleargs),
-		.pc_argzero = sizeof(struct nfsd3_fhandleargs),
-		.pc_ressize = sizeof(struct nfsd3_fsinfores),
-		.pc_cachetype = RC_NOCACHE,
-		.pc_xdrressize = ST+pAT+12,
-		.pc_name = "FSINFO",
+		.pc_func	= nfsd3_proc_fsinfo,
+		.pc_decode	= nfs_svc_decode_FSINFO3args,
+		.pc_encode	= nfs_svc_encode_FSINFO3res,
+		.pc_argsize	= sizeof(struct FSINFO3args_wrapper),
+		.pc_argzero	= 0,
+		.pc_ressize	= sizeof(struct nfsd3_fsinfores),
+		.pc_cachetype	= RC_NOCACHE,
+		.pc_xdrressize	= NFS3_FSINFO3res_sz,
+		.pc_name	= "FSINFO",
 	},
 	[NFSPROC3_PATHCONF] = {
 		.pc_func = nfsd3_proc_pathconf,
@@ -2044,6 +2064,7 @@ union nfsd3_xdrstore {
 	struct nfsd3_readdirres		readdirres;
 	struct FSSTAT3args_wrapper	fsstatargs;
 	struct nfsd3_fsstatres		fsstatres;
+	struct FSINFO3args_wrapper	fsinfoargs;
 	struct nfsd3_fsinfores		fsinfores;
 	struct nfsd3_pathconfres	pathconfres;
 	struct nfsd3_commitres		commitres;
diff --git a/fs/nfsd/nfs3xdr.c b/fs/nfsd/nfs3xdr.c
index 0ca671bdd1c8..9e400a97e435 100644
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -24,15 +24,6 @@ static const struct svc_fh nfs3svc_null_fh = {
 	.fh_no_wcc	= true,
 };
 
-/*
- * time_delta. {1, 0} means the server is accurate only
- * to the nearest second.
- */
-static const struct timespec64 nfs3svc_time_delta = {
-	.tv_sec		= 1,
-	.tv_nsec	= 0,
-};
-
 /*
  * Mapping of S_IF* types to NFS file types
  */
@@ -620,52 +611,6 @@ int nfs3svc_encode_entryplus3(void *data, const char *name, int namlen,
 	return -EINVAL;
 }
 
-static bool
-svcxdr_encode_fsinfo3resok(struct xdr_stream *xdr,
-			   const struct nfsd3_fsinfores *resp)
-{
-	__be32 *p;
-
-	p = xdr_reserve_space(xdr, XDR_UNIT * 12);
-	if (!p)
-		return false;
-	*p++ = cpu_to_be32(resp->f_rtmax);
-	*p++ = cpu_to_be32(resp->f_rtpref);
-	*p++ = cpu_to_be32(resp->f_rtmult);
-	*p++ = cpu_to_be32(resp->f_wtmax);
-	*p++ = cpu_to_be32(resp->f_wtpref);
-	*p++ = cpu_to_be32(resp->f_wtmult);
-	*p++ = cpu_to_be32(resp->f_dtpref);
-	p = xdr_encode_hyper(p, resp->f_maxfilesize);
-	p = encode_nfstime3(p, &nfs3svc_time_delta);
-	*p = cpu_to_be32(resp->f_properties);
-
-	return true;
-}
-
-/* FSINFO */
-bool
-nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	struct nfsd3_fsinfores *resp = rqstp->rq_resp;
-
-	if (!svcxdr_encode_nfsstat3(xdr, resp->status))
-		return false;
-	switch (resp->status) {
-	case nfs_ok:
-		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &nfs3svc_null_fh))
-			return false;
-		if (!svcxdr_encode_fsinfo3resok(xdr, resp))
-			return false;
-		break;
-	default:
-		if (!svcxdr_encode_post_op_attr(rqstp, xdr, &nfs3svc_null_fh))
-			return false;
-	}
-
-	return true;
-}
-
 static bool
 svcxdr_encode_pathconf3resok(struct xdr_stream *xdr,
 			     const struct nfsd3_pathconfres *resp)
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index 577a4beaafc3..979b9ea5b86d 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -93,18 +93,11 @@ struct nfsd3_fsstatres {
 static_assert(offsetof(struct nfsd3_fsstatres, xdrgen) == 0);
 
 struct nfsd3_fsinfores {
-	__be32			status;
-	__u32			f_rtmax;
-	__u32			f_rtpref;
-	__u32			f_rtmult;
-	__u32			f_wtmax;
-	__u32			f_wtpref;
-	__u32			f_wtmult;
-	__u32			f_dtpref;
-	__u64			f_maxfilesize;
-	__u32			f_properties;
+	struct FSINFO3res	xdrgen;
 };
 
+static_assert(offsetof(struct nfsd3_fsinfores, xdrgen) == 0);
+
 struct nfsd3_pathconfres {
 	__be32			status;
 	__u32			p_link_max;
@@ -137,7 +130,6 @@ bool nfs3svc_decode_commitargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 
 bool nfs3svc_encode_accessres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nfs3svc_encode_readdirres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
-bool nfs3svc_encode_fsinfores(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nfs3svc_encode_pathconfres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nfs3svc_encode_commitres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 
-- 
2.55.0


  parent reply	other threads:[~2026-10-13 12:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 12:49 [PATCH v3 20/34] NFSD: Use xdrgen XDR functions for the NFSv3 RMDIR procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 21/34] NFSD: Use xdrgen XDR functions for the NFSv3 RENAME procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 22/34] NFSD: Use xdrgen XDR functions for the NFSv3 LINK procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 23/34] NFSD: Use xdrgen XDR functions for the NFSv3 FSSTAT procedure Chuck Lever
2026-10-13 12:49 ` Chuck Lever [this message]
2026-10-13 12:49 ` [PATCH v3 25/34] NFSD: Use xdrgen XDR functions for the NFSv3 PATHCONF procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 26/34] NFSD: Use xdrgen XDR functions for the NFSv3 COMMIT procedure Chuck Lever
2026-10-13 12:49 ` [PATCH v3 27/34] NFSD: Use xdrgen XDR functions for NFSv3 READDIR arguments Chuck Lever
2026-10-13 12:49 ` [PATCH v3 28/34] NFSD: Use xdrgen XDR functions for NFSv3 READDIRPLUS arguments Chuck Lever
2026-10-13 12:49 ` [PATCH v3 29/34] NFSD: Refactor NFSv3 directory cookie encoding Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261013124944.316808-5-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.