Skip to content

Commit 5c25699

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: don't wait for writeback on clean pages in extent_write_cache_pages
__extent_writepage could have started on more pages than the one it was called for. This happens regularly for zoned file systems, and in theory could happen for compressed I/O if the worker thread was executed very quickly. For such pages extent_write_cache_pages waits for writeback to complete before moving on to the next page, which is highly inefficient as it blocks the flusher thread. Port over the PageDirty check that was added to write_cache_pages in commit 515f4a0 ("mm: write_cache_pages optimise page cleaning") to fix this. CC: stable@vger.kernel.org # 4.14+ Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
1 parent effa24f commit 5c25699

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

fs/btrfs/extent_io.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2145,6 +2145,12 @@ static int extent_write_cache_pages(struct address_space *mapping,
21452145
continue;
21462146
}
21472147

2148+
if (!folio_test_dirty(folio)) {
2149+
/* Someone wrote it for us. */
2150+
folio_unlock(folio);
2151+
continue;
2152+
}
2153+
21482154
if (wbc->sync_mode != WB_SYNC_NONE) {
21492155
if (folio_test_writeback(folio))
21502156
submit_write_bio(bio_ctrl, 0);

0 commit comments

Comments
 (0)