From: Tianxiang Peng <luminosity1999@gmail.com>
To: chandan.babu@oracle.com, djwong@kernel.org, p.raghav@samsung.com,
mcgrof@kernel.org, brauner@kernel.org, dchinner@redhat.com
Cc: Tianxiang Peng <txpeng@tencent.com>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, allexjlzheng@tencent.com,
flyingpeng@tencent.com
Subject: [PATCH 2/2] mkfs: make cluster size tunnable when sparse alloc enabled
Date: Mon, 16 Dec 2024 21:05:49 +0800 [thread overview]
Message-ID: <20241216130551.811305-3-txpeng@tencent.com> (raw)
In-Reply-To: <20241216130551.811305-1-txpeng@tencent.com>
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@tencent.com>
Reviewed-by: Jinliang Zheng <allexjlzheng@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
---
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
next prev parent reply other threads:[~2024-12-16 13:06 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 13:05 [PATCH 0/2] xfs: make cluster size tunnable for sparse allocation Tianxiang Peng
2024-12-16 13:05 ` [PATCH 1/2] xfs: calculate cluster_size_raw from sb when sparse alloc enabled Tianxiang Peng
2024-12-16 13:05 ` Tianxiang Peng [this message]
2024-12-16 21:19 ` [PATCH 0/2] xfs: make cluster size tunnable for sparse allocation Dave Chinner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241216130551.811305-3-txpeng@tencent.com \
--to=luminosity1999@gmail.com \
--cc=allexjlzheng@tencent.com \
--cc=brauner@kernel.org \
--cc=chandan.babu@oracle.com \
--cc=dchinner@redhat.com \
--cc=djwong@kernel.org \
--cc=flyingpeng@tencent.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=p.raghav@samsung.com \
--cc=txpeng@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox