[PATCH 3/3] zram: reset per-priority params when changing algorithm before init
From: Haoqin Huang
Date: Sat Jun 27 2026 - 03:04:31 EST
From: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>
Parameters validated against one algorithm may be invalid for another
(e.g. lz4 accepts level=65535 but zstd does not). Although algorithm
changes are blocked after disksize is set, they are allowed before
device initialization. Reset per-priority params on algorithm change
so that stale parameters do not silently carry over.
Signed-off-by: Haoqin Huang <haoqinhuang@xxxxxxxxxxx>
Reviewed-by: Rongwei Wang <zigiwang@xxxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index a667d0672720..6b47586e8718 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -57,6 +57,7 @@ static size_t huge_class_size;
static const struct block_device_operations zram_devops;
static void slot_free(struct zram *zram, u32 index);
+static void comp_params_reset(struct zram *zram, u32 prio);
#define slot_dep_map(zram, index) (&(zram)->table[(index)].dep_map)
static void slot_lock_init(struct zram *zram, u32 index)
@@ -1681,6 +1682,7 @@ static int __comp_algorithm_store(struct zram *zram, u32 prio, const char *buf)
}
comp_algorithm_set(zram, prio, alg);
+ comp_params_reset(zram, prio);
return 0;
}
--
2.43.7