Skip to content

Commit 7ea1d9b

Browse files
Christoph Hellwigbrauner
authored andcommitted
iomap: clear the per-folio dirty bits on all writeback failures
write_cache_pages always clear the page dirty bit before calling into the file systems, and leaves folios with a writeback failure without the dirty bit after return. We also clear the per-block writeback bits for writeback failures unless no I/O has submitted, which will leave the folio in an inconsistent state where it doesn't have the folio dirty, but one or more per-block dirty bits. This seems to be due the place where the iomap_clear_range_dirty call was inserted into the existing not very clearly structured code when adding per-block dirty bit support and not actually intentional. Switch to always clearing the dirty on writeback failure. Fixes: 4ce02c6 ("iomap: Add per-block dirty state tracking to improve performance") Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/r/20231207072710.176093-2-hch@lst.de Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent 6613476 commit 7ea1d9b

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

fs/iomap/buffered-io.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,16 +1833,10 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
18331833
if (unlikely(error)) {
18341834
/*
18351835
* Let the filesystem know what portion of the current page
1836-
* failed to map. If the page hasn't been added to ioend, it
1837-
* won't be affected by I/O completion and we must unlock it
1838-
* now.
1836+
* failed to map.
18391837
*/
18401838
if (wpc->ops->discard_folio)
18411839
wpc->ops->discard_folio(folio, pos);
1842-
if (!count) {
1843-
folio_unlock(folio);
1844-
goto done;
1845-
}
18461840
}
18471841

18481842
/*
@@ -1851,6 +1845,16 @@ iomap_writepage_map(struct iomap_writepage_ctx *wpc,
18511845
* all the dirty bits in the folio here.
18521846
*/
18531847
iomap_clear_range_dirty(folio, 0, folio_size(folio));
1848+
1849+
/*
1850+
* If the page hasn't been added to the ioend, it won't be affected by
1851+
* I/O completion and we must unlock it now.
1852+
*/
1853+
if (error && !count) {
1854+
folio_unlock(folio);
1855+
goto done;
1856+
}
1857+
18541858
folio_start_writeback(folio);
18551859
folio_unlock(folio);
18561860

0 commit comments

Comments
 (0)