Skip to content

Commit a14e5ec

Browse files
Mikulas Patockasnitm
authored andcommitted
dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size
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: Mikulas Patocka <[email protected]> Reviewed-by: Milan Broz <[email protected]> Cc: [email protected] Signed-off-by: Mike Snitzer <[email protected]>
1 parent a666e5c commit a14e5ec

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/md/dm-bufio.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,6 +1526,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_size);
15261526
sector_t dm_bufio_get_device_size(struct dm_bufio_client *c)
15271527
{
15281528
sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT;
1529+
if (s >= c->start)
1530+
s -= c->start;
1531+
else
1532+
s = 0;
15291533
if (likely(c->sectors_per_block_bits >= 0))
15301534
s >>= c->sectors_per_block_bits;
15311535
else

0 commit comments

Comments
 (0)