erofs-utils: lib: unexport "erofs/compress.h"
Subsystems (2)
PATCH 1/4 erofs-utils: lib: unexport "erofs/compress.h"
It shouldn't be used by external users directly.
Signed-off-by Gao Xiang <[email protected]>
--- dump/main.c | 3 +-- fsck/main.c | 2 +- lib/Makefile.am | 2 +- lib/compress.c | 2 +- lib/fragments.c | 2 +- lib/inode.c | 2 +- .../erofs/compress.h => lib/liberofs_compress.h | 17 ++++------------- mkfs/main.c | 12 ++++++------ 8 files changed, 16 insertions(+), 26 deletions(-) rename include/erofs/compress.h => lib/liberofs_compress.h (80%)
dump/main.c +1 -2
@@ -13,12 +13,11 @@#include "erofs/print.h" #include "erofs/inode.h" #include "erofs/dir.h" -#include "erofs/compress.h" #include "erofs/fragments.h" +#include "../lib/liberofs_compress.h" #include "../lib/liberofs_private.h" #include "../lib/liberofs_uuid.h" -struct erofsdump_cfg {unsigned int totalshow;bool show_inode;
fsck/main.c +1 -1
@@ -11,11 +11,11 @@#include <sys/stat.h> #include <sys/xattr.h> #include "erofs/print.h" -#include "erofs/compress.h" #include "erofs/decompress.h" #include "erofs/dir.h" #include "erofs/xattr.h" #include "../lib/compressor.h" +#include "../lib/liberofs_compress.h" #include "erofs/fragments.h" static int erofsfsck_check_inode (erofs_nid_t pnid,erofs_nid_t nid);
lib/Makefile.am +1 -1
@@ -4,7 +4,6 @@ noinst_LTLIBRARIES = liberofs.la noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/blobchunk.h \ $(top_srcdir)/include/erofs/block_list.h \ - $(top_srcdir)/include/erofs/compress.h \ $(top_srcdir)/include/erofs/config.h \ $(top_srcdir)/include/erofs/decompress.h \ $(top_srcdir)/include/erofs/defs.h \
@@ -29,6 +28,7 @@ noinst_HEADERS = $(top_srcdir)/include/erofs_fs.h \ $(top_srcdir)/include/erofs/importer.h \ $(top_srcdir)/lib/liberofs_base64.h \ $(top_srcdir)/lib/liberofs_cache.h \ + $(top_srcdir)/lib/liberofs_compress.h \ $(top_srcdir)/lib/liberofs_private.h \ $(top_srcdir)/lib/liberofs_xxhash.h \ $(top_srcdir)/lib/liberofs_gzran.h \
lib/compress.c +1 -1
@@ -15,7 +15,6 @@#include <stdlib.h> #include <unistd.h> #include "erofs/print.h" -#include "erofs/compress.h" #include "erofs/dedupe.h" #include "compressor.h" #include "erofs/block_list.h"
@@ -25,6 +24,7 @@#include "erofs/workqueue.h" #endif #include "liberofs_cache.h" +#include "liberofs_compress.h" #include "liberofs_metabox.h" #define Z_EROFS_DESTBUF_SZ (Z_EROFS_PCLUSTER_MAX_SIZE + EROFS_MAX_BLOCK_SIZE * 2)
lib/fragments.c +1 -1
@@ -14,13 +14,13 @@#include <sys/mman.h> #include "erofs/err.h" #include "erofs/inode.h" -#include "erofs/compress.h" #include "erofs/print.h" #include "erofs/internal.h" #include "erofs/fragments.h" #include "erofs/bitops.h" #include "erofs/lock.h" #include "erofs/importer.h" +#include "liberofs_compress.h" #include "liberofs_private.h" #ifdef HAVE_SYS_SENDFILE_H #include <sys/sendfile.h>
lib/inode.c +1 -1
@@ -19,7 +19,6 @@#include "erofs/lock.h" #include "erofs/diskbuf.h" #include "erofs/inode.h" -#include "erofs/compress.h" #include "erofs/xattr.h" #include "erofs/exclude.h" #include "erofs/block_list.h"
@@ -28,6 +27,7 @@#include "erofs/fragments.h" #include "erofs/importer.h" #include "liberofs_cache.h" +#include "liberofs_compress.h" #include "liberofs_private.h" #include "liberofs_metabox.h"
lib/liberofs_compress.h renamed from include/erofs/compress.h +4 -13
@@ -2,17 +2,12 @@/* * Copyright (C) 2019 HUAWEI, Inc. * http://www.huawei.com/ -* Created by Gao Xiang <[email protected]> +* Copyright (C) 2025 Alibaba Cloud */ -#ifndef __EROFS_COMPRESS_H -#define __EROFS_COMPRESS_H +#ifndef __EROFS_LIB_LIBEROFS_COMPRESS_H +#define __EROFS_LIB_LIBEROFS_COMPRESS_H -#ifdef __cplusplus -extern "C" -{ -#endif - -#include "internal.h" +#include "erofs/internal.h" #define EROFS_CONFIG_COMPR_MAX_SZ (4000 * 1024)#define Z_EROFS_COMPR_QUEUE_SZ (EROFS_CONFIG_COMPR_MAX_SZ * 2)
@@ -29,8 +24,4 @@ int z_erofs_compress_exit(struct erofs_sb_info *sbi);const char *z_erofs_list_supported_algorithms (int i,unsigned int *mask);const struct erofs_algorithm *z_erofs_list_available_compressors (int *i); -#ifdef __cplusplus -} -#endif -#endif
mkfs/main.c +6 -6
@@ -19,7 +19,6 @@#include "erofs/diskbuf.h" #include "erofs/inode.h" #include "erofs/tar.h" -#include "erofs/compress.h" #include "erofs/dedupe.h" #include "erofs/xattr.h" #include "erofs/exclude.h"
@@ -28,13 +27,14 @@#include "erofs/blobchunk.h" #include "erofs/fragments.h" #include "erofs/rebuild.h" -#include "../lib/liberofs_private.h" -#include "../lib/liberofs_uuid.h" +#include "../lib/compressor.h" +#include "../lib/liberofs_compress.h" +#include "../lib/liberofs_gzran.h" #include "../lib/liberofs_metabox.h" -#include "../lib/liberofs_s3.h" #include "../lib/liberofs_oci.h" -#include "../lib/liberofs_gzran.h" -#include "../lib/compressor.h" +#include "../lib/liberofs_private.h" +#include "../lib/liberofs_s3.h" +#include "../lib/liberofs_uuid.h" static struct option long_options[] = { {"version" , no_argument,0 ,'V' },
Signature · 1 line
2.43.5
PATCH 2/4 erofs-utils: lib: unexport z_erofs_compress_{init,exit}
Users should use new importer APIs instead.
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/internal.h | 3 ++ lib/compress.c | 97 ++++++++++++++++++++++------------------ lib/global.c | 2 + lib/importer.c | 6 +++ lib/liberofs_compress.h | 7 ++- lib/super.c | 3 +- mkfs/main.c | 9 ---- 7 files changed, 70 insertions(+), 57 deletions(-)
include/erofs/internal.h +3 -0
@@ -488,6 +488,9 @@ int erofs_listxattr(struct erofs_inode *vi, char *buffer, size_t buffer_size);int z_erofs_map_blocks_iter (struct erofs_inode *vi,struct erofs_map_blocks *map,int flags); +const char *z_erofs_list_supported_algorithms (int i,unsigned int *mask); +const struct erofs_algorithm *z_erofs_list_available_compressors (int *i); +/* io.c */ int erofs_dev_open (struct erofs_sb_info *sbi,const char *dev,int flags);void erofs_dev_close (struct erofs_sb_info *sbi);
lib/compress.c +54 -43
196 lines not on this page · raw message
lib/global.c +2 -0
@@ -11,6 +11,7 @@#endif #include "erofs/err.h" #include "erofs/config.h" +#include "liberofs_compress.h" static EROFS_DEFINE_MUTEX (erofs_global_mutex);#ifdef HAVE_LIBCURL
@@ -43,6 +44,7 @@ out_unlock:void liberofs_global_exit (void ) {erofs_mutex_lock (&erofs_global_mutex); +z_erofs_mt_global_exit ();#ifdef HAVE_LIBCURL if (erofs_global_curl_initialized) {curl_global_cleanup ();
lib/importer.c +6 -0
@@ -10,6 +10,7 @@#include "erofs/print.h" #include "erofs/lock.h" #include "liberofs_cache.h" +#include "liberofs_compress.h" #include "liberofs_metabox.h" static EROFS_DEFINE_MUTEX (erofs_importer_global_mutex);
@@ -45,6 +46,11 @@ int erofs_importer_init(struct erofs_importer *im)erofs_importer_global_init (); + subsys ="compression" ; + err =z_erofs_compress_init (im); +if (err) + goto out_err; +if (cfg.c_fragments || cfg.c_extra_ea_name_prefixes) { subsys ="packedfile" ;if (!cfg.c_mkfs_pclustersize_packed)
lib/liberofs_compress.h +3 -4
@@ -7,7 +7,7 @@#ifndef __EROFS_LIB_LIBEROFS_COMPRESS_H#define __EROFS_LIB_LIBEROFS_COMPRESS_H -#include "erofs/internal.h" +#include "erofs/importer.h" #define EROFS_CONFIG_COMPR_MAX_SZ (4000 * 1024)#define Z_EROFS_COMPR_QUEUE_SZ (EROFS_CONFIG_COMPR_MAX_SZ * 2)
@@ -18,10 +18,9 @@ void z_erofs_drop_inline_pcluster(struct erofs_inode *inode);void *erofs_begin_compressed_file (struct erofs_inode *inode,int fd,u64 fpos);int erofs_write_compressed_file (struct z_erofs_compress_ictx *ictx); -int z_erofs_compress_init (struct erofs_sb_info *sbi); +int z_erofs_compress_init (struct erofs_importer *im);int z_erofs_compress_exit (struct erofs_sb_info *sbi); -const char *z_erofs_list_supported_algorithms (int i,unsigned int *mask); -const struct erofs_algorithm *z_erofs_list_available_compressors (int *i); +int z_erofs_mt_global_exit (void );#endif
lib/super.c +2 -1
@@ -7,6 +7,7 @@#include "erofs/print.h" #include "erofs/xattr.h" #include "liberofs_cache.h" +#include "liberofs_compress.h" static bool check_layout_compatibility (struct erofs_sb_info *sbi,struct erofs_super_block *dsb)
@@ -175,7 +176,7 @@ void erofs_put_super(struct erofs_sb_info *sbi)erofs_buffer_exit (sbi->bmgr); sbi->bmgr =NULL ; } - +z_erofs_compress_exit (sbi); sbi->sb_valid = false; }
mkfs/main.c +0 -9
@@ -28,7 +28,6 @@#include "erofs/fragments.h" #include "erofs/rebuild.h" #include "../lib/compressor.h" -#include "../lib/liberofs_compress.h" #include "../lib/liberofs_gzran.h" #include "../lib/liberofs_metabox.h" #include "../lib/liberofs_oci.h"
@@ -1753,13 +1752,6 @@ int main(int argc, char **argv) goto exit; } - err =z_erofs_compress_init (&g_sbi); -if (err) { -erofs_err ("failed to initialize compressor: %s" , -erofs_strerror (err)); - goto exit; - } - importer_params.source = cfg.c_src_path; importer_params.no_datainline = mkfs_no_datainline; importer_params.dot_omitted = mkfs_dot_omitted;
@@ -1918,7 +1910,6 @@ int main(int argc, char **argv) exit:if (root)erofs_iput (root); -z_erofs_compress_exit (&g_sbi);z_erofs_dedupe_exit (); blklst =erofs_blocklist_close ();if (blklst)
Signature · 1 line
2.43.5
PATCH 3/4 erofs-utils: lib: migrate pclustersize configurations
In reply to Gao XiangAlso convert their units from bytes to blocks.
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/compress_hints.h | 8 +- include/erofs/config.h | 4 - include/erofs/importer.h | 4 + lib/compress.c | 129 ++++++++++++++++----------------- lib/compress_hints.c | 39 +++++----- lib/compressor.c | 6 +- lib/compressor.h | 6 +- lib/compressor_liblzma.c | 4 +- lib/compressor_libzstd.c | 4 +- lib/config.c | 1 - lib/importer.c | 4 +- lib/inode.c | 21 +++--- lib/liberofs_compress.h | 3 +- mkfs/main.c | 18 ++--- 14 files changed, 127 insertions(+), 124 deletions(-)
include/erofs/compress_hints.h +5 -3
@@ -11,9 +11,9 @@ extern "C" {#endif -#include "erofs/internal.h" #include <sys/types.h> #include <regex.h> +#include "erofs/importer.h" struct erofs_compress_hints {struct list_head list;
@@ -23,9 +23,11 @@ struct erofs_compress_hints {unsigned char algorithmtype; }; -bool z_erofs_apply_compress_hints (struct erofs_inode *inode); +bool z_erofs_apply_compress_hints (struct erofs_importer *im, +struct erofs_inode *inode);void erofs_cleanup_compress_hints (void ); -int erofs_load_compress_hints (struct erofs_sb_info *sbi); +int erofs_load_compress_hints (struct erofs_importer *im, +struct erofs_sb_info *sbi); #ifdef __cplusplus }
include/erofs/config.h +0 -4
@@ -70,10 +70,6 @@ struct erofs_configure {u8 c_mkfs_metabox_algid;/* < 0, xattr disabled and INT_MAX, always use inline xattrs */ int c_inline_xattr_tolerance; -u32 c_mkfs_pclustersize_max; -u32 c_mkfs_pclustersize_def; -u32 c_mkfs_pclustersize_packed; -s32 c_mkfs_pclustersize_metabox;u32 c_max_decompressed_extent_bytes;u64 c_unix_timestamp;const char *mount_point;
include/erofs/importer.h +4 -0
@@ -25,6 +25,10 @@ struct erofs_importer_params {u32 uid_offset;u32 gid_offset;u32 fsalignblks; +u32 pclusterblks_max; +u32 pclusterblks_def; +u32 pclusterblks_packed; +s32 pclusterblks_metabox;char force_inodeversion;bool ignore_mtime;bool no_datainline;
lib/compress.c +61 -68
246 lines not on this page · raw message
lib/compress_hints.c +21 -18
@@ -45,17 +45,19 @@ static int erofs_insert_compress_hints(const char *s, unsigned int blks,return ret; } -bool z_erofs_apply_compress_hints (struct erofs_inode *inode) +bool z_erofs_apply_compress_hints (struct erofs_importer *im, +struct erofs_inode *inode) { -const char *s; +const struct erofs_importer_params *params = im->params; +unsigned int pclusterblks = params->pclusterblks_def; +unsigned int algorithmtype;struct erofs_compress_hints *r; -unsigned int pclusterblks, algorithmtype; +const char *s;if (inode->z_physical_clusterblks)return true; s =erofs_fspath (inode->i_srcpath); - pclusterblks = cfg.c_mkfs_pclustersize_def >> inode->sbi->blkszbits; algorithmtype =0 ;list_for_each_entry (r, &compress_hints_head, list) {
@@ -86,11 +88,13 @@ void erofs_cleanup_compress_hints(void) } } -int erofs_load_compress_hints (struct erofs_sb_info *sbi) +int erofs_load_compress_hints (struct erofs_importer *im, +struct erofs_sb_info *sbi) { +struct erofs_importer_params *params = im->params;char buf[PATH_MAX +100 ];FILE *f; -unsigned int line, max_pclustersize =0 ; +unsigned int line, max_pclusterblks =0 ;int ret =0 ;if (!cfg.c_compress_hints_file)
@@ -101,7 +105,7 @@ int erofs_load_compress_hints(struct erofs_sb_info *sbi)return -errno;for (line =1 ;fgets (buf,sizeof (buf), f); ++line) { -unsigned int pclustersize, ccfg; +unsigned int pclustersize, pclusterblks, ccfg;char *alg, *pattern;if (*buf =='#' || *buf =='\n' )
@@ -134,22 +138,21 @@ int erofs_load_compress_hints(struct erofs_sb_info *sbi) }if (pclustersize %erofs_blksiz (sbi)) { -erofs_warn ("invalid physical clustersize %u, " -"use default pclusterblks %u" , - pclustersize, cfg.c_mkfs_pclustersize_def); +erofs_warn ("invalid physical clustersize %u, use default pclustersize (%u blocks)" , + pclustersize, params->pclusterblks_max);continue ; } -erofs_insert_compress_hints (pattern, - pclustersize /erofs_blksiz (sbi), ccfg); + pclusterblks = pclustersize >> sbi->blkszbits; +erofs_insert_compress_hints (pattern, pclusterblks, ccfg); -if (pclustersize > max_pclustersize) - max_pclustersize = pclustersize; +if (pclusterblks > max_pclusterblks) + max_pclusterblks = pclusterblks; } -if (cfg.c_mkfs_pclustersize_max < max_pclustersize) { - cfg.c_mkfs_pclustersize_max = max_pclustersize; -erofs_warn ("update max pclustersize to %u" , - cfg.c_mkfs_pclustersize_max); +if (params->pclusterblks_max < max_pclusterblks) { +erofs_warn ("update max pclustersize to %u blocks" , + max_pclusterblks); + params->pclusterblks_max = max_pclusterblks; } out:fclose (f);
lib/compressor.c +4 -2
@@ -97,7 +97,8 @@ int erofs_compress(const struct erofs_compress *c, }int erofs_compressor_init (struct erofs_sb_info *sbi,struct erofs_compress *c, -char *alg_name,int compression_level,u32 dict_size) +char *alg_name,int compression_level, +u32 dict_size,u32 pclustersize_max) {int ret, i;
@@ -135,7 +136,8 @@ int erofs_compressor_init(struct erofs_sb_info *sbi, struct erofs_compress *c, }if (erofs_algs[i].c->setdictsize) { - ret = erofs_algs[i].c->setdictsize (c, dict_size); + ret = erofs_algs[i].c->setdictsize (c, dict_size, + pclustersize_max);if (ret) {erofs_err ("failed to set dict size %u for %s" , dict_size, alg_name);
lib/compressor.h +4 -2
@@ -21,7 +21,8 @@ struct erofs_compressor {int (*exit)(struct erofs_compress *c);void (*reset)(struct erofs_compress *c);int (*setlevel)(struct erofs_compress *c,int compression_level); -int (*setdictsize)(struct erofs_compress *c,u32 dict_size); +int (*setdictsize)(struct erofs_compress *c,u32 dict_size, +u32 pclustersize_max); int (*compress_destsize)(const struct erofs_compress *c, const void *src, unsigned int *srcsize,
@@ -68,7 +69,8 @@ int erofs_compress(const struct erofs_compress *c, void *dst, unsigned int dstcapacity);int erofs_compressor_init (struct erofs_sb_info *sbi,struct erofs_compress *c, -char *alg_name,int compression_level,u32 dict_size); +char *alg_name,int compression_level,u32 dict_size, +u32 pclustersize_max);int erofs_compressor_exit (struct erofs_compress *c);void erofs_compressor_reset (struct erofs_compress *c);
lib/compressor_liblzma.c +2 -2
@@ -68,14 +68,14 @@ static int erofs_compressor_liblzma_setlevel(struct erofs_compress *c, }static int erofs_compressor_liblzma_setdictsize (struct erofs_compress *c, -u32 dict_size) +u32 dict_size,u32 pclustersize_max) {if (!dict_size) {if (erofs_compressor_lzma.default_dictsize) { dict_size = erofs_compressor_lzma.default_dictsize; }else { dict_size =min_t (u32,Z_EROFS_LZMA_MAX_DICT_SIZE , - cfg.c_mkfs_pclustersize_max <<2 ); + pclustersize_max <<2 );if (dict_size <32768 ) dict_size =32768 ; }
lib/compressor_libzstd.c +2 -2
@@ -115,14 +115,14 @@ static int erofs_compressor_libzstd_setlevel(struct erofs_compress *c, }static int erofs_compressor_libzstd_setdictsize (struct erofs_compress *c, -u32 dict_size) +u32 dict_size,u32 pclustersize_max) {if (!dict_size) {if (erofs_compressor_libzstd.default_dictsize) { dict_size = erofs_compressor_libzstd.default_dictsize; }else { dict_size =min_t (u32,Z_EROFS_ZSTD_MAX_DICT_SIZE , - cfg.c_mkfs_pclustersize_max <<3 ); + pclustersize_max <<3 ); dict_size =1 <<ilog2 (dict_size); } }
lib/config.c +0 -1
@@ -32,7 +32,6 @@ void erofs_init_configure(void) cfg.c_inline_xattr_tolerance =2 ; cfg.c_unix_timestamp =-1 ; cfg.c_max_decompressed_extent_bytes =-1 ; - cfg.c_mkfs_pclustersize_metabox =-1 ; erofs_stdout_tty =isatty (STDOUT_FILENO ); }
lib/importer.c +2 -2
@@ -53,8 +53,8 @@ int erofs_importer_init(struct erofs_importer *im)if (cfg.c_fragments || cfg.c_extra_ea_name_prefixes) { subsys ="packedfile" ; -if (!cfg.c_mkfs_pclustersize_packed) - cfg.c_mkfs_pclustersize_packed = cfg.c_mkfs_pclustersize_def; +if (!params->pclusterblks_packed) + params->pclusterblks_packed = params->pclusterblks_def; err =erofs_packedfile_init (sbi, cfg.c_fragments);if (err)
lib/inode.c +11 -10
@@ -600,13 +600,14 @@ int erofs_write_file_from_buffer(struct erofs_inode *inode, char *buf) }/* rules to decide whether a file could be compressed or not */ -static bool erofs_file_is_compressible (struct erofs_inode *inode) +static bool erofs_file_is_compressible (struct erofs_importer *im, +struct erofs_inode *inode) {if (erofs_is_metabox_inode (inode) && - cfg.c_mkfs_pclustersize_metabox <0 ) + !im->params->pclusterblks_metabox)return false;if (cfg.c_compress_hints_file) -return z_erofs_apply_compress_hints (inode); +return z_erofs_apply_compress_hints (im, inode);return true; }
@@ -1804,9 +1805,9 @@ static int erofs_mkfs_handle_inode(struct erofs_importer *im,return -errno;if (cfg.c_compr_opts[0 ].alg && -erofs_file_is_compressible (inode)) { - ctx.ictx =erofs_begin_compressed_file (inode, - ctx.fd,0 ); +erofs_file_is_compressible (im, inode)) { + ctx.ictx =erofs_begin_compressed_file (im, + inode, ctx.fd,0 );if (IS_ERR (ctx.ictx))return PTR_ERR (ctx.ictx); }
@@ -1870,8 +1871,8 @@ static int erofs_rebuild_handle_inode(struct erofs_importer *im,return ret;if (cfg.c_compr_opts[0 ].alg && -erofs_file_is_compressible (inode)) { - ctx.ictx =erofs_begin_compressed_file (inode, +erofs_file_is_compressible (im, inode)) { + ctx.ictx =erofs_begin_compressed_file (im, inode, ctx.fd, ctx.fpos);if (IS_ERR (ctx.ictx))return PTR_ERR (ctx.ictx);
@@ -2137,8 +2138,8 @@ struct erofs_inode *erofs_mkfs_build_special_from_fd(struct erofs_importer *im, }if (cfg.c_compr_opts[0 ].alg && -erofs_file_is_compressible (inode)) { - ictx =erofs_begin_compressed_file (inode, fd,0 ); +erofs_file_is_compressible (im, inode)) { + ictx =erofs_begin_compressed_file (im, inode, fd,0 );if (IS_ERR (ictx))return ERR_CAST (ictx);
lib/liberofs_compress.h +2 -1
@@ -15,7 +15,8 @@struct z_erofs_compress_ictx ;void z_erofs_drop_inline_pcluster (struct erofs_inode *inode); -void *erofs_begin_compressed_file (struct erofs_inode *inode,int fd,u64 fpos); +void *erofs_begin_compressed_file (struct erofs_importer *im, +struct erofs_inode *inode,int fd,u64 fpos);int erofs_write_compressed_file (struct z_erofs_compress_ictx *ictx);int z_erofs_compress_init (struct erofs_importer *im);
mkfs/main.c +9 -9
@@ -1416,8 +1416,8 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params, pclustersize_max);return -EINVAL ; } - cfg.c_mkfs_pclustersize_max = pclustersize_max; - cfg.c_mkfs_pclustersize_def = cfg.c_mkfs_pclustersize_max; + params->pclusterblks_max = pclustersize_max >> mkfs_blkszbits; + params->pclusterblks_def = params->pclusterblks_max; }if (cfg.c_chunkbits && cfg.c_chunkbits < mkfs_blkszbits) { erofs_err("chunksize %u must be larger than block size",
@@ -1447,7 +1447,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params, pclustersize_packed);return -EINVAL ; } - cfg.c_mkfs_pclustersize_packed = pclustersize_packed; + params->pclusterblks_packed = pclustersize_packed >> mkfs_blkszbits; }if (pclustersize_metabox >=0 ) {
@@ -1458,7 +1458,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params, pclustersize_metabox);return -EINVAL ; } - cfg.c_mkfs_pclustersize_metabox = pclustersize_metabox; + params->pclusterblks_metabox = pclustersize_metabox >> mkfs_blkszbits; cfg.c_mkfs_metabox_algid = metabox_algorithmid;erofs_sb_set_metabox (&g_sbi); }
@@ -1468,7 +1468,7 @@ static int mkfs_parse_options_cfg(struct erofs_importer_params *params,return 0 ; } -static void erofs_mkfs_default_options (void ) +static void erofs_mkfs_default_options (struct erofs_importer_params *params) { cfg.c_showprogress = true; cfg.c_legacy_compress = false;
@@ -1478,8 +1478,8 @@ static void erofs_mkfs_default_options(void) cfg.c_mkfs_segment_size =16ULL *1024 *1024 ;#endif mkfs_blkszbits =ilog2 (min_t (u32,getpagesize (),EROFS_MAX_BLOCK_SIZE )); - cfg.c_mkfs_pclustersize_max =1U << mkfs_blkszbits; - cfg.c_mkfs_pclustersize_def = cfg.c_mkfs_pclustersize_max; + params->pclusterblks_max =1U ; + params->pclusterblks_def =1U ; g_sbi.feature_incompat =EROFS_FEATURE_INCOMPAT_ZERO_PADDING ; g_sbi.feature_compat =EROFS_FEATURE_COMPAT_SB_CHKSUM |EROFS_FEATURE_COMPAT_MTIME ;
@@ -1635,8 +1635,8 @@ int main(int argc, char **argv) err =liberofs_global_init ();if (err)return 1 ; -erofs_mkfs_default_options ();erofs_importer_preset (&importer_params); +erofs_mkfs_default_options (&importer_params); err =mkfs_parse_options_cfg (&importer_params, argc, argv);erofs_show_progs (argc, argv);
@@ -1745,7 +1745,7 @@ int main(int argc, char **argv) } } - err =erofs_load_compress_hints (&g_sbi); + err =erofs_load_compress_hints (&importer, &g_sbi);if (err) {erofs_err ("failed to load compress hints %s" , cfg.c_compress_hints_file);
Signature · 1 line
2.43.5
PATCH 4/4 erofs-utils: lib: migrate advance compression configurations
In reply to Gao XiangSigned-off-by Gao Xiang <[email protected]>
--- include/erofs/config.h | 11 -------- include/erofs/importer.h | 11 ++++++++ include/erofs/xattr.h | 4 ++- lib/compress.c | 47 ++++++++++++++++++------------- lib/compressor_deflate.c | 3 +- lib/importer.c | 9 +++--- lib/inode.c | 4 +-- lib/xattr.c | 7 +++-- mkfs/main.c | 61 ++++++++++++++++++++++++---------------- 9 files changed, 93 insertions(+), 64 deletions(-)
include/erofs/config.h +0 -11
@@ -27,12 +27,6 @@ enum { TIMESTAMP_CLAMPING, }; -enum { -FRAGDEDUPE_FULL , -FRAGDEDUPE_INODE , -FRAGDEDUPE_OFF , -}; -#define EROFS_MAX_COMPR_CFGS 64struct erofs_compr_opts {
@@ -48,11 +42,6 @@ struct erofs_configure {bool c_legacy_compress;char c_timeinherit;char c_chunkbits; -bool c_ztailpacking; -bool c_fragments; -bool c_all_fragments; -bool c_dedupe; -char c_fragdedupe;bool c_showprogress;bool c_extra_ea_name_prefixes;bool c_xattr_name_filter;
include/erofs/importer.h +11 -0
@@ -17,6 +17,12 @@ enum { EROFS_FORCE_INODE_EXTENDED, }; +enum { +EROFS_FRAGDEDUPE_FULL , +EROFS_FRAGDEDUPE_INODE , +EROFS_FRAGDEDUPE_OFF , +}; +struct erofs_importer_params {char *source;u32 mt_async_queue_limit;
@@ -35,6 +41,11 @@ struct erofs_importer_params {bool hard_dereference;bool ovlfs_strip;bool dot_omitted; +bool ztailpacking; +bool dedupe; +bool fragments; +bool all_fragments; +char fragdedupe; };struct erofs_importer {
include/erofs/xattr.h +3 -1
@@ -43,6 +43,8 @@ static inline unsigned int xattrblock_offset(struct erofs_inode *vi, (_size -sizeof (struct erofs_xattr_ibody_header )) / \ sizeof(struct erofs_xattr_entry) + 1; }) +struct erofs_importer ; +int erofs_scan_file_xattrs (struct erofs_inode *inode);int erofs_prepare_xattr_ibody (struct erofs_inode *inode,bool noroom);char *erofs_export_xattr_ibody (struct erofs_inode *inode);
@@ -50,7 +52,7 @@ int erofs_build_shared_xattrs_from_path(struct erofs_sb_info *sbi, const char *pint erofs_xattr_insert_name_prefix (const char *prefix);void erofs_xattr_cleanup_name_prefixes (void ); -int erofs_xattr_flush_name_prefixes (struct erofs_sb_info *sbi,bool plain); +int erofs_xattr_flush_name_prefixes (struct erofs_importer *im,bool plain);void erofs_xattr_prefixes_cleanup (struct erofs_sb_info *sbi);int erofs_xattr_prefixes_init (struct erofs_sb_info *sbi);
lib/compress.c +28 -19
172 lines not on this page · raw message
lib/compressor_deflate.c +2 -1
@@ -70,7 +70,8 @@ static int erofs_compressor_deflate_setlevel(struct erofs_compress *c, }static int erofs_compressor_deflate_setdictsize (struct erofs_compress *c, -u32 dict_size) +u32 dict_size, +u32 pclustersize_max) {if (!dict_size) dict_size = erofs_compressor_deflate.default_dictsize;
lib/importer.c +5 -4
@@ -51,12 +51,12 @@ int erofs_importer_init(struct erofs_importer *im)if (err) goto out_err; -if (cfg.c_fragments || cfg.c_extra_ea_name_prefixes) { +if (params->fragments || cfg.c_extra_ea_name_prefixes) { subsys ="packedfile" ;if (!params->pclusterblks_packed) params->pclusterblks_packed = params->pclusterblks_def; - err =erofs_packedfile_init (sbi, cfg.c_fragments); + err =erofs_packedfile_init (sbi, params->fragments);if (err) goto out_err; }
@@ -66,7 +66,7 @@ int erofs_importer_init(struct erofs_importer *im)if (err) goto out_err; -if (cfg.c_fragments) { +if (params->fragments) { subsys ="dedupe_ext" ; err =z_erofs_dedupe_ext_init ();if (err)
@@ -84,6 +84,7 @@ out_err:int erofs_importer_flush_all (struct erofs_importer *im) { +const struct erofs_importer_params *params = im->params;struct erofs_sb_info *sbi = im->sbi;unsigned int fsalignblks;int err;
@@ -95,7 +96,7 @@ int erofs_importer_flush_all(struct erofs_importer *im)return err; } -if ((cfg.c_fragments || cfg.c_extra_ea_name_prefixes) && +if ((params->fragments || cfg.c_extra_ea_name_prefixes) &&erofs_sb_has_fragments (sbi)) {erofs_update_progressinfo ("Handling packed data ..." ); err =erofs_flush_packed_inode (im);
lib/inode.c +2 -2
@@ -874,7 +874,7 @@ static bool erofs_inode_need_48bit(struct erofs_inode *inode)static int erofs_prepare_inode_buffer (struct erofs_importer *im,struct erofs_inode *inode) { -struct erofs_importer_params *params = im->params; +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;
@@ -942,7 +942,7 @@ noinline:return PTR_ERR (bh); }else if (inode->idata_size) {if (is_inode_layout_compression (inode)) { -DBG_BUGON (!cfg.c_ztailpacking); +DBG_BUGON (!params->ztailpacking);erofs_dbg ("Inline %scompressed data (%u bytes) to %s" , inode->compressed_idata ?"" :"un" , inode->idata_size, inode->i_srcpath);
lib/xattr.c +5 -2
@@ -16,6 +16,7 @@#include "erofs/hashtable.h" #include "erofs/xattr.h" #include "erofs/fragments.h" +#include "erofs/importer.h" #include "liberofs_cache.h" #include "liberofs_metabox.h" #include "liberofs_xxhash.h"
@@ -805,9 +806,11 @@ static int comp_shared_xattr_item(const void *a, const void *b)return la > lb; } -int erofs_xattr_flush_name_prefixes (struct erofs_sb_info *sbi,bool plain) +int erofs_xattr_flush_name_prefixes (struct erofs_importer *im,bool plain) { -bool may_fragments = cfg.c_fragments ||erofs_sb_has_fragments (sbi); +const struct erofs_importer_params *params = im->params; +struct erofs_sb_info *sbi = im->sbi; +bool may_fragments = params->fragments ||erofs_sb_has_fragments (sbi);struct erofs_vfile *vf = &sbi->bdev;struct erofs_bufmgr *bmgr = sbi->bmgr;struct erofs_buffer_head *bh =NULL ;
mkfs/main.c +37 -24
165 lines not on this page · raw message
Signature · 1 line
2.43.5