]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: enable inobtcount upgrade via repair
authorDarrick J. Wong <djwong@kernel.org>
Wed, 24 Feb 2021 01:20:57 +0000 (20:20 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 24 Feb 2021 01:20:57 +0000 (20:20 -0500)
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>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
man/man8/xfs_admin.8
repair/globals.c
repair/globals.h
repair/phase2.c
repair/xfs_repair.c

index cdb444b9c866cbff8d426e0817ff0359778969ff..eb9b6523df1dd83376712ccf5467fc01ece03122 100644 (file)
@@ -134,7 +134,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
index 537d068b72b4720ce32e9034e089a1611060fab7..47d90bd326c1c0eda8a2ee6ff0d86bd38a818932 100644 (file)
@@ -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 */
 
index a9287320db09d07d4e9057d52a20ecc561cde1c7..5b6fe4d4fb0a79ade926b35eec5fd8d49ec152b6 100644 (file)
@@ -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 */
 
index f654edcce895086e8a653b4ba129737fd4188b9f..96074a1dfdec8be6e288c4f18691d471eba52ad4 100644 (file)
@@ -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;
 
index 64d7607fe1e50805fa671cc8334217ad3b5fd8d5..8a9caf15c09f592c8c1525d3da0d4f97db9df3e1 100644 (file)
@@ -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;