linux-erofs.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Gao Xiang <hsiangkao@linux.alibaba.com>
To: linux-erofs@lists.ozlabs.org
Cc: Gao Xiang <hsiangkao@linux.alibaba.com>
Subject: [PATCH] erofs-utils: mkfs: use all available processors by default
Date: Sat, 27 Apr 2024 14:25:52 +0800	[thread overview]
Message-ID: <20240427062552.744810-1-hsiangkao@linux.alibaba.com> (raw)

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


                 reply	other threads:[~2024-04-27  6:26 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240427062552.744810-1-hsiangkao@linux.alibaba.com \
    --to=hsiangkao@linux.alibaba.com \
    --cc=linux-erofs@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).