block: call blk_integrity_add earlier in device_add_disk

Doing all the sysfs file creation before adding the bdev and thus
allowing it to be opened will simplify the about to be added error
handling.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Link: https://lore.kernel.org/r/20210818144542.19305-6-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2021-08-18 16:45:36 +02:00 committed by Jens Axboe
parent 9d5ee6767c
commit bab53f6b61

View File

@ -492,6 +492,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
*/
pm_runtime_set_memalloc_noio(ddev, true);
blk_integrity_add(disk);
disk->part0->bd_holder_dir =
kobject_create_and_add("holders", &ddev->kobj);
disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj);
@ -538,7 +540,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
blk_register_queue(disk);
disk_add_events(disk);
blk_integrity_add(disk);
}
EXPORT_SYMBOL(device_add_disk);