* [PATCH] f2fs: fix missing read bio submission on large folio error
@ 2026-05-20 9:52 Wenjie Qi
2026-05-21 8:28 ` Chao Yu
0 siblings, 1 reply; 3+ messages in thread
From: Wenjie Qi @ 2026-05-20 9:52 UTC (permalink / raw)
To: jaegeuk, chao; +Cc: linux-f2fs-devel, linux-kernel, qiwenjie, qwjhust
From: Wenjie Qi <qiwenjie@xiaomi.com>
f2fs_read_data_large_folio() can keep a read bio across multiple
readahead folios. If a later folio hits an error before any of its
blocks are added to the bio, folio_in_bio is false and the current error
path returns immediately after ending that folio.
This can leave the bio accumulated for earlier folios unsubmitted. Those
folios then never receive read completion, and readers can wait
indefinitely on the locked folios.
Route errors through the common out path so any pending bio is submitted
before returning. Stop consuming more readahead folios once an error is
seen, and only wait on and clear the current folio when it was actually
added to the bio.
Fixes: a5d8b9d94e18 ("f2fs: fix to unlock folio in f2fs_read_data_large_folio()")
Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
---
Tested with a local-only fault hook which injected -EIO when
f2fs_read_data_large_folio() had a pending read bio but the current
readahead folio had not been added to it. Without this fix, a 256MiB
immutable file read timed out after 20 seconds. With this fix, the same
read completed without hanging.
fs/f2fs/data.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 8d4f1e75dee..836edb7899d 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -2495,7 +2495,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;
+ bool folio_in_bio = false;
if (!IS_IMMUTABLE(inode) || f2fs_compressed_file(inode)) {
if (folio)
@@ -2611,18 +2611,17 @@ static int f2fs_read_data_large_folio(struct inode *inode,
}
trace_f2fs_read_folio(folio, DATA);
err_out:
- if (!folio_in_bio) {
+ if (!folio_in_bio)
folio_end_read(folio, !ret);
- if (ret)
- return ret;
- }
+ if (ret)
+ goto out;
if (rac) {
folio = readahead_folio(rac);
goto next_folio;
}
out:
f2fs_submit_read_bio(F2FS_I_SB(inode), bio, DATA);
- if (ret) {
+ if (ret && folio_in_bio) {
/* Wait bios and clear uptodate. */
folio_lock(folio);
folio_clear_uptodate(folio);
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] f2fs: fix missing read bio submission on large folio error
2026-05-20 9:52 [PATCH] f2fs: fix missing read bio submission on large folio error Wenjie Qi
@ 2026-05-21 8:28 ` Chao Yu
2026-05-22 4:20 ` [f2fs-dev] " Jaegeuk Kim
0 siblings, 1 reply; 3+ messages in thread
From: Chao Yu @ 2026-05-21 8:28 UTC (permalink / raw)
To: Wenjie Qi, jaegeuk; +Cc: chao, linux-f2fs-devel, linux-kernel, qiwenjie
On 5/20/26 17:52, Wenjie Qi wrote:
> From: Wenjie Qi <qiwenjie@xiaomi.com>
>
> f2fs_read_data_large_folio() can keep a read bio across multiple
> readahead folios. If a later folio hits an error before any of its
> blocks are added to the bio, folio_in_bio is false and the current error
> path returns immediately after ending that folio.
>
> This can leave the bio accumulated for earlier folios unsubmitted. Those
> folios then never receive read completion, and readers can wait
> indefinitely on the locked folios.
>
> Route errors through the common out path so any pending bio is submitted
> before returning. Stop consuming more readahead folios once an error is
> seen, and only wait on and clear the current folio when it was actually
> added to the bio.
>
Cc: stable@kernel.org
> Fixes: a5d8b9d94e18 ("f2fs: fix to unlock folio in f2fs_read_data_large_folio()")
> Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
BTW, I can not apply the patch, can you please rebase it to last dev branch?
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [f2fs-dev] [PATCH] f2fs: fix missing read bio submission on large folio error
2026-05-21 8:28 ` Chao Yu
@ 2026-05-22 4:20 ` Jaegeuk Kim
0 siblings, 0 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2026-05-22 4:20 UTC (permalink / raw)
To: Chao Yu; +Cc: Wenjie Qi, qiwenjie, linux-kernel, linux-f2fs-devel
On 05/21, Chao Yu via Linux-f2fs-devel wrote:
> On 5/20/26 17:52, Wenjie Qi wrote:
> > From: Wenjie Qi <qiwenjie@xiaomi.com>
> >
> > f2fs_read_data_large_folio() can keep a read bio across multiple
> > readahead folios. If a later folio hits an error before any of its
> > blocks are added to the bio, folio_in_bio is false and the current error
> > path returns immediately after ending that folio.
> >
> > This can leave the bio accumulated for earlier folios unsubmitted. Those
> > folios then never receive read completion, and readers can wait
> > indefinitely on the locked folios.
> >
> > Route errors through the common out path so any pending bio is submitted
> > before returning. Stop consuming more readahead folios once an error is
> > seen, and only wait on and clear the current folio when it was actually
> > added to the bio.
> >
>
> Cc: stable@kernel.org
>
> > Fixes: a5d8b9d94e18 ("f2fs: fix to unlock folio in f2fs_read_data_large_folio()")
> > Signed-off-by: Wenjie Qi <qiwenjie@xiaomi.com>
>
> Reviewed-by: Chao Yu <chao@kernel.org>
>
> BTW, I can not apply the patch, can you please rebase it to last dev branch?
I applied.
>
> Thanks,
>
>
> _______________________________________________
> Linux-f2fs-devel mailing list
> Linux-f2fs-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-05-22 4:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-20 9:52 [PATCH] f2fs: fix missing read bio submission on large folio error Wenjie Qi
2026-05-21 8:28 ` Chao Yu
2026-05-22 4:20 ` [f2fs-dev] " Jaegeuk Kim
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox