aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYue Hu <huyue2@coolpad.com>2022-12-09 11:53:37 +0800
committerGao Xiang <hsiangkao@linux.alibaba.com>2022-12-22 10:58:19 +0800
commit1ecb192691d59061bd28f17e94589d1034deaef7 (patch)
tree0f147c2b7fcdfd19cc4730b4b0951b70c29126fd
parent4aa585c21e32f5a2ed6582ee4dfcfdbfdde0571b (diff)
downloaderofs-utils-1ecb192691d59061bd28f17e94589d1034deaef7.tar.gz
erofs-utils: do not deduplicate compressed data for packed inode
Packed inode is composed of fragments which have already been deduplicated before. Signed-off-by: Yue Hu <huyue2@coolpad.com> Link: https://lore.kernel.org/r/20221209035337.26998-1-zbestahu@gmail.com Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
-rw-r--r--lib/compress.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/lib/compress.c b/lib/compress.c
index 4fced9a..2987b10 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -174,6 +174,13 @@ static int z_erofs_compress_dedupe(struct z_erofs_vle_compress_ctx *ctx,
struct erofs_inode *inode = ctx->inode;
int ret = 0;
+ /*
+ * No need dedupe for packed inode since it is composed of
+ * fragments which have already been deduplicated.
+ */
+ if (erofs_is_packed_inode(inode))
+ goto out;
+
do {
struct z_erofs_dedupe_ctx dctx = {
.start = ctx->queue + ctx->head - ({ int rc;
@@ -238,6 +245,7 @@ static int z_erofs_compress_dedupe(struct z_erofs_vle_compress_ctx *ctx,
}
} while (*len);
+out:
z_erofs_write_indexes(ctx);
return ret;
}
@@ -369,12 +377,13 @@ static int vle_compress_one(struct z_erofs_vle_compress_ctx *ctx)
char *const dst = dstbuf + EROFS_BLKSIZ;
struct erofs_compress *const h = &compresshandle;
unsigned int len = ctx->tail - ctx->head;
+ bool is_packed_inode = erofs_is_packed_inode(inode);
bool final = !ctx->remaining;
int ret;
while (len) {
bool may_packing = (cfg.c_fragments && final &&
- !erofs_is_packed_inode(inode));
+ !is_packed_inode);
bool may_inline = (cfg.c_ztailpacking && final &&
!may_packing);
bool fix_dedupedfrag = ctx->fix_dedupedfrag;
@@ -513,7 +522,7 @@ frag_packing:
}
ctx->e.partial = false;
ctx->e.blkaddr = ctx->blkaddr;
- if (!may_inline && !may_packing)
+ if (!may_inline && !may_packing && !is_packed_inode)
(void)z_erofs_dedupe_insert(&ctx->e,
ctx->queue + ctx->head);
ctx->blkaddr += ctx->e.compressedblks;