All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] erofs-utils: move pclustersize to struct z_erofs_compress_sctx
@ 2024-03-21  7:02 Noboru Asai
  2024-03-21  7:09 ` Gao Xiang
  0 siblings, 1 reply; 2+ messages in thread
From: Noboru Asai @ 2024-03-21  7:02 UTC (permalink / raw
  To: hsiangkao, zhaoyifan; +Cc: linux-erofs

With -E(all-)fragments, pclustersize has a different value per segment,
so move it to struct z_erofs_compress_sctx.

Signed-off-by: Noboru Asai <asai@sijam.com>
---
 lib/compress.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/lib/compress.c b/lib/compress.c
index 9eb40b5..0803a63 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -40,7 +40,6 @@ struct z_erofs_extent_item {
 struct z_erofs_compress_ictx {		/* inode context */
 	struct erofs_inode *inode;
 	int fd;
-	unsigned int pclustersize;
 
 	u32 tof_chksum;
 	bool fix_dedupedfrag;
@@ -64,6 +63,7 @@ struct z_erofs_compress_sctx {		/* segment context */
 
 	unsigned int head, tail;
 	erofs_off_t remaining;
+	unsigned int pclustersize;
 	erofs_blk_t blkaddr;		/* pointing to the next blkaddr */
 	u16 clusterofs;
 
@@ -479,7 +479,7 @@ static bool z_erofs_fixup_deduped_fragment(struct z_erofs_compress_sctx *ctx,
 
 	/* try to fix again if it gets larger (should be rare) */
 	if (inode->fragment_size < newsize) {
-		ictx->pclustersize = min_t(erofs_off_t,
+		ctx->pclustersize = min_t(erofs_off_t,
 				z_erofs_get_max_pclustersize(inode),
 				roundup(newsize - inode->fragment_size,
 					erofs_blksiz(sbi)));
@@ -519,12 +519,12 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
 	unsigned int compressedsize;
 	int ret;
 
-	if (len <= ictx->pclustersize) {
+	if (len <= ctx->pclustersize) {
 		if (!final || !len)
 			return 1;
 		if (may_packing) {
 			if (inode->fragment_size && !ictx->fix_dedupedfrag) {
-				ictx->pclustersize = roundup(len, blksz);
+				ctx->pclustersize = roundup(len, blksz);
 				goto fix_dedupedfrag;
 			}
 			e->length = len;
@@ -536,7 +536,7 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
 
 	e->length = min(len, cfg.c_max_decompressed_extent_bytes);
 	ret = erofs_compress_destsize(h, ctx->queue + ctx->head,
-				      &e->length, dst, ictx->pclustersize);
+				      &e->length, dst, ctx->pclustersize);
 	if (ret <= 0) {
 		erofs_err("failed to compress %s: %s", inode->i_srcpath,
 			  erofs_strerror(ret));
@@ -573,7 +573,7 @@ nocompression:
 		e->compressedblks = 1;
 		e->raw = true;
 	} else if (may_packing && len == e->length &&
-		   compressedsize < ictx->pclustersize &&
+		   compressedsize < ctx->pclustersize &&
 		   (!inode->fragment_size || ictx->fix_dedupedfrag)) {
 frag_packing:
 		ret = z_erofs_pack_fragments(inode, ctx->queue + ctx->head,
@@ -612,7 +612,7 @@ frag_packing:
 		if (may_packing && len == e->length &&
 		    (compressedsize & (blksz - 1)) &&
 		    ctx->tail < Z_EROFS_COMPR_QUEUE_SZ) {
-			ictx->pclustersize = roundup(compressedsize, blksz);
+			ctx->pclustersize = roundup(compressedsize, blksz);
 			goto fix_dedupedfrag;
 		}
 
@@ -1202,6 +1202,7 @@ void z_erofs_mt_workfn(struct erofs_work *work, void *tlsp)
 		goto out;
 	}
 	sctx->memoff = 0;
+	sctx->pclustersize = z_erofs_get_max_pclustersize(sctx->ictx->inode);
 
 	ret = z_erofs_compress_segment(sctx, sctx->seg_idx * cfg.c_segment_size,
 				       EROFS_NULL_ADDR);
@@ -1460,7 +1461,6 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd)
 	}
 
 	ctx.inode = inode;
-	ctx.pclustersize = z_erofs_get_max_pclustersize(inode);
 	ctx.metacur = compressmeta + Z_EROFS_LEGACY_MAP_HEADER_SIZE;
 	init_list_head(&ctx.extents);
 	ctx.fd = fd;
@@ -1500,6 +1500,7 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd)
 		sctx.seg_num = 1;
 		sctx.seg_idx = 0;
 		sctx.pivot = &dummy_pivot;
+		sctx.pclustersize = z_erofs_get_max_pclustersize(inode);
 
 		ret = z_erofs_compress_segment(&sctx, -1, blkaddr);
 		if (ret)
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] erofs-utils: move pclustersize to struct z_erofs_compress_sctx
  2024-03-21  7:02 [PATCH] erofs-utils: move pclustersize to struct z_erofs_compress_sctx Noboru Asai
@ 2024-03-21  7:09 ` Gao Xiang
  0 siblings, 0 replies; 2+ messages in thread
From: Gao Xiang @ 2024-03-21  7:09 UTC (permalink / raw
  To: Noboru Asai, zhaoyifan; +Cc: linux-erofs



On 2024/3/21 15:02, Noboru Asai wrote:
> With -E(all-)fragments, pclustersize has a different value per segment,
> so move it to struct z_erofs_compress_sctx.
> 
> Signed-off-by: Noboru Asai <asai@sijam.com>

Thanks, I think it's a good change for the later fragment multi-threaded
compression.

Thanks,
Gao XIang

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-21  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-21  7:02 [PATCH] erofs-utils: move pclustersize to struct z_erofs_compress_sctx Noboru Asai
2024-03-21  7:09 ` Gao Xiang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.