The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] zram: freeze device queue before device reset
@ 2026-08-05  2:18 Sergey Senozhatsky
  2026-08-05 10:29 ` Sergey Senozhatsky
  0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2026-08-05  2:18 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Minchan Kim, Jens Axboe, linux-block, linux-kernel, linux-mmc,
	Longlong Xia, Sergey Senozhatsky, stable

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@163.com
Cc: stable@vger.kernel.org
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
 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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-08-05 10:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-05  2:18 [PATCH] zram: freeze device queue before device reset Sergey Senozhatsky
2026-08-05 10:29 ` Sergey Senozhatsky
2026-08-05 10:52   ` Sergey Senozhatsky

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox