erofs-utils: ignore comments and blank lines in compress hints
PATCH 1/2 erofs-utils: ignore comments and blank lines in compress hints
Identify lines starting with '#' as a comment.
--- lib/compress_hints.c | 3 +++ 1 file changed, 3 insertions(+)
lib/compress_hints.c +3 -0
@@ -101,6 +101,9 @@ int erofs_load_compress_hints(void)unsigned int pclustersize;char *pattern; +if (*buf =='#' || *buf =='\n' ) +continue ; + pclustersize =atoi (strtok (buf,"\t " )); pattern =strtok (NULL ,"\n" );if (!pattern || *pattern =='\0' ) {
Signature · 1 line
2.36.1
PATCH 2/2 erofs-utils: support multiple algorithms in an image
Some binaries in an image may be just for archival purposes only so that the runtime performance is not the top priority at all.
Therefore, it'd better to use another algorithm with higher compression ratios and (even) pack the whole file into the packed inode entirely (will enable this way later.)
In order to use alternative algorithms, just specify two or more compressing configurations together seperated by ':' like below:
-zlzma:lz4hc,12:lzma,9 -C 32768
Although mkfs still choose the first one by default, you could try to write a compress-hints file like below:
4096 1 .*\.so$
32768 2 .*\.txt$
4096 sbin/.*$
16384 0 .*
So that ".so" files will use "lz4hc,1" compression with 4k pclusters ".txt" files will use "lzma,9" compression with 32k pclusters, files in "/sbin" will use the default "lzma" compression with 4k plusters and other files will use "lzma" compression with 16k pclusters.
Note that the largest pcluster size should be specified with "-C" option, otherwise all larger pclusters will be limited.
--- include/erofs/compress_hints.h | 1 + include/erofs/config.h | 6 ++- lib/compress.c | 81 ++++++++++++++++++++-------------- lib/compress_hints.c | 57 ++++++++++++++++-------- lib/config.c | 1 - lib/inode.c | 2 +- mkfs/main.c | 43 +++++++++++++----- 7 files changed, 124 insertions(+), 67 deletions(-)
include/erofs/compress_hints.h +1 -0
@@ -20,6 +20,7 @@ struct erofs_compress_hints {regex_t reg;unsigned int physical_clusterblks; +unsigned char algorithmtype; };bool z_erofs_apply_compress_hints (struct erofs_inode *inode);
include/erofs/config.h +4 -2
@@ -32,6 +32,8 @@ enum { TIMESTAMP_CLAMPING, }; +#define EROFS_MAX_COMPR_CFG 64 +struct erofs_configure {const char *c_version;int c_dbg_lvl;
@@ -57,8 +59,8 @@ struct erofs_configure {char *c_src_path;char *c_blobdev_path;char *c_compress_hints_file; -char *c_compr_alg_master; -int c_compr_level_master; +char *c_compr_alg[EROFS_MAX_COMPR_CFG ]; +int c_compr_level[EROFS_MAX_COMPR_CFG ];char c_force_inodeversion;char c_force_chunkformat;/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
lib/compress.c +48 -33
149 lines not on this page · raw message
lib/compress_hints.c +39 -18
123 lines not on this page · raw message
lib/config.c +0 -1
@@ -25,7 +25,6 @@ void erofs_init_configure(void) cfg.c_version =PACKAGE_VERSION ; cfg.c_dry_run = false; cfg.c_ignore_mtime = false; - cfg.c_compr_level_master =-1 ; cfg.c_force_inodeversion =0 ; cfg.c_inline_xattr_tolerance =2 ; cfg.c_unix_timestamp =-1 ;
lib/inode.c +1 -1
@@ -424,7 +424,7 @@ static int erofs_write_file(struct erofs_inode *inode)return erofs_blob_write_chunked_file (inode); } -if (cfg.c_compr_alg_master &&erofs_file_is_compressible (inode)) { +if (cfg.c_compr_alg[0 ] &&erofs_file_is_compressible (inode)) { fd =open (inode->i_srcpath,O_RDONLY |O_BINARY );if (fd <0 )return -errno;
mkfs/main.c +31 -12
63 lines not on this page · raw message
Signature · 1 line
2.36.1