[PATCH] zram: freeze device queue before device reset

From: Sergey Senozhatsky

Date: Tue Aug 04 2026 - 22:19:55 EST


Device reset does not take into account in-flight async IO
requests so we can free meta table and reset device concurrently
with those requests being executed. The block layer guidelines
indicate that queue state should be protected by blk_mq_freeze_queue()
during teardown. Freeze zram queue before device reset.

Fixes: cd67e10ac699 ("zram: promote zram from staging")
Link: https://sashiko.dev/#/patchset/20260804065919.3970386-1-xialonglong2025@xxxxxxx
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 56183c827e1b..3b9dfcae9317 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -19,6 +19,7 @@
#include <linux/bio.h>
#include <linux/bitops.h>
#include <linux/blkdev.h>
+#include <linux/blk-mq.h>
#include <linux/buffer_head.h>
#include <linux/device.h>
#include <linux/highmem.h>
@@ -2842,6 +2843,9 @@ static void zram_destroy_comps(struct zram *zram)

static void zram_reset_device(struct zram *zram)
{
+ unsigned int memflags;
+
+ memflags = blk_mq_freeze_queue(zram->disk->queue);
guard(rwsem_write)(&zram->dev_lock);

zram->limit_pages = 0;
@@ -2855,6 +2859,7 @@ static void zram_reset_device(struct zram *zram)
zram_destroy_comps(zram);
memset(&zram->stats, 0, sizeof(zram->stats));
reset_bdev(zram);
+ blk_mq_unfreeze_queue(zram->disk->queue, memflags);
}

static ssize_t disksize_store(struct device *dev, struct device_attribute *attr,
--
2.55.0.571.g244d577d93-goog