From 882ad1c3157f7544bd4d004e3b6d744f0cbe3ffc Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Sat, 12 Oct 2024 11:52:13 +0800 Subject: erofs-utils: mkfs: fix `-Eall-fragments` for multi-threaded compression 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 Link: https://lore.kernel.org/r/20241012035213.3729725-1-hsiangkao@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 5d6fb2a..cbd4620 100644 --- a/lib/compress.c +++ b/lib/compress.c @@ -1456,12 +1456,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) @@ -1471,6 +1467,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]]; -- cgit 1.2.3-korg