erofs-utils: mkfs: keep one-block uncompressed data for deduplication
authorGao Xiang <hsiangkao@linux.alibaba.com>
Tue, 21 Jan 2025 16:56:22 +0000 (00:56 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Thu, 6 Feb 2025 05:01:10 +0000 (13:01 +0800)
Otherwise, the deduplication rate will be impacted, but it doesn't
matter since `-Ededupe` is still single-threaded.

Fixes: 341d23a878a2 ("erofs-utils: mkfs: speed up uncompressed data handling")
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20250121165622.2095470-1-hsiangkao@linux.alibaba.com
lib/compress.c

index cd6ef2ffa407fa14872398c9d0b0009852bd7bfb..1f2807b622820530723ce97ed61e38b3eae68915 100644 (file)
@@ -376,6 +376,7 @@ out:
        return 0;
 }
 
+/* TODO: reset clusterofs to 0 if permitted */
 static int write_uncompressed_block(struct z_erofs_compress_sctx *ctx,
                                    unsigned int len, char *dst)
 {
@@ -616,9 +617,11 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
                        may_packing = false;
                        e->length = min_t(u32, e->length, ret);
 nocompression:
-                       /* TODO: reset clusterofs to 0 if permitted */
-                       ret = write_uncompressed_extents(ctx, len,
-                                                        e->length, dst);
+                       if (cfg.c_dedupe)
+                               ret = write_uncompressed_block(ctx, len, dst);
+                       else
+                               ret = write_uncompressed_extents(ctx, len,
+                                                       e->length, dst);
                        if (ret < 0)
                                return ret;
                }