提交 00f20694 编写于 作者: Y Yu Kuai 提交者: Yongqiang Liu

block: check 'bd_super' before rescanning partition

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6BHNT
CVE: NA

--------------------------------

This commit revert following three patches:

1) commit 8551c354 ("block: remove the bd_openers checks in
blk_drop_partitions")
2) commit c14c928e ("block: fix busy device checking in
blk_drop_partitions again")
3) commit db4eff3b ("block: fix busy device checking in
blk_drop_partitions")

Before commit 8551c354 ("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: NYu Kuai <yukuai3@huawei.com>
Reviewed-by: NHou Tao <houtao1@huawei.com>
Signed-off-by: NYongqiang Liu <liuyongqiang13@huawei.com>
上级 6398c1f1
......@@ -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)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册