From: Kemeng Shi <shikemeng@huaweicloud.com>
To: axboe@kernel.dk, hch@lst.de, jack@suse.cz
Cc: andriy.shevchenko@linux.intel.com, qiulaibin@huawei.com,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 5/7] blk-mq: remove unnecessary "set->queue_depth == 0" check in blk_mq_alloc_set_map_and_rqs
Date: Fri, 10 Feb 2023 04:11:14 +0800 [thread overview]
Message-ID: <20230209201116.579809-6-shikemeng@huaweicloud.com> (raw)
In-Reply-To: <20230209201116.579809-1-shikemeng@huaweicloud.com>
We will break the loop and set err to -ENOMEM if "set->queue_depth" is
less than "set->reserved_tags + BLK_MQ_TAG_MIN". set->reserved_tags is
unsigned int and should not be less than 0 logically. BLK_MQ_TAG_MIN is
1 and should be greater than 0 logically. So "set->reserved_tags +
BLK_MQ_TAG_MIN" should be greater than 0. For case set->queue_depth is
halved to zero, "set->queue_depth < set->reserved_tags + BLK_MQ_TAG_MIN"
check is always met first, then this branch will set err to -ENOMEM and
break the loop. Then the loop break condition "while(set->queue_depth)"
is never met and set->queue_depth check in "if (!set->queue_depth ||
err)" is redundant. Just remove these checks.
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
---
block/blk-mq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/block/blk-mq.c b/block/blk-mq.c
index 6014d9b5e296..4d2ab01549cd 100644
--- a/block/blk-mq.c
+++ b/block/blk-mq.c
@@ -4324,9 +4324,9 @@ static int blk_mq_alloc_set_map_and_rqs(struct blk_mq_tag_set *set)
err = -ENOMEM;
break;
}
- } while (set->queue_depth);
+ } while (true);
- if (!set->queue_depth || err) {
+ if (err) {
pr_err("blk-mq: failed to allocate request map\n");
return -ENOMEM;
}
--
2.30.0
next prev parent reply other threads:[~2023-02-09 12:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 20:11 [PATCH 0/7] A few bugfix and cleanup patches to blk-mq Kemeng Shi
2023-02-09 20:11 ` [PATCH 1/7] blk-mq: sync wake_batch update and users number change Kemeng Shi
2023-02-09 13:43 ` Jan Kara
2023-02-09 20:11 ` [PATCH 2/7] blk-mq: count changed hctx as active in blk_mq_get_tag Kemeng Shi
2023-02-09 13:55 ` Jan Kara
2023-02-09 20:11 ` [PATCH 3/7] blk-mq: remove wake_batch recalculation for reserved tags Kemeng Shi
2023-02-09 20:11 ` [PATCH 4/7] blk-mq: remove unnecessary bit clear in __blk_mq_alloc_requests_batch Kemeng Shi
2023-02-09 20:11 ` Kemeng Shi [this message]
2023-02-09 20:11 ` [PATCH 6/7] blk-mq: Remove unnecessary hctx check in function blk_mq_alloc_and_init_hctx Kemeng Shi
2023-02-09 20:11 ` [PATCH 7/7] blk-mq: remove stale comment of function called for iterated request Kemeng Shi
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=20230209201116.579809-6-shikemeng@huaweicloud.com \
--to=shikemeng@huaweicloud.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=axboe@kernel.dk \
--cc=hch@lst.de \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=qiulaibin@huawei.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