]> www.infradead.org Git - users/jedix/linux-maple.git/commit
brd: fix discard end sector
authorYu Kuai <yukuai3@huawei.com>
Tue, 6 May 2025 06:17:56 +0000 (14:17 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 6 May 2025 13:42:27 +0000 (07:42 -0600)
commita26a339a654b9403f0ee1004f1db4c2b2a355460
treefe09926582ec0131a01a30ab1f1ab209e00983c8
parentd4099f8893b057ad7e8d61df76bdeaf807ebd679
brd: fix discard end sector

brd_do_discard() just aligned start sector to page, this can only work
if the discard size if at least one page. For example:

blkdiscard /dev/ram0 -o 5120 -l 1024

In this case, size = (1024 - (8192 - 5120)), which is a huge value.

Fix the problem by round_down() the end sector.

Fixes: 9ead7efc6f3f ("brd: implement discard support")
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/r/20250506061756.2970934-4-yukuai1@huaweicloud.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
drivers/block/brd.c