Skip to contentSkip to conversation

erofs-utils: mkfs: enable block map chunk format

PATCH In review Gao Xiang 2 participants 3 messages Nov 17, 2021 – Nov 18, 2021 Library code

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: mkfs: enable block map chunk format

From: Gao Xiang <[email protected]>

Use 4-byte block map format by default unless a blob device is given or chunk index format is forcely specified.

---
 include/erofs/config.h |  8 +++++++-
 lib/blobchunk.c        | 12 +++++++-----
 lib/inode.c            |  5 ++++-
 man/mkfs.erofs.1       |  6 ++++++
 mkfs/main.c            | 20 ++++++++++++++++++++
 5 files changed, 44 insertions(+), 7 deletions(-)
include/erofs/config.h +7 -1
index 8d459c692dac..2040dc6ff154 100644
@@ -27,6 +27,11 @@ enum {
 	FORCE_INODE_EXTENDED,
 };
 
+enum {
+	FORCE_INODE_BLOCK_MAP = 1,
+	FORCE_INODE_CHUNK_INDEXES,
+};
+
 enum {
 	TIMESTAMP_NONE,
 	TIMESTAMP_FIXED,
@@ -55,7 +60,8 @@ struct erofs_configure {
 	char *c_compress_hints_file;
 	char *c_compr_alg_master;
 	int c_compr_level_master;
-	int c_force_inodeversion;
+	char c_force_inodeversion;
+	char c_force_chunkformat;
 	/* < 0, xattr disabled and INT_MAX, always use inline xattrs */
 	int c_inline_xattr_tolerance;
 
lib/blobchunk.c +7 -5
index a10ca8cc8750..5cbb8315b277 100644
@@ -110,16 +110,18 @@ int erofs_blob_write_chunk_indexes(struct erofs_inode *inode,
 	bool first_extent = true;
 	erofs_blk_t base_blkaddr = 0;
 
+	if (multidev) {
+		idx.device_id = 1;
+		inode->u.chunkformat |= EROFS_CHUNK_FORMAT_INDEXES;
+	} else {
+		base_blkaddr = remapped_base;
+	}
+
 	if (inode->u.chunkformat & EROFS_CHUNK_FORMAT_INDEXES)
 		unit = sizeof(struct erofs_inode_chunk_index);
 	else
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;
 
-	if (multidev)
-		idx.device_id = 1;
-	else
-		base_blkaddr = remapped_base;
-
 	for (dst = src = 0; dst < inode->extent_isize;
 	     src += sizeof(void *), dst += unit) {
 		struct erofs_blobchunk *chunk;
lib/inode.c +4 -1
index 855a0383f31e..5cbfc780e45f 100644
@@ -390,7 +390,10 @@ int erofs_write_file(struct erofs_inode *inode)
 
 	if (cfg.c_chunkbits) {
 		inode->u.chunkbits = cfg.c_chunkbits;
-		inode->u.chunkformat = EROFS_CHUNK_FORMAT_INDEXES;
+		/* chunk indexes when explicitly specified */
+		inode->u.chunkformat = 0;
+		if (cfg.c_force_chunkformat == FORCE_INODE_CHUNK_INDEXES)
+			inode->u.chunkformat = EROFS_CHUNK_FORMAT_INDEXES;
 		return erofs_blob_write_chunked_file(inode);
 	}
 
man/mkfs.erofs.1 +6 -0
index 71a26d88121a..f2e7d690c215 100644
@@ -51,6 +51,12 @@ Forcely generate compact inodes (32-byte inodes) to output.
 .TP
 .BI force-inode-extended
 Forcely generate extended inodes (64-byte inodes) to output.
+.TP
+.BI force-inode-blockmap
+Forcely generate inode chunk format in 4-byte block address array.
+.TP
+.BI force-chunk-indexes
+Forcely generate inode chunk format in 8-byte chunk indexes (with device id).
 .RE
 .TP
 .BI "\-T " #
mkfs/main.c +20 -0
index 29042c801794..58a64411b868 100644
@@ -174,6 +174,18 @@ static int parse_extended_opts(const char *opts)
 				return -EINVAL;
 			cfg.c_noinline_data = true;
 		}
+
+		if (MATCH_EXTENTED_OPT("force-inode-blockmap", token, keylen)) {
+			if (vallen)
+				return -EINVAL;
+			cfg.c_force_chunkformat = FORCE_INODE_BLOCK_MAP;
+		}
+
+		if (MATCH_EXTENTED_OPT("force-chunk-indexes", token, keylen)) {
+			if (vallen)
+				return -EINVAL;
+			cfg.c_force_chunkformat = FORCE_INODE_CHUNK_INDEXES;
+		}
 	}
 	return 0;
 }
@@ -369,6 +381,14 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])
 		erofs_err("--blobdev must be used together with --chunksize");
 		return -EINVAL;
 	}
+
+	/* TODO: can be implemented with (deviceslot) mapped_blkaddr */
+	if (cfg.c_blobdev_path &&
+	    cfg.c_force_chunkformat == FORCE_INODE_BLOCK_MAP) {
+		erofs_err("--blobdev cannot work with block map currently");
+		return -EINVAL;
+	}
+
 	cfg.c_img_path = strdup(argv[optind++]);
 	if (!cfg.c_img_path)
 		return -ENOMEM;
Signature · 1 line
2.20.1
author
#1 lore raw

PATCH 2/2 erofs-utils: manpage: document `noinline_data' extended option

From: Gao Xiang <[email protected]>

Add documentation for `noinline_data' as well.

Fixes 60549d52c3b6 ("erofs-utils: add "noinline_data" extended option")
---
 man/mkfs.erofs.1 | 3 +++
 1 file changed, 3 insertions(+)
man/mkfs.erofs.1 +3 -0
index f2e7d690c215..9c7788efbfec 100644
@@ -52,6 +52,9 @@ Forcely generate compact inodes (32-byte inodes) to output.
 .BI force-inode-extended
 Forcely generate extended inodes (64-byte inodes) to output.
 .TP
+.BI noinline_data
+Don't inline regular files for FSDAX support (Linux v5.15+).
+.TP
 .BI force-inode-blockmap
 Forcely generate inode chunk format in 4-byte block address array.
 .TP
Signature · 1 line
2.20.1
Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] erofs-utils: manpage: document `noinline_data' extended option

Quoted 15 lines · On Wed, 17 Nov 2021 09:57:57 +0800 Gao Xiang <[email protected]> wrote:

From: Gao Xiang <[email protected]>

Add documentation for `noinline_data' as well.

Fixes 60549d52c3b6 ("erofs-utils: add "noinline_data" extended option")
---
 man/mkfs.erofs.1 | 3 +++
 1 file changed, 3 insertions(+)
man/mkfs.erofs.1 +0 -0
index f2e7d690c215..9c7788efbfec 100644

man/mkfs.erofs.1 Forcely generate compact inodes (32-byte inodes) to output. · line 57

Quoted 6 lines
man/mkfs.erofs.1 +3 -0
@@ -52,6 +52,9 @@ Forcely generate compact inodes (32-byte inodes) to output.
 .BI force-inode-extended
 Forcely generate extended inodes (64-byte inodes) to output.
 .TP
+.BI noinline_data
+Don't inline regular files for FSDAX support (Linux v5.15+).
+.TP

Thanks.

Quoted 3 lines
man/mkfs.erofs.1 +0 -0
 .BI force-inode-blockmap
 Forcely generate inode chunk format in 4-byte block address array.
 .TP