Add clustersize parameter for -i(inode size) switch. When sparse inode allocation is enabled, use clustersize from cmdline if it's provided and fallback to XFS_INODE_BIG_CLUSTER_SIZE if not. Signed-off-by: Tianxiang Peng <txpeng@xxxxxxxxxxx> Reviewed-by: Jinliang Zheng <allexjlzheng@xxxxxxxxxxx> Reviewed-by: Hao Peng <flyingpeng@xxxxxxxxxxx> --- mkfs/xfs_mkfs.c | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c index bbd0dbb6..b8a597d4 100644 --- a/mkfs/xfs_mkfs.c +++ b/mkfs/xfs_mkfs.c @@ -92,6 +92,7 @@ enum { I_SPINODES, I_NREXT64, I_EXCHANGE, + I_CLUSTERSIZE, I_MAX_OPTS, }; @@ -474,6 +475,7 @@ static struct opt_params iopts = { [I_SPINODES] = "sparse", [I_NREXT64] = "nrext64", [I_EXCHANGE] = "exchange", + [I_CLUSTERSIZE] = "clustersize", [I_MAX_OPTS] = NULL, }, .subopt_params = { @@ -535,6 +537,13 @@ static struct opt_params iopts = { .maxval = 1, .defaultval = 1, }, + { .index = I_CLUSTERSIZE, + .conflicts = { { NULL, LAST_CONFLICT } }, + .is_power_2 = true, + .minval = XFS_DINODE_MIN_SIZE, + .maxval = XFS_DINODE_MIN_SIZE << XFS_INODES_PER_CHUNK_LOG, + .defaultval = XFS_INODE_BIG_CLUSTER_SIZE, + }, }, }; @@ -956,6 +965,7 @@ struct cli_params { int inopblock; int imaxpct; int lsectorsize; + int clustersize; uuid_t uuid; /* feature flags that are set */ @@ -993,6 +1003,7 @@ struct mkfs_params { int inodesize; int inodelog; int inopblock; + int clustersize; uint64_t dblocks; uint64_t logblocks; @@ -1055,7 +1066,7 @@ usage( void ) /* force overwrite */ [-f]\n\ /* inode size */ [-i perblock=n|size=num,maxpct=n,attr=0|1|2,\n\ projid32bit=0|1,sparse=0|1,nrext64=0|1,\n\ - exchange=0|1]\n\ + exchange=0|1,clustersize=num]\n\ /* no discard */ [-K]\n\ /* log subvol */ [-l agnum=n,internal,size=num,logdev=xxx,version=n\n\ sunit=value|su=num,sectsize=num,lazy-count=0|1,\n\ @@ -1756,6 +1767,9 @@ inode_opts_parser( case I_EXCHANGE: cli->sb_feat.exchrange = getnum(value, opts, subopt); break; + case I_CLUSTERSIZE: + cli->clustersize = getnum(value, opts, subopt); + break; default: return -EINVAL; } @@ -2594,6 +2608,17 @@ validate_inodesize( } } +static void +validate_clustersize( + struct mkfs_params *cfg, + struct cli_params *cli) +{ + if (cli->sb_feat.spinodes && cli->clustersize) + cfg->clustersize = cli->clustersize; + else + cfg->clustersize = XFS_INODE_BIG_CLUSTER_SIZE; +} + static xfs_rfsblock_t calc_dev_size( char *size, @@ -3517,12 +3542,10 @@ sb_set_features( sbp->sb_versionnum |= XFS_SB_VERSION_4; if (fp->inode_align) { - int cluster_size = XFS_INODE_BIG_CLUSTER_SIZE; - sbp->sb_versionnum |= XFS_SB_VERSION_ALIGNBIT; if (cfg->sb_feat.crcs_enabled) - cluster_size *= cfg->inodesize / XFS_DINODE_MIN_SIZE; - sbp->sb_inoalignmt = cluster_size >> cfg->blocklog; + cfg->clustersize *= cfg->inodesize / XFS_DINODE_MIN_SIZE; + sbp->sb_inoalignmt = cfg->clustersize >> cfg->blocklog; } else sbp->sb_inoalignmt = 0; @@ -4634,6 +4657,7 @@ main( */ validate_dirblocksize(&cfg, &cli); validate_inodesize(&cfg, &cli); + validate_clustersize(&cfg, &cli); /* * if the device size was specified convert it to a block count -- 2.43.5