erofs-utils: fix reproducible builds for multi-threaded libdeflate
PATCH 1/2 erofs-utils: fix reproducible builds for multi-threaded libdeflate
last_uncompressed_size should be reset on the basis of segments.
Fixes 830b27bc2334 ("erofs-utils: mkfs: introduce inner-file multi-threaded compression")
Signed-off-by Gao Xiang <[email protected]>
--- lib/compress.c | 2 +- lib/compressor.c | 6 +++++ lib/compressor.h | 2 ++ lib/compressor_libdeflate.c | 46 +++++++++++++++++++++++++++---------- 4 files changed, 43 insertions(+), 13 deletions(-)
lib/compress.c +1 -1
@@ -1245,7 +1245,7 @@ void z_erofs_mt_workfn(struct erofs_work *work, void *tlsp) sctx->queue = tls->queue; sctx->destbuf = tls->destbuf; sctx->chandle = &tls->ccfg[cwork->alg_id].handle; - +erofs_compressor_reset (sctx->chandle); sctx->membuf =malloc (round_up (sctx->remaining,erofs_blksiz (sbi)));if (!sctx->membuf) { ret = -ENOMEM ;
lib/compressor.c +6 -0
@@ -155,3 +155,9 @@ int erofs_compressor_exit(struct erofs_compress *c)return c->alg->c->exit (c);return 0 ; } + +void erofs_compressor_reset (struct erofs_compress *c) +{ +if (c->alg && c->alg->c->reset) + c->alg->c->reset (c); +}
lib/compressor.h +2 -0
@@ -19,6 +19,7 @@ struct erofs_compressor {int (*init)(struct erofs_compress *c);int (*exit)(struct erofs_compress *c); +void (*reset)(struct erofs_compress *c);int (*setlevel)(struct erofs_compress *c,int compression_level);int (*setdictsize)(struct erofs_compress *c,u32 dict_size);
@@ -63,5 +64,6 @@ int erofs_compress_destsize(const struct erofs_compress *c,int erofs_compressor_init (struct erofs_sb_info *sbi,struct erofs_compress *c,char *alg_name,int compression_level,u32 dict_size);int erofs_compressor_exit (struct erofs_compress *c); +void erofs_compressor_reset (struct erofs_compress *c);#endif
lib/compressor_libdeflate.c +34 -12
102 lines not on this page · raw message
Signature · 1 line
2.43.5
PATCH 2/2 erofs-utils: mkfs: fix -U option
-U <UUID> option cannot work properly now.
Fixes 7550a30c332c ("erofs-utils: enable incremental builds")
Signed-off-by Gao Xiang <[email protected]>
--- mkfs/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)
mkfs/main.c +10 -3
@@ -231,6 +231,8 @@ enum {static unsigned int rebuild_src_count;static LIST_HEAD (rebuild_src_list); +static u8 fixeduuid[16 ]; +static bool valid_fixeduuid;static int erofs_mkfs_feat_set_legacy_compress (bool en,const char *val,unsigned int vallen)
@@ -606,10 +608,11 @@ static int mkfs_parse_options_cfg(int argc, char *argv[]) cfg.c_timeinherit =TIMESTAMP_FIXED ;break ;case 'U' : -if (erofs_uuid_parse (optarg, g_sbi.uuid)) { +if (erofs_uuid_parse (optarg, fixeduuid)) {erofs_err ("invalid UUID %s" , optarg);return -EINVAL ; } + valid_fixeduuid = true;break ;case 2 : opt =erofs_parse_exclude_path (optarg, false);
@@ -1250,8 +1253,6 @@ int main(int argc, char **argv) err =PTR_ERR (sb_bh); goto exit; } -/* generate new UUIDs for clean builds */ -erofs_uuid_generate (g_sbi.uuid); } else {union {struct stat st;
@@ -1274,6 +1275,12 @@ int main(int argc, char **argv) sb_bh =NULL ; } +/* Use the user-defined UUID or generate one for clean builds */ +if (valid_fixeduuid) +memcpy (g_sbi.uuid, fixeduuid,sizeof (g_sbi.uuid)); +else if (!incremental_mode) +erofs_uuid_generate (g_sbi.uuid); +if (tar_mode && !erofstar.index_mode) { err =erofs_diskbuf_init (1 );if (err) {
Signature · 1 line
2.43.5