提交 d981cb5b 编写于 作者: C Christoph Hellwig 提交者: Jens Axboe

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.

Fixes: a1548b67 ("block: move rescan_partitions to fs/block_dev.c")
Reported-by: NHe Zhe <zhe.he@windriver.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
Tested-by: NHe Zhe <zhe.he@windriver.com>
Signed-off-by: NJens Axboe <axboe@kernel.dk>
上级 11bde986
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册