linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Brian Foster <bfoster@redhat.com>
To: "Darrick J. Wong" <djwong@kernel.org>
Cc: sandeen@sandeen.net, Christoph Hellwig <hch@lst.de>,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 4/5] xfs_repair: enable inobtcount upgrade via repair
Date: Tue, 16 Feb 2021 07:18:30 -0500	[thread overview]
Message-ID: <20210216121830.GF534175@bfoster> (raw)
In-Reply-To: <161319524563.423010.7140989505952004894.stgit@magnolia>

On Fri, Feb 12, 2021 at 09:47:25PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Use xfs_repair to add the inode btree counter feature to a filesystem.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>
> Reviewed-by: Christoph Hellwig <hch@lst.de>
> ---

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

>  man/man8/xfs_admin.8 |   11 ++++++++++-
>  repair/globals.c     |    1 +
>  repair/globals.h     |    1 +
>  repair/phase2.c      |   30 ++++++++++++++++++++++++++++++
>  repair/xfs_repair.c  |   11 +++++++++++
>  5 files changed, 53 insertions(+), 1 deletion(-)
> 
> 
> diff --git a/man/man8/xfs_admin.8 b/man/man8/xfs_admin.8
> index ae661648..4ba718d8 100644
> --- a/man/man8/xfs_admin.8
> +++ b/man/man8/xfs_admin.8
> @@ -136,7 +136,16 @@ without the
>  .BR -n )
>  must be followed to clean the filesystem.
>  .IP
> -There are no feature options currently.
> +Supported features are as follows:
> +.RS 0.7i
> +.TP 0.4i
> +.B inobtcount
> +Keep a count the number of blocks in each inode btree in the AGI.
> +This reduces mount time by speeding up metadata space reservation calculations.
> +The filesystem cannot be downgraded after this feature is enabled.
> +Once enabled, the filesystem will not be writable by older kernels.
> +This feature was added to Linux 5.10.
> +.RE
>  .TP
>  .BI \-U " uuid"
>  Set the UUID of the filesystem to
> diff --git a/repair/globals.c b/repair/globals.c
> index 537d068b..47d90bd3 100644
> --- a/repair/globals.c
> +++ b/repair/globals.c
> @@ -48,6 +48,7 @@ char	*rt_name;		/* Name of realtime device */
>  int	rt_spec;		/* Realtime dev specified as option */
>  int	convert_lazy_count;	/* Convert lazy-count mode on/off */
>  int	lazy_count;		/* What to set if to if converting */
> +bool	add_inobtcount;		/* add inode btree counts to AGI */
>  
>  /* misc status variables */
>  
> diff --git a/repair/globals.h b/repair/globals.h
> index a9287320..5b6fe4d4 100644
> --- a/repair/globals.h
> +++ b/repair/globals.h
> @@ -89,6 +89,7 @@ extern char	*rt_name;		/* Name of realtime device */
>  extern int	rt_spec;		/* Realtime dev specified as option */
>  extern int	convert_lazy_count;	/* Convert lazy-count mode on/off */
>  extern int	lazy_count;		/* What to set if to if converting */
> +extern bool	add_inobtcount;		/* add inode btree counts to AGI */
>  
>  /* misc status variables */
>  
> diff --git a/repair/phase2.c b/repair/phase2.c
> index f654edcc..96074a1d 100644
> --- a/repair/phase2.c
> +++ b/repair/phase2.c
> @@ -131,6 +131,33 @@ zero_log(
>  		libxfs_max_lsn = log->l_last_sync_lsn;
>  }
>  
> +static bool
> +set_inobtcount(
> +	struct xfs_mount	*mp)
> +{
> +	if (!xfs_sb_version_hascrc(&mp->m_sb)) {
> +		printf(
> +	_("Inode btree count feature only supported on V5 filesystems.\n"));
> +		exit(0);
> +	}
> +
> +	if (!xfs_sb_version_hasfinobt(&mp->m_sb)) {
> +		printf(
> +	_("Inode btree count feature requires free inode btree.\n"));
> +		exit(0);
> +	}
> +
> +	if (xfs_sb_version_hasinobtcounts(&mp->m_sb)) {
> +		printf(_("Filesystem already has inode btree counts.\n"));
> +		exit(0);
> +	}
> +
> +	printf(_("Adding inode btree counts to filesystem.\n"));
> +	mp->m_sb.sb_features_ro_compat |= XFS_SB_FEAT_RO_COMPAT_INOBTCNT;
> +	mp->m_sb.sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
> +	return true;
> +}
> +
>  /* Perform the user's requested upgrades on filesystem. */
>  static void
>  upgrade_filesystem(
> @@ -140,6 +167,9 @@ upgrade_filesystem(
>  	bool			dirty = false;
>  	int			error;
>  
> +	if (add_inobtcount)
> +		dirty |= set_inobtcount(mp);
> +
>          if (no_modify || !dirty)
>                  return;
>  
> diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
> index 6b60b8f4..2d9dca6b 100644
> --- a/repair/xfs_repair.c
> +++ b/repair/xfs_repair.c
> @@ -65,11 +65,13 @@ static char *o_opts[] = {
>   */
>  enum c_opt_nums {
>  	CONVERT_LAZY_COUNT = 0,
> +	CONVERT_INOBTCOUNT,
>  	C_MAX_OPTS,
>  };
>  
>  static char *c_opts[] = {
>  	[CONVERT_LAZY_COUNT]	= "lazycount",
> +	[CONVERT_INOBTCOUNT]	= "inobtcount",
>  	[C_MAX_OPTS]		= NULL,
>  };
>  
> @@ -302,6 +304,15 @@ process_args(int argc, char **argv)
>  					lazy_count = (int)strtol(val, NULL, 0);
>  					convert_lazy_count = 1;
>  					break;
> +				case CONVERT_INOBTCOUNT:
> +					if (!val)
> +						do_abort(
> +		_("-c inobtcount requires a parameter\n"));
> +					if (strtol(val, NULL, 0) != 1)
> +						do_abort(
> +		_("-c inobtcount only supports upgrades\n"));
> +					add_inobtcount = true;
> +					break;
>  				default:
>  					unknown('c', val);
>  					break;
> 


  reply	other threads:[~2021-02-16 12:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-13  5:47 [PATCHSET v6 0/5] xfs_admin: support upgrading v5 filesystems Darrick J. Wong
2021-02-13  5:47 ` [PATCH 1/5] man: mark all deprecated V4 format options Darrick J. Wong
2021-02-25  7:39   ` Christoph Hellwig
2021-02-13  5:47 ` [PATCH 2/5] xfs_repair: allow upgrades to v5 filesystems Darrick J. Wong
2021-02-16 12:18   ` Brian Foster
2021-02-25  7:40   ` Christoph Hellwig
2021-02-13  5:47 ` [PATCH 3/5] xfs_admin: support adding features to V5 filesystems Darrick J. Wong
2021-02-13  5:47 ` [PATCH 4/5] xfs_repair: enable inobtcount upgrade via repair Darrick J. Wong
2021-02-16 12:18   ` Brian Foster [this message]
2021-02-13  5:47 ` [PATCH 5/5] xfs_repair: enable bigtime " Darrick J. Wong
  -- strict thread matches above, loose matches on Subject: below --
2021-02-23  3:01 [PATCHSET v6.1 0/5] xfs_admin: support upgrading v5 filesystems Darrick J. Wong
2021-02-23  3:01 ` [PATCH 4/5] xfs_repair: enable inobtcount upgrade via repair Darrick J. Wong

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=20210216121830.GF534175@bfoster \
    --to=bfoster@redhat.com \
    --cc=djwong@kernel.org \
    --cc=hch@lst.de \
    --cc=linux-xfs@vger.kernel.org \
    --cc=sandeen@sandeen.net \
    /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;
as well as URLs for NNTP newsgroup(s).