[PATCH 0/6] erofs-utils: introduce extra xattr name prefix

Jingbo Xu jefflexu at linux.alibaba.com
Tue Apr 4 18:02:17 AEST 2023


As discussed in [1], erofs paring with overlayfs could satisfy the
scenario which originally composefs targets.  In this case, each file of
erofs is tagged with overlay.metacopy and overlay.redirect xattr, which
can be consumed by overlayfs.

The example xattr arrangement is like:

user.overlay.metacopy=""
user.overlay.redirect="/d6/a6748c13e2ef146a9587c47cd51ef692a368b180fc3d32b1ee32df4bb99133"


In the current implementation of erofs, "user.overlay.redirect" xattr
name will consume duplicate on-disk space.  In other words, each file
will allocate on-disk space for its "user.overlay.redirect" xattr name,
which explodes the output erofs image as a consequence.

This patch set introduces extra xattr name prefix feature, in which user
could specify customised xattr name prefix through mkfs.erofs.  When
matched with a user specified extra xattr name prefix, only the
trailing part of the xattr name apart from the xattr name prefix will be
stored on disk.  Please refer to patch 3 for more details of the on-disk
format.

This feature can significantly reduces the size of the output erofs image
in the scenario where files share the same xattr name or prefix heavily.

Below is the test result of the size of the output erofs image with
different option combinations of mkfs.erofs.  This is tested on the
rootfs givin in [2].

```
4.2M  large.erofs.T0.noxattr
7.4M  large.erofs.T0.xattr
6.4M  large.erofs.T0.xattr.share
5.7M  large.erofs.noxattr
8.9M  large.erofs.xattr
7.8M  large.erofs.xattr.share
```

T0: "-T0" of mkfs.erofs, w/ this option, 32 bytes on-disk inode is used;
wo/ this option, 64 byte on-disk inode is used instead

xattr: no extra option specified
noxattr: "-x -1", i.e. disable xattr

share: "--xattr-prefix=user.overlay.metacopy" and
"--xattr-prefix=user.overlay.redirect" option of mkfs.erofs. w/ this
option, the extra xattr name prefix feature is enabled.

It can be seen ~10% disk space is saved with this feature in the typical
workload.

patch 1-2 are preparing patch.


[1] https://lore.kernel.org/all/CAOQ4uxgGc33_QVBXMbQTnmbpHio4amv=W7ax2vQ1UMet0k_KoA@mail.gmail.com/
[2] https://my.owndrive.com/index.php/s/irHJXRpZHtT3a5i


Jingbo Xu (6):
  erofs-utils: declare prefix_len as u8
  erofs-utils: extract packedfile API
  erofs-utils: introduce on-disk format for extra xattr name prefix
  erofs-utils: introduce init/cleanup routine for extra xattr name prefix
  erofs-utils: build erofs_xattr_entry upon extra xattr name prefix
  erofs-utils: mkfs.erofs: introduce --xattr-prefix option

 include/erofs/config.h    |   2 +
 include/erofs/fragments.h |  19 +++++--
 include/erofs/inode.h     |   2 +
 include/erofs/internal.h  |   3 ++
 include/erofs/xattr.h     |   3 ++
 include/erofs_fs.h        |   7 ++-
 lib/fragments.c           |  20 +++-----
 lib/xattr.c               | 104 +++++++++++++++++++++++++++++++++++++-
 mkfs/main.c               |  48 +++++++++++++++---
 9 files changed, 183 insertions(+), 25 deletions(-)

-- 
2.19.1.6.gb485710b



More information about the Linux-erofs mailing list