block: refine the disk_live check in del_gendisk

hidden gendisks will never be marked live.

Fixes: 40b3a52ffc ("block: add a sanity check for a live disk in del_gendisk")
Reported-by: Bruno Goncalves <bgoncalv@redhat.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20210824144310.1487816-1-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig 2021-08-24 16:43:10 +02:00 committed by Jens Axboe
parent 1743fa54c9
commit 9f2869921f

View File

@ -556,7 +556,7 @@ void del_gendisk(struct gendisk *disk)
{
might_sleep();
if (WARN_ON_ONCE(!disk_live(disk)))
if (WARN_ON_ONCE(!disk_live(disk) && !(disk->flags & GENHD_FL_HIDDEN)))
return;
blk_integrity_del(disk);