+/**
+ * revalidate_disk_size - checks for disk size change and adjusts bdev size.
+ * @disk: struct gendisk to check
+ * @verbose: if %true log a message about a size change if there is any
+ *
+ * This routine checks to see if the bdev size does not match the disk size
+ * and adjusts it if it differs. When shrinking the bdev size, its all caches
+ * are freed.
+ */
+void revalidate_disk_size(struct gendisk *disk, bool verbose)
+{
+ struct block_device *bdev;
+
+ /*
+ * Hidden disks don't have associated bdev so there's no point in
+ * revalidating them.
+ */
+ if (disk->flags & GENHD_FL_HIDDEN)
+ return;
+
+ bdev = bdget_disk(disk, 0);
+ if (bdev) {
+ check_disk_size_change(disk, bdev, verbose);
+ bdput(bdev);
+ }
+}
+EXPORT_SYMBOL(revalidate_disk_size);
+