Skip to content

Commit 669c058

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
NFS: Shortcut lookup revalidations if we have a directory delegation
Holding a directory delegation means we know that nobody else has modified the directory on the server, so we can take a few revalidation shortcuts. Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 2da2116 commit 669c058

3 files changed

Lines changed: 27 additions & 0 deletions

File tree

fs/nfs/delegation.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,11 @@ static inline void nfs_request_directory_delegation(struct inode *inode)
130130
set_bit(NFS_INO_REQ_DIR_DELEG, &NFS_I(inode)->flags);
131131
}
132132

133+
static inline bool nfs_have_directory_delegation(struct inode *inode)
134+
{
135+
return S_ISDIR(inode->i_mode) && nfs_have_delegated_attributes(inode);
136+
}
137+
133138
int nfs4_delegation_hash_alloc(struct nfs_server *server);
134139

135140
#endif

fs/nfs/dir.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,15 @@ static int nfs_check_verifier(struct inode *dir, struct dentry *dentry,
15151515
return 0;
15161516
if (!nfs_dentry_verify_change(dir, dentry))
15171517
return 0;
1518+
1519+
/*
1520+
* If we have a directory delegation then we don't need to revalidate
1521+
* the directory. The delegation will either get recalled or we will
1522+
* receive a notification when it changes.
1523+
*/
1524+
if (nfs_have_directory_delegation(dir))
1525+
return 0;
1526+
15181527
/* Revalidate nfsi->cache_change_attribute before we declare a match */
15191528
if (nfs_mapping_need_revalidate_inode(dir)) {
15201529
if (rcu_walk)
@@ -2207,6 +2216,13 @@ int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
22072216
}
22082217
EXPORT_SYMBOL_GPL(nfs_atomic_open);
22092218

2219+
static int
2220+
nfs_lookup_revalidate_delegated_parent(struct inode *dir, struct dentry *dentry,
2221+
struct inode *inode)
2222+
{
2223+
return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
2224+
}
2225+
22102226
static int
22112227
nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name,
22122228
struct dentry *dentry, unsigned int flags)
@@ -2234,6 +2250,9 @@ nfs4_lookup_revalidate(struct inode *dir, const struct qstr *name,
22342250
if (nfs_verifier_is_delegated(dentry))
22352251
return nfs_lookup_revalidate_delegated(dir, dentry, inode);
22362252

2253+
if (nfs_have_directory_delegation(dir))
2254+
return nfs_lookup_revalidate_delegated_parent(dir, dentry, inode);
2255+
22372256
/* NFS only supports OPEN on regular files */
22382257
if (!S_ISREG(inode->i_mode))
22392258
goto full_reval;

fs/nfs/inode.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,9 @@ __nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
13891389
status = pnfs_sync_inode(inode, false);
13901390
if (status)
13911391
goto out;
1392+
} else if (nfs_have_directory_delegation(inode)) {
1393+
status = 0;
1394+
goto out;
13921395
}
13931396

13941397
status = -ENOMEM;

0 commit comments

Comments
 (0)