From 6afd05ca6d45b834af36c8e1257e7203b2604583 Mon Sep 17 00:00:00 2001 From: Nanzhe Zhao Date: Sun, 11 Jan 2026 18:09:40 +0800 Subject: [PATCH] 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 Reviewed-by: Chao Yu Signed-off-by: Jaegeuk Kim --- fs/f2fs/data.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 7aa1cd43898f..8ca24206fc68 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c @@ -2448,6 +2448,7 @@ static int f2fs_read_data_large_folio(struct inode *inode, unsigned nrpages; struct f2fs_folio_state *ffs; int ret = 0; + bool folio_in_bio; if (!IS_IMMUTABLE(inode)) return -EOPNOTSUPP; @@ -2463,6 +2464,7 @@ next_folio: if (!folio) goto out; + folio_in_bio = false; index = folio->index; offset = 0; ffs = NULL; @@ -2548,6 +2550,7 @@ submit_and_realloc: offset << PAGE_SHIFT)) goto submit_and_realloc; + folio_in_bio = true; inc_page_count(F2FS_I_SB(inode), F2FS_RD_DATA); f2fs_update_iostat(F2FS_I_SB(inode), NULL, FS_DATA_READ_IO, F2FS_BLKSIZE); @@ -2557,6 +2560,10 @@ submit_and_realloc: } trace_f2fs_read_folio(folio, DATA); if (rac) { + if (!folio_in_bio) { + folio_mark_uptodate(folio); + folio_unlock(folio); + } folio = readahead_folio(rac); goto next_folio; } -- 2.47.3