@@ -466,13 +466,9 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
466
466
*/
467
467
pm_runtime_set_memalloc_noio (ddev , true);
468
468
469
- ret = blkcg_init_disk (disk );
470
- if (ret )
471
- goto out_del_block_link ;
472
-
473
469
ret = blk_integrity_add (disk );
474
470
if (ret )
475
- goto out_blkcg_exit ;
471
+ goto out_del_block_link ;
476
472
477
473
disk -> part0 -> bd_holder_dir =
478
474
kobject_create_and_add ("holders" , & ddev -> kobj );
@@ -538,8 +534,6 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk,
538
534
kobject_put (disk -> part0 -> bd_holder_dir );
539
535
out_del_integrity :
540
536
blk_integrity_del (disk );
541
- out_blkcg_exit :
542
- blkcg_exit_disk (disk );
543
537
out_del_block_link :
544
538
if (!sysfs_deprecated )
545
539
sysfs_remove_link (block_depr , dev_name (ddev ));
@@ -668,8 +662,6 @@ void del_gendisk(struct gendisk *disk)
668
662
rq_qos_exit (q );
669
663
blk_mq_unquiesce_queue (q );
670
664
671
- blkcg_exit_disk (disk );
672
-
673
665
/*
674
666
* If the disk does not own the queue, allow using passthrough requests
675
667
* again. Else leave the queue frozen to fail all I/O.
@@ -1178,6 +1170,8 @@ static void disk_release(struct device *dev)
1178
1170
!test_bit (GD_ADDED , & disk -> state ))
1179
1171
blk_mq_exit_queue (disk -> queue );
1180
1172
1173
+ blkcg_exit_disk (disk );
1174
+
1181
1175
bioset_exit (& disk -> bio_split );
1182
1176
1183
1177
disk_release_events (disk );
@@ -1390,6 +1384,9 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
1390
1384
if (xa_insert (& disk -> part_tbl , 0 , disk -> part0 , GFP_KERNEL ))
1391
1385
goto out_destroy_part_tbl ;
1392
1386
1387
+ if (blkcg_init_disk (disk ))
1388
+ goto out_erase_part0 ;
1389
+
1393
1390
rand_initialize_disk (disk );
1394
1391
disk_to_dev (disk )-> class = & block_class ;
1395
1392
disk_to_dev (disk )-> type = & disk_type ;
@@ -1402,6 +1399,8 @@ struct gendisk *__alloc_disk_node(struct request_queue *q, int node_id,
1402
1399
#endif
1403
1400
return disk ;
1404
1401
1402
+ out_erase_part0 :
1403
+ xa_erase (& disk -> part_tbl , 0 );
1405
1404
out_destroy_part_tbl :
1406
1405
xa_destroy (& disk -> part_tbl );
1407
1406
disk -> part0 -> bd_disk = NULL ;
0 commit comments