Skip to content

Commit 029085b

Browse files
yukariatlasTrond Myklebust
authored andcommitted
NFS: Judge the file access cache's timestamp in rcu path
If the user's login time is newer than the cache's timestamp, we expect the cache may be stale and need to clear. The stale cache will remain in the list's tail if no other users operate on that inode. Once the user accesses the inode, the stale cache will be returned in rcu path. Signed-off-by: Chengen Du <chengen.du@canonical.com> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent a6b9d2f commit 029085b

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/nfs/dir.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3023,6 +3023,7 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
30233023
* but do it without locking.
30243024
*/
30253025
struct nfs_inode *nfsi = NFS_I(inode);
3026+
u64 login_time = nfs_access_login_time(current, cred);
30263027
struct nfs_access_entry *cache;
30273028
int err = -ECHILD;
30283029
struct list_head *lh;
@@ -3037,6 +3038,8 @@ static int nfs_access_get_cached_rcu(struct inode *inode, const struct cred *cre
30373038
cache = NULL;
30383039
if (cache == NULL)
30393040
goto out;
3041+
if ((s64)(login_time - cache->timestamp) > 0)
3042+
goto out;
30403043
if (nfs_check_cache_invalid(inode, NFS_INO_INVALID_ACCESS))
30413044
goto out;
30423045
*mask = cache->mask;

0 commit comments

Comments
 (0)