* [PATCH v2] erofs: set fileio bio failed in short read case
@ 2026-02-27 2:30 Sheng Yong
2026-02-27 3:41 ` Gao Xiang
2026-03-03 7:55 ` Chao Yu
0 siblings, 2 replies; 3+ messages in thread
From: Sheng Yong @ 2026-02-27 2:30 UTC (permalink / raw)
To: xiang; +Cc: linux-erofs, linux-kernel, Sheng Yong, chenguanyou, Yunlei He
From: Sheng Yong <shengyong1@xiaomi.com>
For file-backed mount, IO requests are handled by vfs_iocb_iter_read().
However, it can be interrupted by SIGKILL, returning the number of
bytes actually copied. Unused folios in bio are unexpectedly marked
as uptodate.
vfs_read
filemap_read
filemap_get_pages
filemap_readahead
erofs_fileio_readahead
erofs_fileio_rq_submit
vfs_iocb_iter_read
filemap_read
filemap_get_pages <= detect signal
erofs_fileio_ki_complete <= set all folios uptodate
This patch addresses this by setting short read bio with an error
directly.
Fixes: bc804a8d7e86 ("erofs: handle end of filesystem properly for file-backed mounts")
Reported-by: chenguanyou <chenguanyou@xiaomi.com>
Signed-off-by: Yunlei He <heyunlei@xiaomi.com>
Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
---
fs/erofs/fileio.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fs/erofs/fileio.c b/fs/erofs/fileio.c
index abe873f01297..98cdaa1cd1a7 100644
--- a/fs/erofs/fileio.c
+++ b/fs/erofs/fileio.c
@@ -25,10 +25,8 @@ static void erofs_fileio_ki_complete(struct kiocb *iocb, long ret)
container_of(iocb, struct erofs_fileio_rq, iocb);
struct folio_iter fi;
- if (ret >= 0 && ret != rq->bio.bi_iter.bi_size) {
- bio_advance(&rq->bio, ret);
- zero_fill_bio(&rq->bio);
- }
+ if (ret >= 0 && ret != rq->bio.bi_iter.bi_size)
+ ret = -EIO;
if (!rq->bio.bi_end_io) {
bio_for_each_folio_all(fi, &rq->bio) {
DBG_BUGON(folio_test_uptodate(fi.folio));
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] erofs: set fileio bio failed in short read case
2026-02-27 2:30 [PATCH v2] erofs: set fileio bio failed in short read case Sheng Yong
@ 2026-02-27 3:41 ` Gao Xiang
2026-03-03 7:55 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Gao Xiang @ 2026-02-27 3:41 UTC (permalink / raw)
To: Sheng Yong, xiang
Cc: linux-erofs, linux-kernel, Sheng Yong, chenguanyou, Yunlei He
Hi Yong,
On 2026/2/27 10:30, Sheng Yong wrote:
> From: Sheng Yong <shengyong1@xiaomi.com>
>
> For file-backed mount, IO requests are handled by vfs_iocb_iter_read().
> However, it can be interrupted by SIGKILL, returning the number of
> bytes actually copied. Unused folios in bio are unexpectedly marked
> as uptodate.
>
> vfs_read
> filemap_read
> filemap_get_pages
> filemap_readahead
> erofs_fileio_readahead
> erofs_fileio_rq_submit
> vfs_iocb_iter_read
> filemap_read
> filemap_get_pages <= detect signal
> erofs_fileio_ki_complete <= set all folios uptodate
>
> This patch addresses this by setting short read bio with an error
> directly.
>
> Fixes: bc804a8d7e86 ("erofs: handle end of filesystem properly for file-backed mounts")
> Reported-by: chenguanyou <chenguanyou@xiaomi.com>
> Signed-off-by: Yunlei He <heyunlei@xiaomi.com>
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
LGTM, yet I still need more time to run some tests
before upstreaming this in order to miss any corner
cases.
You could run more tests in the same time, thanks!
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Thanks,
Gao Xiang
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] erofs: set fileio bio failed in short read case
2026-02-27 2:30 [PATCH v2] erofs: set fileio bio failed in short read case Sheng Yong
2026-02-27 3:41 ` Gao Xiang
@ 2026-03-03 7:55 ` Chao Yu
1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2026-03-03 7:55 UTC (permalink / raw)
To: Sheng Yong, xiang
Cc: chao, linux-erofs, linux-kernel, Sheng Yong, chenguanyou,
Yunlei He
On 2026/2/27 10:30, Sheng Yong wrote:
> From: Sheng Yong <shengyong1@xiaomi.com>
>
> For file-backed mount, IO requests are handled by vfs_iocb_iter_read().
> However, it can be interrupted by SIGKILL, returning the number of
> bytes actually copied. Unused folios in bio are unexpectedly marked
> as uptodate.
>
> vfs_read
> filemap_read
> filemap_get_pages
> filemap_readahead
> erofs_fileio_readahead
> erofs_fileio_rq_submit
> vfs_iocb_iter_read
> filemap_read
> filemap_get_pages <= detect signal
> erofs_fileio_ki_complete <= set all folios uptodate
>
> This patch addresses this by setting short read bio with an error
> directly.
>
> Fixes: bc804a8d7e86 ("erofs: handle end of filesystem properly for file-backed mounts")
> Reported-by: chenguanyou <chenguanyou@xiaomi.com>
> Signed-off-by: Yunlei He <heyunlei@xiaomi.com>
> Signed-off-by: Sheng Yong <shengyong1@xiaomi.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-03 7:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 2:30 [PATCH v2] erofs: set fileio bio failed in short read case Sheng Yong
2026-02-27 3:41 ` Gao Xiang
2026-03-03 7:55 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox