Skip to content

Commit 482a626

Browse files
author
Brian Foster
committed
iomap: move folio_unlock out of iomap_writeback_folio
JIRA: https://issues.redhat.com/browse/RHEL-121230 commit f8b6a94 Author: Joanne Koong <joannelkoong@gmail.com> Date: Thu Jul 10 15:33:33 2025 +0200 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 <joannelkoong@gmail.com> [hch: split from a larger patch] Signed-off-by: Christoph Hellwig <hch@lst.de> Link: https://lore.kernel.org/20250710133343.399917-10-hch@lst.de Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Christian Brauner <brauner@kernel.org> Signed-off-by: Brian Foster <bfoster@redhat.com>
1 parent 9ae0f92 commit 482a626

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

fs/iomap/buffered-io.c

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

16521652
trace_iomap_writeback_folio(inode, pos, folio_size(folio));
16531653

1654-
if (!iomap_writeback_handle_eof(folio, inode, &end_pos)) {
1655-
folio_unlock(folio);
1654+
if (!iomap_writeback_handle_eof(folio, inode, &end_pos))
16561655
return 0;
1657-
}
16581656
WARN_ON_ONCE(end_pos <= pos);
16591657

16601658
if (i_blocks_per_folio(inode, folio) > 1) {
@@ -1708,7 +1706,6 @@ static int iomap_writeback_folio(struct iomap_writepage_ctx *wpc,
17081706
* already at this point. In that case we need to clear the writeback
17091707
* bit ourselves right after unlocking the page.
17101708
*/
1711-
folio_unlock(folio);
17121709
if (ifs) {
17131710
if (atomic_dec_and_test(&ifs->write_bytes_pending))
17141711
folio_end_writeback(folio);
@@ -1735,8 +1732,10 @@ iomap_writepages(struct iomap_writepage_ctx *wpc)
17351732
PF_MEMALLOC))
17361733
return -EIO;
17371734

1738-
while ((folio = writeback_iter(mapping, wpc->wbc, folio, &error)))
1735+
while ((folio = writeback_iter(mapping, wpc->wbc, folio, &error))) {
17391736
error = iomap_writeback_folio(wpc, folio);
1737+
folio_unlock(folio);
1738+
}
17401739

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

0 commit comments

Comments
 (0)