From 01b45ef87db4e9af5ee912052fe8276bff4a9745 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Fri, 14 Feb 2025 12:21:37 +0100 Subject: [PATCH] fs/erofs: add LZMA compression, allow configurable compression level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of having a bool option for enabling the LZ4HC compression, change the Kconfig definition to a choice, which also adds more flexibility in the future (e.g. for enabling ZSTD compression). The name of the old option was preserved so defconfigs using it won't be affected. Also both for LZMA and LZ4HC, it's now possible to define compression level. Previously it defaulted to 9, which generates images larger than squashfs with comparable settings (which uses level 12 by default). For LZ4HC the default if unset would be still 9. Use a separate config option for LZMA and LZ4HC compression level, because their ranges and meaning are different. Signed-off-by: Jan Čermák Signed-off-by: Arnout Vandecappelle --- fs/erofs/Config.in | 53 +++++++++++++++++++++++++++++++++++++++++++--- fs/erofs/erofs.mk | 4 +++- 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/fs/erofs/Config.in b/fs/erofs/Config.in index e112572688..2041a0034e 100644 --- a/fs/erofs/Config.in +++ b/fs/erofs/Config.in @@ -6,10 +6,57 @@ config BR2_TARGET_ROOTFS_EROFS if BR2_TARGET_ROOTFS_EROFS -config BR2_TARGET_ROOTFS_EROFS_LZ4HC - bool "lz4hc compression" +choice + prompt "Compression algorithm" + default BR2_TARGET_ROOTFS_EROFS_LZ4HC help - Use lz4 high-compression to compress data in the filesystem. + Select the EROFS compression algorithm to use. + + LZ4HC (LZ4 High Compression) is the default algorithm and + provides a good balance between compression ratio and speed, + with increasing levels the compression ratio increases at the + penalty of higher compression times, without significant + decompression penalty. + + LZMA provides the best compression ratio but is significantly + slower both in compression and decompression, and higher + compression levels can have noticeable memory requirements. + +config BR2_TARGET_ROOTFS_EROFS_NONE + bool "no compression" + +config BR2_TARGET_ROOTFS_EROFS_LZ4HC + bool "lz4hc" + +config BR2_TARGET_ROOTFS_EROFS_LZMA + bool "lzma" + +endchoice + +if BR2_TARGET_ROOTFS_EROFS_LZ4HC + +config BR2_TARGET_ROOTFS_EROFS_LZ4HC_LEVEL + int "lz4hc compression level" + default 9 + range 1 12 + help + Specify the compression level for LZ4HC compression. + +endif # BR2_TARGET_ROOTFS_EROFS_LZ4HC + +if BR2_TARGET_ROOTFS_EROFS_LZMA + +config BR2_TARGET_ROOTFS_EROFS_LZMA_LEVEL + int "lzma compression level" + default 6 + range 0 109 + help + Specify the compression level for LZMA compression. + + Values from 0 to 9 are used for the standard compression, + values from 100 to 109 are used for the extreme compression. + +endif # BR2_TARGET_ROOTFS_EROFS_LZMA config BR2_TARGET_ROOTFS_EROFS_PCLUSTERSIZE int "pcluster size" diff --git a/fs/erofs/erofs.mk b/fs/erofs/erofs.mk index e43d74927b..e8d30bace8 100644 --- a/fs/erofs/erofs.mk +++ b/fs/erofs/erofs.mk @@ -7,7 +7,9 @@ ROOTFS_EROFS_DEPENDENCIES = host-erofs-utils ifeq ($(BR2_TARGET_ROOTFS_EROFS_LZ4HC),y) -ROOTFS_EROFS_ARGS += -zlz4hc +ROOTFS_EROFS_ARGS += -zlz4hc,$(BR2_TARGET_ROOTFS_EROFS_LZ4HC_LEVEL) +else ifeq ($(BR2_TARGET_ROOTFS_EROFS_LZMA),y) +ROOTFS_EROFS_ARGS += -zlzma,$(BR2_TARGET_ROOTFS_EROFS_LZMA_LEVEL) endif ifeq ($(BR2_REPRODUCIBLE),y)