[PATCH 1/2] zram: do not leak blk idx at the end of writeback
From: Sergey Senozhatsky
Date: Mon May 25 2026 - 00:47:27 EST
In certain cases zram_writeback_slots() loop can terminate with
blk_idx being valid (in particular when we race with modification
of last slot) but zram_writeback_slots() forgets to release the
reserved block id, which leads to this block becoming unavailable
for future writeback. Release valid blk_idx before returning from
zram_writeback_slots().
Suggested-by: Brian Geffon <bgeffon@xxxxxxxxxx>
Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 07111455eecf..602abfe23797 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1127,6 +1127,9 @@ static int zram_writeback_slots(struct zram *zram,
if (req)
release_wb_req(req);
+ if (blk_idx != INVALID_BDEV_BLOCK)
+ zram_release_bdev_block(zram, blk_idx);
+
while (atomic_read(&wb_ctl->num_inflight) > 0) {
wait_event(wb_ctl->done_wait, !list_empty(&wb_ctl->done_reqs));
err = zram_complete_done_reqs(zram, wb_ctl);
--
2.54.0.746.g67dd491aae-goog