Linux NFS development
 help / color / mirror / Atom feed
* [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h
@ 2026-07-12 20:45 Chuck Lever
  2026-07-12 20:45 ` [PATCH 1/9] NFSD: Make "stats.h" self-contained Chuck Lever
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

fs/nfsd/nfsd.h has become a kitchen sink of unrelated declarations
and definitions, including a broad swathe of headers and other
detritus in NFSD source files. This organization introduces
brittleness that makes it difficult to execute changes that cut
across layers and internal modules that might otherwise be cleanly
siloed. It also pulls in unused items into each TU, making
compilation of nfsd.ko needlessly slower and more computationally-
expensive.

This series begins sorting through this pile to relocate items that
are obviously better placed in NFS version- or task-specific
headers.

Chuck Lever (9):
  NFSD: Make "stats.h" self-contained
  NFSD: Explicitly include "stats.h"
  NFSD: include "netns.h"
  NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h
  NFSD: Move the export.h include from nfsd.h to auth.c
  NFSD: Move struct readdir_cd
  NFSD: Relocate nfsd_user_namespace()
  NFSD: Relocate nfsd4_set_netaddr()
  NFSD: Relocate NFSv4 "supported attributes" to new header

 fs/nfsd/attr4.h     | 162 +++++++++++++++++++++++++++++++++++
 fs/nfsd/auth.c      |  19 +++++
 fs/nfsd/auth.h      |   6 ++
 fs/nfsd/cache.h     |   3 +-
 fs/nfsd/nfs4idmap.c |   1 +
 fs/nfsd/nfs4proc.c  |  32 +++++++
 fs/nfsd/nfs4state.c |   1 +
 fs/nfsd/nfs4xdr.c   |   2 +
 fs/nfsd/nfscache.c  |   2 +
 fs/nfsd/nfsctl.c    |   2 +
 fs/nfsd/nfsd.h      | 202 +-------------------------------------------
 fs/nfsd/nfsfh.c     |   2 +
 fs/nfsd/nfsxdr.c    |   2 +
 fs/nfsd/state.h     |   3 +
 fs/nfsd/stats.c     |   2 +
 fs/nfsd/stats.h     |   3 +
 fs/nfsd/trace.h     |   1 +
 fs/nfsd/vfs.c       |   2 +
 fs/nfsd/vfs.h       |   5 +-
 fs/nfsd/xdr.h       |   1 +
 fs/nfsd/xdr3.h      |   1 +
 fs/nfsd/xdr4.h      |   2 +-
 22 files changed, 253 insertions(+), 203 deletions(-)
 create mode 100644 fs/nfsd/attr4.h

-- 
2.54.0


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

* [PATCH 1/9] NFSD: Make "stats.h" self-contained
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 2/9] NFSD: Explicitly include "stats.h" Chuck Lever
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

The inline helpers in fs/nfsd/stats.h dereference struct nfsd_net and
struct svc_export, yet the header includes neither "netns.h" nor
"export.h", where those types are defined. Each helper therefore
compiles only when its translation unit has already pulled in both
headers ahead of "stats.h" -- a hidden ordering requirement that has
to be honored at every include site.

Include "netns.h" and "export.h" from "stats.h" directly so the
header stands on its own, and no consumer has to order its includes
to satisfy it.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/stats.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/fs/nfsd/stats.h b/fs/nfsd/stats.h
index e4efb0e4e56d..87736b7fbf28 100644
--- a/fs/nfsd/stats.h
+++ b/fs/nfsd/stats.h
@@ -10,6 +10,9 @@
 #include <uapi/linux/nfsd/stats.h>
 #include <linux/percpu_counter.h>
 
+#include "export.h"
+#include "netns.h"
+
 struct proc_dir_entry *nfsd_proc_stat_init(struct net *net);
 void nfsd_proc_stat_shutdown(struct net *net);
 
-- 
2.54.0


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

* [PATCH 2/9] NFSD: Explicitly include "stats.h"
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
  2026-07-12 20:45 ` [PATCH 1/9] NFSD: Make "stats.h" self-contained Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 3/9] NFSD: include "netns.h" Chuck Lever
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Nothing in fs/nfsd/nfsd.h needs what is defined in "stats.h", so that
header can be moved out to the six translation units that actually
need it.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfs4state.c | 1 +
 fs/nfsd/nfscache.c  | 1 +
 fs/nfsd/nfsctl.c    | 1 +
 fs/nfsd/nfsd.h      | 1 -
 fs/nfsd/nfsfh.c     | 1 +
 fs/nfsd/stats.c     | 1 +
 fs/nfsd/vfs.c       | 1 +
 7 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 5559dac9e7f4..7de4b913b0a2 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -51,6 +51,7 @@
 #include "xdr4cb.h"
 #include "vfs.h"
 #include "current_stateid.h"
+#include "stats.h"
 
 #include "netns.h"
 #include "pnfs.h"
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index 18f8556d33dd..bdf92ec00e7e 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -19,6 +19,7 @@
 #include <net/checksum.h>
 
 #include "nfsd.h"
+#include "stats.h"
 #include "cache.h"
 #include "trace.h"
 
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 0543e5bb842f..4de0a8dc7ebe 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -23,6 +23,7 @@
 
 #include "idmap.h"
 #include "nfsd.h"
+#include "stats.h"
 #include "cache.h"
 #include "state.h"
 #include "netns.h"
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 4c5d915225df..0b225eb3ef3f 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -41,7 +41,6 @@
 bool nfsd_support_version(int vers);
 
 #include "netns.h"
-#include "stats.h"
 
 /*
  * Default and maximum payload size (NFS READ or WRITE), in bytes.
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index 8b1a95e1d058..c23ae31f60e0 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -13,6 +13,7 @@
 #include <linux/sunrpc/svcauth_gss.h>
 #include <crypto/utils.h>
 #include "nfsd.h"
+#include "stats.h"
 #include "vfs.h"
 #include "auth.h"
 #include "trace.h"
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index f7eaf95e20fc..d7edbda260f0 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -26,6 +26,7 @@
 #include <net/net_namespace.h>
 
 #include "nfsd.h"
+#include "stats.h"
 
 static int nfsd_show(struct seq_file *seq, void *v)
 {
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 9e05c3949cc1..0a1e7bfea3c8 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -43,6 +43,7 @@
 #endif /* CONFIG_NFSD_V4 */
 
 #include "nfsd.h"
+#include "stats.h"
 #include "vfs.h"
 #include "filecache.h"
 #include "trace.h"
-- 
2.54.0


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

* [PATCH 3/9] NFSD: include "netns.h"
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
  2026-07-12 20:45 ` [PATCH 1/9] NFSD: Make "stats.h" self-contained Chuck Lever
  2026-07-12 20:45 ` [PATCH 2/9] NFSD: Explicitly include "stats.h" Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 4/9] NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h Chuck Lever
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Nothing in fs/nfsd/nfsd.h needs the contents of "netns.h"; the
prototypes there that take a struct nfsd_net pointer need only a
forward declaration of that type. Relocate the existing forward
declaration ahead of the first such prototype, drop the "netns.h"
include from nfsd.h, and include it directly in the translation
units that operate on struct nfsd_net.

"netns.h" had also been the path by which <linux/filelock.h>
reached nfsxdr.c and state.h. Both now include <linux/filelock.h>
themselves.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfscache.c | 1 +
 fs/nfsd/nfsctl.c   | 1 +
 fs/nfsd/nfsd.h     | 6 ++----
 fs/nfsd/nfsfh.c    | 1 +
 fs/nfsd/nfsxdr.c   | 2 ++
 fs/nfsd/state.h    | 3 +++
 fs/nfsd/stats.c    | 1 +
 fs/nfsd/trace.h    | 1 +
 fs/nfsd/vfs.c      | 1 +
 9 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
index bdf92ec00e7e..07a53a5b3d37 100644
--- a/fs/nfsd/nfscache.c
+++ b/fs/nfsd/nfscache.c
@@ -19,6 +19,7 @@
 #include <net/checksum.h>
 
 #include "nfsd.h"
+#include "netns.h"
 #include "stats.h"
 #include "cache.h"
 #include "trace.h"
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 4de0a8dc7ebe..7e1d5a5d6511 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -23,6 +23,7 @@
 
 #include "idmap.h"
 #include "nfsd.h"
+#include "netns.h"
 #include "stats.h"
 #include "cache.h"
 #include "state.h"
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 0b225eb3ef3f..4583d7d51a88 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -40,8 +40,6 @@
 #define NFSD_SUPPORTED_MINOR_VERSION	2
 bool nfsd_support_version(int vers);
 
-#include "netns.h"
-
 /*
  * Default and maximum payload size (NFS READ or WRITE), in bytes.
  * The maximum is an implementation limit.
@@ -100,6 +98,8 @@ struct nfsdfs_client {
 	void (*cl_release)(struct kref *kref);
 };
 
+struct nfsd_net;
+
 struct nfsdfs_client *get_nfsdfs_client(struct inode *);
 struct dentry *nfsd_client_mkdir(struct nfsd_net *nn,
 				 struct nfsdfs_client *ncl, u32 id,
@@ -125,8 +125,6 @@ extern const struct svc_version nfsd_acl_version3;
 extern const struct svc_version localio_version1;
 #endif
 
-struct nfsd_net;
-
 enum vers_op {NFSD_SET, NFSD_CLEAR, NFSD_TEST, NFSD_AVAIL };
 int nfsd_vers(struct nfsd_net *nn, int vers, enum vers_op change);
 int nfsd_minorversion(struct nfsd_net *nn, u32 minorversion, enum vers_op change);
diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
index c23ae31f60e0..c7c60c35bdfc 100644
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -13,6 +13,7 @@
 #include <linux/sunrpc/svcauth_gss.h>
 #include <crypto/utils.h>
 #include "nfsd.h"
+#include "netns.h"
 #include "stats.h"
 #include "vfs.h"
 #include "auth.h"
diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c
index 86c9dd4b334b..019f0cc971a7 100644
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -5,6 +5,8 @@
  * Copyright (C) 1995, 1996 Olaf Kirch <okir@monad.swb.de>
  */
 
+#include <linux/filelock.h>
+
 #include "vfs.h"
 #include "xdr.h"
 #include "auth.h"
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
index bc0181ef1cb6..7255d184b41f 100644
--- a/fs/nfsd/state.h
+++ b/fs/nfsd/state.h
@@ -36,9 +36,12 @@
 #define _NFSD4_STATE_H
 
 #include <crypto/md5.h>
+
+#include <linux/filelock.h>
 #include <linux/idr.h>
 #include <linux/refcount.h>
 #include <linux/sunrpc/svc_xprt.h>
+
 #include "nfsfh.h"
 #include "nfsd.h"
 
diff --git a/fs/nfsd/stats.c b/fs/nfsd/stats.c
index d7edbda260f0..9a03e097cfe5 100644
--- a/fs/nfsd/stats.c
+++ b/fs/nfsd/stats.c
@@ -26,6 +26,7 @@
 #include <net/net_namespace.h>
 
 #include "nfsd.h"
+#include "netns.h"
 #include "stats.h"
 
 static int nfsd_show(struct seq_file *seq, void *v)
diff --git a/fs/nfsd/trace.h b/fs/nfsd/trace.h
index db0a0dc70660..7d7a1483109a 100644
--- a/fs/nfsd/trace.h
+++ b/fs/nfsd/trace.h
@@ -19,6 +19,7 @@
 #include "export.h"
 #include "nfsfh.h"
 #include "xdr4.h"
+#include "netns.h"
 
 #define NFSD_TRACE_PROC_CALL_FIELDS(r) \
 		__field(unsigned int, netns_ino) \
diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
index 0a1e7bfea3c8..8923a9910a08 100644
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -43,6 +43,7 @@
 #endif /* CONFIG_NFSD_V4 */
 
 #include "nfsd.h"
+#include "netns.h"
 #include "stats.h"
 #include "vfs.h"
 #include "filecache.h"
-- 
2.54.0


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

* [PATCH 4/9] NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (2 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 3/9] NFSD: include "netns.h" Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 5/9] NFSD: Move the export.h include from nfsd.h to auth.c Chuck Lever
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Clean up: cache.h does not need the full definition of struct
nfsd_net. A forward declaration suffices.

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

diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h
index bb7addef4a31..3bc4856e34b8 100644
--- a/fs/nfsd/cache.h
+++ b/fs/nfsd/cache.h
@@ -10,7 +10,8 @@
 #define NFSCACHE_H
 
 #include <linux/sunrpc/svc.h>
-#include "nfsd.h"
+
+struct nfsd_net;
 
 /*
  * Representation of a reply cache entry.
-- 
2.54.0


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

* [PATCH 5/9] NFSD: Move the export.h include from nfsd.h to auth.c
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (3 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 4/9] NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 6/9] NFSD: Move struct readdir_cd Chuck Lever
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Nothing declared in fs/nfsd/nfsd.h references a type, macro, or
function that export.h defines. The include is present only so
that source files including nfsd.h pick up export.h's definitions
transitively. Of the twenty source files that include nfsd.h, only
auth.c relies on that side effect: it names struct svc_export and the
NFSEXP_* flags yet includes no header that supplies them.

Add the export.h include directly to auth.c, then drop it from nfsd.h
so the header carries only the dependencies its own declarations
require.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/auth.c | 1 +
 fs/nfsd/nfsd.h | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index 4dc327e02456..e3b4a35caac6 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -3,6 +3,7 @@
 
 #include <linux/sched.h>
 #include "nfsd.h"
+#include "export.h"
 #include "auth.h"
 
 int nfsexp_flags(struct svc_cred *cred, struct svc_export *exp)
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 4583d7d51a88..b35e9a9a112d 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -23,8 +23,6 @@
 
 #include <uapi/linux/nfsd/debug.h>
 
-#include "export.h"
-
 #undef ifdebug
 #ifdef CONFIG_SUNRPC_DEBUG
 # define ifdebug(flag)		if (nfsd_debug & NFSDDBG_##flag)
-- 
2.54.0


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

* [PATCH 6/9] NFSD: Move struct readdir_cd
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (4 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 5/9] NFSD: Move the export.h include from nfsd.h to auth.c Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 7/9] NFSD: Relocate nfsd_user_namespace() Chuck Lever
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

struct readdir_cd is part of the VFS readdir API, but it lives in
nfsd.h, the subsystem's catch-all header, rather than alongside that
API. That forces vfs.h to include nfsd.h solely to declare readdir_cd
for its nfsd_readdir() prototype, a layering inversion since vfs.h is
the lower-level shim.

Relocate readdir_cd to vfs.h, just below the nfsd_filldir_t callback
typedef. vfs.h then defines the struct itself and no longer includes
nfsd.h. The xdr headers that embed readdir_cd by value include vfs.h
to obtain the definition. This prepares the ground for dropping nfsd.h
from more files.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfsd.h | 4 ----
 fs/nfsd/vfs.h  | 5 ++++-
 fs/nfsd/xdr.h  | 1 +
 fs/nfsd/xdr3.h | 1 +
 fs/nfsd/xdr4.h | 2 +-
 5 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index b35e9a9a112d..0503ee0e1bbe 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -47,10 +47,6 @@ enum {
 	NFSSVC_MAXBLKSIZE       = RPCSVC_MAXPAYLOAD,
 };
 
-struct readdir_cd {
-	__be32			err;	/* 0, nfserr, or nfserr_eof */
-};
-
 /* Maximum number of operations per session compound */
 #define NFSD_MAX_OPS_PER_COMPOUND	200
 
diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h
index e09ea04a51b9..4af2ff9e9dfe 100644
--- a/fs/nfsd/vfs.h
+++ b/fs/nfsd/vfs.h
@@ -9,7 +9,6 @@
 #include <linux/fs.h>
 #include <linux/posix_acl.h>
 #include "nfsfh.h"
-#include "nfsd.h"
 
 /*
  * Flags for nfsd_permission
@@ -45,6 +44,10 @@ struct nfsd_file;
  */
 typedef int (*nfsd_filldir_t)(void *, const char *, int, loff_t, u64, unsigned);
 
+struct readdir_cd {
+	__be32			err;	/* nfs_ok, nfserr, or nfserr_eof */
+};
+
 /* nfsd/vfs.c */
 struct nfsd_attrs {
 	struct iattr		*na_iattr;	/* input */
diff --git a/fs/nfsd/xdr.h b/fs/nfsd/xdr.h
index 852f71580bd0..df540c940cef 100644
--- a/fs/nfsd/xdr.h
+++ b/fs/nfsd/xdr.h
@@ -7,6 +7,7 @@
 #include <linux/vfs.h>
 #include "nfsd.h"
 #include "nfsfh.h"
+#include "vfs.h"
 
 struct nfsd_fhandle {
 	struct svc_fh		fh;
diff --git a/fs/nfsd/xdr3.h b/fs/nfsd/xdr3.h
index a7c9714b0b0e..344203874b4c 100644
--- a/fs/nfsd/xdr3.h
+++ b/fs/nfsd/xdr3.h
@@ -9,6 +9,7 @@
 #define _LINUX_NFSD_XDR3_H
 
 #include "xdr.h"
+#include "vfs.h"
 
 struct nfsd3_sattrargs {
 	struct svc_fh		fh;
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h
index 805c7122eb93..0ec0f43b1a87 100644
--- a/fs/nfsd/xdr4.h
+++ b/fs/nfsd/xdr4.h
@@ -38,7 +38,7 @@
 #define _LINUX_NFSD_XDR4_H
 
 #include "state.h"
-#include "nfsd.h"
+#include "vfs.h"
 
 #define NFSD4_MAX_TAGLEN	128
 #define XDR_LEN(n)                     (((n) + 3) & ~3)
-- 
2.54.0


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

* [PATCH 7/9] NFSD: Relocate nfsd_user_namespace()
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (5 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 6/9] NFSD: Move struct readdir_cd Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 8/9] NFSD: Relocate nfsd4_set_netaddr() Chuck Lever
  2026-07-12 20:45 ` [PATCH 9/9] NFSD: Relocate NFSv4 "supported attributes" to new header Chuck Lever
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Refactor: nfsd_user_namespace() currently lives in nfsd.h, so every
caller must pull in nfsd.h -- directly or transitively via state.h --
and with it the NFS protocol definitions from uapi/linux/nfs.h and
friends, even when the caller uses nothing else from nfsd.h.

Since nfsd_user_namespace() is an auth-related function, move it
to fs/nfsd/auth.c in preparation for removing '#include "nfsd.h"'
from a few places.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/auth.c      | 18 ++++++++++++++++++
 fs/nfsd/auth.h      |  6 ++++++
 fs/nfsd/nfs4idmap.c |  1 +
 fs/nfsd/nfs4xdr.c   |  1 +
 fs/nfsd/nfsd.h      |  6 ------
 5 files changed, 26 insertions(+), 6 deletions(-)

diff --git a/fs/nfsd/auth.c b/fs/nfsd/auth.c
index e3b4a35caac6..5ef9a0466eda 100644
--- a/fs/nfsd/auth.c
+++ b/fs/nfsd/auth.c
@@ -88,3 +88,21 @@ int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp)
 	return -ENOMEM;
 }
 
+/**
+ * nfsd_user_namespace - Get user_namespace in effect for an RPC request
+ * @rqstp: RPC execution context
+ *
+ * xpt_cred is set once at transport creation and never modified. The
+ * transport itself is reference-counted during request processing, so
+ * no explicit reference on the namespace is necessary.
+ *
+ * Return: the user_namespace from the transport credential, or
+ * init_user_ns if no credential was set. The returned namespace pointer
+ * is valid for the duration of the RPC request.
+ */
+struct user_namespace *nfsd_user_namespace(const struct svc_rqst *rqstp)
+{
+	const struct cred *cred = rqstp->rq_xprt->xpt_cred;
+
+	return cred ? cred->user_ns : &init_user_ns;
+}
diff --git a/fs/nfsd/auth.h b/fs/nfsd/auth.h
index 8c5031bbbcee..832bc957980d 100644
--- a/fs/nfsd/auth.h
+++ b/fs/nfsd/auth.h
@@ -8,10 +8,16 @@
 #ifndef LINUX_NFSD_AUTH_H
 #define LINUX_NFSD_AUTH_H
 
+struct user_namespace;
+struct svc_export;
+struct svc_rqst;
+
 /*
  * Set the current process's fsuid/fsgid etc to those of the NFS
  * client user
  */
 int nfsd_setuser(struct svc_cred *cred, struct svc_export *exp);
 
+struct user_namespace *nfsd_user_namespace(const struct svc_rqst *rqstp);
+
 #endif /* LINUX_NFSD_AUTH_H */
diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 71ba61b5d0a3..e9faf8b78f74 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -38,6 +38,7 @@
 #include <linux/slab.h>
 #include <linux/sunrpc/svc_xprt.h>
 #include <net/net_namespace.h>
+#include "auth.h"
 #include "idmap.h"
 #include "nfsd.h"
 #include "netns.h"
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index aef48fb0fac2..cba2e72d616c 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -47,6 +47,7 @@
 
 #include <uapi/linux/xattr.h>
 
+#include "auth.h"
 #include "idmap.h"
 #include "acl.h"
 #include "xdr4.h"
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 0503ee0e1bbe..81312b11b5c2 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -153,12 +153,6 @@ static inline int nfsd_v4client(struct svc_rqst *rq)
 {
 	return rq && rq->rq_prog == NFS_PROGRAM && rq->rq_vers == 4;
 }
-static inline struct user_namespace *
-nfsd_user_namespace(const struct svc_rqst *rqstp)
-{
-	const struct cred *cred = rqstp->rq_xprt->xpt_cred;
-	return cred ? cred->user_ns : &init_user_ns;
-}
 
 /* 
  * NFSv4 State
-- 
2.54.0


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

* [PATCH 8/9] NFSD: Relocate nfsd4_set_netaddr()
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (6 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 7/9] NFSD: Relocate nfsd_user_namespace() Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  2026-07-12 20:45 ` [PATCH 9/9] NFSD: Relocate NFSv4 "supported attributes" to new header Chuck Lever
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

Clean up: Common practice in the Linux kernel is to avoid the use of
static inline functions when there is only a single call site. The
30-line helper function is removed from a header pulled into ~25 .c
files, removing <linux/sunrpc/addr.h> from that header's transitive
include surface, dropping a now-redundant <linux/sunrpc/msg_prot.h>
include, and reducing the function's visibility to the one translation
unit that uses it.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/nfs4proc.c | 31 +++++++++++++++++++++++++++++++
 fs/nfsd/nfsd.h     | 33 ---------------------------------
 2 files changed, 31 insertions(+), 33 deletions(-)

diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 669896be08b6..59889cdca109 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -2313,6 +2313,37 @@ nfsd4_offload_cancel(struct svc_rqst *rqstp,
 	return nfs_ok;
 }
 
+static __be32
+nfsd4_set_netaddr(struct sockaddr *addr, struct nfs42_netaddr *netaddr)
+{
+	struct sockaddr_in *sin = (struct sockaddr_in *)addr;
+	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
+	unsigned int port;
+	size_t ret_addr, ret_port;
+
+	switch (addr->sa_family) {
+	case AF_INET:
+		port = ntohs(sin->sin_port);
+		sprintf(netaddr->netid, "tcp");
+		netaddr->netid_len = 3;
+		break;
+	case AF_INET6:
+		port = ntohs(sin6->sin6_port);
+		sprintf(netaddr->netid, "tcp6");
+		netaddr->netid_len = 4;
+		break;
+	default:
+		return nfserr_inval;
+	}
+	ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr));
+	ret_port = snprintf(netaddr->addr + ret_addr,
+			    RPCBIND_MAXUADDRLEN + 1 - ret_addr,
+			    ".%u.%u", port >> 8, port & 0xff);
+	WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr);
+	netaddr->addr_len = ret_addr + ret_port;
+	return 0;
+}
+
 static __be32
 nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 		  union nfsd4_op_u *u)
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 81312b11b5c2..33015657b16f 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -18,8 +18,6 @@
 #include <linux/nfs4.h>
 #include <linux/sunrpc/svc.h>
 #include <linux/sunrpc/svc_xprt.h>
-#include <linux/sunrpc/msg_prot.h>
-#include <linux/sunrpc/addr.h>
 
 #include <uapi/linux/nfsd/debug.h>
 
@@ -450,37 +448,6 @@ enum {
 
 extern const u32 nfsd_suppattrs[3][3];
 
-static inline __be32 nfsd4_set_netaddr(struct sockaddr *addr,
-				    struct nfs42_netaddr *netaddr)
-{
-	struct sockaddr_in *sin = (struct sockaddr_in *)addr;
-	struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)addr;
-	unsigned int port;
-	size_t ret_addr, ret_port;
-
-	switch (addr->sa_family) {
-	case AF_INET:
-		port = ntohs(sin->sin_port);
-		sprintf(netaddr->netid, "tcp");
-		netaddr->netid_len = 3;
-		break;
-	case AF_INET6:
-		port = ntohs(sin6->sin6_port);
-		sprintf(netaddr->netid, "tcp6");
-		netaddr->netid_len = 4;
-		break;
-	default:
-		return nfserr_inval;
-	}
-	ret_addr = rpc_ntop(addr, netaddr->addr, sizeof(netaddr->addr));
-	ret_port = snprintf(netaddr->addr + ret_addr,
-			    RPCBIND_MAXUADDRLEN + 1 - ret_addr,
-			    ".%u.%u", port >> 8, port & 0xff);
-	WARN_ON(ret_port >= RPCBIND_MAXUADDRLEN + 1 - ret_addr);
-	netaddr->addr_len = ret_addr + ret_port;
-	return 0;
-}
-
 static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2)
 {
 	return !((bm1[0] & ~bm2[0]) ||
-- 
2.54.0


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

* [PATCH 9/9] NFSD: Relocate NFSv4 "supported attributes" to new header
  2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
                   ` (7 preceding siblings ...)
  2026-07-12 20:45 ` [PATCH 8/9] NFSD: Relocate nfsd4_set_netaddr() Chuck Lever
@ 2026-07-12 20:45 ` Chuck Lever
  8 siblings, 0 replies; 10+ messages in thread
From: Chuck Lever @ 2026-07-12 20:45 UTC (permalink / raw)
  To: NeilBrown, Jeff Layton, Olga Kornievskaia, Dai Ngo, Tom Talpey; +Cc: linux-nfs

These NFSv4 attribute bitmask definitions live in nfsd.h, which
nearly every nfsd source file includes, yet only nfs4proc.c and
nfs4xdr.c reference them. Move them to a dedicated header so only
those two consumers pull them in.

While moving the block, correct the stale QUOTA_* annotation: the
promised support never materialized, so these attributes are
unlikely to be supported any time soon rather than forthcoming.

Signed-off-by: Chuck Lever <cel@kernel.org>
---
 fs/nfsd/attr4.h    | 162 +++++++++++++++++++++++++++++++++++++++++++++
 fs/nfsd/nfs4proc.c |   1 +
 fs/nfsd/nfs4xdr.c  |   1 +
 fs/nfsd/nfsd.h     | 150 -----------------------------------------
 4 files changed, 164 insertions(+), 150 deletions(-)
 create mode 100644 fs/nfsd/attr4.h

diff --git a/fs/nfsd/attr4.h b/fs/nfsd/attr4.h
new file mode 100644
index 000000000000..f0b51f8050b7
--- /dev/null
+++ b/fs/nfsd/attr4.h
@@ -0,0 +1,162 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * NFSv4 file attributes supported by this implementation
+ */
+
+#ifndef _LINUX_NFSD_ATTR4_H
+#define _LINUX_NFSD_ATTR4_H
+
+#include <linux/types.h>
+#include <linux/nfs4.h>
+
+/*
+ * The following attributes are not implemented by NFSD:
+ *    ARCHIVE       (deprecated anyway)
+ *    HIDDEN        (unlikely to be supported any time soon)
+ *    MIMETYPE      (unlikely to be supported any time soon)
+ *    QUOTA_*       (unlikely to be supported any time soon)
+ *    SYSTEM        (unlikely to be supported any time soon)
+ *    TIME_BACKUP   (unlikely to be supported any time soon)
+ */
+#define NFSD4_SUPPORTED_ATTRS_WORD0                                                         \
+(FATTR4_WORD0_SUPPORTED_ATTRS   | FATTR4_WORD0_TYPE         | FATTR4_WORD0_FH_EXPIRE_TYPE   \
+ | FATTR4_WORD0_CHANGE          | FATTR4_WORD0_SIZE         | FATTR4_WORD0_LINK_SUPPORT     \
+ | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR   | FATTR4_WORD0_FSID             \
+ | FATTR4_WORD0_UNIQUE_HANDLES  | FATTR4_WORD0_LEASE_TIME   | FATTR4_WORD0_RDATTR_ERROR     \
+ | FATTR4_WORD0_ACLSUPPORT      | FATTR4_WORD0_CANSETTIME   | FATTR4_WORD0_CASE_INSENSITIVE \
+ | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED                             \
+ | FATTR4_WORD0_FILEHANDLE      | FATTR4_WORD0_FILEID       | FATTR4_WORD0_FILES_AVAIL      \
+ | FATTR4_WORD0_FILES_FREE      | FATTR4_WORD0_FILES_TOTAL  | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS      \
+ | FATTR4_WORD0_MAXFILESIZE     | FATTR4_WORD0_MAXLINK      | FATTR4_WORD0_MAXNAME          \
+ | FATTR4_WORD0_MAXREAD         | FATTR4_WORD0_MAXWRITE     | FATTR4_WORD0_ACL)
+
+#define NFSD4_SUPPORTED_ATTRS_WORD1                                                         \
+(FATTR4_WORD1_MODE              | FATTR4_WORD1_NO_TRUNC     | FATTR4_WORD1_NUMLINKS         \
+ | FATTR4_WORD1_OWNER	        | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
+ | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
+ | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
+ | FATTR4_WORD1_TIME_DELTA      | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
+ | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
+
+#define NFSD4_SUPPORTED_ATTRS_WORD2 0
+
+/* 4.1 */
+#ifdef CONFIG_NFSD_PNFS
+#define PNFSD_SUPPORTED_ATTRS_WORD1	FATTR4_WORD1_FS_LAYOUT_TYPES
+#define PNFSD_SUPPORTED_ATTRS_WORD2 \
+(FATTR4_WORD2_LAYOUT_BLKSIZE	| FATTR4_WORD2_LAYOUT_TYPES)
+#else
+#define PNFSD_SUPPORTED_ATTRS_WORD1	0
+#define PNFSD_SUPPORTED_ATTRS_WORD2	0
+#endif /* CONFIG_NFSD_PNFS */
+
+#define NFSD4_1_SUPPORTED_ATTRS_WORD0 \
+	NFSD4_SUPPORTED_ATTRS_WORD0
+
+#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \
+	(NFSD4_SUPPORTED_ATTRS_WORD1	| PNFSD_SUPPORTED_ATTRS_WORD1)
+
+#define NFSD4_1_SUPPORTED_ATTRS_WORD2 \
+	(NFSD4_SUPPORTED_ATTRS_WORD2	| PNFSD_SUPPORTED_ATTRS_WORD2 | \
+	 FATTR4_WORD2_SUPPATTR_EXCLCREAT)
+
+/* 4.2 */
+#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
+#define NFSD4_2_SECURITY_ATTRS		FATTR4_WORD2_SECURITY_LABEL
+#else
+#define NFSD4_2_SECURITY_ATTRS		0
+#endif
+
+#ifdef CONFIG_NFSD_V4_POSIX_ACLS
+#define NFSD4_2_POSIX_ACL_ATTRS \
+	(FATTR4_WORD2_ACL_TRUEFORM | \
+	FATTR4_WORD2_ACL_TRUEFORM_SCOPE | \
+	FATTR4_WORD2_POSIX_DEFAULT_ACL | \
+	FATTR4_WORD2_POSIX_ACCESS_ACL)
+#else
+#define NFSD4_2_POSIX_ACL_ATTRS		0
+#endif
+
+#define NFSD4_2_SUPPORTED_ATTRS_WORD2 \
+	(NFSD4_1_SUPPORTED_ATTRS_WORD2 | \
+	FATTR4_WORD2_MODE_UMASK | \
+	FATTR4_WORD2_CLONE_BLKSIZE | \
+	NFSD4_2_SECURITY_ATTRS | \
+	FATTR4_WORD2_XATTR_SUPPORT | \
+	FATTR4_WORD2_TIME_DELEG_ACCESS | \
+	FATTR4_WORD2_TIME_DELEG_MODIFY | \
+	FATTR4_WORD2_OPEN_ARGUMENTS | \
+	NFSD4_2_POSIX_ACL_ATTRS)
+
+/* These will return ERR_INVAL if specified in GETATTR or READDIR. */
+#define NFSD_WRITEONLY_ATTRS_WORD1 \
+	(FATTR4_WORD1_TIME_ACCESS_SET   | FATTR4_WORD1_TIME_MODIFY_SET)
+
+/*
+ * These are the only attrs allowed in CREATE/OPEN/SETATTR. Don't add
+ * a writeable attribute here without also adding code to parse it to
+ * nfsd4_decode_fattr4().
+ */
+#define NFSD_WRITEABLE_ATTRS_WORD0 \
+	(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL)
+#define NFSD_WRITEABLE_ATTRS_WORD1 \
+	(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
+	| FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_CREATE \
+	| FATTR4_WORD1_TIME_MODIFY_SET)
+#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
+#define MAYBE_FATTR4_WORD2_SECURITY_LABEL \
+	FATTR4_WORD2_SECURITY_LABEL
+#else
+#define MAYBE_FATTR4_WORD2_SECURITY_LABEL 0
+#endif
+#ifdef CONFIG_NFSD_V4_POSIX_ACLS
+#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \
+	FATTR4_WORD2_POSIX_DEFAULT_ACL | FATTR4_WORD2_POSIX_ACCESS_ACL
+#else
+#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS 0
+#endif
+#define NFSD_WRITEABLE_ATTRS_WORD2 \
+	(FATTR4_WORD2_MODE_UMASK \
+	| MAYBE_FATTR4_WORD2_SECURITY_LABEL \
+	| FATTR4_WORD2_TIME_DELEG_ACCESS \
+	| FATTR4_WORD2_TIME_DELEG_MODIFY \
+	| MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \
+	)
+
+#define NFSD_SUPPATTR_EXCLCREAT_WORD0 \
+	NFSD_WRITEABLE_ATTRS_WORD0
+/*
+ * we currently store the exclusive create verifier in the v_{a,m}time
+ * attributes so the client can't set these at create time using EXCLUSIVE4_1
+ */
+#define NFSD_SUPPATTR_EXCLCREAT_WORD1 \
+	(NFSD_WRITEABLE_ATTRS_WORD1 & \
+	 ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET))
+/*
+ * The FATTR4_WORD2_TIME_DELEG attributes are not to be allowed for
+ * OPEN(create) with EXCLUSIVE4_1. It doesn't make sense to set a
+ * delegated timestamp on a new file.
+ *
+ * This mask includes NFSv4.2-only attributes (e.g., POSIX ACLs).
+ * Version filtering occurs via nfsd_suppattrs[] before this mask
+ * is applied, so pre-4.2 clients never see unsupported attributes.
+ */
+#define NFSD_SUPPATTR_EXCLCREAT_WORD2 \
+	(NFSD_WRITEABLE_ATTRS_WORD2 & \
+	~(FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MODIFY))
+
+extern const u32 nfsd_suppattrs[3][3];
+
+static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2)
+{
+	return !((bm1[0] & ~bm2[0]) ||
+	         (bm1[1] & ~bm2[1]) ||
+		 (bm1[2] & ~bm2[2]));
+}
+
+static inline bool nfsd_attrs_supported(u32 minorversion, const u32 *bmval)
+{
+	return bmval_is_subset(bmval, nfsd_suppattrs[minorversion]);
+}
+
+#endif /* _LINUX_NFSD_ATTR4_H */
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 59889cdca109..9031a5bdb0fc 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -42,6 +42,7 @@
 #include <linux/sunrpc/addr.h>
 #include <linux/nfs_ssc.h>
 
+#include "attr4.h"
 #include "idmap.h"
 #include "cache.h"
 #include "xdr4.h"
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index cba2e72d616c..29105580c203 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -47,6 +47,7 @@
 
 #include <uapi/linux/xattr.h>
 
+#include "attr4.h"
 #include "auth.h"
 #include "idmap.h"
 #include "acl.h"
diff --git a/fs/nfsd/nfsd.h b/fs/nfsd/nfsd.h
index 33015657b16f..76a69d9a4e73 100644
--- a/fs/nfsd/nfsd.h
+++ b/fs/nfsd/nfsd.h
@@ -367,156 +367,6 @@ enum {
 #define NFSD_DELEGRETURN_TIMEOUT	(HZ / 34)	/* 30ms */
 #define	NFSD_CB_GETATTR_TIMEOUT		NFSD_DELEGRETURN_TIMEOUT
 
-/*
- * The following attributes are not implemented by NFSD:
- *    ARCHIVE       (deprecated anyway)
- *    HIDDEN        (unlikely to be supported any time soon)
- *    MIMETYPE      (unlikely to be supported any time soon)
- *    QUOTA_*       (will be supported in a forthcoming patch)
- *    SYSTEM        (unlikely to be supported any time soon)
- *    TIME_BACKUP   (unlikely to be supported any time soon)
- */
-#define NFSD4_SUPPORTED_ATTRS_WORD0                                                         \
-(FATTR4_WORD0_SUPPORTED_ATTRS   | FATTR4_WORD0_TYPE         | FATTR4_WORD0_FH_EXPIRE_TYPE   \
- | FATTR4_WORD0_CHANGE          | FATTR4_WORD0_SIZE         | FATTR4_WORD0_LINK_SUPPORT     \
- | FATTR4_WORD0_SYMLINK_SUPPORT | FATTR4_WORD0_NAMED_ATTR   | FATTR4_WORD0_FSID             \
- | FATTR4_WORD0_UNIQUE_HANDLES  | FATTR4_WORD0_LEASE_TIME   | FATTR4_WORD0_RDATTR_ERROR     \
- | FATTR4_WORD0_ACLSUPPORT      | FATTR4_WORD0_CANSETTIME   | FATTR4_WORD0_CASE_INSENSITIVE \
- | FATTR4_WORD0_CASE_PRESERVING | FATTR4_WORD0_CHOWN_RESTRICTED                             \
- | FATTR4_WORD0_FILEHANDLE      | FATTR4_WORD0_FILEID       | FATTR4_WORD0_FILES_AVAIL      \
- | FATTR4_WORD0_FILES_FREE      | FATTR4_WORD0_FILES_TOTAL  | FATTR4_WORD0_FS_LOCATIONS | FATTR4_WORD0_HOMOGENEOUS      \
- | FATTR4_WORD0_MAXFILESIZE     | FATTR4_WORD0_MAXLINK      | FATTR4_WORD0_MAXNAME          \
- | FATTR4_WORD0_MAXREAD         | FATTR4_WORD0_MAXWRITE     | FATTR4_WORD0_ACL)
-
-#define NFSD4_SUPPORTED_ATTRS_WORD1                                                         \
-(FATTR4_WORD1_MODE              | FATTR4_WORD1_NO_TRUNC     | FATTR4_WORD1_NUMLINKS         \
- | FATTR4_WORD1_OWNER	        | FATTR4_WORD1_OWNER_GROUP  | FATTR4_WORD1_RAWDEV           \
- | FATTR4_WORD1_SPACE_AVAIL     | FATTR4_WORD1_SPACE_FREE   | FATTR4_WORD1_SPACE_TOTAL      \
- | FATTR4_WORD1_SPACE_USED      | FATTR4_WORD1_TIME_ACCESS  | FATTR4_WORD1_TIME_ACCESS_SET  \
- | FATTR4_WORD1_TIME_DELTA      | FATTR4_WORD1_TIME_METADATA   | FATTR4_WORD1_TIME_CREATE      \
- | FATTR4_WORD1_TIME_MODIFY     | FATTR4_WORD1_TIME_MODIFY_SET | FATTR4_WORD1_MOUNTED_ON_FILEID)
-
-#define NFSD4_SUPPORTED_ATTRS_WORD2 0
-
-/* 4.1 */
-#ifdef CONFIG_NFSD_PNFS
-#define PNFSD_SUPPORTED_ATTRS_WORD1	FATTR4_WORD1_FS_LAYOUT_TYPES
-#define PNFSD_SUPPORTED_ATTRS_WORD2 \
-(FATTR4_WORD2_LAYOUT_BLKSIZE	| FATTR4_WORD2_LAYOUT_TYPES)
-#else
-#define PNFSD_SUPPORTED_ATTRS_WORD1	0
-#define PNFSD_SUPPORTED_ATTRS_WORD2	0
-#endif /* CONFIG_NFSD_PNFS */
-
-#define NFSD4_1_SUPPORTED_ATTRS_WORD0 \
-	NFSD4_SUPPORTED_ATTRS_WORD0
-
-#define NFSD4_1_SUPPORTED_ATTRS_WORD1 \
-	(NFSD4_SUPPORTED_ATTRS_WORD1	| PNFSD_SUPPORTED_ATTRS_WORD1)
-
-#define NFSD4_1_SUPPORTED_ATTRS_WORD2 \
-	(NFSD4_SUPPORTED_ATTRS_WORD2	| PNFSD_SUPPORTED_ATTRS_WORD2 | \
-	 FATTR4_WORD2_SUPPATTR_EXCLCREAT)
-
-/* 4.2 */
-#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
-#define NFSD4_2_SECURITY_ATTRS		FATTR4_WORD2_SECURITY_LABEL
-#else
-#define NFSD4_2_SECURITY_ATTRS		0
-#endif
-
-#ifdef CONFIG_NFSD_V4_POSIX_ACLS
-#define NFSD4_2_POSIX_ACL_ATTRS \
-	(FATTR4_WORD2_ACL_TRUEFORM | \
-	FATTR4_WORD2_ACL_TRUEFORM_SCOPE | \
-	FATTR4_WORD2_POSIX_DEFAULT_ACL | \
-	FATTR4_WORD2_POSIX_ACCESS_ACL)
-#else
-#define NFSD4_2_POSIX_ACL_ATTRS		0
-#endif
-
-#define NFSD4_2_SUPPORTED_ATTRS_WORD2 \
-	(NFSD4_1_SUPPORTED_ATTRS_WORD2 | \
-	FATTR4_WORD2_MODE_UMASK | \
-	FATTR4_WORD2_CLONE_BLKSIZE | \
-	NFSD4_2_SECURITY_ATTRS | \
-	FATTR4_WORD2_XATTR_SUPPORT | \
-	FATTR4_WORD2_TIME_DELEG_ACCESS | \
-	FATTR4_WORD2_TIME_DELEG_MODIFY | \
-	FATTR4_WORD2_OPEN_ARGUMENTS | \
-	NFSD4_2_POSIX_ACL_ATTRS)
-
-extern const u32 nfsd_suppattrs[3][3];
-
-static inline bool bmval_is_subset(const u32 *bm1, const u32 *bm2)
-{
-	return !((bm1[0] & ~bm2[0]) ||
-	         (bm1[1] & ~bm2[1]) ||
-		 (bm1[2] & ~bm2[2]));
-}
-
-static inline bool nfsd_attrs_supported(u32 minorversion, const u32 *bmval)
-{
-	return bmval_is_subset(bmval, nfsd_suppattrs[minorversion]);
-}
-
-/* These will return ERR_INVAL if specified in GETATTR or READDIR. */
-#define NFSD_WRITEONLY_ATTRS_WORD1 \
-	(FATTR4_WORD1_TIME_ACCESS_SET   | FATTR4_WORD1_TIME_MODIFY_SET)
-
-/*
- * These are the only attrs allowed in CREATE/OPEN/SETATTR. Don't add
- * a writeable attribute here without also adding code to parse it to
- * nfsd4_decode_fattr().
- */
-#define NFSD_WRITEABLE_ATTRS_WORD0 \
-	(FATTR4_WORD0_SIZE | FATTR4_WORD0_ACL)
-#define NFSD_WRITEABLE_ATTRS_WORD1 \
-	(FATTR4_WORD1_MODE | FATTR4_WORD1_OWNER | FATTR4_WORD1_OWNER_GROUP \
-	| FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_CREATE \
-	| FATTR4_WORD1_TIME_MODIFY_SET)
-#ifdef CONFIG_NFSD_V4_SECURITY_LABEL
-#define MAYBE_FATTR4_WORD2_SECURITY_LABEL \
-	FATTR4_WORD2_SECURITY_LABEL
-#else
-#define MAYBE_FATTR4_WORD2_SECURITY_LABEL 0
-#endif
-#ifdef CONFIG_NFSD_V4_POSIX_ACLS
-#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \
-	FATTR4_WORD2_POSIX_DEFAULT_ACL | FATTR4_WORD2_POSIX_ACCESS_ACL
-#else
-#define MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS 0
-#endif
-#define NFSD_WRITEABLE_ATTRS_WORD2 \
-	(FATTR4_WORD2_MODE_UMASK \
-	| MAYBE_FATTR4_WORD2_SECURITY_LABEL \
-	| FATTR4_WORD2_TIME_DELEG_ACCESS \
-	| FATTR4_WORD2_TIME_DELEG_MODIFY \
-	| MAYBE_FATTR4_WORD2_POSIX_ACL_ATTRS \
-	)
-
-#define NFSD_SUPPATTR_EXCLCREAT_WORD0 \
-	NFSD_WRITEABLE_ATTRS_WORD0
-/*
- * we currently store the exclusive create verifier in the v_{a,m}time
- * attributes so the client can't set these at create time using EXCLUSIVE4_1
- */
-#define NFSD_SUPPATTR_EXCLCREAT_WORD1 \
-	(NFSD_WRITEABLE_ATTRS_WORD1 & \
-	 ~(FATTR4_WORD1_TIME_ACCESS_SET | FATTR4_WORD1_TIME_MODIFY_SET))
-/*
- * The FATTR4_WORD2_TIME_DELEG attributes are not to be allowed for
- * OPEN(create) with EXCLUSIVE4_1. It doesn't make sense to set a
- * delegated timestamp on a new file.
- *
- * This mask includes NFSv4.2-only attributes (e.g., POSIX ACLs).
- * Version filtering occurs via nfsd_suppattrs[] before this mask
- * is applied, so pre-4.2 clients never see unsupported attributes.
- */
-#define NFSD_SUPPATTR_EXCLCREAT_WORD2 \
-	(NFSD_WRITEABLE_ATTRS_WORD2 & \
-	~(FATTR4_WORD2_TIME_DELEG_ACCESS | FATTR4_WORD2_TIME_DELEG_MODIFY))
-
 extern int nfsd4_is_junction(struct dentry *dentry);
 extern int register_cld_notifier(void);
 extern void unregister_cld_notifier(void);
-- 
2.54.0


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

end of thread, other threads:[~2026-07-12 20:46 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-12 20:45 [PATCH 0/9] Start reorganizing fs/nfsd/nfsd.h Chuck Lever
2026-07-12 20:45 ` [PATCH 1/9] NFSD: Make "stats.h" self-contained Chuck Lever
2026-07-12 20:45 ` [PATCH 2/9] NFSD: Explicitly include "stats.h" Chuck Lever
2026-07-12 20:45 ` [PATCH 3/9] NFSD: include "netns.h" Chuck Lever
2026-07-12 20:45 ` [PATCH 4/9] NFSD: Remove '#include "nfsd.h"' from fs/nfsd/cache.h Chuck Lever
2026-07-12 20:45 ` [PATCH 5/9] NFSD: Move the export.h include from nfsd.h to auth.c Chuck Lever
2026-07-12 20:45 ` [PATCH 6/9] NFSD: Move struct readdir_cd Chuck Lever
2026-07-12 20:45 ` [PATCH 7/9] NFSD: Relocate nfsd_user_namespace() Chuck Lever
2026-07-12 20:45 ` [PATCH 8/9] NFSD: Relocate nfsd4_set_netaddr() Chuck Lever
2026-07-12 20:45 ` [PATCH 9/9] NFSD: Relocate NFSv4 "supported attributes" to new header Chuck Lever

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