]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
mkfs: add a formatting option for exchange-range
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:01 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:06 +0000 (17:01 -0700)
Allow users to enable the logged file mapping exchange intent items on a
filesystem, which in turn enables XFS_IOC_EXCHANGE_RANGE and online
repair of metadata that lives in files, e.g. directories and xattrs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
man/man8/mkfs.xfs.8.in
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 8060d342c2a447ab1e9c1900c5b88f4e11d97243..d5a0783ac5d656bd7164e73d7757c0b2e30baaf4 100644 (file)
@@ -670,6 +670,13 @@ If the value is omitted, 1 is assumed.
 This feature will be enabled when possible.
 This feature is only available for filesystems formatted with -m crc=1.
 .TP
+.BI exchange[= value]
+When enabled, application programs can exchange file contents atomically
+via the XFS_IOC_EXCHANGE_RANGE ioctl.
+Online repair uses this functionality to rebuild extended attributes,
+directories, symbolic links, and realtime metadata files.
+This feature is disabled by default.
+This feature is only available for filesystems formatted with -m crc=1.
 .RE
 .PP
 .PD 0
index 8b2bdd7a34710387885f62b8ae0a4547250b8580..92e8eba6ba8f6d08c8d2fb36fe69259fd672aae1 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=0
 [inode]
 sparse=1
 nrext64=0
+exchange=0
index 40189310af2aa66c634919ad125d7e2a02c3dc38..34e7662cd6719f5411d7ff13a0309a83f3e9c81a 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=0
 [inode]
 sparse=1
 nrext64=0
+exchange=0
index aeecc03556731c23da18820287c7fb44c8fa5b95..a36a5c2b78500a6ad3718f571cb63b1202ad15dd 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=0
 [inode]
 sparse=1
 nrext64=0
+exchange=0
index 0a40718b8f625b2ca0483942c3a79af32b0a1390..4204d5b8f23531c3e882e96f4a692aa142206e35 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=0
 [inode]
 sparse=1
 nrext64=0
+exchange=0
index 452abdf82e62bdb475e5361a8a7f480c66c7935f..9a90def8f489d0efb85677b94850f2d58c98ebe8 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=0
 [inode]
 sparse=1
 nrext64=0
+exchange=0
index 244f8eaf76455142fcc38c2afcd060b8d5a5752b..3f7fb651937d92cc335583adb19f73014d1030e5 100644 (file)
@@ -12,3 +12,4 @@ rmapbt=1
 [inode]
 sparse=1
 nrext64=1
+exchange=0
index 6d2469c3c81fa81cb460ddbb13fe07bf6135c5bd..991ecbdd03ffd5699642712fe2fc65f90146f666 100644 (file)
@@ -90,6 +90,7 @@ enum {
        I_PROJID32BIT,
        I_SPINODES,
        I_NREXT64,
+       I_EXCHANGE,
        I_MAX_OPTS,
 };
 
@@ -469,6 +470,7 @@ static struct opt_params iopts = {
                [I_PROJID32BIT] = "projid32bit",
                [I_SPINODES] = "sparse",
                [I_NREXT64] = "nrext64",
+               [I_EXCHANGE] = "exchange",
                [I_MAX_OPTS] = NULL,
        },
        .subopt_params = {
@@ -523,7 +525,13 @@ static struct opt_params iopts = {
                  .minval = 0,
                  .maxval = 1,
                  .defaultval = 1,
-               }
+               },
+               { .index = I_EXCHANGE,
+                 .conflicts = { { NULL, LAST_CONFLICT } },
+                 .minval = 0,
+                 .maxval = 1,
+                 .defaultval = 1,
+               },
        },
 };
 
@@ -889,6 +897,7 @@ struct sb_feat_args {
        bool    nodalign;
        bool    nortalign;
        bool    nrext64;
+       bool    exchrange;              /* XFS_SB_FEAT_INCOMPAT_EXCHRANGE */
 };
 
 struct cli_params {
@@ -1024,7 +1033,8 @@ usage( void )
                            sectsize=num,concurrency=num]\n\
 /* force overwrite */  [-f]\n\
 /* inode size */       [-i perblock=n|size=num,maxpct=n,attr=0|1|2,\n\
-                           projid32bit=0|1,sparse=0|1,nrext64=0|1]\n\
+                           projid32bit=0|1,sparse=0|1,nrext64=0|1,\n\
+                           exchange=0|1]\n\
 /* no discard */       [-K]\n\
 /* log subvol */       [-l agnum=n,internal,size=num,logdev=xxx,version=n\n\
                            sunit=value|su=num,sectsize=num,lazy-count=0|1,\n\
@@ -1722,6 +1732,9 @@ inode_opts_parser(
        case I_NREXT64:
                cli->sb_feat.nrext64 = getnum(value, opts, subopt);
                break;
+       case I_EXCHANGE:
+               cli->sb_feat.exchrange = getnum(value, opts, subopt);
+               break;
        default:
                return -EINVAL;
        }
@@ -2365,6 +2378,13 @@ _("64 bit extent count not supported without CRC support\n"));
                        usage();
                }
                cli->sb_feat.nrext64 = false;
+
+               if (cli->sb_feat.exchrange && cli_opt_set(&iopts, I_EXCHANGE)) {
+                       fprintf(stderr,
+_("exchange-range not supported without CRC support\n"));
+                       usage();
+               }
+               cli->sb_feat.exchrange = false;
        }
 
        if (!cli->sb_feat.finobt) {
@@ -3498,6 +3518,8 @@ sb_set_features(
 
        if (fp->nrext64)
                sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_NREXT64;
+       if (fp->exchrange)
+               sbp->sb_features_incompat |= XFS_SB_FEAT_INCOMPAT_EXCHRANGE;
 }
 
 /*