mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: Bernd Schubert <bernd@bsbernd.com>,
	miklos@szeredi.hu, linux-fsdevel@vger.kernel.org,
	bschubert@ddn.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] fuse: invalidate the page cache after direct write
Date: Fri, 9 Jan 2026 10:21:31 +0800	[thread overview]
Message-ID: <1fa83cdf-010b-4e95-9dcc-0e9f5cefa68b@linux.alibaba.com> (raw)
In-Reply-To: <5b9fd5cb-2494-4dbd-8779-82525cb46bf4@linux.alibaba.com>

Hi Bernd,

On 1/9/26 10:13 AM, Jingbo Xu wrote:
> 
> 
> 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.
> 

Sorry I just realized that the invalidation for asynchronous write will
be done in fuse_aio_complete() of v1 patch.

I will apply the diff you suggested and send v2 soon.

-- 
Thanks,
Jingbo


      reply	other threads:[~2026-01-09  2:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-06  7:52 Jingbo Xu
2026-01-08 16:16 ` Bernd Schubert
2026-01-09  2:13   ` Jingbo Xu
2026-01-09  2:21     ` Jingbo Xu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1fa83cdf-010b-4e95-9dcc-0e9f5cefa68b@linux.alibaba.com \
    --to=jefflexu@linux.alibaba.com \
    --cc=bernd@bsbernd.com \
    --cc=bschubert@ddn.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®