hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8S3GW CVE: NA
---------------------------
Filesystem on logic devices may be corrupted when writing to a block device which is used to create logic devices, so show info to indicate this risk behavior.
Signed-off-by: Li Lingfeng lilingfeng3@huawei.com --- block/bdev.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/block/bdev.c b/block/bdev.c index 720b01b4cb45..0db7e4ee7a00 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -768,6 +768,14 @@ static bool bdev_writes_blocked(struct block_device *bdev) return !!bdev->bd_mounters; }
+static bool bdev_lower_device_writes_blocked(struct block_device *bdev) +{ + if (bdev_allow_write_mounted & (1 << BLKDEV_DETECT_WRITING_PART0)) + return !!bdev->bd_holder; + else + return !!bdev->bd_holder && bdev->bd_holder != bd_may_claim; +} + static void bdev_block_writes(struct block_device *bdev) { bdev->bd_mounters++; @@ -796,7 +804,8 @@ static void bdev_dump_info(struct block_device *bdev, blk_mode_t mode) if (bdev_allow_write_mounted & (1 << BLKDEV_WRITE_MOUNTED_QUIET)) return;
- if (mode & BLK_OPEN_WRITE && bdev_writes_blocked(bdev)) + if (mode & BLK_OPEN_WRITE && (bdev_writes_blocked(bdev) || + bdev_lower_device_writes_blocked(bdev))) blkdev_dump_conflict_opener(bdev, "VFS: Open an exclusive opened " "block device for write"); else if (mode & BLK_OPEN_RESTRICT_WRITES && bdev_mount_blocked(bdev))