@@ -544,30 +544,12 @@ static int bt_alloc(struct sbitmap_queue *bt, unsigned int depth,
544
544
node );
545
545
}
546
546
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
-
567
547
struct blk_mq_tags * blk_mq_init_tags (unsigned int total_tags ,
568
548
unsigned int reserved_tags ,
569
549
int node , int alloc_policy )
570
550
{
551
+ unsigned int depth = total_tags - reserved_tags ;
552
+ bool round_robin = alloc_policy == BLK_TAG_ALLOC_RR ;
571
553
struct blk_mq_tags * tags ;
572
554
573
555
if (total_tags > BLK_MQ_TAG_MAX ) {
@@ -582,14 +564,18 @@ struct blk_mq_tags *blk_mq_init_tags(unsigned int total_tags,
582
564
tags -> nr_tags = total_tags ;
583
565
tags -> nr_reserved_tags = reserved_tags ;
584
566
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 ;
585
571
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
- }
592
572
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 ;
593
579
}
594
580
595
581
void blk_mq_free_tags (struct blk_mq_tags * tags )
0 commit comments