[PATCH 1/2] erofs-utils: lib: migrate `c_force_inodeversion`
Gao Xiang
hsiangkao at linux.alibaba.com
Tue Sep 9 19:40:12 AEST 2025
Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
include/erofs/config.h | 7 -------
include/erofs/importer.h | 6 ++++++
lib/config.c | 1 -
lib/inode.c | 20 +++++++++++---------
mkfs/main.c | 9 +++++----
5 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/include/erofs/config.h b/include/erofs/config.h
index 0312909..6554ad2 100644
--- a/include/erofs/config.h
+++ b/include/erofs/config.h
@@ -15,12 +15,6 @@ extern "C"
#include "defs.h"
#include "err.h"
-
-enum {
- FORCE_INODE_COMPACT = 1,
- FORCE_INODE_EXTENDED,
-};
-
enum {
FORCE_INODE_BLOCK_MAP = 1,
FORCE_INODE_CHUNK_INDEXES,
@@ -73,7 +67,6 @@ struct erofs_configure {
char *c_blobdev_path;
char *c_compress_hints_file;
struct erofs_compr_opts c_compr_opts[EROFS_MAX_COMPR_CFGS];
- char c_force_inodeversion;
char c_force_chunkformat;
u8 c_mkfs_metabox_algid;
/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
diff --git a/include/erofs/importer.h b/include/erofs/importer.h
index 28d29bd..85e3a50 100644
--- a/include/erofs/importer.h
+++ b/include/erofs/importer.h
@@ -12,6 +12,11 @@ extern "C"
#include "internal.h"
+enum {
+ EROFS_FORCE_INODE_COMPACT = 1,
+ EROFS_FORCE_INODE_EXTENDED,
+};
+
struct erofs_importer_params {
char *source;
u32 mt_async_queue_limit;
@@ -20,6 +25,7 @@ struct erofs_importer_params {
u32 uid_offset;
u32 gid_offset;
u32 fsalignblks;
+ char force_inodeversion;
bool no_datainline;
bool hard_dereference;
bool ovlfs_strip;
diff --git a/lib/config.c b/lib/config.c
index c5e6757..28bfc2f 100644
--- a/lib/config.c
+++ b/lib/config.c
@@ -30,7 +30,6 @@ void erofs_init_configure(void)
cfg.c_version = PACKAGE_VERSION;
cfg.c_dry_run = false;
cfg.c_ignore_mtime = false;
- cfg.c_force_inodeversion = 0;
cfg.c_inline_xattr_tolerance = 2;
cfg.c_unix_timestamp = -1;
cfg.c_max_decompressed_extent_bytes = -1;
diff --git a/lib/inode.c b/lib/inode.c
index 7ee6b3d..0bb82f8 100644
--- a/lib/inode.c
+++ b/lib/inode.c
@@ -1073,10 +1073,10 @@ out:
return 0;
}
-static bool erofs_should_use_inode_extended(struct erofs_inode *inode,
- const char *path)
+static bool erofs_should_use_inode_extended(struct erofs_importer *im,
+ struct erofs_inode *inode, const char *path)
{
- if (cfg.c_force_inodeversion == FORCE_INODE_EXTENDED)
+ if (im->params->force_inodeversion == EROFS_FORCE_INODE_EXTENDED)
return true;
if (inode->i_size > UINT_MAX)
return true;
@@ -1206,8 +1206,10 @@ int __erofs_fill_inode(struct erofs_importer *im, struct erofs_inode *inode,
static int erofs_fill_inode(struct erofs_importer *im, struct erofs_inode *inode,
struct stat *st, const char *path)
{
- int err = __erofs_fill_inode(im, inode, st, path);
+ const struct erofs_importer_params *params = im->params;
+ int err;
+ err = __erofs_fill_inode(im, inode, st, path);
if (err)
return err;
@@ -1239,8 +1241,8 @@ static int erofs_fill_inode(struct erofs_importer *im, struct erofs_inode *inode
return -ENOMEM;
}
- if (erofs_should_use_inode_extended(inode, path)) {
- if (cfg.c_force_inodeversion == FORCE_INODE_COMPACT) {
+ if (erofs_should_use_inode_extended(im, inode, path)) {
+ if (params->force_inodeversion == EROFS_FORCE_INODE_COMPACT) {
erofs_err("file %s cannot be in compact form",
inode->i_srcpath);
return -EINVAL;
@@ -1813,7 +1815,7 @@ static int erofs_mkfs_handle_inode(struct erofs_importer *im,
static int erofs_rebuild_handle_inode(struct erofs_importer *im,
struct erofs_inode *inode, bool incremental)
{
- struct erofs_importer_params *params = im->params;
+ const struct erofs_importer_params *params = im->params;
char *trimmed;
int ret;
@@ -1822,8 +1824,8 @@ static int erofs_rebuild_handle_inode(struct erofs_importer *im,
erofs_update_progressinfo("Processing %s ...", trimmed);
free(trimmed);
- if (erofs_should_use_inode_extended(inode, inode->i_srcpath)) {
- if (cfg.c_force_inodeversion == FORCE_INODE_COMPACT) {
+ if (erofs_should_use_inode_extended(im, inode, inode->i_srcpath)) {
+ if (params->force_inodeversion == EROFS_FORCE_INODE_COMPACT) {
erofs_err("file %s cannot be in compact form",
inode->i_srcpath);
return -EINVAL;
diff --git a/mkfs/main.c b/mkfs/main.c
index 28588db..4f52656 100644
--- a/mkfs/main.c
+++ b/mkfs/main.c
@@ -416,7 +416,8 @@ static struct {
static bool mkfs_no_datainline;
-static int parse_extended_opts(const char *opts)
+static int parse_extended_opts(struct erofs_importer_params *params,
+ const char *opts)
{
#define MATCH_EXTENTED_OPT(opt, token, keylen) \
(keylen == strlen(opt) && !memcmp(token, opt, keylen))
@@ -461,12 +462,12 @@ static int parse_extended_opts(const char *opts)
if (MATCH_EXTENTED_OPT("force-inode-compact", token, keylen)) {
if (vallen)
return -EINVAL;
- cfg.c_force_inodeversion = FORCE_INODE_COMPACT;
+ params->force_inodeversion = EROFS_FORCE_INODE_COMPACT;
cfg.c_ignore_mtime = true;
} else if (MATCH_EXTENTED_OPT("force-inode-extended", token, keylen)) {
if (vallen)
return -EINVAL;
- cfg.c_force_inodeversion = FORCE_INODE_EXTENDED;
+ params->force_inodeversion = EROFS_FORCE_INODE_EXTENDED;
} else if (MATCH_EXTENTED_OPT("nosbcrc", token, keylen)) {
if (vallen)
return -EINVAL;
@@ -1011,7 +1012,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
break;
case 'E':
- opt = parse_extended_opts(optarg);
+ opt = parse_extended_opts(params, optarg);
if (opt)
return opt;
break;
--
2.43.5
More information about the Linux-erofs
mailing list