Commit 56bca017 authored by Tejun Heo's avatar Tejun Heo Committed by Jens Axboe

block: restart partition scan after resizing a device

Device resize via ->set_capacity() can reveal new partitions (e.g. in
chained partition table formats such as dos extended parts).  Restart
partition scan from the beginning after resizing a device.  This
change also makes libata always revalidate the disk after resize which
makes lower layer native capacity unlocking implementation simpler and
more robust as resize can be handled in the usual path.
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Reported-by: default avatarBen Hutchings <ben@decadent.org.uk>
Acked-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent fa4b9074
...@@ -544,7 +544,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -544,7 +544,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
struct hd_struct *part; struct hd_struct *part;
struct parsed_partitions *state; struct parsed_partitions *state;
int p, highest, res; int p, highest, res;
rescan:
if (bdev->bd_part_count) if (bdev->bd_part_count)
return -EBUSY; return -EBUSY;
res = invalidate_partition(disk, 0); res = invalidate_partition(disk, 0);
...@@ -581,7 +581,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -581,7 +581,7 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
/* add partitions */ /* add partitions */
for (p = 1; p < state->limit; p++) { for (p = 1; p < state->limit; p++) {
sector_t size, from; sector_t size, from;
try_scan:
size = state->parts[p].size; size = state->parts[p].size;
if (!size) if (!size)
continue; continue;
...@@ -596,7 +596,6 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -596,7 +596,6 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
if (from + size > get_capacity(disk)) { if (from + size > get_capacity(disk)) {
const struct block_device_operations *bdops = disk->fops; const struct block_device_operations *bdops = disk->fops;
unsigned long long capacity;
printk(KERN_WARNING printk(KERN_WARNING
"%s: p%d size %llu exceeds device capacity, ", "%s: p%d size %llu exceeds device capacity, ",
...@@ -605,14 +604,11 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev) ...@@ -605,14 +604,11 @@ int rescan_partitions(struct gendisk *disk, struct block_device *bdev)
if (bdops->set_capacity && if (bdops->set_capacity &&
(disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) { (disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) {
printk(KERN_CONT "enabling native capacity\n"); printk(KERN_CONT "enabling native capacity\n");
capacity = bdops->set_capacity(disk, ~0ULL); bdops->set_capacity(disk, ~0ULL);
disk->flags |= GENHD_FL_NATIVE_CAPACITY; disk->flags |= GENHD_FL_NATIVE_CAPACITY;
if (capacity > get_capacity(disk)) { /* free state and restart */
set_capacity(disk, capacity); kfree(state);
check_disk_size_change(disk, bdev); goto rescan;
bdev->bd_invalidated = 0;
}
goto try_scan;
} else { } else {
/* /*
* we can not ignore partitions of broken tables * we can not ignore partitions of broken tables
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment