Skip to contentSkip to conversation

nfsd: move delegated timestamps to being runtime disabled instead of compile time

PATCH In review Jeff Layton 2 participants 4 messages Jan 26

Subsystems (2)
lore
Share & tools
lore

Jeff Layton

author maintainer
#0 lore raw

v3 cover nfsd: move delegated timestamps to being runtime disabled instead of compile time

This version just updates the comments an changelogs per Claude's recommendations.

---
Changes in v3:
- add comment over nfsd4_want_deleg_timestamps()
- add info to changelog about how to disable delegated timestamps at runtime
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Don't create debugfs file when CONFIG_NFSD_V4 is disabled
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Jeff Layton (2):
nfsd: add a runtime switch for disabling delegated timestamps
nfsd: remove NFSD_V4_DELEG_TIMESTAMPS Kconfig option

 fs/nfsd/Kconfig     | 10 ----------
 fs/nfsd/debugfs.c   |  4 ++++
 fs/nfsd/nfs4state.c | 15 ++++++++-------
 fs/nfsd/nfsd.h      |  1 +
 4 files changed, 13 insertions(+), 17 deletions(-)

---
base-commit: 2a1dde6dd823e94e0768e929566dd65cd74ca793
change-id: 20260122-delegts-150060ac7c9a

Best regards,

Signature · 1 line
Jeff Layton <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/2 nfsd: add a runtime switch for disabling delegated timestamps

The delegated timestamp code seems to be working well enough now that we want to make it always be built in. In the event that there are problems though, we still want to be able to disable them for debugging purposes. Add a switch to debugfs to enable them at runtime.

---
 fs/nfsd/debugfs.c   | 4 ++++
 fs/nfsd/nfs4state.c | 8 ++++++++
 fs/nfsd/nfsd.h      | 1 +
 3 files changed, 13 insertions(+)
fs/nfsd/debugfs.c +4 -0
index 7f44689e0a53edbfd6ade9dda6af4052976a65d3..386fd1c54f5277fd9b9544caa5220e234915264d 100644
@@ -140,4 +140,8 @@ void nfsd_debugfs_init(void)
 
 	debugfs_create_file("io_cache_write", 0644, nfsd_top_dir, NULL,
 			    &nfsd_io_cache_write_fops);
+#ifdef CONFIG_NFSD_V4
+	debugfs_create_bool("delegated_timestamps", 0644, nfsd_top_dir,
+			    &nfsd_delegts_enabled);
+#endif
 }
fs/nfsd/nfs4state.c +8 -0
index 583c13b5aaf3cd12a87c7aae62fe6a8223368f55..2251ff43aac8ef8a3d01d7094d40f9b2604763d6 100644
@@ -76,6 +76,8 @@ static const stateid_t close_stateid = {
 
 static u64 current_sessionid = 1;
 
+bool nfsd_delegts_enabled __read_mostly = true;
+
 #define ZERO_STATEID(stateid) (!memcmp((stateid), &zero_stateid, sizeof(stateid_t)))
 #define ONE_STATEID(stateid)  (!memcmp((stateid), &one_stateid, sizeof(stateid_t)))
 #define CURRENT_STATEID(stateid) (!memcmp((stateid), &currentstateid, sizeof(stateid_t)))
@@ -6046,8 +6048,14 @@ nfsd4_verify_setuid_write(struct nfsd4_open *open, struct nfsd_file *nf)
 }
 
 #ifdef CONFIG_NFSD_V4_DELEG_TIMESTAMPS
+/*
+ * Timestamp delegation was introduced in RFC7862. Runtime switch for disabling
+ * this feature is /sys/kernel/debug/nfsd/delegated_timestamps.
+ */
 static bool nfsd4_want_deleg_timestamps(const struct nfsd4_open *open)
 {
+	if (!nfsd_delegts_enabled)
+		return false;
 	return open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS;
 }
 #else /* CONFIG_NFSD_V4_DELEG_TIMESTAMPS */
fs/nfsd/nfsd.h +1 -0
index a2e35a4fa105380c2d99cb0865003e0f7f4a8e8d..7c009f07c90b50d7074695d4665a2eca85140eda 100644
@@ -160,6 +160,7 @@ static inline void nfsd_debugfs_exit(void) {}
 #endif
 
 extern bool nfsd_disable_splice_read __read_mostly;
+extern bool nfsd_delegts_enabled __read_mostly;
 
 enum {
 	/* Any new NFSD_IO enum value must be added at the end */
Signature · 1 line
2.52.0
author maintainer
#2 lore raw

PATCH v3 2/2 nfsd: remove NFSD_V4_DELEG_TIMESTAMPS Kconfig option

In reply to Jeff Layton

Now that there is a runtime debugfs switch, eliminate the compile-time switch and always build in support for delegated timestamps.

Administrators who previously disabled this feature at compile time can disable it at runtime via:

echo 0 > /sys/kernel/debug/nfsd/delegated_timestamps

---
 fs/nfsd/Kconfig     | 10 ----------
 fs/nfsd/nfs4state.c |  7 -------
 2 files changed, 17 deletions(-)
fs/nfsd/Kconfig +0 -10
index 4fd6e818565ea24e4e16844a3f82e808dbc558f8..fc0e87eaa25714d621aa893c99dabe4ce34228df 100644
@@ -177,16 +177,6 @@ config NFSD_LEGACY_CLIENT_TRACKING
 	  and will be removed in the future. Say Y here if you need support
 	  for them in the interim.
 
-config NFSD_V4_DELEG_TIMESTAMPS
-	bool "Support delegated timestamps"
-	depends on NFSD_V4
-	default n
-	help
-	  NFSD implements delegated timestamps according to
-	  draft-ietf-nfsv4-delstid-08 "Extending the Opening of Files". This
-	  is currently an experimental feature and is therefore left disabled
-	  by default.
-
 config NFSD_V4_POSIX_ACLS
 	bool "Support NFSv4 POSIX draft ACLs"
 	depends on NFSD_V4
fs/nfsd/nfs4state.c +0 -7
index 2251ff43aac8ef8a3d01d7094d40f9b2604763d6..f105ca19815f97c1dd042bbf9a543c1cc3551282 100644
@@ -6047,7 +6047,6 @@ nfsd4_verify_setuid_write(struct nfsd4_open *open, struct nfsd_file *nf)
 	return 0;
 }
 
-#ifdef CONFIG_NFSD_V4_DELEG_TIMESTAMPS
 /*
  * Timestamp delegation was introduced in RFC7862. Runtime switch for disabling
  * this feature is /sys/kernel/debug/nfsd/delegated_timestamps.
@@ -6058,12 +6057,6 @@ static bool nfsd4_want_deleg_timestamps(const struct nfsd4_open *open)
 		return false;
 	return open->op_deleg_want & OPEN4_SHARE_ACCESS_WANT_DELEG_TIMESTAMPS;
 }
-#else /* CONFIG_NFSD_V4_DELEG_TIMESTAMPS */
-static bool nfsd4_want_deleg_timestamps(const struct nfsd4_open *open)
-{
-	return false;
-}
-#endif /* CONFIG NFSD_V4_DELEG_TIMESTAMPS */
 
 static struct nfs4_delegation *
 nfs4_set_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
Signature · 1 line
2.52.0
maintainer
#3 lore raw
In reply to Jeff Layton

From: Chuck Lever <[email protected]>

Quoted 4 lines · Jeff Layton

This version just updates the comments an changelogs per Claude's recommendations.

Applied to nfsd-testing, thanks!

[1/2] nfsd: add a runtime switch for disabling delegated timestamps

      commit: d0dc64a1a4e8629ffc6ab2a3ce208466de12e75b
[2/2] nfsd: remove NFSD_V4_DELEG_TIMESTAMPS Kconfig option
      commit: aac451587f0d37729d05467badee1578b7efce66

--
Chuck Lever