Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 0/3] Remove NFS client header dependencies from LOCALIO
@ 2026-07-27 13:04 Chuck Lever
  2026-07-27 13:04 ` [PATCH 1/3] NFSD: Move the RPC program definition for LOCALIO Chuck Lever
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Chuck Lever @ 2026-07-27 13:04 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Clean up: fs/nfsd/localio.c is a server-side component, so it should
avoid dependency on client-specific headers and XDR utilities.

No change in behavior is expected.

Chuck Lever (3):
  NFSD: Move the RPC program definition for LOCALIO
  nfs_common: Remove "#include <linux/nfs.h>" from linux/nfslocalio.h
  NFSD: Tighten header includes in localio.c

 fs/nfsd/localio.c          |  7 +++----
 include/linux/nfs.h        |  7 -------
 include/linux/nfslocalio.h | 11 ++++++++++-
 3 files changed, 13 insertions(+), 12 deletions(-)

-- 
2.54.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] NFSD: Move the RPC program definition for LOCALIO
  2026-07-27 13:04 [PATCH 0/3] Remove NFS client header dependencies from LOCALIO Chuck Lever
@ 2026-07-27 13:04 ` Chuck Lever
  2026-07-27 13:04 ` [PATCH 2/3] nfs_common: Remove "#include <linux/nfs.h>" from linux/nfslocalio.h Chuck Lever
  2026-07-27 13:04 ` [PATCH 3/3] NFSD: Tighten header includes in localio.c Chuck Lever
  2 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2026-07-27 13:04 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Clean up: The definitions for the LOCALIO program are not needed by
most files that include linux/nfs.h. Following the convention used
by most other in-kernel RPC program implementations, relocate the
LOCALIO program definitions to a localio-specific header.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 include/linux/nfs.h        | 7 -------
 include/linux/nfslocalio.h | 8 ++++++++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/include/linux/nfs.h b/include/linux/nfs.h
index 0e2b210c103b..8c2818db43c5 100644
--- a/include/linux/nfs.h
+++ b/include/linux/nfs.h
@@ -15,11 +15,4 @@
 
 #include <uapi/linux/nfs.h>
 
-/* The LOCALIO program is entirely private to Linux and is
- * NOT part of the uapi.
- */
-#define NFS_LOCALIO_PROGRAM		400122
-#define LOCALIOPROC_NULL		0
-#define LOCALIOPROC_UUID_IS_LOCAL	1
-
 #endif /* _LINUX_NFS_H */
diff --git a/include/linux/nfslocalio.h b/include/linux/nfslocalio.h
index 3d91043254e6..d2b39e6e6c6a 100644
--- a/include/linux/nfslocalio.h
+++ b/include/linux/nfslocalio.h
@@ -16,6 +16,14 @@
 #include <linux/nfs.h>
 #include <net/net_namespace.h>
 
+/*
+ * The LOCALIO program is entirely private to Linux and is NOT part of
+ * the uapi.
+ */
+#define NFS_LOCALIO_PROGRAM		400122
+#define LOCALIOPROC_NULL		0
+#define LOCALIOPROC_UUID_IS_LOCAL	1
+
 struct nfs_client;
 struct nfs_file_localio;
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] nfs_common: Remove "#include <linux/nfs.h>" from linux/nfslocalio.h
  2026-07-27 13:04 [PATCH 0/3] Remove NFS client header dependencies from LOCALIO Chuck Lever
  2026-07-27 13:04 ` [PATCH 1/3] NFSD: Move the RPC program definition for LOCALIO Chuck Lever
@ 2026-07-27 13:04 ` Chuck Lever
  2026-07-27 13:04 ` [PATCH 3/3] NFSD: Tighten header includes in localio.c Chuck Lever
  2 siblings, 0 replies; 5+ messages in thread
From: Chuck Lever @ 2026-07-27 13:04 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Clean up: linux/nfslocalio.h pulls in linux/nfs.h only for the
definition of struct nfs_fh, which now lives in linux/nfs_fh.h.

Replace linux/nfs.h with linux/nfs_fh.h so that nfslocalio.h no longer
carries uapi/linux/nfs.h into its consumers.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 include/linux/nfslocalio.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/linux/nfslocalio.h b/include/linux/nfslocalio.h
index d2b39e6e6c6a..8ce4d978a636 100644
--- a/include/linux/nfslocalio.h
+++ b/include/linux/nfslocalio.h
@@ -13,7 +13,8 @@
 #include <linux/uuid.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/svcauth.h>
-#include <linux/nfs.h>
+#include <linux/nfs_fh.h>
+
 #include <net/net_namespace.h>
 
 /*
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] NFSD: Tighten header includes in localio.c
  2026-07-27 13:04 [PATCH 0/3] Remove NFS client header dependencies from LOCALIO Chuck Lever
  2026-07-27 13:04 ` [PATCH 1/3] NFSD: Move the RPC program definition for LOCALIO Chuck Lever
  2026-07-27 13:04 ` [PATCH 2/3] nfs_common: Remove "#include <linux/nfs.h>" from linux/nfslocalio.h Chuck Lever
@ 2026-07-27 13:04 ` Chuck Lever
  2026-07-28  0:33   ` NeilBrown
  2 siblings, 1 reply; 5+ messages in thread
From: Chuck Lever @ 2026-07-27 13:04 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

As a prerequisite to converting NFSD to use xdrgen more broadly,
NFSD source files should not depend on NFS client headers.
fs/nfsd/localio.c is server-side LOCALIO code, yet it pulled in
three of them: <linux/nfs_fs.h>, the client inode header (struct
nfs_inode, NFS_I(), writeback helpers), which server code never
uses; <linux/nfs_xdr.h>, whose only referenced symbol is
decode_opaque_fixed(), a static inline that exists to remap the
error return to -EIO for client call sites; and the catch-all
<linux/nfs.h>.

Convert the UUID decoder to call the canonical SUNRPC primitive
xdr_stream_decode_opaque_fixed() directly. It is shared by client
and server, performs the identical bounds check, and is already
reachable through <linux/sunrpc/clnt.h>. With the wrapper gone,
localio.c references no symbol from <linux/nfs_xdr.h>, and with
that header gone, none of the NFSv3 definitions its structs embed
are needed here.

Drop all three client includes and add what the file actually
uses: struct nfs_fh comes from <linux/nfs_fh.h>, included directly
rather than through nfslocalio.h's conditional re-export, and
NFS4_FHSIZE from <linux/nfs4.h>. enum nfs_stat and
nfs_stat_to_errno continue to come from the already-included
<linux/nfs_common.h>.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/localio.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c
index c458c01e9478..4110be02b750 100644
--- a/fs/nfsd/localio.c
+++ b/fs/nfsd/localio.c
@@ -11,11 +11,10 @@
 #include <linux/exportfs.h>
 #include <linux/sunrpc/svcauth.h>
 #include <linux/sunrpc/clnt.h>
-#include <linux/nfs.h>
+#include <linux/nfs4.h>
 #include <linux/nfs_common.h>
+#include <linux/nfs_fh.h>
 #include <linux/nfslocalio.h>
-#include <linux/nfs_fs.h>
-#include <linux/nfs_xdr.h>
 #include <linux/string.h>
 
 #include "nfsd.h"
@@ -179,7 +178,7 @@ static bool localio_decode_uuidarg(struct svc_rqst *rqstp,
 	struct localio_uuidarg *argp = rqstp->rq_argp;
 	u8 uuid[UUID_SIZE];
 
-	if (decode_opaque_fixed(xdr, uuid, UUID_SIZE))
+	if (xdr_stream_decode_opaque_fixed(xdr, uuid, UUID_SIZE) < 0)
 		return false;
 	import_uuid(&argp->uuid, uuid);
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/3] NFSD: Tighten header includes in localio.c
  2026-07-27 13:04 ` [PATCH 3/3] NFSD: Tighten header includes in localio.c Chuck Lever
@ 2026-07-28  0:33   ` NeilBrown
  0 siblings, 0 replies; 5+ messages in thread
From: NeilBrown @ 2026-07-28  0:33 UTC (permalink / raw)
  To: Chuck Lever
  Cc: Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey, linux-nfs

On Mon, 27 Jul 2026, Chuck Lever wrote:
> As a prerequisite to converting NFSD to use xdrgen more broadly,
> NFSD source files should not depend on NFS client headers.
> fs/nfsd/localio.c is server-side LOCALIO code, yet it pulled in
> three of them: <linux/nfs_fs.h>, the client inode header (struct
> nfs_inode, NFS_I(), writeback helpers), which server code never
> uses; <linux/nfs_xdr.h>, whose only referenced symbol is
> decode_opaque_fixed(), a static inline that exists to remap the
> error return to -EIO for client call sites; and the catch-all
> <linux/nfs.h>.
> 
> Convert the UUID decoder to call the canonical SUNRPC primitive
> xdr_stream_decode_opaque_fixed() directly. It is shared by client
> and server, performs the identical bounds check, and is already
> reachable through <linux/sunrpc/clnt.h>. With the wrapper gone,
> localio.c references no symbol from <linux/nfs_xdr.h>, and with
> that header gone, none of the NFSv3 definitions its structs embed
> are needed here.
> 
> Drop all three client includes and add what the file actually
> uses: struct nfs_fh comes from <linux/nfs_fh.h>, included directly
> rather than through nfslocalio.h's conditional re-export, and
> NFS4_FHSIZE from <linux/nfs4.h>. enum nfs_stat and
> nfs_stat_to_errno continue to come from the already-included
> <linux/nfs_common.h>.

I think it would be better to not include nfs4.h because it doesn't seem
particularly relevant to localio.
Instead, replace NFS4_FHSIZE in localio.c with NFS_MAXFHSIZE which is
defined in nfs_fh.h.  I think that macro is a better fit for what is
actually wanted.

Otherwise this all looks good and sensible.

Thanks,
NeilBrown

> 
> Signed-off-by: Chuck Lever <cel@kernel.org>
> ---
>  fs/nfsd/localio.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/fs/nfsd/localio.c b/fs/nfsd/localio.c
> index c458c01e9478..4110be02b750 100644
> --- a/fs/nfsd/localio.c
> +++ b/fs/nfsd/localio.c
> @@ -11,11 +11,10 @@
>  #include <linux/exportfs.h>
>  #include <linux/sunrpc/svcauth.h>
>  #include <linux/sunrpc/clnt.h>
> -#include <linux/nfs.h>
> +#include <linux/nfs4.h>
>  #include <linux/nfs_common.h>
> +#include <linux/nfs_fh.h>
>  #include <linux/nfslocalio.h>
> -#include <linux/nfs_fs.h>
> -#include <linux/nfs_xdr.h>
>  #include <linux/string.h>
>  
>  #include "nfsd.h"
> @@ -179,7 +178,7 @@ static bool localio_decode_uuidarg(struct svc_rqst *rqstp,
>  	struct localio_uuidarg *argp = rqstp->rq_argp;
>  	u8 uuid[UUID_SIZE];
>  
> -	if (decode_opaque_fixed(xdr, uuid, UUID_SIZE))
> +	if (xdr_stream_decode_opaque_fixed(xdr, uuid, UUID_SIZE) < 0)
>  		return false;
>  	import_uuid(&argp->uuid, uuid);
>  
> -- 
> 2.54.0
> 
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-28  0:33 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-27 13:04 [PATCH 0/3] Remove NFS client header dependencies from LOCALIO Chuck Lever
2026-07-27 13:04 ` [PATCH 1/3] NFSD: Move the RPC program definition for LOCALIO Chuck Lever
2026-07-27 13:04 ` [PATCH 2/3] nfs_common: Remove "#include <linux/nfs.h>" from linux/nfslocalio.h Chuck Lever
2026-07-27 13:04 ` [PATCH 3/3] NFSD: Tighten header includes in localio.c Chuck Lever
2026-07-28  0:33   ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox