Re: [PATCH] fuse: invalidate the page cache after direct write
From: Jingbo Xu
Date: Thu Jan 08 2026 - 21:16:19 EST
On 1/9/26 12:16 AM, Bernd Schubert wrote:
>
> The side effect should only come without FOPEN_DIRECT_IO. Could you add
> this diff to avoid it?
>
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index d6ae3b4652f8..c04296316a82 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1177,7 +1177,13 @@ static ssize_t fuse_send_write(struct fuse_io_args *ia, loff_t pos,
> written = ia->write.out.size;
> if (!err && written > count)
> err = -EIO;
> - if (!err && written && mapping->nrpages) {
> +
> + /*
> + * without FOPEN_DIRECT_IO generic_file_direct_write() does the
> + * invalidation for us
> + */
> + if (!err && written && mapping->nrpages &&
> + (ff->open_flags & FOPEN_DIRECT_IO)) {
> /*
> * As in generic_file_direct_write(), invalidate after the
> * write, to invalidate read-ahead cache that may have competed
>
Actually I think it's more complicated:
```
/*
* without FOPEN_DIRECT_IO generic_file_direct_write() does the
* invalidation for synchronous write.
*/
if (!err && written && mapping->nrpages &&
((ff->open_flags & FOPEN_DIRECT_IO) || !io->blocking)) {
```
I will send v2 soon if you feel good about the above diff.
--
Thanks,
Jingbo