[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230209201116.579809-6-shikemeng@huaweicloud.com>
Date: Fri, 10 Feb 2023 04:11:14 +0800
From: Kemeng Shi <shikemeng@...weicloud.com>
To: axboe@...nel.dk, hch@....de, jack@...e.cz
Cc: andriy.shevchenko@...ux.intel.com, qiulaibin@...wei.com,
linux-block@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 5/7] blk-mq: remove unnecessary "set->queue_depth == 0" check in blk_mq_alloc_set_map_and_rqs
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@...weicloud.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
Powered by blists - more mailing lists