]> www.infradead.org Git - nvme.git/commitdiff
block: remove blk_mq_init_bitmaps
authorChristoph Hellwig <hch@lst.de>
Mon, 6 Jan 2025 08:35:09 +0000 (09:35 +0100)
committerJens Axboe <axboe@kernel.dk>
Mon, 6 Jan 2025 14:37:41 +0000 (07:37 -0700)
The little work done in blk_mq_init_bitmaps is easier done in the only
caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Link: https://lore.kernel.org/r/20250106083531.799976-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-mq-tag.c
block/blk-mq.h

index 2cafcf11ee8bee00910c539db74234315272aa7b..ab4a66791a2063925710d810f34190c8f820ce88 100644 (file)
@@ -544,30 +544,12 @@ static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth,
                                       node);
 }
 
-int blk_mq_init_bitmaps(struct sbitmap_queue *bitmap_tags,
-                       struct sbitmap_queue *breserved_tags,
-                       unsigned int queue_depth, unsigned int reserved,
-                       int node, int alloc_policy)
-{
-       unsigned int depth = queue_depth - reserved;
-       bool round_robin = alloc_policy == BLK_TAG_ALLOC_RR;
-
-       if (bt_alloc(bitmap_tags, depth, round_robin, node))
-               return -ENOMEM;
-       if (bt_alloc(breserved_tags, reserved, round_robin, node))
-               goto free_bitmap_tags;
-
-       return 0;
-
-free_bitmap_tags:
-       sbitmap_queue_free(bitmap_tags);
-       return -ENOMEM;
-}
-
 struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
                                     unsigned int reserved_tags,
                                     int node, int alloc_policy)
 {
+       unsigned int depth = total_tags - reserved_tags;
+       bool round_robin = alloc_policy == BLK_TAG_ALLOC_RR;
        struct blk_mq_tags *tags;
 
        if (total_tags > BLK_MQ_TAG_MAX) {
@@ -582,14 +564,18 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
        tags->nr_tags = total_tags;
        tags->nr_reserved_tags = reserved_tags;
        spin_lock_init(&tags->lock);
+       if (bt_alloc(&tags->bitmap_tags, depth, round_robin, node))
+               goto out_free_tags;
+       if (bt_alloc(&tags->breserved_tags, reserved_tags, round_robin, node))
+               goto out_free_bitmap_tags;
 
-       if (blk_mq_init_bitmaps(&tags->bitmap_tags, &tags->breserved_tags,
-                               total_tags, reserved_tags, node,
-                               alloc_policy) < 0) {
-               kfree(tags);
-               return NULL;
-       }
        return tags;
+
+out_free_bitmap_tags:
+       sbitmap_queue_free(&tags->bitmap_tags);
+out_free_tags:
+       kfree(tags);
+       return NULL;
 }
 
 void blk_mq_free_tags(struct blk_mq_tags *tags)
index 89a20fffa4b1ce02bc6d499361f0aac3feb87cdd..3bb9ea80f9b6b661919b1388d9ada425c3ac90d1 100644 (file)
@@ -165,9 +165,6 @@ struct blk_mq_alloc_data {
 struct blk_mq_tags *blk_mq_init_tags(unsigned int nr_tags,
                unsigned int reserved_tags, int node, int alloc_policy);
 void blk_mq_free_tags(struct blk_mq_tags *tags);
-int blk_mq_init_bitmaps(struct sbitmap_queue *bitmap_tags,
-               struct sbitmap_queue *breserved_tags, unsigned int queue_depth,
-               unsigned int reserved, int node, int alloc_policy);
 
 unsigned int blk_mq_get_tag(struct blk_mq_alloc_data *data);
 unsigned long blk_mq_get_tags(struct blk_mq_alloc_data *data, int nr_tags,