Skip to content

iomap: don't mark folio uptodate if read IO has bytes pending

Joanne Koong linux-fsdevel stable 2 versions – Applied

Status from this message: Applied to the vfs.fixes branch of the vfs/vfs.git tree.

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest1 patch 1 replyApplied
  2. v11 patch 8 repliesSuperseded

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/1iomap: don't mark folio uptodate if read IO has bytes pendingfs/iomap/buffered-io.c+12 -30 replies

Reviews trailers per patch

The patch has a Reviewed-by or Acked-by.

PatchWei GaoDarrick J. Wong
1/1T-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH v2 0/1] iomap: don't mark folio uptodate if read IO has bytes pending

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.

There is another discussion in v1 [2] about consolidating the read paths. Until that is resolved, this patch fixes the issue.

Thanks,
Joanne

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

Changelog
---------
v1: https://lore.kernel.org/linux-fsdevel/[email protected]/T/#u
Changes made to v1:
* Add Darrick's reviewed-by, cc stable@, add link to discussion to commit message (Darrick)

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(-)
Signature · 1 line
2.47.3