Re: [Linux kernel bug] INFO: task hung in blk_mq_get_tag

From: Hillf Danton
Date: Mon May 13 2024 - 06:54:44 EST


On Mon, 13 May 2024 10:38:34 +0800 Sam Sun <samsun1006219@xxxxxxxxx>
> Dear developers and maintainers,
>
> We encountered a task hung in function blk_mq_get_tag. It was tested
> against the latest upstream kernel which was compiled by clang 14.

BTW make it clear if repro is available and if you could test patches
in reply.

Thanks for your report. See if the below low-hang pear is sweet, I
mean see if it could survive your repro.

--- x/block/blk-mq-tag.c
+++ y/block/blk-mq-tag.c
@@ -180,8 +180,10 @@ unsigned int blk_mq_get_tag(struct blk_m
sbitmap_prepare_to_wait(bt, ws, &wait, TASK_UNINTERRUPTIBLE);

tag = __blk_mq_get_tag(data, bt);
- if (tag != BLK_MQ_NO_TAG)
+ if (tag != BLK_MQ_NO_TAG) {
+ sbitmap_finish_wait(bt, ws, &wait);
break;
+ }

bt_prev = bt;
io_schedule();
@@ -208,8 +210,6 @@ unsigned int blk_mq_get_tag(struct blk_m
ws = bt_wait_ptr(bt, data->hctx);
} while (1);

- sbitmap_finish_wait(bt, ws, &wait);
-
found_tag:
/*
* Give up this allocation if the hctx is inactive. The caller will
--