From 9d5ee6767c85762205b788ed1245f21fafd6c504 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Wed, 18 Aug 2021 16:45:35 +0200 Subject: block: create the bdi link earlier in device_add_disk This will simplify error handling going forward. Signed-off-by: Christoph Hellwig Reviewed-by: Hannes Reinecke Link: https://lore.kernel.org/r/20210818144542.19305-5-hch@lst.de Signed-off-by: Jens Axboe --- block/genhd.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'block') diff --git a/block/genhd.c b/block/genhd.c index ab455f110be2..f05e58f214d2 100644 --- a/block/genhd.c +++ b/block/genhd.c @@ -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); -- cgit v1.2.3