From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: Markus Elfring <Markus.Elfring@web.de>,
linux-fsdevel@vger.kernel.org, Bernd Schubert <bschubert@ddn.com>,
Miklos Szeredi <miklos@szeredi.hu>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3] fuse: invalidate the page cache after direct write
Date: Mon, 12 Jan 2026 13:37:12 +0800 [thread overview]
Message-ID: <19757b9e-1193-42cb-8d11-33c4e92336cf@linux.alibaba.com> (raw)
In-Reply-To: <abb96eb3-49fe-42bf-aae1-a1bf5e7a3827@web.de>
On 1/11/26 4:18 PM, Markus Elfring wrote:
> …
>> +++ b/fs/fuse/file.c
>> @@ -667,6 +667,18 @@ static void fuse_aio_complete(struct fuse_io_priv *io, int err, ssize_t pos)
>> struct inode *inode = file_inode(io->iocb->ki_filp);
>> struct fuse_conn *fc = get_fuse_conn(inode);
>> struct fuse_inode *fi = get_fuse_inode(inode);
>> + struct address_space *mapping = io->iocb->ki_filp->f_mapping;
>> +
>> + /*
>> + * As in generic_file_direct_write(), invalidate after the
>> + * write, to invalidate read-ahead cache that may have competed
>> + * with the write.
>> + */
>> + if (io->write && res && mapping->nrpages) {
>> + invalidate_inode_pages2_range(mapping,
>> + io->offset >> PAGE_SHIFT,
>> + (io->offset + res - 1) >> PAGE_SHIFT);
>> + }
>>
>> spin_lock(&fi->lock);
> …
>> @@ -1160,10 +1174,26 @@ static ssize_t fuse_send_write(struct fuse_io_args *ia, loff_t pos,
> …
> - return err ?: ia->write.out.size;
>> + /*
>> + * 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
>> + * with the write.
>> + */
>> + invalidate_inode_pages2_range(mapping, pos >> PAGE_SHIFT,
>> + (pos + written - 1) >> PAGE_SHIFT);
>> + }
>> +
>> + return err ?: written;
> …
>
> You may omit curly brackets at selected source code places.
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/coding-style.rst?h=v6.19-rc4#n197
>
It's generally true for **simple** single statement. I would prefer
adding the braces as it's a multi-line statement with a comment block.
--
Thanks,
Jingbo
next prev parent reply other threads:[~2026-01-12 5:37 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-11 7:37 Jingbo Xu
2026-01-11 8:18 ` Markus Elfring
2026-01-11 9:43 ` Bernd Schubert
2026-01-12 5:37 ` Jingbo Xu [this message]
2026-02-24 8:30 ` Jingbo Xu
2026-02-27 15:09 ` Miklos Szeredi
2026-03-02 19:29 ` Bernd Schubert
2026-03-02 21:19 ` Bernd Schubert
2026-03-02 21:28 ` Miklos Szeredi
2026-03-03 2:56 ` Jingbo Xu
2026-03-03 6:47 ` Jingbo Xu
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=19757b9e-1193-42cb-8d11-33c4e92336cf@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=Markus.Elfring@web.de \
--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®