summaryrefslogtreecommitdiffstats
path: root/block/genhd.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2020-10-29 15:58:24 +0100
committerJens Axboe <axboe@kernel.dk>2020-11-16 16:14:29 +0100
commit6b3ba9762f9f9f651873af34481ca20e4a6791e7 (patch)
tree89050459e9ad8e604aa76a581671069a7846e749 /block/genhd.c
parentblock: remove __blkdev_driver_ioctl (diff)
downloadlinux-6b3ba9762f9f9f651873af34481ca20e4a6791e7.tar.xz
linux-6b3ba9762f9f9f651873af34481ca20e4a6791e7.zip
block: cleanup del_gendisk a bit
Merge three hidden gendisk checks into one. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to '')
-rw-r--r--block/genhd.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/block/genhd.c b/block/genhd.c
index b85db1f2233c..d41176eb1f36 100644
--- a/block/genhd.c
+++ b/block/genhd.c
@@ -895,6 +895,9 @@ void del_gendisk(struct gendisk *disk)
might_sleep();
+ if (WARN_ON_ONCE(!disk->queue))
+ return;
+
blk_integrity_del(disk);
disk_del_events(disk);
@@ -917,20 +920,18 @@ void del_gendisk(struct gendisk *disk)
disk->flags &= ~GENHD_FL_UP;
up_write(&disk->lookup_sem);
- if (!(disk->flags & GENHD_FL_HIDDEN))
+ if (!(disk->flags & GENHD_FL_HIDDEN)) {
sysfs_remove_link(&disk_to_dev(disk)->kobj, "bdi");
- if (disk->queue) {
+
/*
* Unregister bdi before releasing device numbers (as they can
* get reused and we'd get clashes in sysfs).
*/
- if (!(disk->flags & GENHD_FL_HIDDEN))
- bdi_unregister(disk->queue->backing_dev_info);
- blk_unregister_queue(disk);
- } else {
- WARN_ON(1);
+ bdi_unregister(disk->queue->backing_dev_info);
}
+ blk_unregister_queue(disk);
+
if (!(disk->flags & GENHD_FL_HIDDEN))
blk_unregister_region(disk_devt(disk), disk->minors);
/*