block: fix a device invalidation regression
Subsystems (2)
PATCH 1/1 block: fix a device invalidation regression
Historically we only set the capacity to zero for devices that support partitions (independ of actually having partitions created). Doing that is rather inconsistent, but changing it broke legacy udisks polling for legacy ide-cdrom devices. Use the crude a crude check for devices that either are non-removable or partitionable to get the sane behavior for most device while not breaking userspace for this particular setup.
--- fs/block_dev.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
fs/block_dev.c +16 -4
@@ -1520,10 +1520,22 @@ int bdev_disk_changed(struct block_device *bdev, bool invalidate)if (ret)return ret; -if (invalidate) -set_capacity (disk,0 ); -else if (disk->fops->revalidate_disk) - disk->fops->revalidate_disk (disk); +/* +* Historically we only set the capacity to zero for devices that +* support partitions (independ of actually having partitions created). +* Doing that is rather inconsistent, but changing it broke legacy +* udisks polling for legacy ide-cdrom devices. Use the crude check +* below to get the sane behavior for most device while not breaking +* userspace for this particular setup. +*/ +if (invalidate) { +if (disk_part_scan_enabled (disk) || + !(disk->flags &GENHD_FL_REMOVABLE )) +set_capacity (disk,0 ); + }else { +if (disk->fops->revalidate_disk) + disk->fops->revalidate_disk (disk); + }check_disk_size_change (disk, bdev, !invalidate);
Signature · 1 line
2.24.1
Quoted 6 lines · Christoph Hellwig
Historically we only set the capacity to zero for devices that support partitions (independ of actually having partitions created). Doing that is rather inconsistent, but changing it broke legacy udisks polling for legacy ide-cdrom devices. Use the crude a crude check for devices that either are non-removable or partitionable to get the sane behavior for most device while not breaking userspace for this particular setup.
Applied, thanks.
Signature · 1 line
Jens Axboe