Skip to content

Commit 8273420

Browse files
zhangxianwei8axboe
authored andcommitted
brd: decrease the number of allocated pages which discarded
The number of allocated pages which discarded will not decrease. Fix it. Fixes: 9ead7ef ("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>
1 parent e8b8344 commit 8273420

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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)