Skip to content

Commit 68ed451

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: remove blk_mq_init_bitmaps
The little work done in blk_mq_init_bitmaps is easier done in the only caller. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: John Garry <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 6783811 commit 68ed451

File tree

2 files changed

+12
-29
lines changed

2 files changed

+12
-29
lines changed

block/blk-mq-tag.c

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -544,30 +544,12 @@ static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth,
544544
node);
545545
}
546546

547-
int blk_mq_init_bitmaps(struct sbitmap_queue *bitmap_tags,
548-
struct sbitmap_queue *breserved_tags,
549-
unsigned int queue_depth, unsigned int reserved,
550-
int node, int alloc_policy)
551-
{
552-
unsigned int depth = queue_depth - reserved;
553-
bool round_robin = alloc_policy == BLK_TAG_ALLOC_RR;
554-
555-
if (bt_alloc(bitmap_tags, depth, round_robin, node))
556-
return -ENOMEM;
557-
if (bt_alloc(breserved_tags, reserved, round_robin, node))
558-
goto free_bitmap_tags;
559-
560-
return 0;
561-
562-
free_bitmap_tags:
563-
sbitmap_queue_free(bitmap_tags);
564-
return -ENOMEM;
565-
}
566-
567547
struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
568548
unsigned int reserved_tags,
569549
int node, int alloc_policy)
570550
{
551+
unsigned int depth = total_tags - reserved_tags;
552+
bool round_robin = alloc_policy == BLK_TAG_ALLOC_RR;
571553
struct blk_mq_tags *tags;
572554

573555
if (total_tags > BLK_MQ_TAG_MAX) {
@@ -582,14 +564,18 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
582564
tags->nr_tags = total_tags;
583565
tags->nr_reserved_tags = reserved_tags;
584566
spin_lock_init(&tags->lock);
567+
if (bt_alloc(&tags->bitmap_tags, depth, round_robin, node))
568+
goto out_free_tags;
569+
if (bt_alloc(&tags->breserved_tags, reserved_tags, round_robin, node))
570+
goto out_free_bitmap_tags;
585571

586-
if (blk_mq_init_bitmaps(&tags->bitmap_tags, &tags->breserved_tags,
587-
total_tags, reserved_tags, node,
588-
alloc_policy) < 0) {
589-
kfree(tags);
590-
return NULL;
591-
}
592572
return tags;
573+
574+
out_free_bitmap_tags:
575+
sbitmap_queue_free(&tags->bitmap_tags);
576+
out_free_tags:
577+
kfree(tags);
578+
return NULL;
593579
}
594580

595581
void blk_mq_free_tags(struct blk_mq_tags *tags)

block/blk-mq.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ struct blk_mq_alloc_data {
165165
struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
166166
unsigned int reserved_tags, int node, int alloc_policy);
167167
void blk_mq_free_tags(struct blk_mq_tags *tags);
168-
int blk_mq_init_bitmaps(struct sbitmap_queue *bitmap_tags,
169-
struct sbitmap_queue *breserved_tags, unsigned int queue_depth,
170-
unsigned int reserved, int node, int alloc_policy);
171168

172169
unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data);
173170
unsigned long blk_mq_get_tags(struct blk_mq_alloc_data *data, int nr_tags,

0 commit comments

Comments
 (0)