| From 067ec71b5f3e6b20fc1854ec54746146fa6557d9 Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Mon, 30 Sep 2019 10:06:19 -0700 |
| Subject: CIFS: Force revalidate inode when dentry is stale |
| |
| From: Pavel Shilovsky <piastryyy@gmail.com> |
| |
| [ Upstream commit c82e5ac7fe3570a269c0929bf7899f62048e7dbc ] |
| |
| Currently the client indicates that a dentry is stale when inode |
| numbers or type types between a local inode and a remote file |
| don't match. If this is the case attributes is not being copied |
| from remote to local, so, it is already known that the local copy |
| has stale metadata. That's why the inode needs to be marked for |
| revalidation in order to tell the VFS to lookup the dentry again |
| before openning a file. This prevents unexpected stale errors |
| to be returned to the user space when openning a file. |
| |
| Cc: <stable@vger.kernel.org> |
| Signed-off-by: Pavel Shilovsky <pshilov@microsoft.com> |
| Signed-off-by: Steve French <stfrench@microsoft.com> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| fs/cifs/inode.c | 4 ++++ |
| 1 file changed, 4 insertions(+) |
| |
| diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c |
| index 3d3c66fcb5ee6..0a219545940d9 100644 |
| --- a/fs/cifs/inode.c |
| +++ b/fs/cifs/inode.c |
| @@ -405,6 +405,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
| /* if uniqueid is different, return error */ |
| if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
| CIFS_I(*pinode)->uniqueid != fattr.cf_uniqueid)) { |
| + CIFS_I(*pinode)->time = 0; /* force reval */ |
| rc = -ESTALE; |
| goto cgiiu_exit; |
| } |
| @@ -412,6 +413,7 @@ int cifs_get_inode_info_unix(struct inode **pinode, |
| /* if filetype is different, return error */ |
| if (unlikely(((*pinode)->i_mode & S_IFMT) != |
| (fattr.cf_mode & S_IFMT))) { |
| + CIFS_I(*pinode)->time = 0; /* force reval */ |
| rc = -ESTALE; |
| goto cgiiu_exit; |
| } |
| @@ -887,6 +889,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
| /* if uniqueid is different, return error */ |
| if (unlikely(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM && |
| CIFS_I(*inode)->uniqueid != fattr.cf_uniqueid)) { |
| + CIFS_I(*inode)->time = 0; /* force reval */ |
| rc = -ESTALE; |
| goto cgii_exit; |
| } |
| @@ -894,6 +897,7 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, |
| /* if filetype is different, return error */ |
| if (unlikely(((*inode)->i_mode & S_IFMT) != |
| (fattr.cf_mode & S_IFMT))) { |
| + CIFS_I(*inode)->time = 0; /* force reval */ |
| rc = -ESTALE; |
| goto cgii_exit; |
| } |
| -- |
| 2.20.1 |
| |