]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
f2fs: advance index and offset after zeroing in large folio read
authorNanzhe Zhao <nzzhao@126.com>
Sun, 11 Jan 2026 10:09:41 +0000 (18:09 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sat, 17 Jan 2026 00:00:35 +0000 (00:00 +0000)
In f2fs_read_data_large_folio(), the block zeroing path calls
folio_zero_range() and then continues the loop. However, it fails to
advance index and offset before continuing.

This can cause the loop to repeatedly process the same subpage of the
folio, leading to stalls/hangs and incorrect progress when reading large
folios with holes/zeroed blocks.

Fix it by advancing index and offset unconditionally in the loop
iteration, so they are updated even when the zeroing path continues.

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 8ca24206fc68e46c1f4cdf060576e62164d0a83d..ef44b8421cd7a8dd7894e38bbf3c1fab1735b1b3 100644 (file)
@@ -2470,7 +2470,7 @@ next_folio:
        ffs = NULL;
        nrpages = folio_nr_pages(folio);
 
-       for (; nrpages; nrpages--, max_nr_pages--) {
+       for (; nrpages; nrpages--, max_nr_pages--, index++, offset++) {
                sector_t block_nr;
                /*
                 * Map blocks using the previous result first.
@@ -2555,8 +2555,6 @@ submit_and_realloc:
                f2fs_update_iostat(F2FS_I_SB(inode), NULL, FS_DATA_READ_IO,
                                F2FS_BLKSIZE);
                last_block_in_bio = block_nr;
-               index++;
-               offset++;
        }
        trace_f2fs_read_folio(folio, DATA);
        if (rac) {