diff mbox series

[9/9] cifs: check the timestamp for the cached dirent when deciding on revalidate

Message ID 20210308230735.337-10-lsahlber@redhat.com (mailing list archive)
State New, archived
Headers show
Series [1/9] cifs: move the check for nohandlecache into open_shroot | expand

Commit Message

Ronnie Sahlberg March 8, 2021, 11:07 p.m. UTC
Signed-off-by: Ronnie Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/inode.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index 98dc6d70d4fa..95326025d77d 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2189,6 +2189,8 @@  cifs_dentry_needs_reval(struct dentry *dentry)
 	struct inode *inode = d_inode(dentry);
 	struct cifsInodeInfo *cifs_i = CIFS_I(inode);
 	struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
+	struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
+	struct cached_fid *cfid = NULL;
 
 	if (cifs_i->time == 0)
 		return true;
@@ -2199,6 +2201,16 @@  cifs_dentry_needs_reval(struct dentry *dentry)
 	if (!lookupCacheEnabled)
 		return true;
 
+	if (!open_cached_dir_by_dentry(tcon, dentry->d_parent, &cfid)) {
+		mutex_lock(&cfid->fid_mutex);
+		if (cfid->time && cifs_i->time > cfid->time) {
+			mutex_unlock(&cfid->fid_mutex);
+			close_cached_dir(cfid);
+			return false;
+		}
+		mutex_unlock(&cfid->fid_mutex);
+		close_cached_dir(cfid);
+	}
 	/*
 	 * depending on inode type, check if attribute caching disabled for
 	 * files or directories