From 72203592c5e9e84e6788a850db21caccb4e1b18e Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sun, 6 Apr 2025 02:57:04 +0800 Subject: [PATCH] erofs-utils: lib: only apply `fix_dedupedfrag` to the last segment Only the segment containing the fragment needs to be fixed. Fixes: b8cc6a36b560 ("erofs-utils: mkfs: implement multi-threaded fragments") Signed-off-by: Gao Xiang Link: https://lore.kernel.org/r/20250405185707.3202298-1-hsiangkao@linux.alibaba.com --- lib/compress.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/compress.c b/lib/compress.c index 5ecb9c8..4b966d8 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -729,6 +729,7 @@ fix_dedupedfrag: static int z_erofs_compress_one(struct z_erofs_compress_sctx *ctx) { struct z_erofs_compress_ictx *ictx = ctx->ictx; + bool tsg = ctx->seg_idx + 1 >= ictx->seg_num; struct z_erofs_extent_item *ei; while (ctx->tail > ctx->head) { @@ -753,7 +754,7 @@ static int z_erofs_compress_one(struct z_erofs_compress_sctx *ctx) } ctx->pivot = ei; - if (ictx->fix_dedupedfrag && !ictx->fragemitted && + if (tsg && ictx->fix_dedupedfrag && !ictx->fragemitted && z_erofs_fixup_deduped_fragment(ctx)) break; -- 2.34.1