diff mbox series

fuse : Improve file open behavior for recently created/unlinked files

Message ID DM6PR12MB3385C7EACD424E9E15B5A3D6DD290@DM6PR12MB3385.namprd12.prod.outlook.com (mailing list archive)
State New, archived
Headers show
Series fuse : Improve file open behavior for recently created/unlinked files | expand

Commit Message

Ken Schalk Sept. 8, 2020, 2:32 p.m. UTC
When a dentry exists for the path argument to an open with O_CREAT or
a negative dentry exists for the path argument to any open, make a
lookup request to the user-space daemon to verify the
existence/non-existence of the path.

This improves file open behavior for a FUSE filesystem where changes
may be made without going through the mount point, such as a
distributed filesystem accessed concurrently from multiple hosts.
Specifically:

- For an open with O_CREAT of a path with a cached dentry, the
  user-space daemon is able to report a recent unlink of a file
  allowing it to be re-created rather than either the open failing
  with EEXIST (when O_EXCL is used) or a FUSE open request causing the
  open to fail with ENOENT (when O_EXCL is not used).

- For an open of a path with a cached negative dentry, the user-space
  daemon is able to report the recent creation of a file allowing it
  to be opened rather than the open failing with ENOENT.

This is intended to be functionally equivalent to behavior in the NFS
client which re-validates a cached dentry on file open.

Signed-off-by: Kenneth C Schalk <kschalk@nvidia.com>
---
 fs/fuse/dir.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--
2.9.2
diff mbox series

Patch

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index c4a0129..b46f5e8 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -204,7 +204,8 @@  static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags)
        if (inode && is_bad_inode(inode))
                goto invalid;
        else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) ||
-                (flags & LOOKUP_REVAL)) {
+                (!inode && (flags & LOOKUP_OPEN)) ||
+                (flags & (LOOKUP_CREATE | LOOKUP_REVAL))) {
                struct fuse_entry_out outarg;
                FUSE_ARGS(args);
                struct fuse_forget_link *forget;