fs/erofs: add LZMA compression, allow configurable compression level

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 <sairon@sairon.cz>
Signed-off-by: Arnout Vandecappelle <arnout@mind.be>
This commit is contained in:
Jan Čermák
2025-02-14 12:21:37 +01:00
committed by Arnout Vandecappelle
parent 9254824fac
commit 01b45ef87d
2 changed files with 53 additions and 4 deletions

View File

@@ -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"

View File

@@ -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)