]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_repair: Add support for upgrading to large extent counters
authorChandan Babu R <chandan.babu@oracle.com>
Fri, 5 Aug 2022 02:54:27 +0000 (21:54 -0500)
committerEric Sandeen <sandeen@sandeen.net>
Fri, 5 Aug 2022 02:54:27 +0000 (21:54 -0500)
This commit adds support to xfs_repair to allow upgrading an existing
filesystem to support per-inode large extent counters.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.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 ad28e0f68c4ec4845dcc67ebb52e04c4e4adc0e2..4794d6774edeb2c63472bfa92ee4a7305840d794 100644 (file)
@@ -149,6 +149,13 @@ Upgrade a filesystem to support larger timestamps up to the year 2486.
 The filesystem cannot be downgraded after this feature is enabled.
 Once enabled, the filesystem will not be mountable by older kernels.
 This feature was added to Linux 5.10.
+.TP 0.4i
+.B nrext64
+Upgrade a filesystem to support large per-inode extent counters. The maximum
+data fork extent count will be 2^48 - 1, while the maximum attribute fork
+extent count will be 2^32 - 1. The filesystem cannot be downgraded after this
+feature is enabled. Once enabled, the filesystem will not be mountable by
+older kernels.  This feature was added to Linux 5.19.
 .RE
 .TP
 .BI \-U " uuid"
index f8d4f1e4016d187d659b3c93e125f0ea8cf3bcc9..c40849853b8f1d20d4e9151b4ea568167c35134e 100644 (file)
@@ -51,6 +51,7 @@ int   lazy_count;             /* What to set if to if converting */
 bool   features_changed;       /* did we change superblock feature bits? */
 bool   add_inobtcount;         /* add inode btree counts to AGI */
 bool   add_bigtime;            /* add support for timestamps up to 2486 */
+bool   add_nrext64;
 
 /* misc status variables */
 
index 0f98bd2b58ce99d8b6bb3808eacd817a2d2bf665..b65e4a2d09cf3e107b3aad1b663cd24d9c9482a2 100644 (file)
@@ -92,6 +92,7 @@ extern int    lazy_count;             /* What to set if to if converting */
 extern bool    features_changed;       /* did we change superblock feature bits? */
 extern bool    add_inobtcount;         /* add inode btree counts to AGI */
 extern bool    add_bigtime;            /* add support for timestamps up to 2486 */
+extern bool    add_nrext64;
 
 /* misc status variables */
 
index 703656203ecf9222f84a8af75d3ae1c3a626d2a0..56a39bb4562dd81a3d45b94b07b86f3025b7286c 100644 (file)
@@ -181,6 +181,28 @@ set_bigtime(
        return true;
 }
 
+static bool
+set_nrext64(
+       struct xfs_mount        *mp,
+       struct xfs_sb           *new_sb)
+{
+       if (!xfs_has_crc(mp)) {
+               printf(
+       _("Nrext64 only supported on V5 filesystems.\n"));
+               exit(0);
+       }
+
+       if (xfs_has_large_extent_counts(mp)) {
+               printf(_("Filesystem already supports nrext64.\n"));
+               exit(0);
+       }
+
+       printf(_("Adding nrext64 to filesystem.\n"));
+       new_sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NREXT64;
+       new_sb->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR;
+       return true;
+}
+
 struct check_state {
        struct xfs_sb           sb;
        uint64_t                features;
@@ -287,6 +309,8 @@ upgrade_filesystem(
                dirty |= set_inobtcount(mp, &new_sb);
        if (add_bigtime)
                dirty |= set_bigtime(mp, &new_sb);
+       if (add_nrext64)
+               dirty |= set_nrext64(mp, &new_sb);
        if (!dirty)
                return;
 
index d08b0cecbc1ef07366cc0bbf904bb095e5e21c1b..c94671d8d18721ad14fbbc083ded49bc0bcc6a0e 100644 (file)
@@ -67,6 +67,7 @@ enum c_opt_nums {
        CONVERT_LAZY_COUNT = 0,
        CONVERT_INOBTCOUNT,
        CONVERT_BIGTIME,
+       CONVERT_NREXT64,
        C_MAX_OPTS,
 };
 
@@ -74,6 +75,7 @@ static char *c_opts[] = {
        [CONVERT_LAZY_COUNT]    = "lazycount",
        [CONVERT_INOBTCOUNT]    = "inobtcount",
        [CONVERT_BIGTIME]       = "bigtime",
+       [CONVERT_NREXT64]       = "nrext64",
        [C_MAX_OPTS]            = NULL,
 };
 
@@ -324,6 +326,15 @@ process_args(int argc, char **argv)
                _("-c bigtime only supports upgrades\n"));
                                        add_bigtime = true;
                                        break;
+                               case CONVERT_NREXT64:
+                                       if (!val)
+                                               do_abort(
+               _("-c nrext64 requires a parameter\n"));
+                                       if (strtol(val, NULL, 0) != 1)
+                                               do_abort(
+               _("-c nrext64 only supports upgrades\n"));
+                                       add_nrext64 = true;
+                                       break;
                                default:
                                        unknown('c', val);
                                        break;