public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] block: avoild hang when bio_list is non-NULL in submit_bio_wait()
@ 2026-03-02  2:51 Jiucheng Xu via B4 Relay
  2026-03-02 13:50 ` Christoph Hellwig
  0 siblings, 1 reply; 8+ messages in thread
From: Jiucheng Xu via B4 Relay @ 2026-03-02  2:51 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-block, linux-kernel, jianxin.pan, tuan.zhang, Jiucheng Xu

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>



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-03-03  2:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-02  2:51 [PATCH] block: avoild hang when bio_list is non-NULL in submit_bio_wait() Jiucheng Xu via B4 Relay
2026-03-02 13:50 ` 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox