Skip to content

Commit

Permalink
block: Don't revalidate bdev of hidden gendisk
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jankara authored and axboe committed May 27, 2019
1 parent 33ec3e5 commit 31cb1d6
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions fs/block_dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 31cb1d6

Please sign in to comment.