Re: [PATCH v2] mm/filemap: bring a folio uptodate if all blocks below EOF are uptodate
From: Matthew Wilcox
Date: Thu Dec 03 2026 - 11:59:08 EST
On Tue, Dec 01, 2026 at 01:21:40PM -0800, Carol L Soto wrote:
> When a filesystem block is smaller than a folio, a write that ends
> before the last block of a new folio leaves the folio partially
> uptodate. The write marks its own blocks uptodate and leaves PG_uptodate
> clear. With 64 KiB pages and 4 KiB blocks, a 1280-byte write to a new
> file is such a write.
Thanks, Carol. This is a really interesting corner case, and it's a
legitimate performance prblem that's worth fixing.
I don't like the particular solution you've chosen, partly because I don't
like spreading the 'may_read' information into the helper, but also because
callers that set one of these flags are supposed to have a fallback. eg,
io_uring will use a helper thread to do the read_folio() call. So if
nginx switches to use io_uring, it's going to see the same contention
on the folio lock because it'll always take the partially uptodate path.
A solutioon that might be worth investigating is marking the folio uptodate
in write_begin for the special case of an extending write. We'll need to
make sure we always zero the post-EOF tail of a page before it's mmaped,
but we already do some of that to handle shared mmap writes beyond EOF.