diff options
author | Zhang Xianwei <zhang.xianwei8@zte.com.cn> | 2024-11-28 17:00:56 +0800 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2024-11-29 08:43:52 -0700 |
commit | 82734209bedd65a8b508844bab652b464379bfdd (patch) | |
tree | 6d2e14d7faa6edd996028ac0c1b070085517f9bd /drivers/block | |
parent | e8b8344de3980709080d86c157d24e7de07d70ad (diff) | |
download | lwn-82734209bedd65a8b508844bab652b464379bfdd.tar.gz lwn-82734209bedd65a8b508844bab652b464379bfdd.zip |
brd: decrease the number of allocated pages which discarded
The number of allocated pages which discarded will not decrease.
Fix it.
Fixes: 9ead7efc6f3f ("brd: implement discard support")
Signed-off-by: Zhang Xianwei <zhang.xianwei8@zte.com.cn>
Reviewed-by: Ming Lei <ming.lei@redhat.com>
Link: https://lore.kernel.org/r/20241128170056565nPKSz2vsP8K8X2uk2iaDG@zte.com.cn
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/brd.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/block/brd.c b/drivers/block/brd.c index 5a95671d8151..292f127cae0a 100644 --- a/drivers/block/brd.c +++ b/drivers/block/brd.c @@ -231,8 +231,10 @@ static void brd_do_discard(struct brd_device *brd, sector_t sector, u32 size) xa_lock(&brd->brd_pages); while (size >= PAGE_SIZE && aligned_sector < rd_size * 2) { page = __xa_erase(&brd->brd_pages, aligned_sector >> PAGE_SECTORS_SHIFT); - if (page) + if (page) { __free_page(page); + brd->brd_nr_pages--; + } aligned_sector += PAGE_SECTORS; size -= PAGE_SIZE; } |