Skip to content

Commit 7d875e6

Browse files
zhangjayceeMiklos Szeredi
authored andcommitted
fuse: invalidate dentry on EEXIST creates or ENOENT deletes
The EEXIST errors returned from server are strong sign that a local negative dentry should be invalidated. Similarly, The ENOENT errors from server can also be a sign of revalidate failure. This commit invalidates dentries on EEXIST creates and ENOENT deletes by calling fuse_invalidate_entry(), which improves the consistency with no performance degradation. Signed-off-by: Jiachen Zhang <zhangjiachen.jaycee@bytedance.com> Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
1 parent 972f4c4 commit 7d875e6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

fs/fuse/dir.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,8 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
749749
if (err == -ENOSYS) {
750750
fc->no_create = 1;
751751
goto mknod;
752-
}
752+
} else if (err == -EEXIST)
753+
fuse_invalidate_entry(entry);
753754
out_dput:
754755
dput(res);
755756
return err;
@@ -829,6 +830,8 @@ static int create_new_entry(struct fuse_mount *fm, struct fuse_args *args,
829830
return 0;
830831

831832
out_put_forget_req:
833+
if (err == -EEXIST)
834+
fuse_invalidate_entry(entry);
832835
kfree(forget);
833836
return err;
834837
}
@@ -980,7 +983,7 @@ static int fuse_unlink(struct inode *dir, struct dentry *entry)
980983
if (!err) {
981984
fuse_dir_changed(dir);
982985
fuse_entry_unlinked(entry);
983-
} else if (err == -EINTR)
986+
} else if (err == -EINTR || err == -ENOENT)
984987
fuse_invalidate_entry(entry);
985988
return err;
986989
}
@@ -1003,7 +1006,7 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
10031006
if (!err) {
10041007
fuse_dir_changed(dir);
10051008
fuse_entry_unlinked(entry);
1006-
} else if (err == -EINTR)
1009+
} else if (err == -EINTR || err == -ENOENT)
10071010
fuse_invalidate_entry(entry);
10081011
return err;
10091012
}
@@ -1044,7 +1047,7 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent,
10441047
/* newent will end up negative */
10451048
if (!(flags & RENAME_EXCHANGE) && d_really_is_positive(newent))
10461049
fuse_entry_unlinked(newent);
1047-
} else if (err == -EINTR) {
1050+
} else if (err == -EINTR || err == -ENOENT) {
10481051
/* If request was interrupted, DEITY only knows if the
10491052
rename actually took place. If the invalidation
10501053
fails (e.g. some process has CWD under the renamed

0 commit comments

Comments
 (0)