diff options
author | Christoph Hellwig <hch@lst.de> | 2021-08-18 16:45:35 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-08-23 12:55:45 -0600 |
commit | 9d5ee6767c85762205b788ed1245f21fafd6c504 (patch) | |
tree | c233addc213f3be8d73a32a7a9eb49cc27fd6d5c | |
parent | 8235b5c1e8c1c0537f03a21a2e380098bed25248 (diff) | |
download | linux-9d5ee6767c85762205b788ed1245f21fafd6c504.tar.gz linux-9d5ee6767c85762205b788ed1245f21fafd6c504.tar.bz2 linux-9d5ee6767c85762205b788ed1245f21fafd6c504.zip |
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>
-rw-r--r-- | block/genhd.c | 13 |
1 files changed, 6 insertions, 7 deletions
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); |