From: Jiucheng Xu via B4 Relay <devnull+jiucheng.xu.amlogic.com@kernel.org>
To: Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
jianxin.pan@amlogic.com, tuan.zhang@amlogic.com,
Jiucheng Xu <jiucheng.xu@amlogic.com>
Subject: [PATCH] block: avoild hang when bio_list is non-NULL in submit_bio_wait()
Date: Mon, 02 Mar 2026 10:51:03 +0800 [thread overview]
Message-ID: <20260302-for-next-v1-1-eb9339e8dc99@amlogic.com> (raw)
From: Jiucheng Xu <jiucheng.xu@amlogic.com>
When current->bio_list is non-NULL in submit_bio_wait(),
submit_bio_noacct_nocheck appends bio to bio_list but skips IO
submission, causing submit_bio_wait() to hang indefinitely.
Fix this by temporarily backup bio_list, setting bio_list to
NULL before calling submit_bio(), then restoring bio_list
after submit_bio() returns.
I've trimmed down the call stack, as follows:
f2fs_submit_read_io
submit_bio
mmc_blk_mq_recovery
z_erofs_endio
vm_map_ram
__pte_alloc_kernel
__alloc_pages_direct_reclaim
shrink_folio_list
__swap_writepage
submit_bio_wait hang!!!
Signed-off-by: Jiucheng Xu <jiucheng.xu@amlogic.com>
---
block/bio.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index d80d5d26804e32944bcfe4506ca190033308844f..22c8769722cc89620c239310a0f3d4924de68cf9 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1505,8 +1505,17 @@ int submit_bio_wait(struct bio *bio)
bio->bi_private = &done;
bio->bi_end_io = submit_bio_wait_endio;
bio->bi_opf |= REQ_SYNC;
- submit_bio(bio);
- blk_wait_io(&done);
+ if (!current->bio_list) {
+ submit_bio(bio);
+ blk_wait_io(&done);
+ } else {
+ struct bio_list *tmp = current->bio_list;
+
+ current->bio_list = NULL;
+ submit_bio(bio);
+ blk_wait_io(&done);
+ current->bio_list = tmp;
+ }
return blk_status_to_errno(bio->bi_status);
}
---
base-commit: 8c5f40a3ba43ae9a26991f0e4a01a3a06e8958fc
change-id: 20260224-for-next-df6f02c3694d
Best regards,
--
Jiucheng Xu <jiucheng.xu@amlogic.com>
next reply other threads:[~2026-03-02 2:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-02 2:51 Jiucheng Xu via B4 Relay [this message]
2026-03-02 13:50 ` [PATCH] block: avoild hang when bio_list is non-NULL in submit_bio_wait() Christoph Hellwig
2026-03-02 14:23 ` Gao Xiang
2026-03-02 14:29 ` Christoph Hellwig
2026-03-02 14:31 ` Gao Xiang
2026-03-03 2:03 ` Jiucheng Xu
2026-03-03 2:11 ` Gao Xiang
2026-03-03 2:17 ` Jiucheng Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260302-for-next-v1-1-eb9339e8dc99@amlogic.com \
--to=devnull+jiucheng.xu.amlogic.com@kernel.org \
--cc=axboe@kernel.dk \
--cc=jianxin.pan@amlogic.com \
--cc=jiucheng.xu@amlogic.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tuan.zhang@amlogic.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox