]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
NFS: Add a module option to disable directory delegations
authorAnna Schumaker <anna.schumaker@oracle.com>
Tue, 4 Nov 2025 15:06:45 +0000 (10:06 -0500)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Sun, 23 Nov 2025 21:01:47 +0000 (16:01 -0500)
When this option is disabled then the client will not request directory
delegations or check if we have one during the revalidation paths.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/delegation.c
fs/nfs/delegation.h
fs/nfs/nfs4proc.c

index b4c192f00e945196af8c1fc528c5c8f3bf11a8ea..2248e3ad089a7c184a5546a7981244b22b34c09f 100644 (file)
 static unsigned nfs_delegation_watermark = NFS_DEFAULT_DELEGATION_WATERMARK;
 module_param_named(delegation_watermark, nfs_delegation_watermark, uint, 0644);
 
+bool directory_delegations = true;
+module_param(directory_delegations, bool, 0644);
+MODULE_PARM_DESC(directory_delegations,
+                "Enable the use of directory delegations, defaults to on.");
+
 static struct hlist_head *nfs_delegation_hash(struct nfs_server *server,
                const struct nfs_fh *fhandle)
 {
@@ -143,6 +148,8 @@ static int nfs4_do_check_delegation(struct inode *inode, fmode_t type,
  */
 int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags)
 {
+       if (S_ISDIR(inode->i_mode) && !directory_delegations)
+               nfs_inode_evict_delegation(inode);
        return nfs4_do_check_delegation(inode, type, flags, true);
 }
 
index 8968f62bf438dbec42243a7e47a736e83f69a40b..46d866adb5c265f4b4a3528e30f1738baa94c946 100644 (file)
@@ -124,6 +124,8 @@ static inline int nfs_have_delegated_mtime(struct inode *inode)
                                                 NFS_DELEGATION_FLAG_TIME);
 }
 
+extern bool directory_delegations;
+
 static inline void nfs_request_directory_delegation(struct inode *inode)
 {
        if (S_ISDIR(inode->i_mode))
index 6691a44866b60e950d8fbcc844550a83f7024cf1..c53ddb185aa3438780fdc228b2e8cf3038ca3d28 100644 (file)
@@ -4473,6 +4473,8 @@ out:
 #if IS_ENABLED(CONFIG_NFS_V4_1)
 static bool should_request_dir_deleg(struct inode *inode)
 {
+       if (!directory_delegations)
+               return false;
        if (!inode)
                return false;
        if (!S_ISDIR(inode->i_mode))