All of lore.kernel.org
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: djwong@kernel.org, linux-xfs@vger.kernel.org,
	david@fromorbit.com, chandanbabu@kernel.org, cem@kernel.org
Cc: martin.petersen@oracle.com, John Garry <john.g.garry@oracle.com>
Subject: [PATCH 6/7] mkfs: add an extsize= option that allows units
Date: Fri, 29 Sep 2023 09:53:41 +0000	[thread overview]
Message-ID: <20230929095342.2976587-7-john.g.garry@oracle.com> (raw)
In-Reply-To: <20230929095342.2976587-1-john.g.garry@oracle.com>

From: "Darrick J. Wong" <djwong@kernel.org>

Add a new mkfs option that allows the user to specify an extent size
hint with units.  This removes the need to specify the option in
filesystem block size, which eases the computation requirements in
deployment scripts.

# mkfs.xfs -d extsize=2m /dev/sda

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: John Garry <john.g.garry@oracle.com>
---
 man/man8/mkfs.xfs.8.in | 15 +++++++++++++
 mkfs/xfs_mkfs.c        | 48 ++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 61 insertions(+), 2 deletions(-)

diff --git a/man/man8/mkfs.xfs.8.in b/man/man8/mkfs.xfs.8.in
index 08bb92f6522d..9742482dcee9 100644
--- a/man/man8/mkfs.xfs.8.in
+++ b/man/man8/mkfs.xfs.8.in
@@ -482,6 +482,18 @@ will be assigned the project quota id provided in
 Directories will pass on the project id to newly created regular files and
 directories.
 .TP
+.BI extsize= num
+All inodes created by
+.B mkfs.xfs
+will have this
+.I value
+extent size hint applied.
+Directories will pass on this hint to newly created regular files and
+directories.
+This option cannot be combined with the
+.B extszinherit
+option.
+.TP
 .BI extszinherit= value
 All inodes created by
 .B mkfs.xfs
@@ -491,6 +503,9 @@ extent size hint applied.
 The value must be provided in units of filesystem blocks.
 Directories will pass on this hint to newly created regular files and
 directories.
+This option cannot be combined with the
+.B extsize
+option.
 .TP
 .BI daxinherit= value
 If
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index d3a15cf44e00..bffe0b7ea8b0 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -74,6 +74,7 @@ enum {
 	D_NOALIGN,
 	D_RTINHERIT,
 	D_PROJINHERIT,
+	D_EXTSIZE,
 	D_EXTSZINHERIT,
 	D_COWEXTSIZE,
 	D_DAXINHERIT,
@@ -315,6 +316,7 @@ static struct opt_params dopts = {
 		[D_NOALIGN] = "noalign",
 		[D_RTINHERIT] = "rtinherit",
 		[D_PROJINHERIT] = "projinherit",
+		[D_EXTSIZE] = "extsize",
 		[D_EXTSZINHERIT] = "extszinherit",
 		[D_COWEXTSIZE] = "cowextsize",
 		[D_DAXINHERIT] = "daxinherit",
@@ -422,8 +424,17 @@ static struct opt_params dopts = {
 		  .maxval = UINT_MAX,
 		  .defaultval = SUBOPT_NEEDS_VAL,
 		},
+		{ .index = D_EXTSIZE,
+		  .conflicts = { { &dopts, D_EXTSZINHERIT },
+				 { NULL, LAST_CONFLICT } },
+		  .convert = true,
+		  .minval = 0,
+		  .maxval = XFS_AG_MAX_BYTES,
+		  .defaultval = SUBOPT_NEEDS_VAL,
+		},
 		{ .index = D_EXTSZINHERIT,
-		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .conflicts = { { &dopts, D_EXTSIZE },
+				 { NULL, LAST_CONFLICT } },
 		  .minval = 0,
 		  .maxval = UINT_MAX,
 		  .defaultval = SUBOPT_NEEDS_VAL,
@@ -881,6 +892,7 @@ struct cli_params {
 	char	*lsu;
 	char	*rtextsize;
 	char	*rtsize;
+	char	*extsize;
 
 	/* parameters where 0 is a valid CLI value */
 	int	dsunit;
@@ -993,7 +1005,7 @@ usage( void )
 			    inobtcount=0|1,bigtime=0|1]\n\
 /* data subvol */	[-d agcount=n,agsize=n,file,name=xxx,size=num,\n\
 			    (sunit=value,swidth=value|su=num,sw=num|noalign),\n\
-			    sectsize=num\n\
+			    sectsize=num,extsize=num\n\
 /* 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\
@@ -1601,6 +1613,9 @@ data_opts_parser(
 		cli->fsx.fsx_projid = getnum(value, opts, subopt);
 		cli->fsx.fsx_xflags |= FS_XFLAG_PROJINHERIT;
 		break;
+	case D_EXTSIZE:
+		cli->extsize = getstr(value, opts, subopt);
+		break;
 	case D_EXTSZINHERIT:
 		cli->fsx.fsx_extsize = getnum(value, opts, subopt);
 		if (cli->fsx.fsx_extsize)
@@ -2084,6 +2099,33 @@ _("Minimum block size for CRC enabled filesystems is %d bytes.\n"),
 
 }
 
+/*
+ * Convert the -d extsize= option to a number, then set the extent size hint
+ * to that number.
+ */
+static void
+set_extsize(
+	struct cli_params	*cli,
+	char			*extsize,
+	struct opt_params	*opts,
+	int			subopt)
+{
+	uint64_t		extsz_bytes;
+	if (!extsize)
+		return;
+
+	extsz_bytes = getnum(extsize, opts, subopt);
+	if (extsz_bytes % blocksize)
+		illegal_option(extsize, opts, subopt,
+				_("Value must be a multiple of block size."));
+
+	cli->fsx.fsx_extsize = extsz_bytes / blocksize;
+	if (cli->fsx.fsx_extsize)
+		cli->fsx.fsx_xflags |= FS_XFLAG_EXTSZINHERIT;
+	else
+		cli->fsx.fsx_xflags &= ~FS_XFLAG_EXTSZINHERIT;
+}
+
 /*
  * Grab log sector size and validate.
  *
@@ -4251,6 +4293,8 @@ main(
 	blocksize = cfg.blocksize;
 	sectorsize = cfg.sectorsize;
 
+	set_extsize(&cli, cli.extsize, &dopts, D_EXTSIZE);
+
 	validate_log_sectorsize(&cfg, &cli, &dft);
 	validate_sb_features(&cfg, &cli);
 
-- 
2.34.1


  parent reply	other threads:[~2023-09-29  9:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-29  9:53 [PATCH 0/7] xfsprogs: Enable extent forcealign feature John Garry
2023-09-29  9:53 ` [PATCH 1/7] xfs: create a new inode flag to require extsize alignment of file data space John Garry
2023-09-29  9:53 ` [PATCH 2/7] xfs: allow files to require data mappings to be aligned to extszhint John Garry
2023-09-29  9:53 ` [PATCH 3/7] xfs_db: expose force_align feature and flags John Garry
2023-09-29  9:53 ` [PATCH 4/7] xfs_io: implement lsattr and chattr support for forcealign John Garry
2023-09-29  9:53 ` [PATCH 5/7] xfs_repair: check the force-align flag John Garry
2023-09-29  9:53 ` John Garry [this message]
2023-09-29  9:53 ` [PATCH 7/7] mkfs: enable the new force-align feature John Garry

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=20230929095342.2976587-7-john.g.garry@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=cem@kernel.org \
    --cc=chandanbabu@kernel.org \
    --cc=david@fromorbit.com \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=martin.petersen@oracle.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.