xfs: create a incompat flag for atomic file mapping exchanges
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:15 +0000 (14:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:15 +0000 (14:54 -0700)
Create a incompat flag so that we only attempt to process file mapping
exchange log items if the filesystem supports it, and a geometry flag to
advertise support if it's present.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_format.h
fs/xfs/libxfs/xfs_fs.h
fs/xfs/libxfs/xfs_sb.c
fs/xfs/xfs_mount.h
fs/xfs/xfs_super.c

index 2b2f9050fbfbbc67ab0d46690ddf3d5963bc7206..ff1e28316e1bb8ea40d9e34f1baf0a9b87fc6380 100644 (file)
@@ -367,18 +367,19 @@ xfs_sb_has_ro_compat_feature(
        return (sbp->sb_features_ro_compat & feature) != 0;
 }
 
-#define XFS_SB_FEAT_INCOMPAT_FTYPE     (1 << 0)        /* filetype in dirent */
-#define XFS_SB_FEAT_INCOMPAT_SPINODES  (1 << 1)        /* sparse inode chunks */
-#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2)        /* metadata UUID */
-#define XFS_SB_FEAT_INCOMPAT_BIGTIME   (1 << 3)        /* large timestamps */
-#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4)      /* needs xfs_repair */
-#define XFS_SB_FEAT_INCOMPAT_NREXT64   (1 << 5)        /* large extent counters */
+#define XFS_SB_FEAT_INCOMPAT_FTYPE     (1 << 0)  /* filetype in dirent */
+#define XFS_SB_FEAT_INCOMPAT_SPINODES  (1 << 1)  /* sparse inode chunks */
+#define XFS_SB_FEAT_INCOMPAT_META_UUID (1 << 2)  /* metadata UUID */
+#define XFS_SB_FEAT_INCOMPAT_BIGTIME   (1 << 3)  /* large timestamps */
+#define XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR (1 << 4) /* needs xfs_repair */
+#define XFS_SB_FEAT_INCOMPAT_NREXT64   (1 << 5)  /* large extent counters */
+#define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6)  /* exchangerange supported */
 #define XFS_SB_FEAT_INCOMPAT_ALL \
-               (XFS_SB_FEAT_INCOMPAT_FTYPE|    \
-                XFS_SB_FEAT_INCOMPAT_SPINODES| \
-                XFS_SB_FEAT_INCOMPAT_META_UUID| \
-                XFS_SB_FEAT_INCOMPAT_BIGTIME| \
-                XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR| \
+               (XFS_SB_FEAT_INCOMPAT_FTYPE | \
+                XFS_SB_FEAT_INCOMPAT_SPINODES | \
+                XFS_SB_FEAT_INCOMPAT_META_UUID | \
+                XFS_SB_FEAT_INCOMPAT_BIGTIME | \
+                XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR | \
                 XFS_SB_FEAT_INCOMPAT_NREXT64)
 
 #define XFS_SB_FEAT_INCOMPAT_UNKNOWN   ~XFS_SB_FEAT_INCOMPAT_ALL
index 8a1e30cf4dc880e3484b35ec3d453e4875852a70..53526fca7386ce0e3ad901d4903f297cf7e5d239 100644 (file)
@@ -239,6 +239,7 @@ typedef struct xfs_fsop_resblks {
 #define XFS_FSOP_GEOM_FLAGS_BIGTIME    (1 << 21) /* 64-bit nsec timestamps */
 #define XFS_FSOP_GEOM_FLAGS_INOBTCNT   (1 << 22) /* inobt btree counter */
 #define XFS_FSOP_GEOM_FLAGS_NREXT64    (1 << 23) /* large extent counters */
+#define XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE (1 << 24) /* exchange range */
 
 /*
  * Minimum and maximum sizes need for growth checks.
index 73a4b895de6704252fc4efbb00b68c3440d3cd4b..c350e259b685574554f9d8b52e4401e2bcb83ccb 100644 (file)
@@ -26,6 +26,7 @@
 #include "xfs_health.h"
 #include "xfs_ag.h"
 #include "xfs_rtbitmap.h"
+#include "xfs_exchrange.h"
 
 /*
  * Physical superblock buffer manipulations. Shared with libxfs in userspace.
@@ -175,6 +176,8 @@ xfs_sb_version_to_features(
                features |= XFS_FEAT_NEEDSREPAIR;
        if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_NREXT64)
                features |= XFS_FEAT_NREXT64;
+       if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_EXCHRANGE)
+               features |= XFS_FEAT_EXCHANGE_RANGE;
 
        return features;
 }
@@ -1259,6 +1262,8 @@ xfs_fs_geometry(
        }
        if (xfs_has_large_extent_counts(mp))
                geo->flags |= XFS_FSOP_GEOM_FLAGS_NREXT64;
+       if (xfs_has_exchange_range(mp))
+               geo->flags |= XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE;
        geo->rtsectsize = sbp->sb_blocksize;
        geo->dirblocksize = xfs_dir2_dirblock_bytes(sbp);
 
index 6ec038b88454c4fb41b25ccfcf20126e7f3d4144..b022e5120dc42db424e79d101935bc23e9002dd0 100644 (file)
@@ -292,6 +292,7 @@ typedef struct xfs_mount {
 #define XFS_FEAT_BIGTIME       (1ULL << 24)    /* large timestamps */
 #define XFS_FEAT_NEEDSREPAIR   (1ULL << 25)    /* needs xfs_repair */
 #define XFS_FEAT_NREXT64       (1ULL << 26)    /* large extent counters */
+#define XFS_FEAT_EXCHANGE_RANGE        (1ULL << 27)    /* exchange range */
 
 /* Mount features */
 #define XFS_FEAT_NOATTR2       (1ULL << 48)    /* disable attr2 creation */
@@ -355,6 +356,7 @@ __XFS_HAS_FEAT(inobtcounts, INOBTCNT)
 __XFS_HAS_FEAT(bigtime, BIGTIME)
 __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR)
 __XFS_HAS_FEAT(large_extent_counts, NREXT64)
+__XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE)
 
 /*
  * Mount features
index bce020374c5eba5255a98d71176d7198024603d2..dbda72df3419bbf4962e33edb50f44349cf747c7 100644 (file)
@@ -1727,6 +1727,10 @@ xfs_fs_fill_super(
                goto out_filestream_unmount;
        }
 
+       if (xfs_has_exchange_range(mp))
+               xfs_warn(mp,
+       "EXPERIMENTAL exchange-range feature enabled. Use at your own risk!");
+
        error = xfs_mountfs(mp);
        if (error)
                goto out_filestream_unmount;