block: add a bdev_check_media_change helper

Like check_disk_changed, except that it does not call ->revalidate_disk
but leaves that to the caller.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Hannes Reinecke <hare@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
This commit is contained in:
Christoph Hellwig
2020-09-08 16:53:29 +02:00
committed by Jens Axboe
parent fc93fe1453
commit 95f6f3a46f
3 changed files with 32 additions and 16 deletions

View File

@@ -1379,21 +1379,10 @@ EXPORT_SYMBOL(revalidate_disk_size);
*/
int check_disk_change(struct block_device *bdev)
{
struct gendisk *disk = bdev->bd_disk;
const struct block_device_operations *bdops = disk->fops;
unsigned int events;
events = disk_clear_events(disk, DISK_EVENT_MEDIA_CHANGE |
DISK_EVENT_EJECT_REQUEST);
if (!(events & DISK_EVENT_MEDIA_CHANGE))
if (!bdev_check_media_change(bdev))
return 0;
if (__invalidate_device(bdev, true))
pr_warn("VFS: busy inodes on changed media %s\n",
disk->disk_name);
set_bit(BDEV_NEED_PART_SCAN, &bdev->bd_flags);
if (bdops->revalidate_disk)
bdops->revalidate_disk(bdev->bd_disk);
if (bdev->bd_disk->fops->revalidate_disk)
bdev->bd_disk->fops->revalidate_disk(bdev->bd_disk);
return 1;
}