]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: use atomic extent swapping to fix user file fork data
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:22:39 +0000 (16:22 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:00 +0000 (17:01 -0700)
Source kernel commit: 629fdaf5f5b1b7f7107ed4de04e0991a99501ced

Build on the code that was recently added to the temporary repair file
code so that we can atomically switch the contents of any file fork,
even if the fork is in local format.  The upcoming functions to repair
xattrs, directories, and symlinks will need that capability.

Repair can lock out access to these user files by holding IOLOCK_EXCL on
these user files.  Therefore, it is safe to drop the ILOCK of both the
file being repaired and the tempfile being used for staging, and cancel
the scrub transaction.  We do this so that we can reuse the resource
estimation and transaction allocation functions used by a regular file
exchange operation.

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

index 71408d7132fa1705682f369a6e8513b83f20bd9a..a8a51ce53881d3e799b70fe8b85ccaa6ffc64a95 100644 (file)
@@ -672,7 +672,7 @@ xfs_exchmaps_rmapbt_blocks(
 }
 
 /* Estimate the bmbt and rmapbt overhead required to exchange mappings. */
-static int
+int
 xfs_exchmaps_estimate_overhead(
        struct xfs_exchmaps_req         *req)
 {
index d8718fca606e57f259a6c6e44d69d886e277c839..fa822dff202adee60a0d3f28c4826199c89f8735 100644 (file)
@@ -97,6 +97,7 @@ xfs_exchmaps_reqfork(const struct xfs_exchmaps_req *req)
        return XFS_DATA_FORK;
 }
 
+int xfs_exchmaps_estimate_overhead(struct xfs_exchmaps_req *req);
 int xfs_exchmaps_estimate(struct xfs_exchmaps_req *req);
 
 extern struct kmem_cache       *xfs_exchmaps_intent_cache;