]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: enable formatting with parent pointers
authorAllison Henderson <allison.henderson@oracle.com>
Mon, 29 Jul 2024 23:23:24 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:12 +0000 (17:01 -0700)
Enable parent pointer support in mkfs via the '-n parent' parameter.

Signed-off-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[djwong: move the no-V4 filesystem check to join the rest]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
mkfs/lts_4.19.conf
mkfs/lts_5.10.conf
mkfs/lts_5.15.conf
mkfs/lts_5.4.conf
mkfs/lts_6.1.conf
mkfs/lts_6.6.conf
mkfs/xfs_mkfs.c

index 92e8eba6ba8f6d08c8d2fb36fe69259fd672aae1..9fa1f9378f3297ed5fe06509edf1eeee7e7e885c 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=0
 sparse=1
 nrext64=0
 exchange=0
+
+[naming]
+parent=0
index 34e7662cd6719f5411d7ff13a0309a83f3e9c81a..d64bcdf8c46bd96a880ad99fe7942843d8cf2032 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=0
 sparse=1
 nrext64=0
 exchange=0
+
+[naming]
+parent=0
index a36a5c2b78500a6ad3718f571cb63b1202ad15dd..775fd9ab91b8c8473c63e674cdf75d18f5bcce26 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=0
 sparse=1
 nrext64=0
 exchange=0
+
+[naming]
+parent=0
index 4204d5b8f23531c3e882e96f4a692aa142206e35..6f43a6c6d469f1492e59278278cd614d0848fd9a 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=0
 sparse=1
 nrext64=0
 exchange=0
+
+[naming]
+parent=0
index 9a90def8f489d0efb85677b94850f2d58c98ebe8..a78a4f9e35dc5b2d3cc977bed210323dcf870b5d 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=0
 sparse=1
 nrext64=0
 exchange=0
+
+[naming]
+parent=0
index 3f7fb651937d92cc335583adb19f73014d1030e5..91a25bd8121f073ad50f8362f386155e042e6d5d 100644 (file)
@@ -13,3 +13,6 @@ rmapbt=1
 sparse=1
 nrext64=1
 exchange=0
+
+[naming]
+parent=0
index 991ecbdd03ffd5699642712fe2fc65f90146f666..394a35771246a661bf0d664638b353bcef084b2c 100644 (file)
@@ -114,6 +114,7 @@ enum {
        N_SIZE = 0,
        N_VERSION,
        N_FTYPE,
+       N_PARENT,
        N_MAX_OPTS,
 };
 
@@ -656,6 +657,7 @@ static struct opt_params nopts = {
                [N_SIZE] = "size",
                [N_VERSION] = "version",
                [N_FTYPE] = "ftype",
+               [N_PARENT] = "parent",
                [N_MAX_OPTS] = NULL,
        },
        .subopt_params = {
@@ -679,6 +681,14 @@ static struct opt_params nopts = {
                  .maxval = 1,
                  .defaultval = 1,
                },
+               { .index = N_PARENT,
+                 .conflicts = { { NULL, LAST_CONFLICT } },
+                 .minval = 0,
+                 .maxval = 1,
+                 .defaultval = 1,
+               },
+
+
        },
 };
 
@@ -1040,7 +1050,7 @@ usage( void )
                            sunit=value|su=num,sectsize=num,lazy-count=0|1,\n\
                            concurrency=num]\n\
 /* label */            [-L label (maximum 12 characters)]\n\
-/* naming */           [-n size=num,version=2|ci,ftype=0|1]\n\
+/* naming */           [-n size=num,version=2|ci,ftype=0|1,parent=0|1]]\n\
 /* no-op info only */  [-N]\n\
 /* prototype file */   [-p fname]\n\
 /* quiet */            [-q]\n\
@@ -1878,6 +1888,9 @@ naming_opts_parser(
        case N_FTYPE:
                cli->sb_feat.dirftype = getnum(value, opts, subopt);
                break;
+       case N_PARENT:
+               cli->sb_feat.parent_pointers = getnum(value, &nopts, N_PARENT);
+               break;
        default:
                return -EINVAL;
        }
@@ -2385,6 +2398,14 @@ _("exchange-range not supported without CRC support\n"));
                        usage();
                }
                cli->sb_feat.exchrange = false;
+
+               if (cli->sb_feat.parent_pointers &&
+                   cli_opt_set(&nopts, N_PARENT)) {
+                       fprintf(stderr,
+_("parent pointers not supported without CRC support\n"));
+                       usage();
+               }
+               cli->sb_feat.parent_pointers = false;
        }
 
        if (!cli->sb_feat.finobt) {
@@ -2419,6 +2440,17 @@ _("cowextsize not supported without reflink support\n"));
                usage();
        }
 
+       /*
+        * Turn on exchange-range if parent pointers are enabled and the caller
+        * did not provide an explicit exchange-range parameter so that users
+        * can take advantage of online repair.  It's not required for correct
+        * operation, but it costs us nothing to enable it.
+        */
+       if (cli->sb_feat.parent_pointers && !cli->sb_feat.exchrange &&
+           !cli_opt_set(&iopts, I_EXCHANGE)) {
+               cli->sb_feat.exchrange = true;
+       }
+
        /*
         * Copy features across to config structure now.
         */
@@ -3458,8 +3490,6 @@ sb_set_features(
                sbp->sb_features2 |= XFS_SB_VERSION2_LAZYSBCOUNTBIT;
        if (fp->projid32bit)
                sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT;
-       if (fp->parent_pointers)
-               sbp->sb_features2 |= XFS_SB_VERSION2_PARENTBIT;
        if (fp->crcs_enabled)
                sbp->sb_features2 |= XFS_SB_VERSION2_CRCBIT;
        if (fp->attr_version == 2)
@@ -3520,6 +3550,15 @@ sb_set_features(
                sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NREXT64;
        if (fp->exchrange)
                sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_EXCHRANGE;
+       if (fp->parent_pointers) {
+               sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_PARENT;
+               /*
+                * Set ATTRBIT even if mkfs doesn't write out a single parent
+                * pointer so that the kernel doesn't have to do that for us
+                * with a synchronous write to the primary super at runtime.
+                */
+               sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT;
+       }
 }
 
 /*