提交 ff2a9941 编写于 作者: T Tejun Heo 提交者: Linus Torvalds

block: move bd_set_size() above rescan_partitions() in __blkdev_get()

02e35228 (block: rescan partitions on invalidated devices on
-ENOMEDIA too) relocated partition rescan above explicit bd_set_size()
to simplify condition check.  As rescan_partitions() does its own bdev
size setting, this doesn't break anything; however,
rescan_partitions() prints out the following messages when adjusting
bdev size, which can be confusing.

  sda: detected capacity change from 0 to 146815737856
  sdb: detected capacity change from 0 to 146815737856

This patch restores the original order and remove the warning
messages.

stable: Please apply together with 02e35228 (block: rescan
        partitions on invalidated devices on -ENOMEDIA too).
Signed-off-by: NTejun Heo <tj@kernel.org>
Reported-by: NTony Luck <tony.luck@gmail.com>
Tested-by: NTony Luck <tony.luck@gmail.com>
Cc: stable@kernel.org
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 f4b10bc6
...@@ -1120,6 +1120,15 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) ...@@ -1120,6 +1120,15 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
goto restart; goto restart;
} }
} }
if (!ret && !bdev->bd_openers) {
bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
bdi = blk_get_backing_dev_info(bdev);
if (bdi == NULL)
bdi = &default_backing_dev_info;
bdev_inode_switch_bdi(bdev->bd_inode, bdi);
}
/* /*
* If the device is invalidated, rescan partition * If the device is invalidated, rescan partition
* if open succeeded or failed with -ENOMEDIUM. * if open succeeded or failed with -ENOMEDIUM.
...@@ -1130,14 +1139,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part) ...@@ -1130,14 +1139,6 @@ static int __blkdev_get(struct block_device *bdev, fmode_t mode, int for_part)
rescan_partitions(disk, bdev); rescan_partitions(disk, bdev);
if (ret) if (ret)
goto out_clear; goto out_clear;
if (!bdev->bd_openers) {
bd_set_size(bdev,(loff_t)get_capacity(disk)<<9);
bdi = blk_get_backing_dev_info(bdev);
if (bdi == NULL)
bdi = &default_backing_dev_info;
bdev_inode_switch_bdi(bdev->bd_inode, bdi);
}
} else { } else {
struct block_device *whole; struct block_device *whole;
whole = bdget_disk(disk, 0); whole = bdget_disk(disk, 0);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册