erofs-utils: mkfs: fix unintended multi-threaded disable
PATCH 1/3 erofs-utils: mkfs: fix unintended multi-threaded disable
--- lib/compress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
lib/compress.c +1 -1
@@ -1743,7 +1743,7 @@ static int z_erofs_mt_global_init(struct erofs_importer *im)if (workers <1 )return 0 ;/* XXX: `dedupe` is actually not a global option here. */ -if (workers >=1 && params->dedupe !=EROFS_DEDUPE_FORCE_OFF ) { +if (workers >=1 && params->dedupe ==EROFS_DEDUPE_FORCE_ON ) {erofs_warn ("multi-threaded dedupe is NOT implemented for now" ); cfg.c_mt_workers =0 ; }else {
Signature · 1 line
2.43.5
PATCH 2/3 erofs-utils: lib: ibmgr should be assigned in advance
Otherwise, metabox won't keep several types of inodes.
--- lib/inode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
lib/inode.c +8 -8
@@ -903,8 +903,7 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im, {const struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = im->sbi; -struct erofs_bufmgr *bmgr = sbi->bmgr; -struct erofs_bufmgr *ibmgr = bmgr; +struct erofs_bufmgr *ibmgr;unsigned int inodesize;struct erofs_buffer_head *bh, *ibh;
@@ -922,6 +921,13 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im,if (inode->extent_isize) inodesize =roundup (inodesize,8 ) + inode->extent_isize; +if (!erofs_is_special_identifier (inode->i_srcpath) && +erofs_metabox_bmgr (sbi)) + inode->in_metabox = true; + +if (inode->in_metabox) + ibmgr =erofs_metabox_bmgr (sbi) ?: sbi->bmgr; +if (inode->datalayout ==EROFS_INODE_FLAT_PLAIN ) goto noinline;
@@ -942,12 +948,6 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im, inode->datalayout =EROFS_INODE_FLAT_PLAIN ; } -if (!erofs_is_special_identifier (inode->i_srcpath) && -erofs_metabox_bmgr (sbi)) - inode->in_metabox = true; - -if (inode->in_metabox) - ibmgr =erofs_metabox_bmgr (sbi) ?: bmgr; bh =erofs_balloc (ibmgr,INODE , inodesize, inode->idata_size);if (bh ==ERR_PTR (-ENOSPC )) {int ret;
Signature · 1 line
2.43.5
Re: [PATCH 2/3] erofs-utils: lib: ibmgr should be assigned in advance
Quoted 4 lines · Gao Xiang
Otherwise, metabox won't keep several types of inodes.
Fixes 7928074b7643 ("erofs-utils: introduce metadata compression [metabox]")Signed-off-by Gao Xiang <[email protected]>
Thanks,
Hongbo
Quoted 45 lines
--- lib/inode.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)lib/inode.c +8
-8@@ -903,8 +903,7 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im, {const struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = im->sbi; -struct erofs_bufmgr *bmgr = sbi->bmgr; -struct erofs_bufmgr *ibmgr = bmgr; +struct erofs_bufmgr *ibmgr;unsigned int inodesize;struct erofs_buffer_head *bh, *ibh;@@ -922,6 +921,13 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im,if (inode->extent_isize) inodesize =roundup (inodesize,8 ) + inode->extent_isize; +if (!erofs_is_special_identifier (inode->i_srcpath) && +erofs_metabox_bmgr (sbi)) + inode->in_metabox = true; + +if (inode->in_metabox) + ibmgr =erofs_metabox_bmgr (sbi) ?: sbi->bmgr; +if (inode->datalayout ==EROFS_INODE_FLAT_PLAIN ) goto noinline;@@ -942,12 +948,6 @@ static int erofs_prepare_inode_buffer(struct erofs_importer *im, inode->datalayout =EROFS_INODE_FLAT_PLAIN ; } -if (!erofs_is_special_identifier (inode->i_srcpath) && -erofs_metabox_bmgr (sbi)) - inode->in_metabox = true; - -if (inode->in_metabox) - ibmgr =erofs_metabox_bmgr (sbi) ?: bmgr; bh =erofs_balloc (ibmgr,INODE , inodesize, inode->idata_size);if (bh ==ERR_PTR (-ENOSPC )) {int ret;
PATCH 3/3 erofs-utils: mkfs: add optional support for inode meta zone
In reply to Gao XiangMany use cases benefit from concentrating inode metadata, such as image filesystems primarily accessed over a network (e.g., EROFS native full container images). Otherwise, scattered on-disk inodes increase network access overhead and make metadata prefetching (so that systems won't be stuck by metadata I/Os due to network failures, for example) difficult to implement.
Usage:
--ZI or --ZI=1 Enable inode meta zone;
--ZI=0 Disable inode meta zone (default).
--- include/erofs/internal.h | 12 ++-- lib/importer.c | 10 ++- lib/inode.c | 46 ++++++++------ lib/liberofs_metabox.h | 14 ++++- lib/metabox.c | 127 ++++++++++++++++++++++++++++++--------- lib/super.c | 10 ++- lib/xattr.c | 2 +- mkfs/main.c | 12 +++- 8 files changed, 168 insertions(+), 65 deletions(-)
include/erofs/internal.h +6 -6
@@ -97,7 +97,7 @@ struct erofs_sb_info {u64 total_blocks;u64 primarydevice_blocks; -u32 meta_blkaddr; +s32 meta_blkaddr;u32 xattr_blkaddr;u32 feature_compat;
@@ -150,7 +150,7 @@ struct erofs_sb_info {struct erofs_bufmgr *bmgr;struct erofs_xattrmgr *xamgr;struct z_erofs_mgr *zmgr; -struct erofs_metaboxmgr *m2gr; +struct erofs_metamgr *m2gr, *mxgr;struct erofs_packed_inode *packedinode;struct erofs_buffer_head *bh_sb;struct erofs_buffer_head *bh_devt;
@@ -309,8 +309,8 @@ static inline bool erofs_inode_in_metabox(struct erofs_inode *inode)static inline erofs_off_t erofs_iloc (struct erofs_inode *inode) {struct erofs_sb_info *sbi = inode->sbi; -erofs_off_t base =erofs_inode_in_metabox (inode) ?0 : -erofs_pos (sbi, sbi->meta_blkaddr); +s64 base =erofs_inode_in_metabox (inode) ?0 : + (s64 )erofs_pos (sbi, sbi->meta_blkaddr);return base + ((inode->nid &EROFS_DIRENT_NID_MASK ) <<EROFS_ISLOTBITS ); }
@@ -434,8 +434,8 @@ int erofs_mkfs_init_devices(struct erofs_sb_info *sbi, unsigned int devices);int erofs_write_device_table (struct erofs_sb_info *sbi);int erofs_enable_sb_chksum (struct erofs_sb_info *sbi,u32 *crc);int erofs_superblock_csum_verify (struct erofs_sb_info *sbi); -int erofs_mkfs_format_fs (struct erofs_sb_info *sbi, -unsigned int blkszbits,unsigned int dsunit); +int erofs_mkfs_format_fs (struct erofs_sb_info *sbi,unsigned int blkszbits, +unsigned int dsunit,bool metazone);int erofs_mkfs_load_fs (struct erofs_sb_info *sbi,unsigned int dsunit);/* namei.c */
lib/importer.c +7 -3
@@ -69,8 +69,8 @@ int erofs_importer_init(struct erofs_importer *im) goto out_err; } - subsys ="metabox" ; - err =erofs_metabox_init (sbi); + subsys ="metadata" ; + err =erofs_metadata_init (sbi);if (err) goto out_err;
@@ -107,6 +107,10 @@ int erofs_importer_flush_all(struct erofs_importer *im)if (err)return err; + err =erofs_metazone_flush (sbi); +if (err) +return err; + fsalignblks = im->params->fsalignblks ?roundup_pow_of_two (im->params->fsalignblks) :1 ; sbi->primarydevice_blocks = roundup(erofs_mapbh(sbi->bmgr, NULL),
@@ -128,6 +132,6 @@ void erofs_importer_exit(struct erofs_importer *im)struct erofs_sb_info *sbi = im->sbi;z_erofs_dedupe_ext_exit (); -erofs_metabox_exit (sbi); +erofs_metadata_exit (sbi);erofs_packedfile_exit (sbi); }
lib/inode.c +26 -20
93 lines not on this page · raw message
lib/liberofs_metabox.h +11 -3
@@ -4,6 +4,8 @@#include "erofs/internal.h" +#define EROFS_META_NEW_ADDR ((u32)-1ULL) +extern const char *erofs_metabox_identifier;#define EROFS_METABOX_INODE erofs_metabox_identifier
@@ -12,11 +14,17 @@ static inline bool erofs_is_metabox_inode(struct erofs_inode *inode) return inode->i_srcpath == EROFS_METABOX_INODE; } +static inline bool erofs_has_meta_zone (struct erofs_sb_info *sbi) +{ +return sbi->m2gr || sbi->meta_blkaddr ==EROFS_META_NEW_ADDR ; +} +struct erofs_importer ; -void erofs_metabox_exit (struct erofs_sb_info *sbi); -int erofs_metabox_init (struct erofs_sb_info *sbi); -struct erofs_bufmgr *erofs_metabox_bmgr (struct erofs_sb_info *sbi); +void erofs_metadata_exit (struct erofs_sb_info *sbi); +int erofs_metadata_init (struct erofs_sb_info *sbi); +struct erofs_bufmgr *erofs_metadata_bmgr (struct erofs_sb_info *sbi,bool mbox);int erofs_metabox_iflush (struct erofs_importer *im); +int erofs_metazone_flush (struct erofs_sb_info *sbi);#endif
lib/metabox.c +99 -28
180 lines not on this page · raw message
lib/super.c +7 -3
@@ -8,6 +8,7 @@#include "erofs/xattr.h" #include "liberofs_cache.h" #include "liberofs_compress.h" +#include "liberofs_metabox.h" static bool check_layout_compatibility (struct erofs_sb_info *sbi,struct erofs_super_block *dsb)
@@ -418,8 +419,8 @@ out:return 0 ; } -int erofs_mkfs_format_fs (struct erofs_sb_info *sbi, -unsigned int blkszbits,unsigned int dsunit) +int erofs_mkfs_format_fs (struct erofs_sb_info *sbi,unsigned int blkszbits, +unsigned int dsunit,bool metazone) {struct erofs_buffer_head *bh;struct erofs_bufmgr *bmgr;
@@ -430,7 +431,10 @@ int erofs_mkfs_format_fs(struct erofs_sb_info *sbi,return -ENOMEM ; sbi->bmgr = bmgr; bmgr->dsunit = dsunit; - +if (metazone) + sbi->meta_blkaddr =EROFS_META_NEW_ADDR ; +else + sbi->meta_blkaddr =0 ; bh =erofs_reserve_sb (bmgr);if (IS_ERR (bh))return PTR_ERR (bh);
lib/xattr.c +1 -1
@@ -828,7 +828,7 @@ int erofs_xattr_flush_name_prefixes(struct erofs_importer *im, bool plain)if (!plain) {if (erofs_sb_has_metabox (sbi)) { - bmgr =erofs_metabox_bmgr (sbi); + bmgr =erofs_metadata_bmgr (sbi, true); vf = bmgr->vf; }else if (may_fragments) {erofs_sb_set_fragments (sbi);
mkfs/main.c +11 -1
@@ -101,6 +101,7 @@ static struct option long_options[] = { {"oci", optional_argument, NULL, 534}, #endif {"zD", optional_argument, NULL, 536}, + {"ZI", optional_argument, NULL, 537}, {0, 0, 0, 0}, };
@@ -176,6 +177,7 @@ static void usage(int argc, char **argv)" --mkfs-time the timestamp is applied as build time only\n" " -UX use a given filesystem UUID\n" " --zD[=<0|1>] specify directory compression: 0=disable [default], 1=enable\n" +" --ZI[=<0|1>] specify the separate inode metadata zone availability: 0=disable [default], 1=enable\n" " --all-root make all files owned by root\n" #ifdef EROFS_MT_ENABLED" --async-queue-limit=# specify the maximum number of entries in the multi-threaded job queue\n"
@@ -269,6 +271,7 @@ static void version(void)static struct erofsmkfs_cfg {/* < 0, xattr disabled and >= INT_MAX, always use inline xattrs */ long inlinexattr_tolerance; +bool inode_metazone; } mkfscfg = { .inlinexattr_tolerance =2 , };
@@ -1412,6 +1415,12 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,else params->compress_dir = false;break ; +case 537 : +if (!optarg ||strcmp (optarg,"1" )) + mkfscfg.inode_metazone = true; +else + mkfscfg.inode_metazone = false; +break ;case 'V' :version ();exit (0 );
@@ -1787,7 +1796,8 @@ int main(int argc, char **argv) }if (!incremental_mode) - err =erofs_mkfs_format_fs (&g_sbi, mkfs_blkszbits, dsunit); + err =erofs_mkfs_format_fs (&g_sbi, mkfs_blkszbits, dsunit, + mkfscfg.inode_metazone);else err =erofs_mkfs_load_fs (&g_sbi, dsunit);if (err)
Signature · 1 line
2.43.5