[PATCH 3/5] zram: recompression priority param should override algo
From: Sergey Senozhatsky
Date: Fri Feb 27 2026 - 03:23:09 EST
Recompression algorithm lookup by name is ambiguous and
can lead to unexpected results. The problem is that
the system can configure the same algorithm but with
different parameters (compression level, C/D-dicts, etc.)
multiple times:
[zstd clevel=3] [zstd clevel=8 dict=/etc/dict]
making it impossible to distinguish compressors by name.
It is advised to always use "priority". Additionally,
override "algo" with "priority", when both params are
provided.
Suggested-by: Minchan Kim <minchan@xxxxxxxxxx>
Signed-off-by: Sergey Senozhatsky <senozhatsky@xxxxxxxxxxxx>
---
drivers/block/zram/zram_drv.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 6ca5a76c3865..118b0b277e37 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -2594,6 +2594,16 @@ static ssize_t recompress_store(struct device *dev,
if (ret)
return ret;
+ /*
+ * "priority" overrides "algo".
+ *
+ * We can have several algorithms configured with
+ * different params (compression/acceleration level,
+ * C/D-dict, etc.) but under the same name.
+ *
+ * "algorithm" name lookup is ambiguous.
+ */
+ algo = NULL;
prio_max = min(prio + 1, ZRAM_MAX_COMPS);
continue;
}
--
2.53.0.473.g4a7958ca14-goog