]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_fsr: skip the xattr/forkoff levering with the newer swapext implementations
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:00 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:06 +0000 (17:01 -0700)
The newer swapext implementations in the kernel run at a high enough
level (above the bmap layer) that it's no longer required to manipulate
bs_forkoff by creating garbage xattrs to get the extent tree that we
want.  If we detect the newer algorithms, skip this error prone step.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fsr/xfs_fsr.c

index c6dbfb22acdcbff824a59c6910aaa7a0010ca93c..22e134adfd73abd8525d6cf8033d5691a3c38f25 100644 (file)
@@ -999,6 +999,20 @@ fsr_setup_attr_fork(
        if (!(bstatp->bs_xflags & FS_XFLAG_HASATTR))
                return 0;
 
+       /*
+        * If the filesystem has the ability to perform atomic file mapping
+        * exchanges, the file extent swap implementation uses a higher level
+        * algorithm that calls into the bmap code instead of playing games
+        * with swapping the extent forks.
+        *
+        * This new functionality does not require specific values of
+        * bs_forkoff, unlike the old fork swap code.  Leave the extended
+        * attributes alone if we know we're not using the old fork swap
+        * strategy.  This eliminates a major source of runtime errors in fsr.
+        */
+       if (fsgeom.flags & XFS_FSOP_GEOM_FLAGS_EXCHANGE_RANGE)
+               return 0;
+
        /*
         * use the old method if we have attr1 or the kernel does not yet
         * support passing the fork offset in the bulkstat data.