Skip to contentSkip to conversation

NFS: Add some knobs for disabling delegations in sysfs

RFC PATCH In review Scott Mayhew 4 participants 7 messages Nov 25, 2025 – Jan 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 NFS: Add some knobs for disabling delegations in sysfs

There's occasionally a need to disable delegations, whether it be due to known bugs or simply to give support staff some breathing room to troubleshoot issues. Currently the only real method for disabling delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has some major drawbacks in that 1) it's only applicable to knfsd, and 2) it affects all clients using that server.

Technically it's not really possible to disable delegations from the client side since it's ultimately up to the server whether grants a delegation or not, but we can achieve a similar affect in NFSv4.1+ by manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Rather than proliferating a bunch of new mount options, add some sysfs knobs to allow some of the nfs_server->caps flags related to delegations to be adjusted.

---
 fs/nfs/nfs4proc.c         |  8 ++++++
 fs/nfs/sysfs.c            | 55 +++++++++++++++++++++++++++++++++++++++
 include/linux/nfs_fs_sb.h |  1 +
 3 files changed, 64 insertions(+)
fs/nfs/nfs4proc.c +8 -0
index 93c6ce04332b..42810260f7d8 100644
@@ -1396,6 +1396,11 @@ nfs4_map_atomic_open_share(struct nfs_server *server,
 		res |= NFS4_SHARE_WANT_NO_DELEG;
 		goto out;
 	}
+	/* open delegation disabled in sysfs */
+	if (!(server->caps & NFS_CAP_DELEGATION)) {
+		res |= NFS4_SHARE_WANT_NO_DELEG;
+		goto out;
+	}
 	/* res |= NFS4_SHARE_WANT_NO_PREFERENCE; */
 	if (server->caps & NFS_CAP_DELEGTIME)
 		res |= NFS4_SHARE_WANT_DELEG_TIMESTAMPS;
@@ -10796,6 +10801,7 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = {
 	.minor_version = 0,
 	.init_caps = NFS_CAP_READDIRPLUS
 		| NFS_CAP_ATOMIC_OPEN
+		| NFS_CAP_DELEGATION
 		| NFS_CAP_POSIX_LOCK,
 	.init_client = nfs40_init_client,
 	.shutdown_client = nfs40_shutdown_client,
@@ -10822,6 +10828,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = {
 	.minor_version = 1,
 	.init_caps = NFS_CAP_READDIRPLUS
 		| NFS_CAP_ATOMIC_OPEN
+		| NFS_CAP_DELEGATION
 		| NFS_CAP_POSIX_LOCK
 		| NFS_CAP_STATEID_NFSV41
 		| NFS_CAP_ATOMIC_OPEN_V1
@@ -10848,6 +10855,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = {
 	.minor_version = 2,
 	.init_caps = NFS_CAP_READDIRPLUS
 		| NFS_CAP_ATOMIC_OPEN
+		| NFS_CAP_DELEGATION
 		| NFS_CAP_POSIX_LOCK
 		| NFS_CAP_STATEID_NFSV41
 		| NFS_CAP_ATOMIC_OPEN_V1
fs/nfs/sysfs.c +55 -0

67 lines not on this page · raw message

include/linux/nfs_fs_sb.h +1 -0
index d30c0245031c..dcbb4ce6b3fd 100644
@@ -305,6 +305,7 @@ struct nfs_server {
 #define NFS_CAP_REBOOT_LAYOUTRETURN	(1U << 8)
 #define NFS_CAP_OFFLOAD_STATUS	(1U << 9)
 #define NFS_CAP_ZERO_RANGE	(1U << 10)
+#define NFS_CAP_DELEGATION	(1U << 11)
 #define NFS_CAP_OPEN_XOR	(1U << 12)
 #define NFS_CAP_DELEGTIME	(1U << 13)
 #define NFS_CAP_POSIX_LOCK	(1U << 14)
Signature · 1 line
2.51.0
maintainer
#1 lore raw

Hi Scott,

Quoted 14 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due to
known bugs or simply to give support staff some breathing room to troubleshoot issues.  Currently the only real method for disabling delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has some major drawbacks in that 1) it's only applicable to knfsd, and 2) it
affects all clients using that server.

Technically it's not really possible to disable delegations from the client side since it's ultimately up to the server whether grants a delegation or not, but we can achieve a similar affect in NFSv4.1+ by manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Shouldn't we rather be allowing the application to select whether it wants to request a delegation or not?

IOW: while there may or may not be a place for a 'big hammer' solution like you propose, should we not rather first try to enable a solution in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

That might also allow someone to add an LD_PRELOAD library to add or remove these flags from an existing application's open() calls.

It might also be useful for the directory delegation functionality that Anna and Jeff have been working on...

Just some food for thought while you're digesting on Thursday :-)...

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
#2 lore raw
Quoted 27 lines · Trond Myklebust

Hi Scott,

Quoted 14 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due to
known bugs or simply to give support staff some breathing room to troubleshoot issues.  Currently the only real method for disabling delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has some major drawbacks in that 1) it's only applicable to knfsd, and 2) it
affects all clients using that server.

Technically it's not really possible to disable delegations from the client side since it's ultimately up to the server whether grants a delegation or not, but we can achieve a similar affect in NFSv4.1+ by manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Shouldn't we rather be allowing the application to select whether it wants to request a delegation or not?

Quoted 7 lines

IOW: while there may or may not be a place for a 'big hammer' solution like you propose, should we not rather first try to enable a solution in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

That might also allow someone to add an LD_PRELOAD library to add or remove these flags from an existing application's open() calls.

Sure, allowing the application to specify whether it wants a delegation or not would be better... but with open() being governed by POSIX and with delegations being an NFS-specific feature, I figured adding open flags related to delegations wasn't feasible. I discussed it with Olga, and she had the same opinion. Are we mistaken here?

Quoted 11 lines

It might also be useful for the directory delegation functionality that Anna and Jeff have been working on...

Just some food for thought while you're digesting on Thursday :-)...

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
maintainer
#3 lore raw
Quoted 48 lines · Scott Mayhew
Quoted 42 lines · Trond Myklebust

Hi Scott,

Quoted 21 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due
to
known bugs or simply to give support staff some breathing room to troubleshoot issues.  Currently the only real method for disabling
delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has
some major drawbacks in that 1) it's only applicable to knfsd, and 2)
it
affects all clients using that server.

Technically it's not really possible to disable delegations from the
client side since it's ultimately up to the server whether grants a
delegation or not, but we can achieve a similar affect in NFSv4.1+ by
manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Shouldn't we rather be allowing the application to select whether it
wants to request a delegation or not?

IOW: while there may or may not be a place for a 'big hammer' solution
like you propose, should we not rather first try to enable a solution
in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

Quoted 3 lines

That might also allow someone to add an LD_PRELOAD library to add or
remove these flags from an existing application's open() calls.

Quoted 8 lines

Sure, allowing the application to specify whether it wants a delegation
or not would be better... but with open() being governed by POSIX and with delegations being an NFS-specific feature, I figured adding open flags related to delegations wasn't feasible.  I discussed it with Olga,
and she had the same opinion.  Are we mistaken here?

O_DIRECT, O_NOATIME, O_PATH and O_TMPFILE are all open modes that are unsupported by POSIX.
Furthermore, the openat2() system call is designed to be extensible.

Quoted 8 lines
Quoted 8 lines

It might also be useful for the directory delegation functionality that
Anna and Jeff have been working on...

Just some food for thought while you're digesting on Thursday :- )...

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
#4 lore raw
In reply to Trond Myklebust
Quoted 25 lines · Trond Myklebust

Hi Scott,

Quoted 14 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due to
known bugs or simply to give support staff some breathing room to troubleshoot issues. Currently the only real method for disabling delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has some major drawbacks in that 1) it's only applicable to knfsd, and 2) it
affects all clients using that server.

Technically it's not really possible to disable delegations from the client side since it's ultimately up to the server whether grants a delegation or not, but we can achieve a similar affect in NFSv4.1+ by manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Quoted 7 lines

Shouldn't we rather be allowing the application to select whether it wants to request a delegation or not?

IOW: while there may or may not be a place for a 'big hammer' solution like you propose, should we not rather first try to enable a solution in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

Hi Trond,

Shouldn't open flags be something that's a generic concept for all filesystems? O_DELEGATION seems to be NFS specific (or at most network filesystem specific).

Quoted 5 lines

That might also allow someone to add an LD_PRELOAD library to add or remove these flags from an existing application's open() calls.

It might also be useful for the directory delegation functionality that Anna and Jeff have been working on...

Being able to control directory delegations feature (might be) useful too? We used to be able to toggle features via mount options, wouldn't it be nice if we could again.... Toggling features via sysfs is useful for when mount is already in place though.

Quoted 8 lines

Just some food for thought while you're digesting on Thursday :-)...

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace [email protected], [email protected]

maintainer
#5 lore raw
Quoted 60 lines · Olga Kornievskaia
Quoted 36 lines · Trond Myklebust

Hi Scott,

Quoted 21 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due
to
known bugs or simply to give support staff some breathing room to troubleshoot issues.  Currently the only real method for disabling
delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has
some major drawbacks in that 1) it's only applicable to knfsd, and 2)
it
affects all clients using that server.

Technically it's not really possible to disable delegations from the
client side since it's ultimately up to the server whether grants a
delegation or not, but we can achieve a similar affect in NFSv4.1+ by
manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Shouldn't we rather be allowing the application to select whether it
wants to request a delegation or not?

Quoted 6 lines

IOW: while there may or may not be a place for a 'big hammer' solution
like you propose, should we not rather first try to enable a solution
in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

Hi Trond,

Shouldn't open flags be something that's a generic concept for all filesystems? O_DELEGATION seems to be NFS specific (or at most network
filesystem specific).

Quoted 7 lines

That might also allow someone to add an LD_PRELOAD library to add or
remove these flags from an existing application's open() calls.

It might also be useful for the directory delegation functionality that
Anna and Jeff have been working on...

Quoted 7 lines

Being able to control directory delegations feature (might be) useful too? We used to be able to toggle features via mount options, wouldn't
it be nice if we could again.... Toggling features via sysfs is useful
for when mount is already in place though.

Quoted 1 line

Isn't Jeff Layton in the process of exporting the NFSv4 delegation functionality to userspace through the lease mechanisms?

Signature · 3 lines
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected], [email protected]
maintainer
#6 lore raw
Quoted 69 lines · Trond Myklebust
Quoted 60 lines · Olga Kornievskaia
Quoted 36 lines · Trond Myklebust

Hi Scott,

Quoted 21 lines · Scott Mayhew

There's occasionally a need to disable delegations, whether it be due
to
known bugs or simply to give support staff some breathing room to troubleshoot issues.  Currently the only real method for disabling
delegations in Linux NFS is via /proc/sys/fs/leases-enable, which has
some major drawbacks in that 1) it's only applicable to knfsd, and 2)
it
affects all clients using that server.

Technically it's not really possible to disable delegations from the
client side since it's ultimately up to the server whether grants a
delegation or not, but we can achieve a similar affect in NFSv4.1+ by
manipulating the OPEN4_SHARE_ACCESS_WANT* flags.

Quoted 6 lines

Rather than proliferating a bunch of new mount options, add some sysfs
knobs to allow some of the nfs_server->caps flags related to delegations
to be adjusted.

Shouldn't we rather be allowing the application to select whether it
wants to request a delegation or not?

Quoted 6 lines

IOW: while there may or may not be a place for a 'big hammer' solution
like you propose, should we not rather first try to enable a solution
in which someone could add a O_DELEGATION or O_NODELEGATION flag to open() in order to specify what they want.

Hi Trond,

Shouldn't open flags be something that's a generic concept for all filesystems? O_DELEGATION seems to be NFS specific (or at most network
filesystem specific).

Quoted 7 lines

That might also allow someone to add an LD_PRELOAD library to add or
remove these flags from an existing application's open() calls.

It might also be useful for the directory delegation functionality that
Anna and Jeff have been working on...

Quoted 7 lines

Being able to control directory delegations feature (might be) useful too? We used to be able to toggle features via mount options, wouldn't
it be nice if we could again.... Toggling features via sysfs is useful
for when mount is already in place though.

Quoted 1 line
Quoted 2 lines

Isn't Jeff Layton in the process of exporting the NFSv4 delegation functionality to userspace through the lease mechanisms?

It's not quite the same thing, as they aren't acquired at open time. Similar to leases, you have to call fcntl(..., F_SETDELEG, ...) to get one. It doesn't seem like it really meshes with the idea of an O_NODELEGATION flag.

Being able to disable delegations on a per-mount basis seems like it could be useful though.

Signature · 1 line
Jeff Layton <[email protected]>