Skip to contentSkip to conversation

erofs-utils: mkfs: add --hot-file-list for cold-start locality

PATCH New Mengdie Yan 1 participant 5 messages Nov 22 Library code

lore
Share & tools
lore
#0 lore raw

cover erofs-utils: mkfs: add --hot-file-list for cold-start locality

Hi,

When a container image is lazily loaded, its first start reads a small and mostly fixed set of files, whose data is spread across the image in directory traversal order. This turns the cold start into many small random reads.

This series adds a --hot-file-list option to mkfs.erofs:

  mkfs.erofs --hot-file-list=startup.list foo.erofs rootfs/

The list holds one image-relative path per line, typically recorded from a startup trace. Data of the listed regular files is allocated ahead of other files in list order, while unlisted files keep their relative order. Directories and symlinks along the listed paths are prioritized as well. Paths are resolved inside the image root, and missing entries are reported and skipped. Without the option, the output is unchanged.

Patch 1 adds the list parser and a hot pass in erofs_mkfs_dump_tree() for local directories. Patch 2 supports compression and keeps hot files out of fragments, since the packed inode is written last. Patches 3 and 4 add tar and OCI imports, where paths are resolved against the final imported tree.

With elasticsearch:8.13.0 and a list recorded from a real startup (610 regular files, 441 MB), reading the hot files in order from a cold loop device took 573 ms instead of 793 ms (-28%, median of 15 pairs).

Tested with local directory, tar and OCI sources and various compression options; image contents were verified with fsck.erofs and kernel mounts.

A regression test for experimental-tests is sent separately.

This series is based on erofs-utils dev at 652a204d0ec6.

Thanks,
Mengdie Yan

Mengdie Yan (4):
erofs-utils: mkfs: prioritize hot files in directory sources
erofs-utils: mkfs: preserve hot file placement during compression
erofs-utils: mkfs: support hot file lists for full TAR imports
erofs-utils: mkfs: support hot file lists for full OCI imports

 include/erofs/hotfile.h  |  25 ++
 include/erofs/internal.h |  11 +
 lib/Makefile.am          |   2 +
 lib/compress.c           |  19 +-
 lib/hotfile.c            | 754 +++++++++++++++++++++++++++++++++++++++
 lib/inode.c              | 202 ++++++++++-
 man/mkfs.erofs.1         |  24 ++
 mkfs/main.c              |  65 ++++
 8 files changed, 1091 insertions(+), 11 deletions(-)
 create mode 100644 include/erofs/hotfile.h
 create mode 100644 lib/hotfile.c

base-commit: 652a204d0ec628c887df88c95f76073502704c52

Signature · 1 line
2.50.1 (Apple Git-155)
#1 lore raw

PATCH 1/4 erofs-utils: mkfs: prioritize hot files in directory sources

Add an ordered hot-file list for uncompressed directory builds. Resolve paths inside the image root and aggregate the earliest rank across hardlinks before scheduling hot files and their path metadata.

Keep the earliest descendant rank when a directory is also listed directly. Reuse the common directory traversal while preserving the relative order of unlisted cold files, link counts and complete directory extents. Reject incremental builds because existing allocations cannot satisfy this ordering contract. Document the file-level layout guarantees.

---
 include/erofs/hotfile.h  |  22 ++
 include/erofs/internal.h |  11 +
 lib/Makefile.am          |   2 +
 lib/hotfile.c            | 532 +++++++++++++++++++++++++++++++++++++++
 lib/inode.c              | 202 ++++++++++++++-
 man/mkfs.erofs.1         |  20 ++
 mkfs/main.c              |  39 +++
 7 files changed, 821 insertions(+), 7 deletions(-)
 create mode 100644 include/erofs/hotfile.h
 create mode 100644 lib/hotfile.c
include/erofs/hotfile.h new file +22 -0
new file mode 100644
index 0000000..3fcdc1a
@@ -0,0 +1,22 @@
+/* SPDX-License-Identifier: GPL-2.0+ OR MIT */
+#ifndef __EROFS_HOTFILE_H
+#define __EROFS_HOTFILE_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "defs.h"
+
+int erofs_hotfile_load(const char *path);
+void erofs_hotfile_exit(void);
+bool erofs_hotfile_enabled(void);
+
+unsigned int erofs_hotfile_rank(const char *path, bool isdir);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
include/erofs/internal.h +11 -0
index 87c7b9a..ad8a1ee 100644
@@ -273,6 +273,8 @@ struct erofs_inode {
 	/* OVL: non-merge dir that may contain whiteout entries */
 	bool whiteouts;
 	bool dot_omitted;
+	/* position in --hot-file-list, or EROFS_HOT_RANK_NONE if not hot */
+	unsigned int hot_rank;
 
 	unsigned int xattr_isize;
 	unsigned int extent_isize;
@@ -358,6 +360,7 @@ static inline struct erofs_inode *erofs_parent_inode(struct erofs_inode *inode)
 
 #define EROFS_DENTRY_FLAG_VALIDNID	0x01
 #define EROFS_DENTRY_FLAG_FIXUP_PNID	0x02
+#define EROFS_DENTRY_FLAG_NLINK_COUNTED	0x04
 struct erofs_dentry {
 	struct list_head d_child;	/* child of parent list */
 	union {
@@ -569,6 +572,14 @@ static inline bool erofs_is_packed_inode(struct erofs_inode *inode)
 		inode->nid == inode->sbi->packed_nid;
 }
 
+#define EROFS_HOT_RANK_NONE	UINT_MAX
+
+static inline bool erofs_inode_is_hotfile(struct erofs_inode *inode)
+{
+	return !S_ISDIR(inode->i_mode) &&
+		inode->hot_rank != EROFS_HOT_RANK_NONE;
+}
+
 int erofs_packedfile_init(struct erofs_sb_info *sbi, bool fragments_mkfs);
 void erofs_packedfile_exit(struct erofs_sb_info *sbi);
 
lib/Makefile.am +2 -0
index 8177c52..d6394ef 100644
@@ -10,6 +10,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \
       $(top_srcdir)/include/erofs/diskbuf.h \
       $(top_srcdir)/include/erofs/err.h \
       $(top_srcdir)/include/erofs/exclude.h \
+      $(top_srcdir)/include/erofs/hotfile.h \
       $(top_srcdir)/include/erofs/inode.h \
       $(top_srcdir)/include/erofs/internal.h \
       $(top_srcdir)/include/erofs/io.h \
@@ -47,6 +48,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \
 		      compress_hints.c sha256.c blobchunk.c dir.c \
 		      fragments.c dedupe.c uuid_unparse.c uuid.c tar.c \
 		      block_list.c rebuild.c diskbuf.c bitops.c dedupe_ext.c \
+		      hotfile.c \
 		      vmdk.c metabox.c global.c importer.c base64.c
 
 liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include
lib/hotfile.c new file +532 -0

532 lines not on this page · raw message

lib/inode.c +195 -7

270 lines not on this page · raw message

man/mkfs.erofs.1 +20 -0
index 65ec807..f8157b4 100644
@@ -310,6 +310,26 @@ random gzip access. Source file must be a gzip-compressed tarball.
 .BI "\-\-hard-dereference"
 Dereference hardlinks and add links as separate inodes.
 .TP
+.BI "\-\-hot-file-list=" path
+Read a newline-delimited list of image-relative hot file paths for local
+directory sources.
+Leading slashes refer to the image root.  Empty lines and lines starting
+with # are ignored; other spaces are part of the filename.  Use ./ to list
+a filename beginning with #.
+Hot regular files are scheduled in list order before cold files.
+Unlisted files retain their relative traversal order.
+Hardlink aliases share the earliest matching rank.
+Symlinks are resolved within the image root, including intermediate components.
+Parent directories are also prioritized.  Entries ending in \fI/\fR prioritize
+the directory without recursively marking its children hot.
+This option currently requires uncompressed builds.
+Data deduplication and chunk sharing are kept, so hot files may still
+share physical extents with other files.
+This is file-level data ordering: directory compression, metadata zones and
+metadata allocation can place metadata elsewhere in the image, so a complete,
+independently usable hot prefix is not guaranteed.
+This option cannot be combined with \fB--incremental\fR.
+.TP
 .B "\-\-ignore-mtime"
 Ignore the file modification time whenever it would cause \fBmkfs.erofs\fR to
 use extended inodes over compact inodes. When not using a fixed timestamp, this
mkfs/main.c +39 -0
index f75225b..f5044ba 100644
@@ -23,6 +23,7 @@
 #include "erofs/xattr.h"
 #include "erofs/exclude.h"
 #include "erofs/block_list.h"
+#include "erofs/hotfile.h"
 #include "erofs/compress_hints.h"
 #include "../lib/compressor.h"
 #include "../lib/liberofs_chunk.h"
@@ -105,9 +106,12 @@ static struct option long_options[] = {
 	{"MZ", optional_argument, NULL, 537},
 	{"xattr-prefix", required_argument, NULL, 538},
 	{"xattr-inode-digest", optional_argument, NULL, 539},
+	{"hot-file-list", required_argument, NULL, 540},
 	{0, 0, 0, 0},
 };
 
+static char *hotfile_list_path;
+
 static void print_available_compressors(FILE *f, const char *delim)
 {
 	int i = 0;
@@ -210,6 +214,8 @@ static void usage(int argc, char **argv)
 		" --uid-offset=#         add offset # to all file uids (# = id offset)\n"
 		" --gid-offset=#         add offset # to all file gids (# = id offset)\n"
 		" --hard-dereference     dereference hardlinks, add links as separate inodes\n"
+		" --hot-file-list=X      specify newline-separated hot file paths for\n"
+		"                        local directory sources\n"
 		" --ignore-mtime         use build time instead of strict per-file modification time\n"
 		" --max-extent-bytes=#   set maximum decompressed extent size # in bytes\n"
 		" --mount-point=X        X=prefix of target fs path (default: /)\n"
@@ -1497,6 +1503,12 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 				return err;
 			}
 			break;
+		case 540:
+			free(hotfile_list_path);
+			hotfile_list_path = strdup(optarg);
+			if (!hotfile_list_path)
+				return -ENOMEM;
+			break;
 		case 'V':
 			version();
 			exit(0);
@@ -1552,6 +1564,15 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 			return err;
 	}
 
+	if (hotfile_list_path && incremental_mode) {
+		erofs_err("--hot-file-list conflicts with --incremental");
+		return -EINVAL;
+	}
+	if (hotfile_list_path && source_mode != EROFS_MKFS_SOURCE_LOCALDIR) {
+		erofs_err("--hot-file-list requires a local directory source");
+		return -EOPNOTSUPP;
+	}
+
 	if (quiet) {
 		cfg.c_dbg_lvl = EROFS_ERR;
 		cfg.c_showprogress = false;
@@ -1789,6 +1810,15 @@ int main(int argc, char **argv)
 		goto exit;
 	}
 
+	if (hotfile_list_path) {
+		err = erofs_hotfile_load(hotfile_list_path);
+		if (err) {
+			erofs_err("failed to load hot-file list %s: %s",
+				  hotfile_list_path, erofs_strerror(err));
+			goto exit;
+		}
+	}
+
 	err = parse_source_date_epoch();
 	if (err) {
 		fprintf(stderr, "Try '%s --help' for more information.\n", argv[0]);
@@ -1910,6 +1940,12 @@ int main(int argc, char **argv)
 	if (err)
 		goto exit;
 
+	if (erofs_hotfile_enabled() && g_sbi.available_compr_algs) {
+		erofs_err("--hot-file-list requires uncompressed output");
+		err = -EOPNOTSUPP;
+		goto exit;
+	}
+
 	if (importer_params.dedupe == EROFS_DEDUPE_FORCE_ON &&
 	    g_sbi.available_compr_algs) {
 		err = z_erofs_dedupe_init(erofs_blksiz(&g_sbi));
@@ -2084,6 +2120,9 @@ exit:
 		fclose(blklst);
 	erofs_cleanup_compress_hints();
 	erofs_cleanup_exclude_rules();
+	erofs_hotfile_exit();
+	free(hotfile_list_path);
+	hotfile_list_path = NULL;
 	erofs_xattr_cleanup_name_prefixes();
 	erofs_rebuild_cleanup();
 	erofs_diskbuf_exit();
Signature · 1 line
2.50.1 (Apple Git-155)
#2 lore raw

PATCH 2/4 erofs-utils: mkfs: preserve hot file placement during compression

In reply to Mengdie Yan

Allow hot files to be compressed, but keep them out of fragment packing. Fragments move file tails into the packed inode, which is written after all other data, so hot tails would end up far away from the hot area.

Since hot files are not packed, their tails can be inlined even if fragments are enabled. Don't mark them as interlaced in that case, as inline pclusters are never interlaced.

Inline tails, data deduplication and extent deduplication only place data next to the inode or reference data written earlier, so they are kept as is.

---
 lib/compress.c   | 19 +++++++++++++++----
 man/mkfs.erofs.1 | 10 ++++++----
 mkfs/main.c      |  6 ------
 3 files changed, 21 insertions(+), 14 deletions(-)
lib/compress.c +15 -4
index e764e44..56e559b 100644
@@ -599,7 +599,8 @@ static int __z_erofs_compress_one(struct z_erofs_compress_sctx *ctx,
 	bool is_packed_inode = erofs_is_packed_inode(inode);
 	bool tsg = (ctx->seg_idx + 1 >= ictx->seg_num), final = !ctx->remaining;
 	bool may_packing = (params->fragments && tsg && final && !is_packed_inode &&
-			    !erofs_is_metabox_inode(inode));
+			    !erofs_is_metabox_inode(inode) &&
+			    !erofs_inode_is_hotfile(inode));
 	bool data_unaligned = ictx->data_unaligned;
 	bool may_inline = (params->ztailpacking && !data_unaligned && tsg &&
 			   final && !may_packing);
@@ -1343,6 +1344,7 @@ int z_erofs_compress_segment(struct z_erofs_compress_sctx *ctx,
 	struct erofs_inode *inode = ictx->inode;
 	bool frag = params->fragments && !erofs_is_packed_inode(inode) &&
 		!erofs_is_metabox_inode(inode) &&
+		!erofs_inode_is_hotfile(inode) &&
 		ctx->seg_idx >= ictx->seg_num - 1;
 	struct erofs_vfile *vf = ictx->vf;
 	int ret;
@@ -1978,7 +1980,8 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 	struct erofs_sb_info *sbi = inode->sbi;
 	struct z_erofs_compress_ictx *ictx;
 	bool frag = params->fragments && !erofs_is_packed_inode(inode) &&
-		!erofs_is_metabox_inode(inode);
+		!erofs_is_metabox_inode(inode) &&
+		!erofs_inode_is_hotfile(inode);
 	bool all_fragments = params->all_fragments && frag;
 
 	/* initialize per-file compression setting */
@@ -2018,6 +2021,9 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 	}
 	ictx->im = im;
 	ictx->inode = inode;
+	/* hot files are never packed, skip the fragment tail queue */
+	if (erofs_inode_is_hotfile(inode))
+		ictx->tofh = ~0U;
 	ictx->device_id = !params->fragments && !params->dedupe &&
 		!erofs_is_packed_inode(inode) &&
 		!erofs_is_metabox_inode(inode) &&
@@ -2067,8 +2073,12 @@ void *erofs_prepare_compressed_file(struct erofs_importer *im,
 			params->max_compressed_extent_size;
 		ictx->data_unaligned = false;
 	}
+	/*
+	 * Hot files are not packed, so their tails may be inlined; inline
+	 * pclusters are never interlaced.
+	 */
 	if (params->fragments && params->dedupe != EROFS_DEDUPE_FORCE_ON &&
-	    !ictx->data_unaligned)
+	    !ictx->data_unaligned && !erofs_inode_is_hotfile(inode))
 		inode->z_advise |= Z_EROFS_ADVISE_INTERLACED_PCLUSTER;
 
 	init_list_head(&ictx->extents);
@@ -2094,7 +2104,8 @@ int erofs_begin_compressed_file(struct z_erofs_compress_ictx *ictx)
 	const struct erofs_importer_params *params = ictx->im->params;
 	struct erofs_inode *inode = ictx->inode;
 	bool frag = params->fragments && !erofs_is_packed_inode(inode) &&
-		!erofs_is_metabox_inode(inode);
+		!erofs_is_metabox_inode(inode) &&
+		!erofs_inode_is_hotfile(inode);
 	bool all_fragments = params->all_fragments && frag;
 	int ret;
 
man/mkfs.erofs.1 +6 -4
index f8157b4..f06ff9b 100644
@@ -316,13 +316,15 @@ directory sources.
 Leading slashes refer to the image root.  Empty lines and lines starting
 with # are ignored; other spaces are part of the filename.  Use ./ to list
 a filename beginning with #.
-Hot regular files are scheduled in list order before cold files.
-Unlisted files retain their relative traversal order.
+Hot regular files are scheduled in list order before cold files while keeping
+compression enabled.  Unlisted files retain their relative traversal order.
 Hardlink aliases share the earliest matching rank.
-Symlinks are resolved within the image root, including intermediate components.
+Symlinks, including intermediate ones, are resolved within the image root
+and are prioritized together with their targets.
 Parent directories are also prioritized.  Entries ending in \fI/\fR prioritize
 the directory without recursively marking its children hot.
-This option currently requires uncompressed builds.
+Hot files are never packed into fragments, since that would move their
+tails out of the hot area.
 Data deduplication and chunk sharing are kept, so hot files may still
 share physical extents with other files.
 This is file-level data ordering: directory compression, metadata zones and
mkfs/main.c +0 -6
index f5044ba..299f2cd 100644
@@ -1940,12 +1940,6 @@ int main(int argc, char **argv)
 	if (err)
 		goto exit;
 
-	if (erofs_hotfile_enabled() && g_sbi.available_compr_algs) {
-		erofs_err("--hot-file-list requires uncompressed output");
-		err = -EOPNOTSUPP;
-		goto exit;
-	}
-
 	if (importer_params.dedupe == EROFS_DEDUPE_FORCE_ON &&
 	    g_sbi.available_compr_algs) {
 		err = z_erofs_dedupe_init(erofs_blksiz(&g_sbi));
Signature · 1 line
2.50.1 (Apple Git-155)
#3 lore raw

PATCH 3/4 erofs-utils: mkfs: support hot file lists for full TAR imports

In reply to Mengdie Yan

Defer imported hot paths until the final TAR tree exists. Build a temporary lookup index and clear shared inode ranks before aggregating only surviving aliases.

Reuse the directory scheduler and reject incompatible TAR modes and sort options. Missing paths remain a no-op and replacement aliases are ranked from the final imported tree.

---
 include/erofs/hotfile.h |   5 +-
 lib/hotfile.c           | 242 ++++++++++++++++++++++++++++++++++++++--
 man/mkfs.erofs.1        |   6 +-
 mkfs/main.c             |  34 +++++-
 4 files changed, 270 insertions(+), 17 deletions(-)
include/erofs/hotfile.h +4 -1
index 3fcdc1a..9dc3a7e 100644
@@ -9,7 +9,10 @@ extern "C"
 
 #include "defs.h"
 
-int erofs_hotfile_load(const char *path);
+struct erofs_inode;
+
+int erofs_hotfile_load(const char *path, const char *root);
+int erofs_hotfile_prepare_tree(struct erofs_inode *root);
 void erofs_hotfile_exit(void);
 bool erofs_hotfile_enabled(void);
 
lib/hotfile.c +232 -10

312 lines not on this page · raw message

man/mkfs.erofs.1 +4 -2
index f06ff9b..983f385 100644
@@ -312,7 +312,7 @@ Dereference hardlinks and add links as separate inodes.
 .TP
 .BI "\-\-hot-file-list=" path
 Read a newline-delimited list of image-relative hot file paths for local
-directory sources.
+directory or tar full sources.
 Leading slashes refer to the image root.  Empty lines and lines starting
 with # are ignored; other spaces are part of the filename.  Use ./ to list
 a filename beginning with #.
@@ -320,7 +320,8 @@ Hot regular files are scheduled in list order before cold files while keeping
 compression enabled.  Unlisted files retain their relative traversal order.
 Hardlink aliases share the earliest matching rank.
 Symlinks, including intermediate ones, are resolved within the image root
-and are prioritized together with their targets.
+and are prioritized together with their targets; for tar sources, matching
+uses the final imported tree.
 Parent directories are also prioritized.  Entries ending in \fI/\fR prioritize
 the directory without recursively marking its children hot.
 Hot files are never packed into fragments, since that would move their
@@ -331,6 +332,7 @@ This is file-level data ordering: directory compression, metadata zones and
 metadata allocation can place metadata elsewhere in the image, so a complete,
 independently usable hot prefix is not guaranteed.
 This option cannot be combined with \fB--incremental\fR.
+This option cannot be combined with \fB--sort=none\fR for tar input.
 .TP
 .B "\-\-ignore-mtime"
 Ignore the file modification time whenever it would cause \fBmkfs.erofs\fR to
mkfs/main.c +30 -4
index 299f2cd..8ebd3a0 100644
@@ -215,7 +215,7 @@ static void usage(int argc, char **argv)
 		" --gid-offset=#         add offset # to all file gids (# = id offset)\n"
 		" --hard-dereference     dereference hardlinks, add links as separate inodes\n"
 		" --hot-file-list=X      specify newline-separated hot file paths for\n"
-		"                        local directory sources\n"
+		"                        local directory or tar full sources\n"
 		" --ignore-mtime         use build time instead of strict per-file modification time\n"
 		" --max-extent-bytes=#   set maximum decompressed extent size # in bytes\n"
 		" --mount-point=X        X=prefix of target fs path (default: /)\n"
@@ -332,6 +332,20 @@ static enum {
 	EROFS_MKFS_SOURCE_REBUILD,
 } source_mode;
 
+static bool mkfs_hotfile_supported_source(void)
+{
+	switch (source_mode) {
+	case EROFS_MKFS_SOURCE_LOCALDIR:
+		return true;
+	case EROFS_MKFS_SOURCE_TAR:
+		return !erofstar.index_mode &&
+		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_RVSP &&
+		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_ZEROFILL;
+	default:
+		return false;
+	}
+}
+
 static unsigned int rebuild_src_count;
 static LIST_HEAD(rebuild_src_list);
 static u8 fixeduuid[16];
@@ -1568,8 +1582,13 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 		erofs_err("--hot-file-list conflicts with --incremental");
 		return -EINVAL;
 	}
-	if (hotfile_list_path && source_mode != EROFS_MKFS_SOURCE_LOCALDIR) {
-		erofs_err("--hot-file-list requires a local directory source");
+	if (hotfile_list_path && source_mode == EROFS_MKFS_SOURCE_TAR &&
+	    erofstar.try_no_reorder) {
+		erofs_err("--hot-file-list conflicts with --sort=none");
+		return -EINVAL;
+	}
+	if (hotfile_list_path && !mkfs_hotfile_supported_source()) {
+		erofs_err("--hot-file-list is only supported for local directories and tar full mode");
 		return -EOPNOTSUPP;
 	}
 
@@ -1811,7 +1830,9 @@ int main(int argc, char **argv)
 	}
 
 	if (hotfile_list_path) {
-		err = erofs_hotfile_load(hotfile_list_path);
+		err = erofs_hotfile_load(hotfile_list_path,
+				source_mode == EROFS_MKFS_SOURCE_LOCALDIR ?
+				cfg.c_src_path : NULL);
 		if (err) {
 			erofs_err("failed to load hot-file list %s: %s",
 				  hotfile_list_path, erofs_strerror(err));
@@ -2065,6 +2086,11 @@ int main(int argc, char **argv)
 	if (err < 0)
 		goto exit;
 
+	if (hotfile_list_path && source_mode == EROFS_MKFS_SOURCE_TAR) {
+		err = erofs_hotfile_prepare_tree(root);
+		if (err)
+			goto exit;
+	}
 	err = erofs_importer_load_tree(&importer,
 				       source_mode != EROFS_MKFS_SOURCE_LOCALDIR,
 				       incremental_mode);
Signature · 1 line
2.50.1 (Apple Git-155)
#4 lore raw

PATCH 4/4 erofs-utils: mkfs: support hot file lists for full OCI imports

In reply to Mengdie Yan

Prepare hot paths after OCI import using the same final-tree lookup and file scheduler as full TAR inputs. Select the source explicitly so a local path matching an image reference cannot affect hot-list parsing.

---
 man/mkfs.erofs.1 |  6 +++---
 mkfs/main.c      | 12 +++++++++---
 2 files changed, 12 insertions(+), 6 deletions(-)
man/mkfs.erofs.1 +3 -3
index 983f385..9cbf436 100644
@@ -312,7 +312,7 @@ Dereference hardlinks and add links as separate inodes.
 .TP
 .BI "\-\-hot-file-list=" path
 Read a newline-delimited list of image-relative hot file paths for local
-directory or tar full sources.
+directory, tar full, or OCI full sources.
 Leading slashes refer to the image root.  Empty lines and lines starting
 with # are ignored; other spaces are part of the filename.  Use ./ to list
 a filename beginning with #.
@@ -320,8 +320,8 @@ Hot regular files are scheduled in list order before cold files while keeping
 compression enabled.  Unlisted files retain their relative traversal order.
 Hardlink aliases share the earliest matching rank.
 Symlinks, including intermediate ones, are resolved within the image root
-and are prioritized together with their targets; for tar sources, matching
-uses the final imported tree.
+and are prioritized together with their targets; for tar and OCI sources,
+matching uses the final imported tree.
 Parent directories are also prioritized.  Entries ending in \fI/\fR prioritize
 the directory without recursively marking its children hot.
 Hot files are never packed into fragments, since that would move their
mkfs/main.c +9 -3
index 8ebd3a0..3cfd555 100644
@@ -215,7 +215,7 @@ static void usage(int argc, char **argv)
 		" --gid-offset=#         add offset # to all file gids (# = id offset)\n"
 		" --hard-dereference     dereference hardlinks, add links as separate inodes\n"
 		" --hot-file-list=X      specify newline-separated hot file paths for\n"
-		"                        local directory or tar full sources\n"
+		"                        local directory, tar full, or OCI full sources\n"
 		" --ignore-mtime         use build time instead of strict per-file modification time\n"
 		" --max-extent-bytes=#   set maximum decompressed extent size # in bytes\n"
 		" --mount-point=X        X=prefix of target fs path (default: /)\n"
@@ -341,6 +341,10 @@ static bool mkfs_hotfile_supported_source(void)
 		return !erofstar.index_mode &&
 		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_RVSP &&
 		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_ZEROFILL;
+	case EROFS_MKFS_SOURCE_OCI:
+		return !mkfs_oci_tarindex_mode &&
+		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_RVSP &&
+		       dataimport_mode != EROFS_MKFS_DATA_IMPORT_ZEROFILL;
 	default:
 		return false;
 	}
@@ -1588,7 +1592,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,
 		return -EINVAL;
 	}
 	if (hotfile_list_path && !mkfs_hotfile_supported_source()) {
-		erofs_err("--hot-file-list is only supported for local directories and tar full mode");
+		erofs_err("--hot-file-list is only supported for local directories, tar full mode, and OCI full mode");
 		return -EOPNOTSUPP;
 	}
 
@@ -2086,7 +2090,9 @@ int main(int argc, char **argv)
 	if (err < 0)
 		goto exit;
 
-	if (hotfile_list_path && source_mode == EROFS_MKFS_SOURCE_TAR) {
+	if (hotfile_list_path &&
+	    (source_mode == EROFS_MKFS_SOURCE_TAR ||
+	     source_mode == EROFS_MKFS_SOURCE_OCI)) {
 		err = erofs_hotfile_prepare_tree(root);
 		if (err)
 			goto exit;
Signature · 1 line
2.50.1 (Apple Git-155)