fs/erofs: add custom compression option with optional compress-hints file

Add another option for FS compression that allows fine-grained control using a
list of algorithms and optional compress-hints file. This way multiple
algorithms and pcluster sizes can be used for different files, fully exposing
EROFS compression abilities.

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:39 +01:00
committed by Arnout Vandecappelle
parent 39aec97630
commit a02e437417
2 changed files with 41 additions and 0 deletions

View File

@@ -22,6 +22,10 @@ choice
slower both in compression and decompression, and higher
compression levels can have noticeable memory requirements.
Custom compression allows for advanced configuration of the
compression algorithms, and adds the possibility of
finegrained per-file compression using compression hints.
config BR2_TARGET_ROOTFS_EROFS_NONE
bool "no compression"
@@ -31,6 +35,9 @@ config BR2_TARGET_ROOTFS_EROFS_LZ4HC
config BR2_TARGET_ROOTFS_EROFS_LZMA
bool "lzma"
config BR2_TARGET_ROOTFS_EROFS_CUSTOM_COMPRESSION
bool "custom"
endchoice
if BR2_TARGET_ROOTFS_EROFS_LZ4HC
@@ -58,6 +65,35 @@ config BR2_TARGET_ROOTFS_EROFS_LZMA_LEVEL
endif # BR2_TARGET_ROOTFS_EROFS_LZMA
if BR2_TARGET_ROOTFS_EROFS_CUSTOM_COMPRESSION
config BR2_TARGET_ROOTFS_EROFS_COMPRESSION_ALGORITHMS
string "compression algorithms"
default "lz4hc,12"
help
Specify arbitrary compression option, useful in combination
with compression hints. Individual algorithms are separated
by colon with optional level, e.g. "lz4hc,12:lzma".
See erofs-utils documentaion for detailed information.
config BR2_TARGET_ROOTFS_EROFS_COMPRESSION_HINTS
string "path to compression hints file"
default ""
help
Path to file containing compression hints. Each line in the
file is defined by tokens separated by spaces in the
following form. Optionally, instead of the given primary
algorithm, algorithms can be specified with zero-based
algorithm-index explicitly:
<pcluster-size-in-bytes> [algorithm-index] <match-pattern>
match-patterns are extended regular expressions, matched
against absolute paths within the output filesystem, with no
leading /.
endif # BR2_TARGET_ROOTFS_EROFS_LZMA
config BR2_TARGET_ROOTFS_EROFS_DEDUPE
bool "enable data deduplication"
depends on !BR2_TARGET_ROOTFS_EROFS_NONE

View File

@@ -10,6 +10,11 @@ ifeq ($(BR2_TARGET_ROOTFS_EROFS_LZ4HC),y)
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)
else ifeq ($(BR2_TARGET_ROOTFS_EROFS_CUSTOM_COMPRESSION),y)
ROOTFS_EROFS_ARGS += -z$(strip $(BR2_TARGET_ROOTFS_EROFS_COMPRESSION_ALGORITHMS))
ifneq ($(strip $(BR2_TARGET_ROOTFS_EROFS_COMPRESSION_HINTS)),)
ROOTFS_EROFS_ARGS += --compress-hints $(strip $(BR2_TARGET_ROOTFS_EROFS_COMPRESSION_HINTS))
endif
endif
ifeq ($(BR2_REPRODUCIBLE),y)