Linux NFS development
 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 2/5] xdrgen: Share void RPC procedure handlers across programs
Date: Sun, 12 Jul 2026 15:31:19 -0400	[thread overview]
Message-ID: <20260712193122.116845-3-cel@kernel.org> (raw)
In-Reply-To: <20260712193122.116845-1-cel@kernel.org>

The generated server-side decoder and encoder for a void procedure
argument or result are named after the RPC program (for example,
nfs_svc_decode_void). xdrgen derives that prefix from the program
name alone, not the version, so two versions of one program built
into the same module emit the identical symbol. NFSv2 and NFSv3
both declare program NFS_PROGRAM; once both are converted, fs/nfsd
fails to link with multiple definitions of nfs_svc_decode_void and
nfs_svc_encode_void.

A void handler carries no program- or version-specific behavior:
each merely forwards to xdrgen_decode_void() or xdrgen_encode_void().
Define one shared pair, xdrgen_svc_decode_void() and
xdrgen_svc_encode_void(), in the xdrgen builtins, and stop the
program generator from emitting a per-program void handler.

lockd is the one in-tree consumer that already emits per-program
void handlers, so regenerate the NLMv3 and NLMv4 XDR code to drop
nlm_svc_{decode,encode}_void() and nlm4_svc_{decode,encode}_void()
and point both procedure tables at the shared handlers. The shared
handlers are identical to the generated ones they replace, so no
wire behavior changes.

Only the server (svc) handlers are affected. The client-side void
stubs remain static and per-program, so they do not collide.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/lockd/nlm3xdr_gen.c                        | 28 -------------
 fs/lockd/nlm3xdr_gen.h                        |  2 -
 fs/lockd/nlm4xdr_gen.c                        | 28 -------------
 fs/lockd/nlm4xdr_gen.h                        |  2 -
 fs/lockd/svc4proc.c                           | 40 +++++++++----------
 fs/lockd/svcproc.c                            | 40 +++++++++----------
 include/linux/sunrpc/xdrgen/_builtins.h       | 32 +++++++++++++++
 tools/net/sunrpc/xdrgen/generators/program.py |  8 ++++
 .../templates/C/program/decoder/argument.j2   |  4 --
 .../templates/C/program/encoder/result.j2     |  4 --
 10 files changed, 80 insertions(+), 108 deletions(-)

diff --git a/fs/lockd/nlm3xdr_gen.c b/fs/lockd/nlm3xdr_gen.c
index df14692ce37f..4b6e3ee7a719 100644
--- a/fs/lockd/nlm3xdr_gen.c
+++ b/fs/lockd/nlm3xdr_gen.c
@@ -271,20 +271,6 @@ xdrgen_decode_nlm_notifyargs(struct xdr_stream *xdr, struct nlm_notifyargs *ptr)
 	return true;
 }
 
-/**
- * nlm_svc_decode_void - Decode a void argument
- * @rqstp: RPC transaction context
- * @xdr: source XDR data stream
- *
- * Return values:
- *   %true: procedure arguments decoded successfully
- *   %false: decode failed
- */
-bool nlm_svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	return xdrgen_decode_void(xdr);
-}
-
 /**
  * nlm_svc_decode_nlm_testargs - Decode a nlm_testargs argument
  * @rqstp: RPC transaction context
@@ -651,20 +637,6 @@ xdrgen_encode_nlm_notifyargs(struct xdr_stream *xdr, const struct nlm_notifyargs
 	return true;
 }
 
-/**
- * nlm_svc_encode_void - Encode a void result
- * @rqstp: RPC transaction context
- * @xdr: target XDR data stream
- *
- * Return values:
- *   %true: procedure results encoded successfully
- *   %false: encode failed
- */
-bool nlm_svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	return xdrgen_encode_void(xdr);
-}
-
 /**
  * nlm_svc_encode_nlm_testres - Encode a nlm_testres result
  * @rqstp: RPC transaction context
diff --git a/fs/lockd/nlm3xdr_gen.h b/fs/lockd/nlm3xdr_gen.h
index 3824ffe2aae4..bdbfc26ba0e4 100644
--- a/fs/lockd/nlm3xdr_gen.h
+++ b/fs/lockd/nlm3xdr_gen.h
@@ -13,7 +13,6 @@
 #include <linux/sunrpc/xdrgen/_builtins.h>
 #include <linux/sunrpc/xdrgen/nlm3.h>
 
-bool nlm_svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_decode_nlm_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_decode_nlm_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_decode_nlm_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
@@ -24,7 +23,6 @@ bool nlm_svc_decode_nlm_notifyargs(struct svc_rqst *rqstp, struct xdr_stream *xd
 bool nlm_svc_decode_nlm_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_decode_nlm_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 
-bool nlm_svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_encode_nlm_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_encode_nlm_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm_svc_encode_nlm_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
diff --git a/fs/lockd/nlm4xdr_gen.c b/fs/lockd/nlm4xdr_gen.c
index 5a60aff06714..f98d74ee3d41 100644
--- a/fs/lockd/nlm4xdr_gen.c
+++ b/fs/lockd/nlm4xdr_gen.c
@@ -300,20 +300,6 @@ xdrgen_decode_nlm4_notifyargs(struct xdr_stream *xdr, struct nlm4_notifyargs *pt
 	return true;
 }
 
-/**
- * nlm4_svc_decode_void - Decode a void argument
- * @rqstp: RPC transaction context
- * @xdr: source XDR data stream
- *
- * Return values:
- *   %true: procedure arguments decoded successfully
- *   %false: decode failed
- */
-bool nlm4_svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	return xdrgen_decode_void(xdr);
-}
-
 /**
  * nlm4_svc_decode_nlm4_testargs - Decode a nlm4_testargs argument
  * @rqstp: RPC transaction context
@@ -704,20 +690,6 @@ xdrgen_encode_nlm4_notifyargs(struct xdr_stream *xdr, const struct nlm4_notifyar
 	return true;
 }
 
-/**
- * nlm4_svc_encode_void - Encode a void result
- * @rqstp: RPC transaction context
- * @xdr: target XDR data stream
- *
- * Return values:
- *   %true: procedure results encoded successfully
- *   %false: encode failed
- */
-bool nlm4_svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
-{
-	return xdrgen_encode_void(xdr);
-}
-
 /**
  * nlm4_svc_encode_nlm4_testres - Encode a nlm4_testres result
  * @rqstp: RPC transaction context
diff --git a/fs/lockd/nlm4xdr_gen.h b/fs/lockd/nlm4xdr_gen.h
index ce9dda0a052a..1a72c26ad18a 100644
--- a/fs/lockd/nlm4xdr_gen.h
+++ b/fs/lockd/nlm4xdr_gen.h
@@ -13,7 +13,6 @@
 #include <linux/sunrpc/xdrgen/_builtins.h>
 #include <linux/sunrpc/xdrgen/nlm4.h>
 
-bool nlm4_svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_decode_nlm4_testargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_decode_nlm4_lockargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_decode_nlm4_cancargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
@@ -24,7 +23,6 @@ bool nlm4_svc_decode_nlm4_notifyargs(struct svc_rqst *rqstp, struct xdr_stream *
 bool nlm4_svc_decode_nlm4_shareargs(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_decode_nlm4_notify(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 
-bool nlm4_svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_encode_nlm4_testres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_encode_nlm4_res(struct svc_rqst *rqstp, struct xdr_stream *xdr);
 bool nlm4_svc_encode_nlm4_shareres(struct svc_rqst *rqstp, struct xdr_stream *xdr);
diff --git a/fs/lockd/svc4proc.c b/fs/lockd/svc4proc.c
index d104aab0881a..5a70dbe9c6a4 100644
--- a/fs/lockd/svc4proc.c
+++ b/fs/lockd/svc4proc.c
@@ -1167,8 +1167,8 @@ static __be32 nlm4svc_proc_free_all(struct svc_rqst *rqstp)
 static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_NULL] = {
 		.pc_func	= nlm4svc_proc_null,
-		.pc_decode	= nlm4_svc_decode_void,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= XDR_void,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1228,7 +1228,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_TEST_MSG] = {
 		.pc_func	= nlm4svc_proc_test_msg,
 		.pc_decode	= nlm4_svc_decode_nlm4_testargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_testargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1238,7 +1238,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_LOCK_MSG] = {
 		.pc_func	= nlm4svc_proc_lock_msg,
 		.pc_decode	= nlm4_svc_decode_nlm4_lockargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_lockargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1248,7 +1248,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_CANCEL_MSG] = {
 		.pc_func	= nlm4svc_proc_cancel_msg,
 		.pc_decode	= nlm4_svc_decode_nlm4_cancargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_cancargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1258,7 +1258,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_UNLOCK_MSG] = {
 		.pc_func	= nlm4svc_proc_unlock_msg,
 		.pc_decode	= nlm4_svc_decode_nlm4_unlockargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_unlockargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1268,7 +1268,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_GRANTED_MSG] = {
 		.pc_func	= nlm4svc_proc_granted_msg,
 		.pc_decode	= nlm4_svc_decode_nlm4_testargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_testargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1278,7 +1278,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_TEST_RES] = {
 		.pc_func	= nlm4svc_proc_null,
 		.pc_decode	= nlm4_svc_decode_nlm4_testres,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_testres),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1288,7 +1288,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_LOCK_RES] = {
 		.pc_func	= nlm4svc_proc_null,
 		.pc_decode	= nlm4_svc_decode_nlm4_res,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1298,7 +1298,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_CANCEL_RES] = {
 		.pc_func	= nlm4svc_proc_null,
 		.pc_decode	= nlm4_svc_decode_nlm4_res,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1308,7 +1308,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_UNLOCK_RES] = {
 		.pc_func	= nlm4svc_proc_null,
 		.pc_decode	= nlm4_svc_decode_nlm4_res,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1318,7 +1318,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_GRANTED_RES] = {
 		.pc_func	= nlm4svc_proc_granted_res,
 		.pc_decode	= nlm4_svc_decode_nlm4_res,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_res_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1328,7 +1328,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_SM_NOTIFY] = {
 		.pc_func	= nlm4svc_proc_sm_notify,
 		.pc_decode	= nlm4_svc_decode_nlm4_notifyargs,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_notifyargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1337,8 +1337,8 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	},
 	[17] = {
 		.pc_func	= nlm4svc_proc_unused,
-		.pc_decode	= nlm4_svc_decode_void,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1347,8 +1347,8 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	},
 	[18] = {
 		.pc_func	= nlm4svc_proc_unused,
-		.pc_decode	= nlm4_svc_decode_void,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1357,8 +1357,8 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	},
 	[19] = {
 		.pc_func	= nlm4svc_proc_unused,
-		.pc_decode	= nlm4_svc_decode_void,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1398,7 +1398,7 @@ static const struct svc_procedure nlm4svc_procedures[24] = {
 	[NLMPROC4_FREE_ALL] = {
 		.pc_func	= nlm4svc_proc_free_all,
 		.pc_decode	= nlm4_svc_decode_nlm4_notify,
-		.pc_encode	= nlm4_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm4_notify_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
diff --git a/fs/lockd/svcproc.c b/fs/lockd/svcproc.c
index a1f9d66c2981..7ba628939cff 100644
--- a/fs/lockd/svcproc.c
+++ b/fs/lockd/svcproc.c
@@ -1176,8 +1176,8 @@ static __be32 nlmsvc_proc_free_all(struct svc_rqst *rqstp)
 static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_NULL] = {
 		.pc_func	= nlmsvc_proc_null,
-		.pc_decode	= nlm_svc_decode_void,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= XDR_void,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1237,7 +1237,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_TEST_MSG] = {
 		.pc_func	= nlmsvc_proc_test_msg,
 		.pc_decode	= nlm_svc_decode_nlm_testargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_testargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1247,7 +1247,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_LOCK_MSG] = {
 		.pc_func	= nlmsvc_proc_lock_msg,
 		.pc_decode	= nlm_svc_decode_nlm_lockargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_lockargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1257,7 +1257,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_CANCEL_MSG] = {
 		.pc_func	= nlmsvc_proc_cancel_msg,
 		.pc_decode	= nlm_svc_decode_nlm_cancargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_cancargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1267,7 +1267,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_UNLOCK_MSG] = {
 		.pc_func	= nlmsvc_proc_unlock_msg,
 		.pc_decode	= nlm_svc_decode_nlm_unlockargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_unlockargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1277,7 +1277,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_GRANTED_MSG] = {
 		.pc_func	= nlmsvc_proc_granted_msg,
 		.pc_decode	= nlm_svc_decode_nlm_testargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_testargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1287,7 +1287,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_TEST_RES] = {
 		.pc_func	= nlmsvc_proc_null,
 		.pc_decode	= nlm_svc_decode_nlm_testres,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_testres),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1297,7 +1297,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_LOCK_RES] = {
 		.pc_func	= nlmsvc_proc_null,
 		.pc_decode	= nlm_svc_decode_nlm_res,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1307,7 +1307,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_CANCEL_RES] = {
 		.pc_func	= nlmsvc_proc_null,
 		.pc_decode	= nlm_svc_decode_nlm_res,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1317,7 +1317,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_UNLOCK_RES] = {
 		.pc_func	= nlmsvc_proc_null,
 		.pc_decode	= nlm_svc_decode_nlm_res,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_res),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1327,7 +1327,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_GRANTED_RES] = {
 		.pc_func	= nlmsvc_proc_granted_res,
 		.pc_decode	= nlm_svc_decode_nlm_res,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_res_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1337,7 +1337,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_SM_NOTIFY] = {
 		.pc_func	= nlmsvc_proc_sm_notify,
 		.pc_decode	= nlm_svc_decode_nlm_notifyargs,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_notifyargs_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1346,8 +1346,8 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	},
 	[17] = {
 		.pc_func	= nlmsvc_proc_unused,
-		.pc_decode	= nlm_svc_decode_void,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1356,8 +1356,8 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	},
 	[18] = {
 		.pc_func	= nlmsvc_proc_unused,
-		.pc_decode	= nlm_svc_decode_void,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1366,8 +1366,8 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	},
 	[19] = {
 		.pc_func	= nlmsvc_proc_unused,
-		.pc_decode	= nlm_svc_decode_void,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_decode	= xdrgen_svc_decode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= 0,
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
@@ -1407,7 +1407,7 @@ static const struct svc_procedure nlmsvc_procedures[24] = {
 	[NLM_FREE_ALL] = {
 		.pc_func	= nlmsvc_proc_free_all,
 		.pc_decode	= nlm_svc_decode_nlm_notify,
-		.pc_encode	= nlm_svc_encode_void,
+		.pc_encode	= xdrgen_svc_encode_void,
 		.pc_argsize	= sizeof(struct nlm_notify_wrapper),
 		.pc_argzero	= 0,
 		.pc_ressize	= 0,
diff --git a/include/linux/sunrpc/xdrgen/_builtins.h b/include/linux/sunrpc/xdrgen/_builtins.h
index a723fb1da9c8..c9033eb1c829 100644
--- a/include/linux/sunrpc/xdrgen/_builtins.h
+++ b/include/linux/sunrpc/xdrgen/_builtins.h
@@ -296,4 +296,36 @@ xdrgen_encode_opaque(struct xdr_stream *xdr, opaque val)
 	return true;
 }
 
+struct svc_rqst;
+
+/**
+ * xdrgen_svc_decode_void - Decode a void argument
+ * @rqstp: RPC transaction context
+ * @xdr: source XDR data stream
+ *
+ * Return values:
+ *   %true: procedure arguments decoded successfully
+ *   %false: decode failed
+ */
+static inline bool
+xdrgen_svc_decode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
+{
+	return xdrgen_decode_void(xdr);
+}
+
+/**
+ * xdrgen_svc_encode_void - Encode a void result
+ * @rqstp: RPC transaction context
+ * @xdr: target XDR data stream
+ *
+ * Return values:
+ *   %true: procedure results encoded successfully
+ *   %false: encode failed
+ */
+static inline bool
+xdrgen_svc_encode_void(struct svc_rqst *rqstp, struct xdr_stream *xdr)
+{
+	return xdrgen_encode_void(xdr);
+}
+
 #endif /* _SUNRPC_XDRGEN__BUILTINS_H_ */
diff --git a/tools/net/sunrpc/xdrgen/generators/program.py b/tools/net/sunrpc/xdrgen/generators/program.py
index c0cb3f6d3319..37f9655c83fe 100644
--- a/tools/net/sunrpc/xdrgen/generators/program.py
+++ b/tools/net/sunrpc/xdrgen/generators/program.py
@@ -38,6 +38,8 @@ def emit_version_declarations(
     arguments = dict.fromkeys([])
     for procedure in version.procedures:
         if procedure.name not in excluded_apis:
+            if procedure.argument.type_name == "void":
+                continue
             arguments[procedure.argument.type_name] = None
     if len(arguments) > 0:
         print("")
@@ -48,6 +50,8 @@ def emit_version_declarations(
     results = dict.fromkeys([])
     for procedure in version.procedures:
         if procedure.name not in excluded_apis:
+            if procedure.result.type_name == "void":
+                continue
             results[procedure.result.type_name] = None
     if len(results) > 0:
         print("")
@@ -63,6 +67,8 @@ def emit_version_argument_decoders(
     arguments = dict.fromkeys([])
     for procedure in version.procedures:
         if procedure.name not in excluded_apis:
+            if procedure.argument.type_name == "void":
+                continue
             arguments[procedure.argument.type_name] = None
 
     template = environment.get_template("decoder/argument.j2")
@@ -105,6 +111,8 @@ def emit_version_result_encoders(
     results = dict.fromkeys([])
     for procedure in version.procedures:
         if procedure.name not in excluded_apis:
+            if procedure.result.type_name == "void":
+                continue
             results[procedure.result.type_name] = None
 
     template = environment.get_template("encoder/result.j2")
diff --git a/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2 b/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
index 19b219dd276d..096d553b2a1e 100644
--- a/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
+++ b/tools/net/sunrpc/xdrgen/templates/C/program/decoder/argument.j2
@@ -11,9 +11,6 @@
  */
 bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 {
-{% if argument == 'void' %}
-	return xdrgen_decode_void(xdr);
-{% else %}
 {% if argument in structs %}
 	struct {{ argument }} *argp = rqstp->rq_argp;
 {% else %}
@@ -21,5 +18,4 @@ bool {{ program }}_svc_decode_{{ argument }}(struct svc_rqst *rqstp, struct xdr_
 {% endif %}
 
 	return xdrgen_decode_{{ argument }}(xdr, argp);
-{% endif %}
 }
diff --git a/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2 b/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
index 746592cfda56..4243d91966fd 100644
--- a/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
+++ b/tools/net/sunrpc/xdrgen/templates/C/program/encoder/result.j2
@@ -11,9 +11,6 @@
  */
 bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_stream *xdr)
 {
-{% if result == 'void' %}
-	return xdrgen_encode_void(xdr);
-{% else %}
 {% if result in structs %}
 	struct {{ result }} *resp = rqstp->rq_resp;
 
@@ -23,5 +20,4 @@ bool {{ program }}_svc_encode_{{ result }}(struct svc_rqst *rqstp, struct xdr_st
 
 	return xdrgen_encode_{{ result }}(xdr, *resp);
 {% endif %}
-{% endif %}
 }
-- 
2.54.0


  parent reply	other threads:[~2026-07-12 19:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-12 19:31 [PATCH 0/5] Minor fixes for xdrgen Chuck Lever
2026-07-12 19:31 ` [PATCH 1/5] xdrgen: Emit a blank line ahead of enum declarations Chuck Lever
2026-07-12 19:31 ` Chuck Lever [this message]
2026-07-12 19:31 ` [PATCH 3/5] xdrgen: Do not declare union XDR functions in the definitions header Chuck Lever
2026-07-12 19:31 ` [PATCH 4/5] xdrgen: Add XDR width macros for short integer types Chuck Lever
2026-07-12 19:31 ` [PATCH 5/5] xdrgen: Fix opaque and string encoders for unbounded members 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=20260712193122.116845-3-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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox