From: He Zhe <[email protected]>
This reverts commit 142fe8f4bb169e8632024d51c64653a8bf140561.
Also reverts commit 490547ca2df6 ("block: don't send uevent for empty disk when
not invalidating")
---
block/ioctl.c | 6 ++++--
block/partition-generic.c | 5 -----
fs/block_dev.c | 25 ++++++++++++++++++-------
include/linux/genhd.h | 1 -
4 files changed, 22 insertions(+), 15 deletions(-)
diff --git a/block/ioctl.c b/block/ioctl.c
index 775023548cb7..f5d75ba9ceb4 100644
--- a/block/ioctl.c
+++ b/block/ioctl.c
@@ -162,14 +162,16 @@ static int blkpg_ioctl(struct block_device *bdev, struct
blkpg_ioctl_arg __user
*/
int __blkdev_reread_part(struct block_device *bdev)
{
- if (!disk_part_scan_enabled(bdev->bd_disk) || bdev != bdev->bd_contains)
+ struct gendisk *disk = bdev->bd_disk;
+
+ if (!disk_part_scan_enabled(disk) || bdev != bdev->bd_contains)
return -EINVAL;
if (!capable(CAP_SYS_ADMIN))
return -EACCES;
lockdep_assert_held(&bdev->bd_mutex);
- return bdev_disk_changed(bdev, false);
+ return rescan_partitions(disk, bdev, false);
}
EXPORT_SYMBOL(__blkdev_reread_part);
diff --git a/block/partition-generic.c b/block/partition-generic.c
index 564fae77711d..535fbb9b6337 100644
--- a/block/partition-generic.c
+++ b/block/partition-generic.c
@@ -466,8 +466,6 @@ int blk_drop_partitions(struct gendisk *disk, struct
block_device *bdev)
struct hd_struct *part;
int res;
- if (!disk_part_scan_enabled(disk))
- return 0;
if (bdev->bd_part_count || bdev->bd_super)
return -EBUSY;
res = invalidate_partition(disk, 0);
@@ -537,9 +535,6 @@ int blk_add_partitions(struct gendisk *disk, struct
block_device *bdev)
struct parsed_partitions *state;
int ret = -EAGAIN, p, highest;
- if (!disk_part_scan_enabled(disk))
- return 0;
-
state = check_partition(disk, bdev);
if (!state)
return 0;
diff --git a/fs/block_dev.c b/fs/block_dev.c
index 6f335fc1501d..ec10dacd18d0 100644
--- a/fs/block_dev.c
+++ b/fs/block_dev.c
@@ -1508,9 +1508,9 @@ EXPORT_SYMBOL(bd_set_size);
static void __blkdev_put(struct block_device *bdev, fmode_t mode, int
for_part);
-int bdev_disk_changed(struct block_device *bdev, bool invalidate)
+static int rescan_partitions(struct gendisk *disk, struct block_device *bdev,
+ bool invalidate)
{
- struct gendisk *disk = bdev->bd_disk;
int ret;
rescan:
@@ -1526,21 +1526,32 @@ int bdev_disk_changed(struct block_device *bdev, bool
invalidate)
check_disk_size_change(disk, bdev, !invalidate);
bdev->bd_invalidated = 0;
- if (get_capacity(disk)) {
- ret = blk_add_partitions(disk, bdev);
- if (ret == -EAGAIN)
- goto rescan;
- } else if (invalidate) {
+ if (!get_capacity(disk)) {
/*
* Tell userspace that the media / partition table may have
* changed.
*/
kobject_uevent(&disk_to_dev(disk)->kobj, KOBJ_CHANGE);
+ return 0;
}
+ ret = blk_add_partitions(disk, bdev);
+ if (ret == -EAGAIN)
+ goto rescan;
return ret;
}
+
+static void bdev_disk_changed(struct block_device *bdev, bool invalidate)
+{
+ if (disk_part_scan_enabled(bdev->bd_disk)) {
+ rescan_partitions(bdev->bd_disk, bdev, invalidate);
+ } else {
+ check_disk_size_change(bdev->bd_disk, bdev, !invalidate);
+ bdev->bd_invalidated = 0;
+ }
+}
+
/*
* bd_mutex locking:
*
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index ea4c133b4139..0cc259daed8e 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -633,7 +633,6 @@ extern void blk_invalidate_devt(dev_t devt);
extern dev_t blk_lookup_devt(const char *name, int partno);
extern char *disk_name (struct gendisk *hd, int partno, char *buf);
-int bdev_disk_changed(struct block_device *bdev, bool invalidate);
int blk_add_partitions(struct gendisk *disk, struct block_device *bdev);
int blk_drop_partitions(struct gendisk *disk, struct block_device *bdev);
extern int disk_expand_part_tbl(struct gendisk *disk, int target);
--
2.24.1
-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#8445):
https://lists.yoctoproject.org/g/linux-yocto/message/8445
Mute This Topic: https://lists.yoctoproject.org/mt/71728980/21656
Group Owner: [email protected]
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-