Skip to content

Commit 6afd05c

Browse files
sigmanatureJaegeuk Kim
authored andcommitted
f2fs: add 'folio_in_bio' to handle readahead folios with no BIO submission
f2fs_read_data_large_folio() can build a single read BIO across multiple folios during readahead. If a folio ends up having none of its subpages added to the BIO (e.g. all subpages are zeroed / treated as holes), it will never be seen by f2fs_finish_read_bio(), so folio_end_read() is never called. This leaves the folio locked and not marked uptodate. Track whether the current folio has been added to a BIO via a local 'folio_in_bio' bool flag, and when iterating readahead folios, explicitly mark the folio uptodate (on success) and unlock it when nothing was added. Signed-off-by: Nanzhe Zhao <nzzhao@126.com> Reviewed-by: Chao Yu <chao@kernel.org> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
1 parent 540d34c commit 6afd05c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

fs/f2fs/data.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2448,6 +2448,7 @@ static int f2fs_read_data_large_folio(struct inode *inode,
24482448
unsigned nrpages;
24492449
struct f2fs_folio_state *ffs;
24502450
int ret = 0;
2451+
bool folio_in_bio;
24512452

24522453
if (!IS_IMMUTABLE(inode))
24532454
return -EOPNOTSUPP;
@@ -2463,6 +2464,7 @@ static int f2fs_read_data_large_folio(struct inode *inode,
24632464
if (!folio)
24642465
goto out;
24652466

2467+
folio_in_bio = false;
24662468
index = folio->index;
24672469
offset = 0;
24682470
ffs = NULL;
@@ -2548,6 +2550,7 @@ static int f2fs_read_data_large_folio(struct inode *inode,
25482550
offset << PAGE_SHIFT))
25492551
goto submit_and_realloc;
25502552

2553+
folio_in_bio = true;
25512554
inc_page_count(F2FS_I_SB(inode), F2FS_RD_DATA);
25522555
f2fs_update_iostat(F2FS_I_SB(inode), NULL, FS_DATA_READ_IO,
25532556
F2FS_BLKSIZE);
@@ -2557,6 +2560,10 @@ static int f2fs_read_data_large_folio(struct inode *inode,
25572560
}
25582561
trace_f2fs_read_folio(folio, DATA);
25592562
if (rac) {
2563+
if (!folio_in_bio) {
2564+
folio_mark_uptodate(folio);
2565+
folio_unlock(folio);
2566+
}
25602567
folio = readahead_folio(rac);
25612568
goto next_folio;
25622569
}

0 commit comments

Comments
 (0)