]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: force swapext to a realtime file to use the file content exchange ioctl
authorDarrick J. Wong <djwong@kernel.org>
Wed, 29 May 2024 04:11:22 +0000 (21:11 -0700)
committerChristoph Hellwig <hch@lst.de>
Tue, 6 Aug 2024 13:05:15 +0000 (06:05 -0700)
xfs_swap_extent_rmap does not use log items to track the overall
progress of an attempt to swap the extent mappings between two files.
If the system crashes in the middle of swapping a partially written
realtime extent, the mapping will be left in an inconsistent state
wherein a file can point to multiple extents on the rt volume.

The new file range exchange functionality handles this correctly, so all
callers must upgrade to that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
fs/xfs/xfs_bmap_util.c

index fe2e2c930975501b447ca5b36109de998275dd3f..d3d454675892fa7f01cba1e6022f3c0379da699f 100644 (file)
@@ -1522,6 +1522,18 @@ xfs_swap_extents(
                goto out_unlock;
        }
 
+       /*
+        * The rmapbt implementation is unable to resume a swapext operation
+        * after a crash if the allocation unit size is larger than a block.
+        * This (deprecated) interface will not be upgraded to handle this
+        * situation.  Defragmentation must be performed with the logged file
+        * exchange ioctls.
+        */
+       if (XFS_IS_REALTIME_INODE(ip) && xfs_has_rtgroups(ip->i_mount)) {
+               error = -EOPNOTSUPP;
+               goto out_unlock;
+       }
+
        error = xfs_qm_dqattach(ip);
        if (error)
                goto out_unlock;