/* This routine checks whether a removable media has been changed, and invalidates all buffer-cache-entries in that case. This is a relatively slow routine, so we have to try to minimize using it. Thus it is called only upon a 'mount' or 'open'. This is the best way of combining speed and utility, I think. People changing diskettes in the middle of an operation deserve to lose :-)  */
int check_disk_change(struct block_device *bdev)
/* This routine checks whether a removable media has been changed, and invalidates all buffer-cache-entries in that case. This is a relatively slow routine, so we have to try to minimize using it. Thus it is called only upon a 'mount' or 'open'. This is the best way of combining speed and utility, I think. People changing diskettes in the middle of an operation deserve to lose :-)  */
int check_disk_change(struct block_device *bdev)
{
	struct gendisk *disk = bdev->bd_disk;
	const struct block_device_operations *bdops = disk->fops;
	if (!bdops->media_changed)
		return 0;
	if (!bdops->media_changed(bdev->bd_disk))
		return 0;
	flush_disk(bdev);
	if (bdops->revalidate_disk)
		bdops->revalidate_disk(bdev->bd_disk);
	return 1;
}