diff mbox series

[8/9] mkfs: enable the inode btree counter feature

Message ID 160375523682.880355.16796358046529188083.stgit@magnolia
State Accepted
Headers show
Series xfsprogs: add a inode btree blocks counts to the AGI header | expand

Commit Message

Darrick J. Wong Oct. 26, 2020, 11:33 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

Teach mkfs how to enable the inode btree counter feature.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 man/man8/mkfs.xfs.8 |   15 +++++++++++++++
 mkfs/xfs_mkfs.c     |   34 +++++++++++++++++++++++++++++++++-
 2 files changed, 48 insertions(+), 1 deletion(-)

Comments

Brian Foster Oct. 28, 2020, 5:30 p.m. UTC | #1
On Mon, Oct 26, 2020 at 04:33:56PM -0700, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Teach mkfs how to enable the inode btree counter feature.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  man/man8/mkfs.xfs.8 |   15 +++++++++++++++
>  mkfs/xfs_mkfs.c     |   34 +++++++++++++++++++++++++++++++++-
>  2 files changed, 48 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
> index 0a7858748457..1a6a5f93f0ea 100644
> --- a/man/man8/mkfs.xfs.8
> +++ b/man/man8/mkfs.xfs.8
...
> @@ -862,7 +871,8 @@ usage( void )
>  {
>  	fprintf(stderr, _("Usage: %s\n\
>  /* blocksize */		[-b size=num]\n\
> -/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1]\n\
> +/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
> +			    inobtcnt=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\

Any plans to add a geometry flag so the feature state is reported on
success? Otherwise LGTM:

Reviewed-by: Brian Foster <bfoster@redhat.com>

> @@ -1565,6 +1575,9 @@ meta_opts_parser(
>  	case M_REFLINK:
>  		cli->sb_feat.reflink = getnum(value, opts, subopt);
>  		break;
> +	case M_INOBTCNT:
> +		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
> +		break;
>  	default:
>  		return -EINVAL;
>  	}
> @@ -1988,6 +2001,22 @@ _("reflink not supported without CRC support\n"));
>  			usage();
>  		}
>  		cli->sb_feat.reflink = false;
> +
> +		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
> +			fprintf(stderr,
> +_("inode btree counters not supported without CRC support\n"));
> +			usage();
> +		}
> +		cli->sb_feat.inobtcnt = false;
> +	}
> +
> +	if (!cli->sb_feat.finobt) {
> +		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
> +			fprintf(stderr,
> +_("inode btree counters not supported without finobt support\n"));
> +			usage();
> +		}
> +		cli->sb_feat.inobtcnt = false;
>  	}
>  
>  	if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
> @@ -2955,6 +2984,8 @@ sb_set_features(
>  		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT;
>  	if (fp->reflink)
>  		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
> +	if (fp->inobtcnt)
> +		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
>  
>  	/*
>  	 * Sparse inode chunk support has two main inode alignment requirements.
> @@ -3617,6 +3648,7 @@ main(
>  			.spinodes = true,
>  			.rmapbt = false,
>  			.reflink = true,
> +			.inobtcnt = false,
>  			.parent_pointers = false,
>  			.nodalign = false,
>  			.nortalign = false,
>
Darrick J. Wong Oct. 29, 2020, 1:02 a.m. UTC | #2
On Wed, Oct 28, 2020 at 01:30:38PM -0400, Brian Foster wrote:
> On Mon, Oct 26, 2020 at 04:33:56PM -0700, Darrick J. Wong wrote:
> > From: Darrick J. Wong <darrick.wong@oracle.com>
> > 
> > Teach mkfs how to enable the inode btree counter feature.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  man/man8/mkfs.xfs.8 |   15 +++++++++++++++
> >  mkfs/xfs_mkfs.c     |   34 +++++++++++++++++++++++++++++++++-
> >  2 files changed, 48 insertions(+), 1 deletion(-)
> > 
> > 
> > diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
> > index 0a7858748457..1a6a5f93f0ea 100644
> > --- a/man/man8/mkfs.xfs.8
> > +++ b/man/man8/mkfs.xfs.8
> ...
> > @@ -862,7 +871,8 @@ usage( void )
> >  {
> >  	fprintf(stderr, _("Usage: %s\n\
> >  /* blocksize */		[-b size=num]\n\
> > -/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1]\n\
> > +/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
> > +			    inobtcnt=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\
> 
> Any plans to add a geometry flag so the feature state is reported on
> success? Otherwise LGTM:

<shrug> This feature doesn't enable any user-visible functionality, so I
don't see much point in doing so.

Thanks for the review!

--D

> Reviewed-by: Brian Foster <bfoster@redhat.com>
> 
> > @@ -1565,6 +1575,9 @@ meta_opts_parser(
> >  	case M_REFLINK:
> >  		cli->sb_feat.reflink = getnum(value, opts, subopt);
> >  		break;
> > +	case M_INOBTCNT:
> > +		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
> > +		break;
> >  	default:
> >  		return -EINVAL;
> >  	}
> > @@ -1988,6 +2001,22 @@ _("reflink not supported without CRC support\n"));
> >  			usage();
> >  		}
> >  		cli->sb_feat.reflink = false;
> > +
> > +		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
> > +			fprintf(stderr,
> > +_("inode btree counters not supported without CRC support\n"));
> > +			usage();
> > +		}
> > +		cli->sb_feat.inobtcnt = false;
> > +	}
> > +
> > +	if (!cli->sb_feat.finobt) {
> > +		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
> > +			fprintf(stderr,
> > +_("inode btree counters not supported without finobt support\n"));
> > +			usage();
> > +		}
> > +		cli->sb_feat.inobtcnt = false;
> >  	}
> >  
> >  	if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
> > @@ -2955,6 +2984,8 @@ sb_set_features(
> >  		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT;
> >  	if (fp->reflink)
> >  		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
> > +	if (fp->inobtcnt)
> > +		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
> >  
> >  	/*
> >  	 * Sparse inode chunk support has two main inode alignment requirements.
> > @@ -3617,6 +3648,7 @@ main(
> >  			.spinodes = true,
> >  			.rmapbt = false,
> >  			.reflink = true,
> > +			.inobtcnt = false,
> >  			.parent_pointers = false,
> >  			.nodalign = false,
> >  			.nortalign = false,
> > 
>
diff mbox series

Patch

diff --git a/man/man8/mkfs.xfs.8 b/man/man8/mkfs.xfs.8
index 0a7858748457..1a6a5f93f0ea 100644
--- a/man/man8/mkfs.xfs.8
+++ b/man/man8/mkfs.xfs.8
@@ -184,6 +184,21 @@  option set. When the option
 .B \-m crc=0
 is used, the free inode btree feature is not supported and is disabled.
 .TP
+.BI inobtcount= value
+This option causes the filesystem to record the number of blocks used by
+the inode btree and the free inode btree.
+This can be used to reduce mount times when the free inode btree is enabled.
+.IP
+By default,
+.B mkfs.xfs
+will not enable this option.
+This feature is only available for filesystems created with the (default)
+.B \-m finobt=1
+option set.
+When the option
+.B \-m finobt=0
+is used, the inode btree counter feature is not supported and is disabled.
+.TP
 .BI uuid= value
 Use the given value as the filesystem UUID for the newly created filesystem.
 The default is to generate a random UUID.
diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
index 908d520df909..23e3077e0174 100644
--- a/mkfs/xfs_mkfs.c
+++ b/mkfs/xfs_mkfs.c
@@ -119,6 +119,7 @@  enum {
 	M_UUID,
 	M_RMAPBT,
 	M_REFLINK,
+	M_INOBTCNT,
 	M_MAX_OPTS,
 };
 
@@ -660,6 +661,7 @@  static struct opt_params mopts = {
 		[M_UUID] = "uuid",
 		[M_RMAPBT] = "rmapbt",
 		[M_REFLINK] = "reflink",
+		[M_INOBTCNT] = "inobtcount",
 	},
 	.subopt_params = {
 		{ .index = M_CRC,
@@ -690,6 +692,12 @@  static struct opt_params mopts = {
 		  .maxval = 1,
 		  .defaultval = 1,
 		},
+		{ .index = M_INOBTCNT,
+		  .conflicts = { { NULL, LAST_CONFLICT } },
+		  .minval = 0,
+		  .maxval = 1,
+		  .defaultval = 1,
+		},
 	},
 };
 
@@ -740,6 +748,7 @@  struct sb_feat_args {
 	bool	spinodes;		/* XFS_SB_FEAT_INCOMPAT_SPINODES */
 	bool	rmapbt;			/* XFS_SB_FEAT_RO_COMPAT_RMAPBT */
 	bool	reflink;		/* XFS_SB_FEAT_RO_COMPAT_REFLINK */
+	bool	inobtcnt;		/* XFS_SB_FEAT_RO_COMPAT_INOBTCNT */
 	bool	nodalign;
 	bool	nortalign;
 };
@@ -862,7 +871,8 @@  usage( void )
 {
 	fprintf(stderr, _("Usage: %s\n\
 /* blocksize */		[-b size=num]\n\
-/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1]\n\
+/* metadata */		[-m crc=0|1,finobt=0|1,uuid=xxx,rmapbt=0|1,reflink=0|1,\n\
+			    inobtcnt=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\
@@ -1565,6 +1575,9 @@  meta_opts_parser(
 	case M_REFLINK:
 		cli->sb_feat.reflink = getnum(value, opts, subopt);
 		break;
+	case M_INOBTCNT:
+		cli->sb_feat.inobtcnt = getnum(value, opts, subopt);
+		break;
 	default:
 		return -EINVAL;
 	}
@@ -1988,6 +2001,22 @@  _("reflink not supported without CRC support\n"));
 			usage();
 		}
 		cli->sb_feat.reflink = false;
+
+		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
+			fprintf(stderr,
+_("inode btree counters not supported without CRC support\n"));
+			usage();
+		}
+		cli->sb_feat.inobtcnt = false;
+	}
+
+	if (!cli->sb_feat.finobt) {
+		if (cli->sb_feat.inobtcnt && cli_opt_set(&mopts, M_INOBTCNT)) {
+			fprintf(stderr,
+_("inode btree counters not supported without finobt support\n"));
+			usage();
+		}
+		cli->sb_feat.inobtcnt = false;
 	}
 
 	if ((cli->fsx.fsx_xflags & FS_XFLAG_COWEXTSIZE) &&
@@ -2955,6 +2984,8 @@  sb_set_features(
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_RMAPBT;
 	if (fp->reflink)
 		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_REFLINK;
+	if (fp->inobtcnt)
+		sbp->sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
 
 	/*
 	 * Sparse inode chunk support has two main inode alignment requirements.
@@ -3617,6 +3648,7 @@  main(
 			.spinodes = true,
 			.rmapbt = false,
 			.reflink = true,
+			.inobtcnt = false,
 			.parent_pointers = false,
 			.nodalign = false,
 			.nortalign = false,