From: Li Lingfeng lilingfeng3@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I53Q6M CVE: NA
---------------------------
Commit 14eae9d6bcf68eccf28478694ca764ab8fd2067b. can't cover some special situations, so revert it and add a more complete one.
Signed-off-by: Li Lingfeng lilingfeng3@huawei.com Reviewed-by: Zhihao Cheng chengzhihao1@huawei.com Reviewed-by: Yang Erkun yangerkun@huawei.com Reviewed-by: Hou Tao houtao1@huawei.com Signed-off-by: Yongqiang Liu liuyongqiang13@huawei.com --- fs/block_dev.c | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-)
diff --git a/fs/block_dev.c b/fs/block_dev.c index 4daa2998fbaf..58be97f412fd 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1726,13 +1726,13 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
res = __blkdev_get(bdev, mode, 0);
- mutex_lock(&bdev->bd_mutex); - spin_lock(&bdev_lock); - if (whole) { struct gendisk *disk = whole->bd_disk;
/* finish claiming */ + mutex_lock(&bdev->bd_mutex); + spin_lock(&bdev_lock); + if (!res) { BUG_ON(!bd_may_claim(bdev, whole, holder)); /* @@ -1769,22 +1769,6 @@ int blkdev_get(struct block_device *bdev, fmode_t mode, void *holder)
mutex_unlock(&bdev->bd_mutex); bdput(whole); - } else { - if (!res && (mode & FMODE_WRITE) && bdev->bd_holders) { - char name[BDEVNAME_SIZE]; - - /* - * Open an exclusive opened device for write may - * probability corrupt the device, such as a - * mounted file system, give a hint here. - */ - pr_info_ratelimited("VFS: Open an exclusive opened " - "block device for write %s [%d %s].\n", - bdevname(bdev, name), current->pid, - current->comm); - } - spin_unlock(&bdev_lock); - mutex_unlock(&bdev->bd_mutex); }
if (res)