Skip to content

Commit e082164

Browse files
Matthew Wilcox (Oracle)Jaegeuk Kim
authored andcommitted
f2fs: Convert f2fs_finish_read_bio() to use folios
Use bio_for_each_folio_all() to iterate over each folio in the bio. This lets us use folio_end_read() which saves an atomic operation and memory barrier compared to marking the folio uptodate and unlocking it as two separate operations. This also removes a few hidden calls to compound_head(). Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Reviewed-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 1cf7460 commit e082164

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

fs/f2fs/data.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,27 +136,22 @@ struct bio_post_read_ctx {
136136
*/
137137
static void f2fs_finish_read_bio(struct bio *bio, bool in_task)
138138
{
139-
struct bio_vec *bv;
140-
struct bvec_iter_all iter_all;
139+
struct folio_iter fi;
141140
struct bio_post_read_ctx *ctx = bio->bi_private;
142141

143-
bio_for_each_segment_all(bv, bio, iter_all) {
144-
struct page *page = bv->bv_page;
142+
bio_for_each_folio_all(fi, bio) {
143+
struct folio *folio = fi.folio;
145144

146-
if (f2fs_is_compressed_page(page)) {
145+
if (f2fs_is_compressed_page(&folio->page)) {
147146
if (ctx && !ctx->decompression_attempted)
148-
f2fs_end_read_compressed_page(page, true, 0,
147+
f2fs_end_read_compressed_page(&folio->page, true, 0,
149148
in_task);
150-
f2fs_put_page_dic(page, in_task);
149+
f2fs_put_page_dic(&folio->page, in_task);
151150
continue;
152151
}
153152

154-
if (bio->bi_status)
155-
ClearPageUptodate(page);
156-
else
157-
SetPageUptodate(page);
158-
dec_page_count(F2FS_P_SB(page), __read_io_type(page));
159-
unlock_page(page);
153+
dec_page_count(F2FS_F_SB(folio), __read_io_type(&folio->page));
154+
folio_end_read(folio, bio->bi_status == 0);
160155
}
161156

162157
if (ctx)

0 commit comments

Comments
 (0)