fuse: respect FOPEN_KEEP_CACHE on opendir
Subsystems (2)
PATCH 1/1 fuse: respect FOPEN_KEEP_CACHE on opendir
The re-factoring of fuse_dir_open() missed the need to invalidate directory inode page cache with open flag FOPEN_KEEP_CACHE.
---
Miklos,
I verified the fix using:passthrough_ll -d -o source=/src,cache=always /mnt
and watching debug prints from repeating 'ls /mnt' invocations.
With current upstream, dir cache is kept even though passthrough_ll never sets keep_cache in opendir.
passthrough_hp always set keep_cache together with cache_readdir, so it could not have noticed this regression.
I've modified passthrough_ll as follows to test the keep_cache flag:
fi->fh = (uintptr_t) d;
< if (lo->cache == CACHE_ALWAYS)
Quoted 1 line
if (lo->cache != CACHE_NEVER)
fi->cache_readdir = 1;
Quoted 2 lines
if (lo->cache == CACHE_ALWAYS)
fi->keep_cache = 1; fuse_reply_open(req, fi);
return;Thanks,
Amir.
fs/fuse/dir.c +2 -0
@@ -1681,6 +1681,8 @@ static int fuse_dir_open(struct inode *inode, struct file *file)*/ if (ff->open_flags & (FOPEN_STREAM |FOPEN_NONSEEKABLE ))nonseekable_open (inode, file); +if (!(ff->open_flags &FOPEN_KEEP_CACHE )) +invalidate_inode_pages2 (inode->i_mapping); }return err;
Signature · 1 line
2.34.1
Quoted 41 lines · Amir Goldstein
The re-factoring of
fuse_dir_open()missed the need to invalidate directory inode page cache with open flagFOPEN_KEEP_CACHE.Fixes 7de64d521bf92 ("fuse: break up fuse_open_common()")Reported-by Prince Kumar <[email protected]>Closes https://lore.kernel.org/linux-fsdevel/CAEW=TRr7CYb4LtsvQPLj-zx5Y+EYBmGfM24SuzwyDoGVNoKm7w@mail.gmail.com/ open hereSigned-off-by Amir Goldstein <[email protected]>---
Miklos,
I verified the fix using:
passthrough_ll-d -o source=/src,cache=always /mntand watching debug prints from repeating 'ls /mnt' invocations.
With current upstream, dir cache is kept even though
passthrough_llnever setskeep_cachein opendir.
passthrough_hpalways setkeep_cachetogether withcache_readdir, so it could not have noticed this regression.I've modified
passthrough_llas follows to test thekeep_cacheflag:fi->fh = (uintptr_t) d;< if (
lo->cache==CACHE_ALWAYS)Quoted 1 line
if (lo->cache != CACHE_NEVER)fi->cache_readdir = 1;Quoted 2 lines
if (lo->cache == CACHE_ALWAYS) fi->keep_cache = 1;fuse_reply_open(req, fi); return;Thanks,
Amir.fs/fuse/dir.c +0
-0
fs/fuse/dir.c static int fuse_dir_open(struct inode *inode, struct file *file) · line 1688
Quoted 8 lines
fs/fuse/dir.c +2
-0@@ -1681,6 +1681,8 @@ static int fuse_dir_open(struct inode *inode, struct file *file)*/ if (ff->open_flags & (FOPEN_STREAM |FOPEN_NONSEEKABLE ))nonseekable_open (inode, file); +if (!(ff->open_flags &FOPEN_KEEP_CACHE )) +invalidate_inode_pages2 (inode->i_mapping); }return err;
LGTM. Thanks for the quick fix Amir, especially during holidays!
Quoted 4 lines · Amir Goldstein
The re-factoring of
fuse_dir_open()missed the need to invalidate directory inode page cache with open flagFOPEN_KEEP_CACHE.
Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.
Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.
It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.
Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git branch: vfs.fixes
[1/1] fuse: respect FOPEN_KEEP_CACHE on opendir
https://git.kernel.org/vfs/vfs/c/03f275adb8fb
Miklos Szeredi
maintainerQuoted 25 lines · Amir Goldstein
The re-factoring of
fuse_dir_open()missed the need to invalidate directory inode page cache with open flagFOPEN_KEEP_CACHE.Fixes 7de64d521bf92 ("fuse: break up fuse_open_common()")Reported-by Prince Kumar <[email protected]>Closes https://lore.kernel.org/linux-fsdevel/CAEW=TRr7CYb4LtsvQPLj-zx5Y+EYBmGfM24SuzwyDoGVNoKm7w@mail.gmail.com/ open hereSigned-off-by Amir Goldstein <[email protected]>---
Miklos,
I verified the fix using:
passthrough_ll-d -o source=/src,cache=always /mntand watching debug prints from repeating 'ls /mnt' invocations.
With current upstream, dir cache is kept even though
passthrough_llnever setskeep_cachein opendir.
passthrough_hpalways setkeep_cachetogether withcache_readdir, so it could not have noticed this regression.I've modified
passthrough_llas follows to test thekeep_cacheflag:
Quoted 8 lines
fi->fh = (uintptr_t) d;< if (
lo->cache==CACHE_ALWAYS)Quoted 1 line
if (lo->cache != CACHE_NEVER)fi->cache_readdir = 1;Quoted 2 lines
if (lo->cache == CACHE_ALWAYS) fi->keep_cache = 1;fuse_reply_open(req, fi); return;
Thanks for fixing this, Amir.
Miklos
Thanks everyone for the quick turnaround, especially Amir for the quick fix!!
Looking forward to the new release with this fix.
Regards,
Prince Kumar.
Quoted 39 lines · Miklos Szeredi
Quoted 25 lines · Amir Goldstein
The re-factoring of
fuse_dir_open()missed the need to invalidate directory inode page cache with open flagFOPEN_KEEP_CACHE.Fixes 7de64d521bf92 ("fuse: break up fuse_open_common()")Reported-by Prince Kumar <[email protected]>Closes https://lore.kernel.org/linux-fsdevel/CAEW=TRr7CYb4LtsvQPLj-zx5Y+EYBmGfM24SuzwyDoGVNoKm7w@mail.gmail.com/ open hereSigned-off-by Amir Goldstein <[email protected]>---
Miklos,
I verified the fix using:
passthrough_ll-d -o source=/src,cache=always /mntand watching debug prints from repeating 'ls /mnt' invocations.
With current upstream, dir cache is kept even though
passthrough_llnever setskeep_cachein opendir.
passthrough_hpalways setkeep_cachetogether withcache_readdir, so it could not have noticed this regression.I've modified
passthrough_llas follows to test thekeep_cacheflag:Quoted 8 lines
fi->fh = (uintptr_t) d;< if (
lo->cache==CACHE_ALWAYS)Quoted 1 line
if (lo->cache != CACHE_NEVER)fi->cache_readdir = 1;Quoted 2 lines
if (lo->cache == CACHE_ALWAYS) fi->keep_cache = 1;fuse_reply_open(req, fi); return;Thanks for fixing this, Amir.
Miklos