Skip to content

Commit 21b200d

Browse files
aaptelSteve French
authored andcommitted
cifs: report error instead of invalid when revalidating a dentry fails
Assuming - //HOST/a is mounted on /mnt - //HOST/b is mounted on /mnt/b On a slow connection, running 'df' and killing it while it's processing /mnt/b can make cifs_get_inode_info() returns -ERESTARTSYS. This triggers the following chain of events: => the dentry revalidation fail => dentry is put and released => superblock associated with the dentry is put => /mnt/b is unmounted This patch makes cifs_d_revalidate() return the error instead of 0 (invalid) when cifs_revalidate_dentry() fails, except for ENOENT (file deleted) and ESTALE (file recreated). Signed-off-by: Aurelien Aptel <[email protected]> Suggested-by: Shyam Prasad N <[email protected]> Reviewed-by: Shyam Prasad N <[email protected]> CC: [email protected] Signed-off-by: Steve French <[email protected]>
1 parent 91792bb commit 21b200d

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

fs/cifs/dir.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -737,6 +737,7 @@ static int
737737
cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
738738
{
739739
struct inode *inode;
740+
int rc;
740741

741742
if (flags & LOOKUP_RCU)
742743
return -ECHILD;
@@ -746,8 +747,25 @@ cifs_d_revalidate(struct dentry *direntry, unsigned int flags)
746747
if ((flags & LOOKUP_REVAL) && !CIFS_CACHE_READ(CIFS_I(inode)))
747748
CIFS_I(inode)->time = 0; /* force reval */
748749

749-
if (cifs_revalidate_dentry(direntry))
750-
return 0;
750+
rc = cifs_revalidate_dentry(direntry);
751+
if (rc) {
752+
cifs_dbg(FYI, "cifs_revalidate_dentry failed with rc=%d", rc);
753+
switch (rc) {
754+
case -ENOENT:
755+
case -ESTALE:
756+
/*
757+
* Those errors mean the dentry is invalid
758+
* (file was deleted or recreated)
759+
*/
760+
return 0;
761+
default:
762+
/*
763+
* Otherwise some unexpected error happened
764+
* report it as-is to VFS layer
765+
*/
766+
return rc;
767+
}
768+
}
751769
else {
752770
/*
753771
* If the inode wasn't known to be a dfs entry when

0 commit comments

Comments
 (0)