erofs-utils: move pclustersize to struct z_erofs_compress_sctx
PATCH 1/1 erofs-utils: move pclustersize to struct z_erofs_compress_sctx
With -E(all-)fragments, pclustersize has a different value per segment, so move it to struct z_erofs_compress_sctx.
Signed-off-by Noboru Asai <[email protected]>
--- lib/compress.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
lib/compress.c +9 -8
@@ -40,7 +40,6 @@ struct z_erofs_extent_item {struct z_erofs_compress_ictx {/* inode context */ struct erofs_inode *inode;int fd; -unsigned int pclustersize;u32 tof_chksum;bool fix_dedupedfrag;
@@ -64,6 +63,7 @@ struct z_erofs_compress_sctx { /* segment context */unsigned int head, tail;erofs_off_t remaining; +unsigned int pclustersize;erofs_blk_t blkaddr;/* pointing to the next blkaddr */ u16 clusterofs;
@@ -479,7 +479,7 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_compress_sctx *ctx,/* try to fix again if it gets larger (should be rare) */ if (inode->fragment_size < newsize) { - ictx->pclustersize =min_t (erofs_off_t, + ctx->pclustersize =min_t (erofs_off_t,z_erofs_get_max_pclustersize (inode),roundup (newsize - inode->fragment_size,erofs_blksiz (sbi)));
@@ -519,12 +519,12 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,unsigned int compressedsize;int ret; -if (len <= ictx->pclustersize) { +if (len <= ctx->pclustersize) {if (!final || !len)return 1 ;if (may_packing) {if (inode->fragment_size && !ictx->fix_dedupedfrag) { - ictx->pclustersize =roundup (len, blksz); + ctx->pclustersize =roundup (len, blksz); goto fix_dedupedfrag; } e->length = len;
@@ -536,7 +536,7 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx, e->length =min (len, cfg.c_max_decompressed_extent_bytes); ret =erofs_compress_destsize (h, ctx->queue + ctx->head, - &e->length, dst, ictx->pclustersize); + &e->length, dst, ctx->pclustersize);if (ret <=0 ) {erofs_err ("failed to compress %s: %s" , inode->i_srcpath,erofs_strerror (ret));
@@ -573,7 +573,7 @@ nocompression: e->compressedblks =1 ; e->raw = true; }else if (may_packing && len == e->length && - compressedsize < ictx->pclustersize && + compressedsize < ctx->pclustersize && (!inode->fragment_size || ictx->fix_dedupedfrag)) { frag_packing: ret = z_erofs_pack_fragments(inode, ctx->queue + ctx->head,
@@ -612,7 +612,7 @@ frag_packing:if (may_packing && len == e->length && (compressedsize & (blksz -1 )) && ctx->tail <Z_EROFS_COMPR_QUEUE_SZ ) { - ictx->pclustersize =roundup (compressedsize, blksz); + ctx->pclustersize =roundup (compressedsize, blksz); goto fix_dedupedfrag; }
@@ -1202,6 +1202,7 @@ void z_erofs_mt_workfn(struct erofs_work *work, void *tlsp) goto out; } sctx->memoff =0 ; + sctx->pclustersize =z_erofs_get_max_pclustersize (sctx->ictx->inode); ret =z_erofs_compress_segment (sctx, sctx->seg_idx * cfg.c_segment_size,EROFS_NULL_ADDR );
@@ -1460,7 +1461,6 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd) } ctx.inode = inode; - ctx.pclustersize =z_erofs_get_max_pclustersize (inode); ctx.metacur = compressmeta +Z_EROFS_LEGACY_MAP_HEADER_SIZE ;init_list_head (&ctx.extents); ctx.fd = fd;
@@ -1500,6 +1500,7 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd) sctx.seg_num =1 ; sctx.seg_idx =0 ; sctx.pivot = &dummy_pivot; + sctx.pclustersize =z_erofs_get_max_pclustersize (inode); ret =z_erofs_compress_segment (&sctx,-1 , blkaddr);if (ret)
Signature · 1 line
2.44.0
Quoted 4 lines · Noboru Asai
With -E(all-)fragments, pclustersize has a different value per segment, so move it to struct
z_erofs_compress_sctx.Signed-off-by Noboru Asai <[email protected]>
Thanks, I think it's a good change for the later fragment multi-threaded compression.
Thanks,
Gao XIang