erofs-utils: mkfs: use all available processors by default
PATCH 1/1 erofs-utils: mkfs: use all available processors by default
Fulfill the needs of most users.
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/config.h | 3 +-- lib/compress.c | 16 ++++++++++++---- lib/config.c | 5 ----- mkfs/main.c | 10 ++++------ 4 files changed, 17 insertions(+), 17 deletions(-)
include/erofs/config.h +1 -2
@@ -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;
lib/compress.c +12 -4
@@ -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,
lib/config.c +0 -5
@@ -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 ); }
mkfs/main.c +4 -6
@@ -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 |
Signature · 1 line
2.39.3