f2fs: Convert f2fs_write_end_io() to use a folio_iter

Iterate over each folio in the bio instead of each page.
Follow the pattern in ext4 for handling bounce folios.  Removes
a few calls to compound_head() and references to page->mapping.

Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
Matthew Wilcox (Oracle) 2025-02-18 05:51:48 +00:00 committed by Jaegeuk Kim
parent cd8f95718c
commit fb9660481e

View File

@ -319,8 +319,7 @@ static void f2fs_read_end_io(struct bio *bio)
static void f2fs_write_end_io(struct bio *bio)
{
struct f2fs_sb_info *sbi;
struct bio_vec *bvec;
struct bvec_iter_all iter_all;
struct folio_iter fi;
iostat_update_and_unbind_ctx(bio);
sbi = bio->bi_private;
@ -328,34 +327,41 @@ static void f2fs_write_end_io(struct bio *bio)
if (time_to_inject(sbi, FAULT_WRITE_IO))
bio->bi_status = BLK_STS_IOERR;
bio_for_each_segment_all(bvec, bio, iter_all) {
struct page *page = bvec->bv_page;
enum count_type type = WB_DATA_TYPE(page, false);
bio_for_each_folio_all(fi, bio) {
struct folio *folio = fi.folio;
enum count_type type;
fscrypt_finalize_bounce_page(&page);
if (fscrypt_is_bounce_folio(folio)) {
struct folio *io_folio = folio;
folio = fscrypt_pagecache_folio(io_folio);
fscrypt_free_bounce_page(&io_folio->page);
}
#ifdef CONFIG_F2FS_FS_COMPRESSION
if (f2fs_is_compressed_page(page)) {
f2fs_compress_write_end_io(bio, page);
if (f2fs_is_compressed_page(&folio->page)) {
f2fs_compress_write_end_io(bio, &folio->page);
continue;
}
#endif
type = WB_DATA_TYPE(&folio->page, false);
if (unlikely(bio->bi_status)) {
mapping_set_error(page->mapping, -EIO);
mapping_set_error(folio->mapping, -EIO);
if (type == F2FS_WB_CP_DATA)
f2fs_stop_checkpoint(sbi, true,
STOP_CP_REASON_WRITE_FAIL);
}
f2fs_bug_on(sbi, page->mapping == NODE_MAPPING(sbi) &&
page_folio(page)->index != nid_of_node(page));
f2fs_bug_on(sbi, folio->mapping == NODE_MAPPING(sbi) &&
folio->index != nid_of_node(&folio->page));
dec_page_count(sbi, type);
if (f2fs_in_warm_node_list(sbi, page))
f2fs_del_fsync_node_entry(sbi, page);
clear_page_private_gcing(page);
end_page_writeback(page);
if (f2fs_in_warm_node_list(sbi, &folio->page))
f2fs_del_fsync_node_entry(sbi, &folio->page);
clear_page_private_gcing(&folio->page);
folio_end_writeback(folio);
}
if (!get_pages(sbi, F2FS_WB_CP_DATA) &&
wq_has_sleeper(&sbi->cp_wait))