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: Tejun Heo <tj@kernel.org>
Reported-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
struct hd_struct *part;
struct parsed_partitions *state;
int p, highest, res;
struct hd_struct *part;
struct parsed_partitions *state;
int p, highest, res;
if (bdev->bd_part_count)
return -EBUSY;
res = invalidate_partition(disk, 0);
if (bdev->bd_part_count)
return -EBUSY;
res = invalidate_partition(disk, 0);
/* add partitions */
for (p = 1; p < state->limit; p++) {
sector_t size, from;
/* add partitions */
for (p = 1; p < state->limit; p++) {
sector_t size, from;
size = state->parts[p].size;
if (!size)
continue;
size = state->parts[p].size;
if (!size)
continue;
if (from + size > get_capacity(disk)) {
const struct block_device_operations *bdops = disk->fops;
if (from + size > get_capacity(disk)) {
const struct block_device_operations *bdops = disk->fops;
- unsigned long long capacity;
printk(KERN_WARNING
"%s: p%d size %llu exceeds device capacity, ",
printk(KERN_WARNING
"%s: p%d size %llu exceeds device capacity, ",
if (bdops->set_capacity &&
(disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) {
printk(KERN_CONT "enabling native capacity\n");
if (bdops->set_capacity &&
(disk->flags & GENHD_FL_NATIVE_CAPACITY) == 0) {
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)) {
- set_capacity(disk, capacity);
- check_disk_size_change(disk, bdev);
- bdev->bd_invalidated = 0;
- }
- goto try_scan;
+ /* free state and restart */
+ kfree(state);
+ goto rescan;
} else {
/*
* we can not ignore partitions of broken tables
} else {
/*
* we can not ignore partitions of broken tables