Skip to content

Commit b6d2a52

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
NFS: Add a module option to disable directory delegations
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>
1 parent 669c058 commit b6d2a52

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

fs/nfs/delegation.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@
3030
static unsigned nfs_delegation_watermark = NFS_DEFAULT_DELEGATION_WATERMARK;
3131
module_param_named(delegation_watermark, nfs_delegation_watermark, uint, 0644);
3232

33+
bool directory_delegations = true;
34+
module_param(directory_delegations, bool, 0644);
35+
MODULE_PARM_DESC(directory_delegations,
36+
"Enable the use of directory delegations, defaults to on.");
37+
3338
static struct hlist_head *nfs_delegation_hash(struct nfs_server *server,
3439
const struct nfs_fh *fhandle)
3540
{
@@ -143,6 +148,8 @@ static int nfs4_do_check_delegation(struct inode *inode, fmode_t type,
143148
*/
144149
int nfs4_have_delegation(struct inode *inode, fmode_t type, int flags)
145150
{
151+
if (S_ISDIR(inode->i_mode) && !directory_delegations)
152+
nfs_inode_evict_delegation(inode);
146153
return nfs4_do_check_delegation(inode, type, flags, true);
147154
}
148155

fs/nfs/delegation.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ static inline int nfs_have_delegated_mtime(struct inode *inode)
124124
NFS_DELEGATION_FLAG_TIME);
125125
}
126126

127+
extern bool directory_delegations;
128+
127129
static inline void nfs_request_directory_delegation(struct inode *inode)
128130
{
129131
if (S_ISDIR(inode->i_mode))

fs/nfs/nfs4proc.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4473,6 +4473,8 @@ static int nfs4_get_referral(struct rpc_clnt *client, struct inode *dir,
44734473
#if IS_ENABLED(CONFIG_NFS_V4_1)
44744474
static bool should_request_dir_deleg(struct inode *inode)
44754475
{
4476+
if (!directory_delegations)
4477+
return false;
44764478
if (!inode)
44774479
return false;
44784480
if (!S_ISDIR(inode->i_mode))

0 commit comments

Comments
 (0)