Skip to content

Fix silent write loss in iomap

Matthew Wilcox (Oracle) linux-fsdevel linux-xfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2iomap: Clear page error before beginning a writefs/iomap/buffered-io.c+1 -01 reply
2/2iomap: Mark read blocks uptodate in write_beginfs/iomap/buffered-io.c+6 -81 reply

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchChristoph Hellwig
1/2R-b
2/2R-b

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

Read the v1 thread

Cover letter [PATCH 0/2] Fix silent write loss in iomap

While working on the THP patchset, I decided to inject errors, and unfortunately I found a hole in our handling of errors with non-THPs. You can probably reproduce these errors by inserting your own error injection for readahead pages; mine is a little too tied to the THP patchset to post.

The basic outline of the problem is:

- read(ahead) hits an error, page is marked Error, !Uptodate
- write_begin succeeds at reading in page, but it is not marked Uptodate due to PageError being set
- write path copies data to page, write() call returns success
- subsequent read() sees a page which is !Uptodate, clears Error, calls ->readpage, re-reads data from storage, overwrites data from write() with old data.

The solution presented here is to behave compatibly with mm/filemap.c. I don't _like_ how we handle PageError for read errors. See that other mail to linux-fsdevel for details, but this solution fixes an error that can be hit by people with flaky storage.

I've done this as two patches because there are actually two independent problems here. The bug is not fixed without applying both patches, so I'm happy to combine them into a single patch if that makes life easier.

The problem was introduced with commit 9dc55f1389f9, which made setting PageUptodate conditional on PageError().

Matthew Wilcox (Oracle) (2):
iomap: Clear page error before beginning a write
iomap: Mark read blocks uptodate in write_begin

 fs/iomap/buffered-io.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
Signature · 1 line
2.28.0