[PATCH] erofs-utils: mkfs: fix `-Eall-fragments` for multi-threaded compression

Gao Xiang hsiangkao at linux.alibaba.com
Sat Oct 12 14:52:13 AEDT 2024


If `-Eall-fragments` is specified when multi-threaded compression is
enabled, it should only apply to the packed inode instead of other
real inodes for now.

Fixes: 10c1590c0920 ("erofs-utils: enable multi-threaded support for `-Eall-fragments`")
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 lib/compress.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/lib/compress.c b/lib/compress.c
index 17e7112..f441214 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1453,12 +1453,8 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos)
 	inode->idata_size = 0;
 	inode->fragment_size = 0;
 
-	if (z_erofs_mt_enabled) {
-		ictx = malloc(sizeof(*ictx));
-		if (!ictx)
-			return ERR_PTR(-ENOMEM);
-		ictx->fd = dup(fd);
-	} else {
+	if (!z_erofs_mt_enabled ||
+	    (cfg.c_all_fragments && !erofs_is_packed_inode(inode))) {
 #ifdef EROFS_MT_ENABLED
 		pthread_mutex_lock(&g_ictx.mutex);
 		if (g_ictx.seg_num)
@@ -1468,6 +1464,11 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos)
 #endif
 		ictx = &g_ictx;
 		ictx->fd = fd;
+	} else {
+		ictx = malloc(sizeof(*ictx));
+		if (!ictx)
+			return ERR_PTR(-ENOMEM);
+		ictx->fd = dup(fd);
 	}
 
 	ictx->ccfg = &erofs_ccfg[inode->z_algorithmtype[0]];
-- 
2.43.5



More information about the Linux-erofs mailing list