erofs-utils: lib: only apply `fix_dedupedfrag` to the last segment
authorGao Xiang <hsiangkao@linux.alibaba.com>
Sat, 5 Apr 2025 18:57:04 +0000 (02:57 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Sat, 5 Apr 2025 19:29:34 +0000 (03:29 +0800)
Only the segment containing the fragment needs to be fixed.

Fixes: b8cc6a36b560 ("erofs-utils: mkfs: implement multi-threaded fragments")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250405185707.3202298-1-hsiangkao@linux.alibaba.com
lib/compress.c

index 5ecb9c853b184ee7a3c5271bf938fc8241f99ded..4b966d828ba7822645d820a3d391415fe369392f 100644 (file)
@@ -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;