block: Don't revalidate bdev of hidden gendisk
authorJan Kara <jack@suse.cz>
Wed, 15 May 2019 06:57:40 +0000 (08:57 +0200)
committerJens Axboe <axboe@kernel.dk>
Mon, 27 May 2019 13:35:02 +0000 (07:35 -0600)
When hidden gendisk is revalidated, there's no point in revalidating
associated block device as there's none. We would thus just create new
bdev inode, report "detected capacity change from 0 to XXX" message and
evict the bdev inode again. Avoid this pointless dance and confusing
message in the kernel log.

Reviewed-by: Hannes Reinecke <hare@suse.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/block_dev.c

index e6886c93c89dafbc17fd2d22c25035dddc178e13..749f5984425dd493b212e589f4b7389b38bf1bc9 100644 (file)
@@ -1406,20 +1406,27 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev,
  */
 int revalidate_disk(struct gendisk *disk)
 {
-       struct block_device *bdev;
        int ret = 0;
 
        if (disk->fops->revalidate_disk)
                ret = disk->fops->revalidate_disk(disk);
-       bdev = bdget_disk(disk, 0);
-       if (!bdev)
-               return ret;
 
-       mutex_lock(&bdev->bd_mutex);
-       check_disk_size_change(disk, bdev, ret == 0);
-       bdev->bd_invalidated = 0;
-       mutex_unlock(&bdev->bd_mutex);
-       bdput(bdev);
+       /*
+        * Hidden disks don't have associated bdev so there's no point in
+        * revalidating it.
+        */
+       if (!(disk->flags & GENHD_FL_HIDDEN)) {
+               struct block_device *bdev = bdget_disk(disk, 0);
+
+               if (!bdev)
+                       return ret;
+
+               mutex_lock(&bdev->bd_mutex);
+               check_disk_size_change(disk, bdev, ret == 0);
+               bdev->bd_invalidated = 0;
+               mutex_unlock(&bdev->bd_mutex);
+               bdput(bdev);
+       }
        return ret;
 }
 EXPORT_SYMBOL(revalidate_disk);