erofs-utils: support randomizing algorithms in debugging mode
PATCH 1/1 erofs-utils: support randomizing algorithms in debugging mode
It's used for multiple algorithms selftest.
Signed-off-by Gao Xiang <[email protected]>
--- include/erofs/config.h | 1 + lib/compress.c | 11 +++++++++++ mkfs/main.c | 5 +++++ 3 files changed, 17 insertions(+)
include/erofs/config.h +1 -0
@@ -41,6 +41,7 @@ struct erofs_configure {bool c_legacy_compress;#ifndef NDEBUG bool c_random_pclusterblks; +bool c_random_algorithms;#endif char c_timeinherit;char c_chunkbits;
lib/compress.c +11 -0
@@ -860,6 +860,16 @@ int erofs_write_compressed_file(struct erofs_inode *inode, int fd)if (cfg.c_fragments && !cfg.c_dedupe) inode->z_advise |=Z_EROFS_ADVISE_INTERLACED_PCLUSTER ; +#ifndef NDEBUG +if (cfg.c_random_algorithms) { +while (1 ) { + inode->z_algorithmtype[0 ] = +rand () %EROFS_MAX_COMPR_CFG ; +if (erofs_ccfg[inode->z_algorithmtype[0 ]].enable) +break ; + } + } +#endif ctx.ccfg = &erofs_ccfg[inode->z_algorithmtype[0 ]]; inode->z_algorithmtype[0 ] = ctx.ccfg[0 ].algorithmtype; inode->z_algorithmtype[1 ] =0 ;
@@ -1075,6 +1085,7 @@ int z_erofs_compress_init(struct erofs_buffer_head *sb_bh)if (ret <0 )return ret; erofs_ccfg[i].algorithmtype = ret; + erofs_ccfg[i].enable = true; sbi.available_compr_algs |=1 << ret;if (ret !=Z_EROFS_COMPRESSION_LZ4 )erofs_sb_set_compr_cfgs ();
mkfs/main.c +5 -0
@@ -45,6 +45,7 @@ static struct option long_options[] = { {"all-root", no_argument, NULL, 7}, #ifndef NDEBUG {"random-pclusterblks", no_argument, NULL, 8}, + {"random-algorithms", no_argument, NULL, 18}, #endif {"max-extent-bytes", required_argument, NULL, 9}, {"compress-hints", required_argument, NULL, 10},
@@ -111,6 +112,7 @@ static void usage(void) " --quiet quiet execution (do not write anything to standard output.)\n" #ifndef NDEBUG " --random-pclusterblks randomize pclusterblks for big pcluster (debugging only)\n" + " --random-algorithms randomize per-file algorithms (debugging only)\n" #endif " --mount-point=X X=prefix of target fs path (default: /)\n"#ifdef WITH_ANDROID
@@ -370,6 +372,9 @@ static int mkfs_parse_options_cfg(int argc, char *argv[])case 8 : cfg.c_random_pclusterblks = true;break ; +case 18 : + cfg.c_random_algorithms = true; +break ;#endif case 9 : cfg.c_max_decompressed_extent_bytes =
Signature · 1 line
2.36.1