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.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
This commit is contained in:
Jeff Layton 2026-01-26 07:10:13 -05:00 committed by Chuck Lever
commit 6237a17fb8
3 changed files with 13 additions and 0 deletions

View file

@ -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
}

View file

@ -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)))
@ -6045,8 +6047,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 */

View file

@ -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 */