Re: [PATCH 2/7] fuse: Use filemap_invalidate_pages()

Matthew Wilcox <[email protected]>
Newsgroups dev.linux.lists.fuse-devel,org.kernel.vger.linux-block,org.kernel.vger.linux-btrfs,org.kernel.vger.linux-fsdevel,org.kernel.vger.linux-nfs,org.kvack.linux-mm
Message-ID <[email protected]>
On Mon, Aug 24, 2026 at 11:05:46AM +0200, Miklos Szeredi wrote:
> On Thu, 20 Aug 2026 at 21:34, Matthew Wilcox (Oracle)
> <[email protected]> wrote:
> >
> > FUSE relies on invalidate_inode_pages2() / invalidate_inode_pages2_range()
> > doing writeback by calling fuse_launder_folio().  While this works, it
> > is inefficient as each page is written back and waited for individually.
> > Far better to call filemap_invalidate_pages() which will do a bulk write
> > first, then remove the page cache.
> 
> filemap_invalidate_page() suggests to use invalidate_lock to prevent
> races with pages coming back.  I'm not sure that without it the
> behavior is identical.
> 
> Maybe add a variant that takes that lock?

I don't understand what use that would be.  As soon as that function
drops the lock, the pages could be reinstated.  If the caller needs the
pages to not come back, it must need to hold the invalidate_lock across
the whole operation.

Before any filesystem people get funny ideas about closing the O_DIRECT
race, you can't do that because you'll deadlock on doing I/O to the same
file that you've mmaped.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.