Skip to contentSkip to conversation

erofs-utils: fix liblzma extreme compression levels

PATCH New Gao Xiang 1 participant 2 messages Mar 10, 2023 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: fix liblzma extreme compression levels

100 ~ 109 are now valid for LZMA extreme compression.

---
 lib/compressor_liblzma.c | 11 ++++++++---
 man/mkfs.erofs.1         |  3 ++-
 2 files changed, 10 insertions(+), 4 deletions(-)
lib/compressor_liblzma.c +8 -3
index 4886d6a..f274dce 100644
@@ -56,11 +56,16 @@ static int erofs_compressor_liblzma_setlevel(struct erofs_compress *c,
 					     int compression_level)
 {
 	struct erofs_liblzma_context *ctx = c->private_data;
+	u32 preset;
 
 	if (compression_level < 0)
-		compression_level = LZMA_PRESET_DEFAULT;
+		preset = LZMA_PRESET_DEFAULT;
+	else if (compression_level >= 100)
+		preset = (compression_level - 100) | LZMA_PRESET_EXTREME;
+	else
+		preset = compression_level;
 
-	if (lzma_lzma_preset(&ctx->opt, compression_level))
+	if (lzma_lzma_preset(&ctx->opt, preset))
 		return -EINVAL;
 
 	/* XXX: temporary hack */
@@ -97,7 +102,7 @@ static int erofs_compressor_liblzma_init(struct erofs_compress *c)
 const struct erofs_compressor erofs_compressor_lzma = {
 	.name = "lzma",
 	.default_level = LZMA_PRESET_DEFAULT,
-	.best_level = LZMA_PRESET_EXTREME,
+	.best_level = 109,
 	.init = erofs_compressor_liblzma_init,
 	.exit = erofs_compressor_liblzma_exit,
 	.setlevel = erofs_compressor_liblzma_setlevel,
man/mkfs.erofs.1 +2 -1
index c1ad47d..e237877 100644
@@ -22,7 +22,8 @@ from \fISOURCE\fR directory.
 .TP
 .BI "\-z " compression-algorithm " [" ",#" "]"
 Set an algorithm for file compression, which can be set with an optional
-compression level separated by a comma.
+compression level (1 to 12 for LZ4HC, 0 to 9 for LZMA and 100 to 109 for LZMA
+extreme compression) separated by a comma.
 .TP
 .BI "\-C " max-pcluster-size
 Specify the maximum size of compress physical cluster in bytes. It may enable
Signature · 1 line
2.24.4
author
#1 lore raw

PATCH 2/2 erofs-utils: refine README

Add some words about userspace fragment cache as a TODO.

---
 README | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
README +9 -5
index 6474ed1..e224b23 100644
@@ -183,7 +183,7 @@ Therefore, NEVER use it if performance is the top concern.
 How to mount an EROFS image with erofsfuse
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
-As the other FUSE implementations, it's quite simple to mount with
+As the other FUSE implementations, it's quite easy to mount by using
 erofsfuse, e.g.:
  $ erofsfuse foo.erofs.img foo/
 
@@ -202,15 +202,19 @@ dump.erofs and fsck.erofs
 
 dump.erofs and fsck.erofs are used to analyze, check, and extract
 EROFS filesystems. Note that extended attributes and ACLs are still
-unsupported when extracting images with fsck.erofs.  If you are
-interested, contribution is, as always, welcome.
+unsupported when extracting images with fsck.erofs.
+
+Note that fragment extraction with fsck.erofs could be slow now and
+it needs to be optimized later.  If you are interested, contribution
+is, as always, welcome.
 
 
 Contribution
 ------------
 
-erofs-utils is a part of EROFS filesystem project, feel free to send
-patches or feedback to:
+erofs-utils is a part of EROFS filesystem project, which is completely
+community-driven open source software.  If you have interest in EROFS,
+feel free to send feedback and/or patches to:
   linux-erofs mailing list   <[email protected]>
 
 
Signature · 1 line
2.24.4