From: Liu Song <liusong@linux.alibaba.com>
To: axboe@kernel.dk
Cc: linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] blk-mq: avoid potential infinite loop in __blk_mq_alloc_request
Date: Fri, 22 Jul 2022 13:22:23 +0800 [thread overview]
Message-ID: <1658467343-55843-1-git-send-email-liusong@linux.alibaba.com> (raw)
From: Liu Song <liusong@linux.alibaba.com>
If "blk_mq_get_tag" returns BLK_MQ_NO_TAG because the value of
"tags->nr_reserved_tags" is 0, it will fall into an infinite loop in
"__blk_mq_alloc_requests", so borrow BLK_MQ_REQ_NOWAIT to exit the loop.
Because "blk_mq_alloc_data" objects are allocated on the stack, changing
the content of flags will not generate extra impact.
Signed-off-by: Liu Song <liusong@linux.alibaba.com>
---
block/blk-mq-tag.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/block/blk-mq-tag.c b/block/blk-mq-tag.c
index 2dcd738..6f1d6e6 100644
--- a/block/blk-mq-tag.c
+++ b/block/blk-mq-tag.c
@@ -139,6 +139,7 @@ unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data)
if (data->flags & BLK_MQ_REQ_RESERVED) {
if (unlikely(!tags->nr_reserved_tags)) {
WARN_ON_ONCE(1);
+ data->flags |= BLK_MQ_REQ_NOWAIT;
return BLK_MQ_NO_TAG;
}
bt = &tags->breserved_tags;
--
1.8.3.1
next reply other threads:[~2022-07-22 5:22 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-22 5:22 Liu Song [this message]
2022-07-22 5:33 ` [PATCH] blk-mq: avoid potential infinite loop in __blk_mq_alloc_request Christoph Hellwig
2022-07-22 8:15 ` Liu Song
2022-07-22 16:08 ` Christoph Hellwig
2022-08-09 10:10 ` Liu Song
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=1658467343-55843-1-git-send-email-liusong@linux.alibaba.com \
--to=liusong@linux.alibaba.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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