block: create the bdi link earlier in device_add_disk

This will simplify error handling going forward.

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

View File

@ -518,8 +518,13 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
disk->major, disk->first_minor);
WARN_ON(ret);
bdi_set_owner(disk->bdi, ddev);
bdev_add(disk->part0, ddev->devt);
if (disk->bdi->dev) {
ret = sysfs_create_link(&ddev->kobj,
&disk->bdi->dev->kobj, "bdi");
WARN_ON(ret);
}
bdev_add(disk->part0, ddev->devt);
disk_scan_partitions(disk);
/*
@ -528,12 +533,6 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
*/
dev_set_uevent_suppress(ddev, 0);
disk_uevent(disk, KOBJ_ADD);
if (disk->bdi->dev) {
ret = sysfs_create_link(&ddev->kobj,
&disk->bdi->dev->kobj, "bdi");
WARN_ON(ret);
}
}
blk_register_queue(disk);