[PATCH 2/3] erofs-utils: skip the redundant write for ztailpacking block
Noboru Asai
asai at sijam.com
Thu Apr 18 15:52:30 AEST 2024
z_erofs_merge_segment() doesn't consider the ztailpacking block in the
extent list and unnecessarily writes it back to the disk. This patch
fixes this issue by changing compressdblks to 0.
And the value of blkaddr corresponding to the ztailpacking block
in the extent list is handled in z_erofs_write_extent function.
* legacy: 0 (fragmentoff >> 32)
* compact: -1 (EROFS_NULL_ADDR)
Signed-off-by: Noboru Asai <asai at sijam.com>
---
lib/compress.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/lib/compress.c b/lib/compress.c
index dfe59da..d745e5b 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -555,24 +555,19 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
if (may_inline && (erofs_get_lowest_offset(inode) + len < blksz)) {
ret = z_erofs_fill_inline_data(inode,
ctx->queue + ctx->head, len, true);
+ e->compressedblks = 0;
} else {
may_inline = false;
may_packing = false;
nocompression:
/* TODO: reset clusterofs to 0 if permitted */
ret = write_uncompressed_extent(ctx, len, dst);
+ e->compressedblks = 1;
}
if (ret < 0)
return ret;
e->length = ret;
-
- /*
- * XXX: For now, we have to leave `ctx->compressedblk = 1'
- * since there is no way to generate compressed indexes after
- * the time that ztailpacking is decided.
- */
- e->compressedblks = 1;
e->raw = true;
} else if (may_packing && len == e->length &&
compressedsize < ctx->pclustersize &&
@@ -601,7 +596,7 @@ frag_packing:
compressedsize, false);
if (ret < 0)
return ret;
- e->compressedblks = 1;
+ e->compressedblks = 0;
e->raw = false;
} else {
unsigned int tailused, padding;
@@ -1151,6 +1146,9 @@ int z_erofs_merge_segment(struct z_erofs_compress_ictx *ictx,
if (ei->e.blkaddr != EROFS_NULL_ADDR) /* deduped extents */
continue;
+ if (!ei->e.compressedblks)
+ continue;
+
ei->e.blkaddr = sctx->blkaddr;
sctx->blkaddr += ei->e.compressedblks;
@@ -1358,10 +1356,6 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd, u64 fpos)
compressed_blocks = sctx.blkaddr - blkaddr;
}
- /* fall back to no compression mode */
- DBG_BUGON(compressed_blocks < !!inode->idata_size);
- compressed_blocks -= !!inode->idata_size;
-
/* generate an extent for the deduplicated fragment */
if (inode->fragment_size && !ctx.fragemitted) {
struct z_erofs_extent_item *ei;
--
2.44.0
More information about the Linux-erofs
mailing list