erofs-utils: add liblzma dependency
PATCH 1/3 erofs-utils: add liblzma dependency
liblzma [1] has a fixed-sized output LZMA compression implementation now since v5.3.2alpha. Let's add such dependency in the build system.
[1] https://git.tukaani.org/?p=xz.git
Cc Lasse Collin <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- README | 3 +++ configure.ac | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ fuse/Makefile.am | 3 ++- lib/Makefile.am | 1 + mkfs/Makefile.am | 3 ++- 5 files changed, 57 insertions(+), 2 deletions(-)
README +3 -0
@@ -8,6 +8,7 @@ Dependencies & build -------------------- lz4 1.8.0+ for lz4 enabled [2], lz4 1.9.3+ highly recommended [4][5]. + XZ Utils 5.3.2alpha [6] or later versions for MicroLZMA enabled. libfuse 2.6+ for erofsfuse enabled as a plus.
@@ -221,3 +222,5 @@ Comments https://github.com/lz4/lz4/issues/783 which is also resolved in lz4-1.9.3. + +[6] https://tukaani.org/xz/xz-5.3.2alpha.tar.xz
configure.ac +49 -0
77 lines not on this page · raw message
fuse/Makefile.am +2 -1
@@ -5,4 +5,5 @@ bin_PROGRAMS = erofsfuse erofsfuse_SOURCES = dir.c main.c erofsfuse_CFLAGS = -Wall -Werror -I$(top_srcdir)/include erofsfuse_CFLAGS += -DFUSE_USE_VERSION=26 ${libfuse_CFLAGS} ${libselinux_CFLAGS} -erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} ${libselinux_LIBS} +erofsfuse_LDADD = $(top_builddir)/lib/liberofs.la ${libfuse_LIBS} ${liblz4_LIBS} \ + ${libselinux_LIBS} ${liblzma_LIBS}
lib/Makefile.am +1 -0
@@ -31,3 +31,4 @@ if ENABLE_LZ4HC liberofs_la_SOURCES += compressor_lz4hc.c endif endif +liberofs_la_CFLAGS += ${liblzma_CFLAGS}
mkfs/Makefile.am +2 -1
@@ -5,4 +5,5 @@ bin_PROGRAMS = mkfs.erofs AM_CPPFLAGS = ${libuuid_CFLAGS} ${libselinux_CFLAGS} mkfs_erofs_SOURCES = main.c mkfs_erofs_CFLAGS = -Wall -Werror -I$(top_srcdir)/include -mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} ${liblz4_LIBS} +mkfs_erofs_LDADD = ${libuuid_LIBS} $(top_builddir)/lib/liberofs.la ${libselinux_LIBS} \ + ${liblz4_LIBS} ${liblzma_LIBS}
Signature · 1 line
2.20.1
PATCH 2/3 erofs-utils: fuse: add LZMA algorithm support
This patch adds LZMA compression algorithm support to erofsfuse to test if LZMA fixed-sized output compression works as expected.
Cc Lasse Collin <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs_fs.h | 5 +++- lib/data.c | 7 ++--- lib/decompress.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 4 deletions(-)
include/erofs_fs.h +4 -1
@@ -248,7 +248,8 @@ struct erofs_inode_chunk_index {/* available compression algorithm types (for h_algorithmtype) */ enum { -Z_EROFS_COMPRESSION_LZ4 =0 , +Z_EROFS_COMPRESSION_LZ4 =0 , +Z_EROFS_COMPRESSION_LZMA =1 ,Z_EROFS_COMPRESSION_MAX };#define Z_EROFS_ALL_COMPR_ALGS (1 << (Z_EROFS_COMPRESSION_MAX - 1))
@@ -260,6 +261,8 @@ struct z_erofs_lz4_cfgs {u8 reserved[10 ]; } __packed; +#define Z_EROFS_LZMA_MAX_DICT_SIZE (8 * Z_EROFS_PCLUSTER_MAX_SIZE) +/* * bit 0 : COMPACTED_2B indexes (0 - off; 1 - on) * e.g. for 4k logical cluster size, 4B if compacted 2B is off;
lib/data.c +4 -3
@@ -244,9 +244,10 @@ static int z_erofs_read_data(struct erofs_inode *inode, char *buffer,if (ret <0 )break ; - algorithmformat = map.m_flags &EROFS_MAP_ZIPPED ? -Z_EROFS_COMPRESSION_LZ4 : -Z_EROFS_COMPRESSION_SHIFTED ; +if (map.m_flags &EROFS_MAP_ZIPPED ) + algorithmformat = inode->z_algorithmtype[0 ]; +else + algorithmformat =Z_EROFS_COMPRESSION_SHIFTED ; ret = z_erofs_decompress(&(struct z_erofs_decompress_req) { .in = raw,
lib/decompress.c +66 -0
78 lines not on this page · raw message
Signature · 1 line
2.20.1
PATCH 3/3 erofs-utils: mkfs: add LZMA algorithm support
In reply to Gao XiangThis patch adds LZMA compression algorithm support to erofs-utils compression framework with upstream liblzma.
Cc Lasse Collin <[email protected]>
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/config.h | 1 + include/erofs_fs.h | 6 +++ lib/Makefile.am | 3 ++ lib/compress.c | 37 ++++++++++++-- lib/compressor.c | 3 ++ lib/compressor.h | 1 + lib/compressor_liblzma.c | 105 +++++++++++++++++++++++++++++++++++++++ mkfs/main.c | 1 - 8 files changed, 152 insertions(+), 5 deletions(-) create mode 100644 lib/compressor_liblzma.c
include/erofs/config.h +1 -0
@@ -60,6 +60,7 @@ struct erofs_configure {u32 c_pclusterblks_max, c_pclusterblks_def;u32 c_max_decompressed_extent_bytes; +u32 c_dict_size;u64 c_unix_timestamp;u32 c_uid, c_gid;#ifdef WITH_ANDROID
include/erofs_fs.h +6 -0
@@ -261,6 +261,12 @@ struct z_erofs_lz4_cfgs {u8 reserved[10 ]; } __packed; +/* 14 bytes (+ length field = 16 bytes) */ +struct z_erofs_lzma_cfgs { +__le32 dict_size; +__le16 format; +u8 reserved[8 ]; +} __packed;#define Z_EROFS_LZMA_MAX_DICT_SIZE (8 * Z_EROFS_PCLUSTER_MAX_SIZE)/*
lib/Makefile.am +3 -0
@@ -31,4 +31,7 @@ if ENABLE_LZ4HC liberofs_la_SOURCES += compressor_lz4hc.c endif endif +if ENABLE_LIBLZMA liberofs_la_CFLAGS += ${liblzma_CFLAGS} +liberofs_la_SOURCES += compressor_liblzma.c +endif
lib/compress.c +33 -4
@@ -588,6 +588,8 @@ static int erofs_get_compress_algorithm_id(const char *name) {if (!strcmp (name,"lz4" ) || !strcmp (name,"lz4hc" ))return Z_EROFS_COMPRESSION_LZ4 ; +if (!strcmp (name,"lzma" )) +return Z_EROFS_COMPRESSION_LZMA ;return -ENOTSUP ; }
@@ -619,6 +621,29 @@ int z_erofs_build_compr_cfgs(struct erofs_buffer_head *sb_bh) sizeof(lz4alg)); bh->op = &erofs_drop_directly_bhops; } +#ifdef HAVE_LIBLZMA +if (sbi.available_compr_algs & (1 <<Z_EROFS_COMPRESSION_LZMA )) { +struct { +__le16 size; +struct z_erofs_lzma_cfgs lzma; + } __packed lzmaalg = { + .size =cpu_to_le16 (sizeof (struct z_erofs_lzma_cfgs )), + .lzma = { + .dict_size =cpu_to_le32 (cfg.c_dict_size), + } + }; + + bh =erofs_battach (bh,META ,sizeof (lzmaalg)); +if (IS_ERR (bh)) { +DBG_BUGON (1 ); +return PTR_ERR (bh); + } +erofs_mapbh (bh->block); + ret =dev_write (&lzmaalg,erofs_btell (bh, false), +sizeof (lzmaalg)); + bh->op = &erofs_drop_directly_bhops; + } +#endif return ret; }
@@ -632,17 +657,18 @@ int z_erofs_compress_init(struct erofs_buffer_head *sb_bh)return ret;/* -* if primary algorithm is not lz4* (e.g. compression off), -* clear LZ4_0PADDING feature for old kernel compatibility. +* if primary algorithm is empty (e.g. compression off), +* clear 0PADDING feature for old kernel compatibility. */ if (!cfg.c_compr_alg_master || -strncmp (cfg.c_compr_alg_master,"lz4" ,3 )) + (cfg.c_legacy_compress && !strcmp (cfg.c_compr_alg_master,"lz4" )))erofs_sb_clear_lz4_0padding ();if (!cfg.c_compr_alg_master)return 0 ; - ret =erofs_compressor_setlevel (&compresshandle, cfg.c_compr_level_master); + ret =erofs_compressor_setlevel (&compresshandle, + cfg.c_compr_level_master);if (ret)return ret;
@@ -668,6 +694,9 @@ int z_erofs_compress_init(struct erofs_buffer_head *sb_bh)erofs_warn ("EXPERIMENTAL big pcluster feature in use. Use at your own risk!" ); } +if (ret !=Z_EROFS_COMPRESSION_LZ4 ) +erofs_sb_set_compr_cfgs (); +if (erofs_sb_has_compr_cfgs ()) { sbi.available_compr_algs |=1 << ret;return z_erofs_build_compr_cfgs (sb_bh);
lib/compressor.c +3 -0
@@ -17,6 +17,9 @@ static struct erofs_compressor *compressors[] = {#endif &erofs_compressor_lz4,#endif +#if HAVE_LIBLZMA + &erofs_compressor_lzma, +#endif }; int erofs_compress_destsize(struct erofs_compress *c,
lib/compressor.h +1 -0
@@ -43,6 +43,7 @@ struct erofs_compress {/* list of compression algorithms */ extern struct erofs_compressor erofs_compressor_lz4;extern struct erofs_compressor erofs_compressor_lz4hc; +extern struct erofs_compressor erofs_compressor_lzma; int erofs_compress_destsize(struct erofs_compress *c, void *src, unsigned int *srcsize,
lib/compressor_liblzma.c new file +105 -0
105 lines not on this page · raw message
mkfs/main.c +0 -1
@@ -147,7 +147,6 @@ static int parse_extended_opts(const char *opts)return -EINVAL ;/* disable compacted indexes and 0padding */ cfg.c_legacy_compress = true; -erofs_sb_clear_lz4_0padding (); }if (MATCH_EXTENTED_OPT ("force-inode-compact" , token, keylen)) {
Signature · 1 line
2.20.1