[PATCH v2 5/5] zram: reset per-priority params when changing algorithm before init
From: Haoqin Huang
Date: Tue Jul 28 2026 - 05:47:52 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>
Signed-off-by: Rongwei Wang <zigiwang@xxxxxxxxxxx>
Reviewed-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 d86f4eb06d58..da2921082712 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1661,6 +1661,8 @@ static void comp_algorithm_set(struct zram *zram, u32 prio, const char *alg)
zram->comp_algs[prio] = alg;
}
+static void comp_params_reset(struct zram *zram, u32 prio);
+
static int __comp_algorithm_store(struct zram *zram, u32 prio, const char *buf)
{
const char *alg;
@@ -1681,6 +1683,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