Skip to content

Commit fbc3423

Browse files
zhangxianwei8gregkh
authored andcommitted
brd: decrease the number of allocated pages which discarded
[ Upstream commit 8273420 ] The number of allocated pages which discarded will not decrease. Fix it. Fixes: 9ead7ef ("brd: implement discard support") Signed-off-by: Zhang Xianwei <[email protected]> Reviewed-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 01a853f commit fbc3423

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/block/brd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,8 +231,10 @@ static void brd_do_discard(struct brd_device *brd, sector_t sector, u32 size)
231231
xa_lock(&brd->brd_pages);
232232
while (size >= PAGE_SIZE && aligned_sector < rd_size * 2) {
233233
page = __xa_erase(&brd->brd_pages, aligned_sector >> PAGE_SECTORS_SHIFT);
234-
if (page)
234+
if (page) {
235235
__free_page(page);
236+
brd->brd_nr_pages--;
237+
}
236238
aligned_sector += PAGE_SECTORS;
237239
size -= PAGE_SIZE;
238240
}

0 commit comments

Comments
 (0)