From: Markus Elfring <Markus.Elfring@web.de>
To: Jingbo Xu <jefflexu@linux.alibaba.com>,
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: Sun, 11 Jan 2026 09:18:46 +0100 [thread overview]
Message-ID: <abb96eb3-49fe-42bf-aae1-a1bf5e7a3827@web.de> (raw)
In-Reply-To: <20260111073701.6071-1-jefflexu@linux.alibaba.com>
…
> +++ 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
Regards,
Markus
next prev parent reply other threads:[~2026-01-11 8:19 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 [this message]
2026-01-11 9:43 ` Bernd Schubert
2026-01-12 5:37 ` Jingbo Xu
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=abb96eb3-49fe-42bf-aae1-a1bf5e7a3827@web.de \
--to=markus.elfring@web.de \
--cc=bschubert@ddn.com \
--cc=jefflexu@linux.alibaba.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®