Re: Fuse: directory cache eviction stopped working in the linux 6.9.X and onwards

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 31, 2024 at 4:36 AM Prince Kumar <princer@xxxxxxxxxx> wrote:
>
> Thanks Bernd for looking into this!
>
> I think 6.9 added passthrough support. Are you using that?
> > Not yet, but we have plans to try this out.
>
> FOPEN_CACHE_DIR is default when there is no fuse-server open method
> defined - does your implementation have an open/dir_open?
> > Yes, here is the implementation in GCSFuse (internally uses jacobsa/fuse library) - https://github.com/GoogleCloudPlatform/gcsfuse/blob/b0ca9c5b2c0a35aeb8a48fe7a36120d7b33216aa/internal/fs/fs.go#L2328
> Here, op.CacheDir maps to FOPEN_CACHE_DIR and op.KeepCache maps to
> FOPEN_KEEP_CACHE.
>
> I think the only user of FOPEN_CACHE_DIR is in fs/fuse/readdir.c and
> that always checks if it is set - either the flag gets set or does not
> come into role at all, because passthrough is used?
> > Being honest, I don't have much idea of linux source code. As a user, to me the FOPEN_CACHE_DIR flag is working as expected.
> The problem is with the FOPEN_KEEP_CACHE flags, setting this should
> evict the dir cache, but it's not happening for linux 6.9.x and above.
> Although I see  a line in fs/fuse/dir.c
> (https://github.com/torvalds/linux/blob/ccb98ccef0e543c2bd4ef1a72270461957f3d8d0/fs/fuse/dir.c#L718)
> which invalidates the inode pages if FOPEN_KEEP_CACHE is not set.
>
> So my ultimate question would be:
> (1) Do you see such recent changes in fs/fuse which explains the above
> regression?
> (2) If the changes are intentional, what should be the right way for
> fuse-server to evict the dir-cache (other than auto eviction due to
> change in dir-content, e.g., addition of new file inside a dir)?
>

Hi Prince,

The change is not international.
It is a regression due to commit
7de64d521bf92 ("fuse: break up fuse_open_common()") that missed the fact
the fuse_dir_open() may need to clean the page cache.

Can you test the attached fix patch?
It is only compile tested.
Due to holidays, I had no time to verify the fix.

Thanks,
Amir.
From c8f500679f0d28f37ef3d7755ff131788c47408d Mon Sep 17 00:00:00 2001
From: Amir Goldstein <amir73il@xxxxxxxxx>
Date: Tue, 31 Dec 2024 16:55:24 +0100
Subject: [PATCH] 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.

Fixes: 7de64d521bf92 ("fuse: break up fuse_open_common()")
Reported-by: Prince Kumar <princer@xxxxxxxxxx>
Closes: https://lore.kernel.org/linux-fsdevel/CAEW=TRr7CYb4LtsvQPLj-zx5Y+EYBmGfM24SuzwyDoGVNoKm7w@xxxxxxxxxxxxxx/
Signed-off-by: Amir Goldstein <amir73il@xxxxxxxxx>
---
 fs/fuse/dir.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 494ac372ace07..e540d05549fff 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -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;
-- 
2.34.1


[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux