Skip to content

Commit 13aab04

Browse files
joannekoongkawasaki
authored andcommitted
iomap: move folio_unlock out of iomap_writeback_folio
Move unlocking the folio out of iomap_writeback_folio into the caller. This means the end writeback machinery is now run with the folio locked when no writeback happened, or writeback completed extremely fast. Note that having the folio locked over the call to folio_end_writeback in iomap_writeback_folio means that the dropbehind handling there will never run because the trylock fails. The only way this can happen is if the writepage either never wrote back any dirty data at all, in which case the dropbehind handling isn't needed, or if all writeback finished instantly, which is rather unlikely. Even in the latter case the dropbehind handling is an optional optimization so skipping it will not cause correctness issues. This prepares for exporting iomap_writeback_folio for use in folio laundering. Signed-off-by: Joanne Koong <[email protected]> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: "Darrick J. Wong" <[email protected]>
1 parent d466824 commit 13aab04

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

fs/iomap/buffered-io.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1655,10 +1655,8 @@ static int iomap_writeback_folio(struct iomap_writepage_ctx *wpc,
16551655

16561656
trace_iomap_writeback_folio(inode, pos, folio_size(folio));
16571657

1658-
if (!iomap_writeback_handle_eof(folio, inode, &end_pos)) {
1659-
folio_unlock(folio);
1658+
if (!iomap_writeback_handle_eof(folio, inode, &end_pos))
16601659
return 0;
1661-
}
16621660
WARN_ON_ONCE(end_pos <= pos);
16631661

16641662
if (i_blocks_per_folio(inode, folio) > 1) {
@@ -1712,7 +1710,6 @@ static int iomap_writeback_folio(struct iomap_writepage_ctx *wpc,
17121710
* already at this point. In that case we need to clear the writeback
17131711
* bit ourselves right after unlocking the page.
17141712
*/
1715-
folio_unlock(folio);
17161713
if (ifs) {
17171714
if (atomic_dec_and_test(&ifs->write_bytes_pending))
17181715
folio_end_writeback(folio);
@@ -1739,8 +1736,10 @@ iomap_writepages(struct iomap_writepage_ctx *wpc)
17391736
PF_MEMALLOC))
17401737
return -EIO;
17411738

1742-
while ((folio = writeback_iter(mapping, wpc->wbc, folio, &error)))
1739+
while ((folio = writeback_iter(mapping, wpc->wbc, folio, &error))) {
17431740
error = iomap_writeback_folio(wpc, folio);
1741+
folio_unlock(folio);
1742+
}
17441743

17451744
/*
17461745
* If @error is non-zero, it means that we have a situation where some

0 commit comments

Comments
 (0)