]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: add 'folio_in_bio' to handle readahead folios with no BIO submission
authorNanzhe Zhao <nzzhao@126.com>
Sun, 11 Jan 2026 10:09:40 +0000 (18:09 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 17 Jan 2026 00:00:35 +0000 (00:00 +0000)
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>
fs/f2fs/data.c

index 7aa1cd43898fbc6783a87271e684953bba8f7b31..8ca24206fc68e46c1f4cdf060576e62164d0a83d 100644 (file)
@@ -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;
        }