Linux filesystem development
 help / color / mirror / Atom feed
* [PATCH v1 0/1] iomap: don't mark folio uptodate if read IO has bytes pending
@ 2026-02-19  0:39 Joanne Koong
  2026-02-19  0:39 ` [PATCH v1 1/1] " Joanne Koong
  0 siblings, 1 reply; 10+ messages in thread
From: Joanne Koong @ 2026-02-19  0:39 UTC (permalink / raw)
  To: brauner; +Cc: willy, wegao, sashal, djwong, hch, linux-fsdevel

This is a fix for this scenario:

->read_folio() gets called on a folio size that is 16k while the file is 4k:
  a) ifs->read_bytes_pending gets initialized to 16k
  b) ->read_folio_range() is called for the 4k read
  c) the 4k read succeeds, ifs->read_bytes_pending is now 12k and the
0 to 4k range is marked uptodate
  d) the post-eof blocks are zeroed and marked uptodate in the call to
iomap_set_range_uptodate()
  e) iomap_set_range_uptodate() sees all the ranges are marked
uptodate and it marks the folio uptodate
  f) iomap_read_end() gets called to subtract the 12k from
ifs->read_bytes_pending. it too sees all the ranges are marked
uptodate and marks the folio uptodate using XOR
  g) the XOR call clears the uptodate flag on the folio

The same situation can occur if the last range read for the folio is done as an
inline read and all the previous ranges have already completed by the time the
inline read completes.

For more context, the full discussion can be found in [1]. There was a
discussion about alternative approaches in that thread, but they had more
complications.

Thanks,
Joanne

[1] https://lore.kernel.org/linux-fsdevel/CAJnrk1Z9za5w4FoJqTGx50zR2haHHaoot1KJViQyEHJQq4=34w@mail.gmail.com/#t

Joanne Koong (1):
  iomap: don't mark folio uptodate if read IO has bytes pending

 fs/iomap/buffered-io.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

-- 
2.47.3


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-02-24 15:16 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-19  0:39 [PATCH v1 0/1] iomap: don't mark folio uptodate if read IO has bytes pending Joanne Koong
2026-02-19  0:39 ` [PATCH v1 1/1] " Joanne Koong
2026-02-19  2:45   ` Darrick J. Wong
2026-02-19  4:23     ` Matthew Wilcox
2026-02-19  6:11       ` Darrick J. Wong
2026-02-19  6:11         ` Christoph Hellwig
2026-02-20 22:13         ` Joanne Koong
2026-02-20 23:45       ` Darrick J. Wong
2026-02-23 23:53         ` Joanne Koong
2026-02-24 15:16           ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox