linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: mkfs: use all available processors by default
@ 2024-04-27  6:25 Gao Xiang
  0 siblings, 0 replies; only message in thread
From: Gao Xiang @ 2024-04-27  6:25 UTC (permalink / raw)
  To: linux-erofs; +Cc: Gao Xiang

Fulfill the needs of most users.

Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
---
 include/erofs/config.h |  3 +--
 lib/compress.c         | 16 ++++++++++++----
 lib/config.c           |  5 -----
 mkfs/main.c            | 10 ++++------
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/erofs/config.h b/include/erofs/config.h
index d2f91ff..16910ea 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -76,10 +76,9 @@ struct erofs_configure {
 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
 	int c_inline_xattr_tolerance;
 #ifdef EROFS_MT_ENABLED
-	u64 c_segment_size;
+	u64 c_mkfs_segment_size;
 	u32 c_mt_workers;
 #endif
-
 	u32 c_pclusterblks_max, c_pclusterblks_def, c_pclusterblks_packed;
 	u32 c_max_decompressed_extent_bytes;
 	u64 c_unix_timestamp;
diff --git a/lib/compress.c b/lib/compress.c
index 7fef698..f918322 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1255,7 +1255,7 @@ void z_erofs_mt_workfn(struct erofs_work *work, void *tlsp)
 	}
 	sctx->memoff = 0;
 
-	ret = z_erofs_compress_segment(sctx, sctx->seg_idx * cfg.c_segment_size,
+	ret = z_erofs_compress_segment(sctx, sctx->seg_idx * cfg.c_mkfs_segment_size,
 				       EROFS_NULL_ADDR);
 
 out:
@@ -1304,7 +1304,7 @@ int z_erofs_mt_compress(struct z_erofs_compress_ictx *ictx)
 	struct erofs_compress_work *cur, *head = NULL, **last = &head;
 	struct erofs_compress_cfg *ccfg = ictx->ccfg;
 	struct erofs_inode *inode = ictx->inode;
-	int nsegs = DIV_ROUND_UP(inode->i_size, cfg.c_segment_size);
+	int nsegs = DIV_ROUND_UP(inode->i_size, cfg.c_mkfs_segment_size);
 	int i;
 
 	ictx->seg_num = nsegs;
@@ -1338,9 +1338,9 @@ int z_erofs_mt_compress(struct z_erofs_compress_ictx *ictx)
 		if (i == nsegs - 1)
 			cur->ctx.remaining = inode->i_size -
 					      inode->fragment_size -
-					      i * cfg.c_segment_size;
+					      i * cfg.c_mkfs_segment_size;
 		else
-			cur->ctx.remaining = cfg.c_segment_size;
+			cur->ctx.remaining = cfg.c_mkfs_segment_size;
 
 		cur->alg_id = ccfg->handle.alg->id;
 		cur->alg_name = ccfg->handle.alg->name;
@@ -1718,6 +1718,14 @@ 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_dedupe)
+			erofs_warn("multi-threaded dedupe is NOT implemented for now");
+		if (cfg.c_fragments)
+			erofs_warn("multi-threaded fragments is NOT implemented for now");
+		cfg.c_mt_workers = 0;
+	}
+
 	if (cfg.c_mt_workers > 1) {
 		ret = erofs_alloc_workqueue(&z_erofs_mt_ctrl.wq,
 					    cfg.c_mt_workers,
diff --git a/lib/config.c b/lib/config.c
index 2530274..98adaef 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -38,11 +38,6 @@ void erofs_init_configure(void)
 	cfg.c_pclusterblks_max = 1;
 	cfg.c_pclusterblks_def = 1;
 	cfg.c_max_decompressed_extent_bytes = -1;
-#ifdef EROFS_MT_ENABLED
-	cfg.c_segment_size = 16ULL * 1024 * 1024;
-	cfg.c_mt_workers = 1;
-#endif
-
 	erofs_stdout_tty = isatty(STDOUT_FILENO);
 }
 
diff --git a/mkfs/main.c b/mkfs/main.c
index d632f74..9ad213b 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -838,12 +838,6 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 		}
 		cfg.c_pclusterblks_packed = pclustersize_packed >> sbi.blkszbits;
 	}
-#ifdef EROFS_MT_ENABLED
-	if (cfg.c_mt_workers > 1 && (cfg.c_dedupe || cfg.c_fragments)) {
-		erofs_warn("Note that dedupe/fragments are NOT supported in multi-threaded mode for now, resetting --workers=1.");
-		cfg.c_mt_workers = 1;
-	}
-#endif
 	return 0;
 }
 
@@ -954,6 +948,10 @@ static void erofs_mkfs_default_options(void)
 	cfg.c_legacy_compress = false;
 	cfg.c_inline_data = true;
 	cfg.c_xattr_name_filter = true;
+#ifdef EROFS_MT_ENABLED
+	cfg.c_mt_workers = erofs_get_available_processors();
+	cfg.c_mkfs_segment_size = 16ULL * 1024 * 1024;
+#endif
 	sbi.blkszbits = ilog2(min_t(u32, getpagesize(), EROFS_MAX_BLOCK_SIZE));
 	sbi.feature_incompat = EROFS_FEATURE_INCOMPAT_ZERO_PADDING;
 	sbi.feature_compat = EROFS_FEATURE_COMPAT_SB_CHKSUM |
-- 
2.39.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-27  6:26 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-27  6:25 [PATCH] erofs-utils: mkfs: use all available processors by default Gao Xiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).