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 v2] fuse: invalidate the page cache after direct write
Date: Sun, 11 Jan 2026 15:29:10 +0800 [thread overview]
Message-ID: <6fd06c7f-a30b-4ba5-97aa-b7277d56b190@linux.alibaba.com> (raw)
In-Reply-To: <b8f7dd35-7702-4c70-be4f-0704abc1976d@bsbernd.com>
On 1/9/26 10:05 PM, Bernd Schubert wrote:
>
>
> On 1/9/26 08:01, Jingbo Xu wrote:
>> - return err ?: ia->write.out.size;
>> + /*
>> + * As in generic_file_direct_write(), invalidate after the write, to
>> + * invalidate read-ahead cache that may have competed with the write.
>> + * 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) || !ia->io->blocking)) {
>> + invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT,
>> + (pos + written - 1) >> PAGE_SHIFT);
>> + }
>> +
>> + return err ?: written;
>> }
>
> Sorry, but I'm confused about "|| !ia->io->blocking". When we go into this
> code path it either via generic_file_direct_write(), which then
> already invalidates or directly and then
> (ff->open_flags & FOPEN_DIRECT_IO) is set?
>
Alright. I mistakenly thought that generic_file_direct_write() will skip
the invalidation for async write (without FOPEN_DIRECT_IO) when
fc->async_dio is false, as the ->direct_IO() will return -EIOCBQUEUED
for async write.
But in fact when fc->async_dio is false, fuse_direct_IO() will wait for
the IO completion and return the number of bytes written on success.
Thus generic_file_direct_write() will do the invalidation in this case.
I will drop "|| !ia->io->blocking" in v3 and add your "Reviewed-by" tag
then.
Thank you for the reviewing!
--
Thanks,
Jingbo
prev parent reply other threads:[~2026-01-11 7:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 7:01 Jingbo Xu
2026-01-09 14:05 ` Bernd Schubert
2026-01-11 7:29 ` 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=6fd06c7f-a30b-4ba5-97aa-b7277d56b190@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®