[PATCH 1/3] erofs-utils: mkfs: eliminate redundant FD duplication
Gao Xiang
hsiangkao at linux.alibaba.com
Sat Jun 14 12:32:57 AEST 2025
Removing unnecessary FD duplication prevents EMFILE errors.
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
lib/compress.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/compress.c b/lib/compress.c
index 73554d6..2bafb0e 100644
--- a/lib/compress.c
+++ b/lib/compress.c
@@ -1720,7 +1720,6 @@ int erofs_mt_write_compressed_file(struct z_erofs_compress_ictx *ictx)
ret = erofs_commit_compressed_file(ictx, bh, pstart - ptotal, ptotal);
out:
- close(ictx->fd);
free(ictx);
return ret;
}
@@ -1791,13 +1790,12 @@ void *erofs_begin_compressed_file(struct erofs_inode *inode, int fd, u64 fpos)
pthread_mutex_unlock(&g_ictx.mutex);
#endif
ictx = &g_ictx;
- ictx->fd = fd;
} else {
ictx = malloc(sizeof(*ictx));
if (!ictx)
return ERR_PTR(-ENOMEM);
- ictx->fd = dup(fd);
}
+ ictx->fd = fd;
ictx->ccfg = &sbi->zmgr->ccfg[inode->z_algorithmtype[0]];
inode->z_algorithmtype[0] = ictx->ccfg->algorithmtype;
--
2.43.5
More information about the Linux-erofs
mailing list