Skip to content

Commit

Permalink
block: call blk_register_queue earlier in device_add_disk
Browse files Browse the repository at this point in the history
Ensure that all the sysfs bits are set up before bdev_add is called,
as that will make the upcomding error handling much easier.  However
this means the call to disk_update_readahead has to be split as that
requires a bdi.  Also remove various sanity checks that don't make
sense now that blk_register_queue only has a single caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210818144542.19305-7-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Christoph Hellwig authored and Jens Axboe committed Aug 23, 2021
1 parent bab53f6 commit 75f4dca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
9 changes: 0 additions & 9 deletions block/blk-sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -856,15 +856,6 @@ int blk_register_queue(struct gendisk *disk)
struct device *dev = disk_to_dev(disk);
struct request_queue *q = disk->queue;

if (WARN_ON(!q))
return -ENXIO;

WARN_ONCE(blk_queue_registered(q),
"%s is registering an already registered queue\n",
kobject_name(&dev->kobj));

disk_update_readahead(disk);

ret = blk_trace_init_sysfs(dev);
if (ret)
return ret;
Expand Down
5 changes: 3 additions & 2 deletions block/genhd.c
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
disk->slave_dir = NULL;
}

blk_register_queue(disk);

if (disk->flags & GENHD_FL_HIDDEN) {
/*
* Don't let hidden disks show up in /proc/partitions,
Expand Down Expand Up @@ -537,8 +539,7 @@ void device_add_disk(struct device *parent, struct gendisk *disk,
disk_uevent(disk, KOBJ_ADD);
}

blk_register_queue(disk);

disk_update_readahead(disk);
disk_add_events(disk);
}
EXPORT_SYMBOL(device_add_disk);
Expand Down

0 comments on commit 75f4dca

Please sign in to comment.