erofs-utils: enable multi-threaded support for `-Eall-fragments`
authorGao Xiang <hsiangkao@linux.alibaba.com>
Wed, 7 Aug 2024 08:54:13 +0000 (16:54 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 8 Aug 2024 10:00:26 +0000 (18:00 +0800)
Since `-Eall-fragments` packs the whole data into the special inode,
it's possible to use the multi-threaded compression for this.

Some users may be interested in `-Eall-fragments` for extreme
compression anyway.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Reviewed-by: Sandeep Dhavale <dhavale@google.com>
Link: https://lore.kernel.org/r/20240807085413.717066-1-hsiangkao@linux.alibaba.com
lib/compress.c

index cea96f41647e4fc2dc308b0deff66c3bec8ac893..8655e785be21d69ae0bc19103c6edfb3011e11de 100644 (file)
@@ -1763,7 +1763,8 @@ int z_erofs_compress_init(struct erofs_sb_info *sbi, struct erofs_buffer_head *s
 
        z_erofs_mt_enabled = false;
 #ifdef EROFS_MT_ENABLED
-       if (cfg.c_mt_workers > 1 && (cfg.c_dedupe || cfg.c_fragments)) {
+       if (cfg.c_mt_workers >= 1 && (cfg.c_dedupe ||
+                                     (cfg.c_fragments && !cfg.c_all_fragments))) {
                if (cfg.c_dedupe)
                        erofs_warn("multi-threaded dedupe is NOT implemented for now");
                if (cfg.c_fragments)
@@ -1771,7 +1772,7 @@ int z_erofs_compress_init(struct erofs_sb_info *sbi, struct erofs_buffer_head *s
                cfg.c_mt_workers = 0;
        }
 
-       if (cfg.c_mt_workers > 1) {
+       if (cfg.c_mt_workers >= 1) {
                ret = erofs_alloc_workqueue(&z_erofs_mt_ctrl.wq,
                                            cfg.c_mt_workers,
                                            cfg.c_mt_workers << 2,