mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-09-22 09:34:56 +02:00
dm-bufio: fix wrong count calculation in dm_bufio_issue_discard
commit422f1d4f14upstream. block_to_sector converts a block number to a sector number and adds c->start to the result. It is inappropriate to use this function for converting the number of blocks to a number to sectors because c->start would be incorrectly added to the result. Luckily, the only target that uses dm_bufio_issue_discard is dm-ebs, which sets c->start to 0, so this bug is latent. Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Assisted-by: Claude:claude-opus-4-6 Fixes:6fbeb0048e("dm bufio: implement discard") Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7e1822f83c
commit
ae7fac9cb5
@@ -2189,7 +2189,9 @@ int dm_bufio_issue_discard(struct dm_bufio_client *c, sector_t block, sector_t c
|
||||
struct dm_io_region io_reg = {
|
||||
.bdev = c->bdev,
|
||||
.sector = block_to_sector(c, block),
|
||||
.count = block_to_sector(c, count),
|
||||
.count = likely(c->sectors_per_block_bits >= 0) ?
|
||||
count << c->sectors_per_block_bits :
|
||||
count * (c->block_size >> SECTOR_SHIFT),
|
||||
};
|
||||
|
||||
if (WARN_ON_ONCE(dm_bufio_in_request()))
|
||||
|
||||
Reference in New Issue
Block a user