erofs-utils: mkfs: introduce rebuild mode
v7 cover erofs-utils: mkfs: introduce rebuild mode
v6: https://lore.kernel.org/r/[email protected]
changes since v6:
- several random fixes when testing with --enable-debug
- better code arrangement.
I plan to use this version for testing.
Thanks,
Gao Xiang
Gao Xiang (2):
erofs-utils: lib: avoid exporting non-EROFS xattrs
erofs-utils: lib: always fix up xattr_isize even w/o xattrs
Jingbo Xu (11):
erofs-utils: lib: remove unneeded NULL checks
erofs-utils: lib: add erofs_inode_is_whiteout() helper
erofs-utils: lib: set OVL_XATTR_ORIGIN for directories with whiteouts
erofs-utils: lib: add list_splice_tail() helper
erofs-utils: lib: make erofs_get_unhashed_chunk() global
erofs-utils: lib: add erofs_read_xattrs_from_disk() helper
erofs-utils: lib: add erofs_insert_ihash() helper
erofs-utils: lib: add erofs_rebuild_get_dentry() helper
erofs-utils: lib: add erofs_rebuild_load_tree() helper
erofs-utils: mkfs: introduce rebuild mode
erofs-utils: mkfs: add --ovlfs-strip option
include/erofs/blobchunk.h | 2 + include/erofs/config.h | 1 + include/erofs/inode.h | 5 +- include/erofs/internal.h | 18 +- include/erofs/list.h | 20 ++ include/erofs/rebuild.h | 21 ++ include/erofs/xattr.h | 34 +--- lib/Makefile.am | 3 +- lib/blobchunk.c | 2 +- lib/inode.c | 29 ++- lib/rebuild.c | 404 ++++++++++++++++++++++++++++++++++++++ lib/tar.c | 125 ++---------- lib/xattr.c | 138 ++++++++++++- mkfs/main.c | 225 ++++++++++++++++----- 14 files changed, 815 insertions(+), 212 deletions(-) create mode 100644 include/erofs/rebuild.h create mode 100644 lib/rebuild.c
Signature · 1 line
2.24.4
PATCH v7 1/13 erofs-utils: lib: remove unneeded NULL checks
From: Jingbo Xu <[email protected]>
get_xattritem() will in no way return NULL. Use DBG_BUGONs instead.
--- lib/xattr.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
lib/xattr.c +2 -4
@@ -437,8 +437,7 @@ int erofs_setxattr(struct erofs_inode *inode, char *key, item =get_xattritem (prefix, kvbuf, len);if (IS_ERR (item))return PTR_ERR (item); -if (!item) -return 0 ; +DBG_BUGON (!item);return erofs_xattr_add (&inode->i_xattrs, item); }
@@ -473,8 +472,7 @@ static int erofs_droid_xattr_set_caps(struct erofs_inode *inode) item =get_xattritem (EROFS_XATTR_INDEX_SECURITY , kvbuf, len);if (IS_ERR (item))return PTR_ERR (item); -if (!item) -return 0 ; +DBG_BUGON (!item);return erofs_xattr_add (&inode->i_xattrs, item); }
Signature · 1 line
2.24.4
PATCH v7 2/13 erofs-utils: lib: avoid exporting non-EROFS xattrs
In reply to Gao XiangMove all non-EROFS xattr macros to xattr.c and introduce erofs_set_opaque_xattr() helper to hide all these details.
--- include/erofs/xattr.h | 32 +---------------------------- lib/tar.c | 7 +------ lib/xattr.c | 48 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 37 deletions(-)
include/erofs/xattr.h +1 -31
@@ -43,37 +43,6 @@ static inline unsigned int xattrblock_offset(struct erofs_inode *vi, (_size -sizeof (struct erofs_xattr_ibody_header )) / \ sizeof(struct erofs_xattr_entry) + 1; }) -#ifndef XATTR_SYSTEM_PREFIX -#define XATTR_SYSTEM_PREFIX "system." -#endif -#ifndef XATTR_SYSTEM_PREFIX_LEN -#define XATTR_SYSTEM_PREFIX_LEN (sizeof(XATTR_SYSTEM_PREFIX) - 1) -#endif -#ifndef XATTR_USER_PREFIX -#define XATTR_USER_PREFIX "user." -#endif -#ifndef XATTR_USER_PREFIX_LEN -#define XATTR_USER_PREFIX_LEN (sizeof(XATTR_USER_PREFIX) - 1) -#endif -#ifndef XATTR_SECURITY_PREFIX -#define XATTR_SECURITY_PREFIX "security." -#endif -#ifndef XATTR_SECURITY_PREFIX_LEN -#define XATTR_SECURITY_PREFIX_LEN (sizeof(XATTR_SECURITY_PREFIX) - 1) -#endif -#ifndef XATTR_TRUSTED_PREFIX -#define XATTR_TRUSTED_PREFIX "trusted." -#endif -#ifndef XATTR_TRUSTED_PREFIX_LEN -#define XATTR_TRUSTED_PREFIX_LEN (sizeof(XATTR_TRUSTED_PREFIX) - 1) -#endif -#ifndef XATTR_NAME_POSIX_ACL_ACCESS -#define XATTR_NAME_POSIX_ACL_ACCESS "system.posix_acl_access" -#endif -#ifndef XATTR_NAME_POSIX_ACL_DEFAULT -#define XATTR_NAME_POSIX_ACL_DEFAULT "system.posix_acl_default" -#endif -int erofs_scan_file_xattrs (struct erofs_inode *inode);int erofs_prepare_xattr_ibody (struct erofs_inode *inode);char *erofs_export_xattr_ibody (struct erofs_inode *inode);
@@ -87,6 +56,7 @@ int erofs_xattr_prefixes_init(struct erofs_sb_info *sbi);int erofs_setxattr (struct erofs_inode *inode,char *key,const void *value,size_t size); +int erofs_set_opaque_xattr (struct erofs_inode *inode); #ifdef __cplusplus }
lib/tar.c +1 -6
@@ -19,11 +19,6 @@#include "erofs/xattr.h" #include "erofs/blobchunk.h" -#define OVL_XATTR_NAMESPACE "overlay." -#define OVL_XATTR_TRUSTED_PREFIX XATTR_TRUSTED_PREFIX OVL_XATTR_NAMESPACE -#define OVL_XATTR_OPAQUE_POSTFIX "opaque" -#define OVL_XATTR_OPAQUE OVL_XATTR_TRUSTED_PREFIX OVL_XATTR_OPAQUE_POSTFIX -#define EROFS_WHITEOUT_DEV 0static char erofs_libbuf[16384 ];
@@ -788,7 +783,7 @@ restart: }else if (opq) {DBG_BUGON (d->type ==EROFS_FT_UNKNOWN );DBG_BUGON (!d->inode); - ret =erofs_setxattr (d->inode,OVL_XATTR_OPAQUE ,"y" ,1 ); + ret =erofs_set_opaque_xattr (d->inode); goto out; }else if (th.typeflag =='1' ) {/* hard link cases */ struct erofs_dentry *d2;
lib/xattr.c +48 -0
60 lines not on this page · raw message
Signature · 1 line
2.24.4
PATCH v7 3/13 erofs-utils: lib: add erofs_inode_is_whiteout() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add erofs_inode_is_whiteout() helper to check if a given inode is a whiteout.
--- include/erofs/internal.h | 7 +++++++ lib/tar.c | 2 -- 2 files changed, 7 insertions(+), 2 deletions(-)
include/erofs/internal.h +7 -0
@@ -20,6 +20,7 @@ typedef unsigned short umode_t;#include "erofs_fs.h" #include <fcntl.h> #include <sys/types.h> /* for off_t definition */ +#include <sys/stat.h> /* for S_ISCHR definition */ #include <stdio.h> #ifndef PATH_MAX
@@ -423,6 +424,12 @@ static inline u32 erofs_crc32c(u32 crc, const u8 *in, size_t len)return crc; } +#define EROFS_WHITEOUT_DEV 0 +static inline bool erofs_inode_is_whiteout (struct erofs_inode *inode) +{ +return S_ISCHR (inode->i_mode) && inode->u.i_rdev ==EROFS_WHITEOUT_DEV ; +} + #ifdef __cplusplus }#endif
lib/tar.c +0 -2
@@ -19,8 +19,6 @@#include "erofs/xattr.h" #include "erofs/blobchunk.h" -#define EROFS_WHITEOUT_DEV 0 -static char erofs_libbuf[16384 ];struct tar_header {
Signature · 1 line
2.24.4
PATCH v7 4/13 erofs-utils: lib: set OVL_XATTR_ORIGIN for directories with whiteouts
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Whiteouts are exposed in the overlayfs mount if these are from some non-merged directory without OVL_XATTR_ORIGIN set on the directory.
To fix this, tag OVL_XATTR_ORIGIN (with empty value) on the parent directory of whiteouts.
--- include/erofs/internal.h | 2 ++ include/erofs/xattr.h | 1 + lib/inode.c | 3 +++ lib/tar.c | 7 +++++++ lib/xattr.c | 11 +++++++++++ 5 files changed, 24 insertions(+)
include/erofs/internal.h +2 -0
@@ -192,6 +192,8 @@ struct erofs_inode {bool compressed_idata;bool lazy_tailblock;bool with_tmpfile; +/* OVL: non-merge dir that may contain whiteout entries */ +bool whiteouts;unsigned int xattr_isize;unsigned int extent_isize;
include/erofs/xattr.h +1 -0
@@ -57,6 +57,7 @@ int erofs_xattr_prefixes_init(struct erofs_sb_info *sbi);int erofs_setxattr (struct erofs_inode *inode,char *key,const void *value,size_t size);int erofs_set_opaque_xattr (struct erofs_inode *inode); +int erofs_set_origin_xattr (struct erofs_inode *inode); #ifdef __cplusplus }
lib/inode.c +3 -0
@@ -1337,6 +1337,9 @@ int tarerofs_dump_tree(struct erofs_inode *dir) dir->inode_isize =sizeof (struct erofs_inode_compact ); } +if (dir->whiteouts) +erofs_set_origin_xattr (dir); + ret =erofs_prepare_xattr_ibody (dir);if (ret <0 )return ret;
lib/tar.c +7 -0
@@ -843,6 +843,13 @@ new_inode: inode->i_mode = (inode->i_mode & ~S_IFMT ) |S_IFCHR ; inode->u.i_rdev =EROFS_WHITEOUT_DEV ; d->type =EROFS_FT_CHRDEV ; + +/* +* Mark the parent directory as copied-up to avoid exposing +* whiteouts if mounted. See kernel commit b79e05aaa166 +* ("ovl: no direct iteration for dir with origin xattr") +*/ + inode->i_parent->whiteouts = true; }else { inode->i_mode = st.st_mode;if (S_ISBLK (st.st_mode) ||S_ISCHR (st.st_mode))
lib/xattr.c +11 -0
@@ -57,12 +57,18 @@#ifndef OVL_XATTR_OPAQUE_POSTFIX #define OVL_XATTR_OPAQUE_POSTFIX "opaque"#endif +#ifndef OVL_XATTR_ORIGIN_POSTFIX +#define OVL_XATTR_ORIGIN_POSTFIX "origin" +#endif #ifndef OVL_XATTR_TRUSTED_PREFIX #define OVL_XATTR_TRUSTED_PREFIX XATTR_TRUSTED_PREFIX OVL_XATTR_NAMESPACE#endif #ifndef OVL_XATTR_OPAQUE #define OVL_XATTR_OPAQUE OVL_XATTR_TRUSTED_PREFIX OVL_XATTR_OPAQUE_POSTFIX#endif +#ifndef OVL_XATTR_ORIGIN +#define OVL_XATTR_ORIGIN OVL_XATTR_TRUSTED_PREFIX OVL_XATTR_ORIGIN_POSTFIX +#endif #define EA_HASHTABLE_BITS 16
@@ -490,6 +496,11 @@ int erofs_set_opaque_xattr(struct erofs_inode *inode)return erofs_setxattr (inode,OVL_XATTR_OPAQUE ,"y" ,1 ); } +int erofs_set_origin_xattr (struct erofs_inode *inode) +{ +return erofs_setxattr (inode,OVL_XATTR_ORIGIN ,NULL ,0 ); +} +#ifdef WITH_ANDROID static int erofs_droid_xattr_set_caps (struct erofs_inode *inode) {
Signature · 1 line
2.24.4
PATCH v7 5/13 erofs-utils: lib: always fix up xattr_isize even w/o xattrs
In reply to Gao XiangDon't assume xattr_isize is 0 before since it's not true for the upcoming rebuild mode.
--- lib/xattr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/xattr.c +3 -1
@@ -564,8 +564,10 @@ int erofs_prepare_xattr_ibody(struct erofs_inode *inode)struct inode_xattr_node *node;struct list_head *ixattrs = &inode->i_xattrs; -if (list_empty (ixattrs)) +if (list_empty (ixattrs)) { + inode->xattr_isize =0 ;return 0 ; + }/* get xattr ibody size */ ret =sizeof (struct erofs_xattr_ibody_header );
Signature · 1 line
2.24.4
Re: [PATCH v7 05/13] erofs-utils: lib: always fix up xattr_isize even w/o xattrs
Quoted 4 lines · Gao Xiang
Don't assume
xattr_isizeis 0 before since it's not true for the upcoming rebuild mode.Signed-off-by Gao Xiang <[email protected]>
The first five patches are applied now.
Thanks,
Gao Xiang
PATCH v7 6/13 erofs-utils: lib: add list_splice_tail() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add list_splice_tail() helper.
--- include/erofs/list.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
include/erofs/list.h +20 -0
@@ -70,6 +70,26 @@ static inline int list_empty(struct list_head *head)return head->next == head; } +static inline void __list_splice (struct list_head *list, +struct list_head *prev,struct list_head *next) +{ +struct list_head *first = list->next; +struct list_head *last = list->prev; + + first->prev = prev; + prev->next = first; + + last->next = next; + next->prev = last; +} + +static inline void list_splice_tail (struct list_head *list, +struct list_head *head) +{ +if (!list_empty (list)) +__list_splice (list, head->prev, head); +} +#define list_entry (ptr, type, member) container_of(ptr, type, member)#define list_first_entry (ptr, type, member) \
Signature · 1 line
2.24.4
PATCH v7 7/13 erofs-utils: lib: make erofs_get_unhashed_chunk() global
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
... so that it could be called from outside blobchunk.c later.
--- include/erofs/blobchunk.h | 2 ++ lib/blobchunk.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
include/erofs/blobchunk.h +2 -0
@@ -14,6 +14,8 @@ extern "C"#include "erofs/internal.h" +struct erofs_blobchunk *erofs_get_unhashed_chunk (unsigned int device_id, +erofs_blk_t blkaddr,erofs_off_t sourceoffset);int erofs_blob_write_chunk_indexes (struct erofs_inode *inode,erofs_off_t off);int erofs_blob_write_chunked_file (struct erofs_inode *inode,int fd);int tarerofs_write_chunkes (struct erofs_inode *inode,erofs_off_t data_offset);
lib/blobchunk.c +1 -1
@@ -38,7 +38,7 @@ struct erofs_blobchunk erofs_holechunk = { };static LIST_HEAD (unhashed_blobchunks); -static struct erofs_blobchunk *erofs_get_unhashed_chunk (unsigned int device_id, +struct erofs_blobchunk *erofs_get_unhashed_chunk (unsigned int device_id,erofs_blk_t blkaddr,erofs_off_t sourceoffset) {struct erofs_blobchunk *chunk;
Signature · 1 line
2.24.4
PATCH v7 8/13 erofs-utils: lib: add erofs_read_xattrs_from_disk() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add erofs_read_xattrs_from_disk() helper to reading extended attributes from disk.
--- include/erofs/internal.h | 1 + include/erofs/xattr.h | 1 + lib/xattr.c | 69 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+)
include/erofs/internal.h +1 -0
@@ -192,6 +192,7 @@ struct erofs_inode {bool compressed_idata;bool lazy_tailblock;bool with_tmpfile; +bool opaque;/* OVL: non-merge dir that may contain whiteout entries */ bool whiteouts;
include/erofs/xattr.h +1 -0
@@ -58,6 +58,7 @@ int erofs_setxattr(struct erofs_inode *inode, char *key, const void *value, size_t size);int erofs_set_opaque_xattr (struct erofs_inode *inode);int erofs_set_origin_xattr (struct erofs_inode *inode); +int erofs_read_xattrs_from_disk (struct erofs_inode *inode); #ifdef __cplusplus }
lib/xattr.c +69 -0
75 lines not on this page · raw message
Signature · 1 line
2.24.4
PATCH v7 9/13 erofs-utils: lib: add erofs_insert_ihash() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add erofs_insert_ihash() helper inserting inode into inode hash table.
Also add prototypes of erofs_iget() and erofs_iget_by_nid() in the header file.
--- include/erofs/inode.h | 3 +++ lib/inode.c | 10 +++++++--- 2 files changed, 10 insertions(+), 3 deletions(-)
include/erofs/inode.h +3 -0
@@ -25,6 +25,9 @@ u32 erofs_new_encode_dev(dev_t dev);unsigned char erofs_mode_to_ftype (umode_t mode);unsigned char erofs_ftype_to_dtype (unsigned int filetype);void erofs_inode_manager_init (void ); +void erofs_insert_ihash (struct erofs_inode *inode,dev_t dev,ino_t ino); +struct erofs_inode *erofs_iget (dev_t dev,ino_t ino); +struct erofs_inode *erofs_iget_by_nid (erofs_nid_t nid);unsigned int erofs_iput (struct erofs_inode *inode);erofs_nid_t erofs_lookupnid (struct erofs_inode *inode); struct erofs_dentry *erofs_d_alloc(struct erofs_inode *parent,
lib/inode.c +7 -3
@@ -75,6 +75,12 @@ void erofs_inode_manager_init(void)init_list_head (&inode_hashtable[i]); } +void erofs_insert_ihash (struct erofs_inode *inode,dev_t dev,ino_t ino) +{ +list_add (&inode->i_hash, + &inode_hashtable[(ino ^ dev) %NR_INODE_HASHTABLE ]); +} +/* get the inode from the (source) inode # */ struct erofs_inode *erofs_iget (dev_t dev,ino_t ino) {
@@ -976,9 +982,7 @@ static int erofs_fill_inode(struct erofs_inode *inode, struct stat *st, inode->inode_isize =sizeof (struct erofs_inode_compact ); } -list_add (&inode->i_hash, - &inode_hashtable[(st->st_ino ^ st->st_dev) % -NR_INODE_HASHTABLE ]); +erofs_insert_ihash (inode, st->st_dev, st->st_ino);return 0 ; }
Signature · 1 line
2.24.4
PATCH v7 10/13 erofs-utils: lib: add erofs_rebuild_get_dentry() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Rename tarerofs_get_dentry() to erofs_rebuild_get_dentry() and move it into lib/rebuild.c.
No logic changes.
--- include/erofs/rebuild.h | 19 +++++++ lib/Makefile.am | 3 +- lib/rebuild.c | 116 ++++++++++++++++++++++++++++++++++++++++ lib/tar.c | 109 ++----------------------------------- 4 files changed, 140 insertions(+), 107 deletions(-) create mode 100644 include/erofs/rebuild.h create mode 100644 lib/rebuild.c
include/erofs/rebuild.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0+ OR Apache-2.0 */ +#ifndef __EROFS_REBUILD_H +#define __EROFS_REBUILD_H + +#ifdef __cplusplus +extern "C" +{ +#endif + +#include "internal.h" + +struct erofs_dentry *erofs_rebuild_get_dentry (struct erofs_inode *pwd, +char *path,bool aufs,bool *whout,bool *opq); + +#ifdef __cplusplus +} +#endif + +#endif
lib/Makefile.am +2 -1
@@ -25,6 +25,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/compress_hints.h \ $(top_srcdir)/include/erofs/fragments.h \ $(top_srcdir)/include/erofs/xxhash.h \ + $(top_srcdir)/include/erofs/rebuild.h \ $(top_srcdir)/lib/liberofs_private.h noinst_HEADERS += compressor.h
@@ -32,7 +33,7 @@ liberofs_la_SOURCES = config.c io.c cache.c super.c inode.c xattr.c exclude.c \ namei.c data.c compress.c compressor.c zmap.c decompress.c \ compress_hints.c hashmap.c sha256.c blobchunk.c dir.c \ fragments.c rb_tree.c dedupe.c uuid_unparse.c uuid.c tar.c \ - block_list.c xxhash.c + block_list.c xxhash.c rebuild.c liberofs_la_CFLAGS = -Wall ${libuuid_CFLAGS} -I$(top_srcdir)/include if ENABLE_LZ4
lib/rebuild.c new file +116 -0
116 lines not on this page · raw message
lib/tar.c +3 -106
139 lines not on this page · raw message
Signature · 1 line
2.24.4
PATCH v7 11/13 erofs-utils: lib: add erofs_rebuild_load_tree() helper
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add erofs_rebuild_load_tree() helper to load the inode tree from a given erofs image, and make it merged acting as an overlayfs-like model.
Since the content of the symlink file needs to be read when loading tree, let's add a dependency on zlib_LIBS for mkfs.erofs.
Also rename tarerofs_dump_tree() to erofs_rebuild_dump_tree() since it is also called in the rebuild mode.
--- include/erofs/inode.h | 2 +- include/erofs/internal.h | 6 +- include/erofs/rebuild.h | 2 + lib/inode.c | 4 +- lib/rebuild.c | 288 +++++++++++++++++++++++++++++++++++++++ mkfs/main.c | 2 +- 6 files changed, 298 insertions(+), 6 deletions(-)
include/erofs/inode.h +1 -1
@@ -32,7 +32,7 @@ unsigned int erofs_iput(struct erofs_inode *inode);erofs_nid_t erofs_lookupnid (struct erofs_inode *inode);struct erofs_dentry *erofs_d_alloc (struct erofs_inode *parent,const char *name); -int tarerofs_dump_tree (struct erofs_inode *dir); +int erofs_rebuild_dump_tree (struct erofs_inode *dir);int erofs_init_empty_dir (struct erofs_inode *dir);struct erofs_inode *erofs_new_inode (void );struct erofs_inode *erofs_mkfs_build_tree_from_path (const char *path);
include/erofs/internal.h +4 -2
@@ -109,6 +109,7 @@ struct erofs_sb_info {int devfd;u64 devsz; +dev_t dev;unsigned int nblobs;unsigned int blobfd[256 ]; };
@@ -151,8 +152,6 @@ struct erofs_inode {union {/* (erofsfuse) runtime flags */ unsigned int flags; -/* (mkfs.erofs) device ID containing source file */ -u32 dev;/* (mkfs.erofs) queued sub-directories blocking dump */ u32 subdirs_queued; };
@@ -160,6 +159,9 @@ struct erofs_inode {struct erofs_sb_info *sbi;struct erofs_inode *i_parent; +/* (mkfs.erofs) device ID containing source file */ +u32 dev; +umode_t i_mode;erofs_off_t i_size;
include/erofs/rebuild.h +2 -0
@@ -12,6 +12,8 @@ extern "C"struct erofs_dentry *erofs_rebuild_get_dentry (struct erofs_inode *pwd,char *path,bool aufs,bool *whout,bool *opq); +int erofs_rebuild_load_tree (struct erofs_inode *root,struct erofs_sb_info *sbi); + #ifdef __cplusplus }#endif
lib/inode.c +2 -2
@@ -1324,7 +1324,7 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(int fd, const char *name)return inode; } -int tarerofs_dump_tree (struct erofs_inode *dir) +int erofs_rebuild_dump_tree (struct erofs_inode *dir) {struct erofs_dentry *d;unsigned int nr_subdirs;
@@ -1395,7 +1395,7 @@ int tarerofs_dump_tree(struct erofs_inode *dir)continue ; inode =erofs_igrab (d->inode); - ret =tarerofs_dump_tree (inode); + ret =erofs_rebuild_dump_tree (inode); dir->i_nlink += (erofs_mode_to_ftype (inode->i_mode) ==EROFS_FT_DIR );erofs_iput (inode);if (ret)
lib/rebuild.c +288 -0
300 lines not on this page · raw message
mkfs/main.c +1 -1
@@ -962,7 +962,7 @@ int main(int argc, char **argv)if (err <0 ) goto exit; - err =tarerofs_dump_tree (root_inode); + err =erofs_rebuild_dump_tree (root_inode);if (err <0 ) goto exit; }
Signature · 1 line
2.24.4
PATCH v7 12/13 erofs-utils: mkfs: introduce rebuild mode
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Introduce a new EXPERIMENTAL rebuild mode, which can be used to generate a meta-only multidev manifest image with an overlayfs-like merged tree from multiple specific EROFS images either of
tarerofs index mode (--tar=i):
mkfs.erofs --tar=i --aufs layer0.erofs layer0.tar ... mkfs.erofs --tar=i --aufs layerN.erofs layerN-1.tar
or mkfs.erofs uncompressed mode without inline data:
mkfs.erofs --tar=f -Enoinline_data --aufs layer0.erofs layer0.tar ... mkfs.erofs --tar=f -Enoinline_data --aufs layerN-1.erofs layerN-1.tar
To merge these layers, just type:
mkfs.erofs merged.erofs layer0.erofs ... layerN-1.erofs
It doesn't support compression and/or flat inline datalayout yet.
--- include/erofs/internal.h | 2 + mkfs/main.c | 217 ++++++++++++++++++++++++++++++--------- 2 files changed, 169 insertions(+), 50 deletions(-)
include/erofs/internal.h +2 -0
@@ -112,6 +112,8 @@ struct erofs_sb_info {dev_t dev;unsigned int nblobs;unsigned int blobfd[256 ]; + +struct list_head list; };/* make sure that any user of the erofs headers has atleast 64bit off_t type */
mkfs/main.c +167 -50
302 lines not on this page · raw message
Signature · 1 line
2.24.4
PATCH v7 13/13 erofs-utils: mkfs: add `--ovlfs-strip` option
In reply to Gao XiangFrom: Jingbo Xu <[email protected]>
Add --ovlfs-strip=[0|1] option for tarfs and rebuild mode for now in order to control whether some overlayfs related stuffs (e.g. whiteout files and OVL_XATTR_ORIGIN xattrs) are finally stripped.
Actually all overlayfs unnecessary xattrs should be stripped, but it isn't implemented in this commit due to complexity.
This option is disabled by default for mkfs, that is, whiteout files and OVL_XATTR_ORIGIN xattrs are kept in the image by default.
Specify --ovlfs-strip=1 explicitly to strip these stuffs.
--- include/erofs/config.h | 1 + lib/inode.c | 14 +++++++++++--- mkfs/main.c | 8 ++++++++ 3 files changed, 20 insertions(+), 3 deletions(-)
include/erofs/config.h +1 -0
@@ -54,6 +54,7 @@ struct erofs_configure {bool c_showprogress;bool c_extra_ea_name_prefixes;bool c_xattr_name_filter; +bool c_ovlfs_strip;#ifdef HAVE_LIBSELINUX struct selabel_handle *sehnd;
lib/inode.c +11 -3
@@ -1326,7 +1326,7 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(int fd, const char *name)int erofs_rebuild_dump_tree (struct erofs_inode *dir) { -struct erofs_dentry *d; +struct erofs_dentry *d, *n;unsigned int nr_subdirs;int ret;
@@ -1341,7 +1341,7 @@ int erofs_rebuild_dump_tree(struct erofs_inode *dir) dir->inode_isize =sizeof (struct erofs_inode_compact ); } -if (dir->whiteouts) +if (!cfg.c_ovlfs_strip && dir->whiteouts)erofs_set_origin_xattr (dir); ret =erofs_prepare_xattr_ibody (dir);
@@ -1373,8 +1373,16 @@ int erofs_rebuild_dump_tree(struct erofs_inode *dir) } nr_subdirs =0 ; -list_for_each_entry (d, &dir->i_subdirs, d_child) +list_for_each_entry_safe (d, n, &dir->i_subdirs, d_child) { +if (cfg.c_ovlfs_strip &&erofs_inode_is_whiteout (d->inode)) { +erofs_dbg ("remove whiteout %s" , d->inode->i_srcpath); +list_del (&d->d_child); +erofs_d_invalidate (d); +free (d); +continue ; + } ++nr_subdirs; + } ret =erofs_prepare_dir_layout (dir, nr_subdirs);if (ret)
mkfs/main.c +8 -0
@@ -64,6 +64,7 @@ static struct option long_options[] = { {"fs-config-file", required_argument, NULL, 514}, {"block-list-file", required_argument, NULL, 515}, #endif + {"ovlfs-strip", optional_argument, NULL, 516}, {0, 0, 0, 0}, };
@@ -115,6 +116,7 @@ static void usage(void)" --preserve-mtime keep per-file modification time strictly\n" " --aufs replace aufs special files with overlayfs metadata\n" " --tar=[fi] generate an image from tarball(s)\n" +" --ovlfs-strip=[01] strip overlayfs metadata in the target image (e.g. whiteouts)\n" " --quiet quiet execution (do not write anything to standard output.)\n" #ifndef NDEBUG" --random-pclusterblks randomize pclusterblks for big pcluster (debugging only)\n"
@@ -530,6 +532,12 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])case 21 : erofstar.aufs = true;break ; +case 516 : +if (!optarg || !strcmp (optarg,"1" )) + cfg.c_ovlfs_strip = true; +else + cfg.c_ovlfs_strip = false; +break ;case 1 :usage ();exit (0 );
Signature · 1 line
2.24.4