
From: Yu Kuai <yukuai3@huawei.com> hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/I6BHNT CVE: NA -------------------------------- This commit revert following three patches: 1) commit 8551c3543624 ("block: remove the bd_openers checks in blk_drop_partitions") 2) commit c14c928ea979 ("block: fix busy device checking in blk_drop_partitions again") 3) commit db4eff3b44c8 ("block: fix busy device checking in blk_drop_partitions") Before commit 8551c3543624 ("block: remove the bd_openers checks in blk_drop_partitions"), if block device is opened already, rescan will fail by checking bd_openers. And the commit remove such checking because checking bd_openers is not logical, for example, if block device is opened by someone else, rescan will always fail. However, after the commit, we meet a problem that rescan a block device with a mounted filesystem(ext4) will cause data lost. Since that mount ext4 will set bd_super, fix the problem by checking bd_super instead of bd_openers. Noted that some filesystem(for example, ext4/xfs log device, btrfs) doesn't set bd_super, such problem still exists. Signed-off-by: Yu Kuai <yukuai3@huawei.com> Reviewed-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Yongqiang Liu <liuyongqiang13@huawei.com> --- block/partition-generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/partition-generic.c b/block/partition-generic.c index 2261566741f4..c4ac7a8c77dc 100644 --- a/block/partition-generic.c +++ b/block/partition-generic.c @@ -464,7 +464,7 @@ static int drop_partitions(struct gendisk *disk, struct block_device *bdev) struct hd_struct *part; int res; - if (bdev->bd_part_count) + if (bdev->bd_part_count || bdev->bd_super) return -EBUSY; res = invalidate_partition(disk, 0); if (res) -- 2.25.1