Skip to content

Commit 3981e94

Browse files
chaseyuJaegeuk Kim
authored andcommitted
f2fs: convert f2fs_read_multi_pages() to use folio
Convert to use folio, so that we can get rid of 'page->index' to prepare for removal of 'index' field in structure page [1]. [1] https://lore.kernel.org/all/[email protected]/ Cc: Matthew Wilcox <[email protected]> Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 138a762 commit 3981e94

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

fs/f2fs/data.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,19 +2207,22 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
22072207
/* get rid of pages beyond EOF */
22082208
for (i = 0; i < cc->cluster_size; i++) {
22092209
struct page *page = cc->rpages[i];
2210+
struct folio *folio;
22102211

22112212
if (!page)
22122213
continue;
2213-
if ((sector_t)page->index >= last_block_in_file) {
2214-
zero_user_segment(page, 0, PAGE_SIZE);
2215-
if (!PageUptodate(page))
2216-
SetPageUptodate(page);
2217-
} else if (!PageUptodate(page)) {
2214+
2215+
folio = page_folio(page);
2216+
if ((sector_t)folio->index >= last_block_in_file) {
2217+
folio_zero_segment(folio, 0, folio_size(folio));
2218+
if (!folio_test_uptodate(folio))
2219+
folio_mark_uptodate(folio);
2220+
} else if (!folio_test_uptodate(folio)) {
22182221
continue;
22192222
}
2220-
unlock_page(page);
2223+
folio_unlock(folio);
22212224
if (for_write)
2222-
put_page(page);
2225+
folio_put(folio);
22232226
cc->rpages[i] = NULL;
22242227
cc->nr_rpages--;
22252228
}
@@ -2279,7 +2282,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
22792282
}
22802283

22812284
for (i = 0; i < cc->nr_cpages; i++) {
2282-
struct page *page = dic->cpages[i];
2285+
struct folio *folio = page_folio(dic->cpages[i]);
22832286
block_t blkaddr;
22842287
struct bio_post_read_ctx *ctx;
22852288

@@ -2289,7 +2292,8 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
22892292

22902293
f2fs_wait_on_block_writeback(inode, blkaddr);
22912294

2292-
if (f2fs_load_compressed_page(sbi, page, blkaddr)) {
2295+
if (f2fs_load_compressed_page(sbi, folio_page(folio, 0),
2296+
blkaddr)) {
22932297
if (atomic_dec_and_test(&dic->remaining_pages)) {
22942298
f2fs_decompress_cluster(dic, true);
22952299
break;
@@ -2299,7 +2303,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
22992303

23002304
if (bio && (!page_is_mergeable(sbi, bio,
23012305
*last_block_in_bio, blkaddr) ||
2302-
!f2fs_crypt_mergeable_bio(bio, inode, page->index, NULL))) {
2306+
!f2fs_crypt_mergeable_bio(bio, inode, folio->index, NULL))) {
23032307
submit_and_realloc:
23042308
f2fs_submit_read_bio(sbi, bio, DATA);
23052309
bio = NULL;
@@ -2308,7 +2312,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23082312
if (!bio) {
23092313
bio = f2fs_grab_read_bio(inode, blkaddr, nr_pages,
23102314
f2fs_ra_op_flags(rac),
2311-
page->index, for_write);
2315+
folio->index, for_write);
23122316
if (IS_ERR(bio)) {
23132317
ret = PTR_ERR(bio);
23142318
f2fs_decompress_end_io(dic, ret, true);
@@ -2318,7 +2322,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
23182322
}
23192323
}
23202324

2321-
if (bio_add_page(bio, page, blocksize, 0) < blocksize)
2325+
if (!bio_add_folio(bio, folio, blocksize, 0))
23222326
goto submit_and_realloc;
23232327

23242328
ctx = get_post_read_ctx(bio);

0 commit comments

Comments
 (0)