提交 77f23bb0 编写于 作者: M Mikulas Patocka 提交者: Cheng Jian

dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size

stable inclusion
from linux-4.19.180
commit 85295f08866a6a26d013ae46699104b80699fb4e

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

commit a14e5ec6 upstream.

dm_bufio_get_device_size returns the device size in blocks. Before
returning the value, we must subtract the nubmer of starting
sectors. The number of starting sectors may not be divisible by block
size.

Note that currently, no target is using dm_bufio_set_sector_offset and
dm_bufio_get_device_size simultaneously, so this change has no effect.
However, an upcoming dm-verity-fec fix needs this change.
Signed-off-by: NMikulas Patocka <mpatocka@redhat.com>
Reviewed-by: NMilan Broz <gmazyland@gmail.com>
Cc: stable@vger.kernel.org
Signed-off-by: NMike Snitzer <snitzer@redhat.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
Signed-off-by: NCheng Jian <cj.chengjian@huawei.com>
上级 2b6b8c9b
...@@ -1463,6 +1463,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_size); ...@@ -1463,6 +1463,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_size);
sector_t dm_bufio_get_device_size(struct dm_bufio_client *c) sector_t dm_bufio_get_device_size(struct dm_bufio_client *c)
{ {
sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT; sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT;
if (s >= c->start)
s -= c->start;
else
s = 0;
if (likely(c->sectors_per_block_bits >= 0)) if (likely(c->sectors_per_block_bits >= 0))
s >>= c->sectors_per_block_bits; s >>= c->sectors_per_block_bits;
else else
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册