This series adds an incremental file-merge mode for mkfs.erofs.

This is motivated by layered microVM snapshots (memory and rootfs)
backed by EROFS external devices.  With blob indexes, mkfs can describe
file contents at block granularity and let a new layer store only
modified ranges while reusing unchanged data from lower images.

This series reuses the existing incremental build interface and adds a
new file-merge mode.  In this mode, when a source file exists in the
upper directory and a same-name file exists in the lower image, mkfs
treats holes in the sparse upper file as ranges that should inherit
data from the lower file.  Data ranges in the upper file are promoted
into the new image, while compatible clean lower ranges can be reused.

For compressed files, mkfs walks the sparse upper source and the lower
extent mapping together.  If a lower compressed extent is completely
unchanged by the upper source, it can be inherited directly.  If upper
data appears inside a lower extent, mkfs keeps the clean prefix when
possible and recompresses the promoted dirty suffix from the upper
source.  For uncompressed data, mkfs builds a logical source view that
selects the lower or upper backing file per range.

This allows incremental images to describe merged file contents without
materializing entire files in the new layer.  It is especially useful
for layered microVM snapshot images backed by multiple external devices.

The interface is still open to discussion.  It currently relies on
sparse source files to encode the inherit semantics.  In addition, mkfs
still lacks an interface to split blob data and blob indexes out of the
incremental build output, which needs further discussion.

Yifan Zhao (3):
  erofs-utils: lib: directly propagate vfile errors
  erofs-utils: refactor inode data source vfiles
  erofs-utils: support incremental file merge

 include/erofs/blobchunk.h |   4 +-
 include/erofs/importer.h  |   1 +
 include/erofs/internal.h  |  33 ++--
 lib/Makefile.am           |   4 +-
 lib/blobchunk.c           |  24 +--
 lib/compress.c            | 224 ++++++++++++++++++++++-
 lib/file_merge.c          | 118 ++++++++++++
 lib/inode.c               | 369 ++++++++++++++++++++++++++++----------
 lib/liberofs_compress.h   |   5 +
 lib/liberofs_file_merge.h |  22 +++
 lib/liberofs_rebuild.h    |   3 +-
 lib/rebuild.c             |  97 ++++++++--
 lib/remotes/s3.c          |  25 +--
 lib/tar.c                 |  23 +--
 man/mkfs.erofs.1          |  11 +-
 mkfs/main.c               |  17 +-
 16 files changed, 826 insertions(+), 154 deletions(-)
 create mode 100644 lib/file_merge.c
 create mode 100644 lib/liberofs_file_merge.h

-- 
2.47.3


Reply via email to