xfs: teach the tempfile to set up atomic file content exchanges
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:32 +0000 (14:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:58:49 +0000 (14:58 -0700)
commit56596d8bffd2f3c80d9844835e6c118d89b67ca9
treea5d03e93bc506e319c94107a0394923d4745d165
parente81ce4241318d5ec943b4fe205953498a66ca071
xfs: teach the tempfile to set up atomic file content exchanges

Create some new routines to exchange the contents of a temporary file
created to stage a repair with another ondisk file.  This will be used
by the realtime summary repair function to commit atomically the new
rtsummary data, which will be staged in the tempfile.

The rest of XFS coordinates access to the realtime metadata inodes
solely through the ILOCK.  For repair to hold its exclusive access to
the realtime summary file, it has to allocate a single large transaction
and roll it repeatedly throughout the repair while holding the ILOCK.
In turn, this means that for now there's only a partial file mapping
exchange implementation for the temporary file because we can only work
within an existing transaction.

For now, the only tempswap functions needed here are to estimate the
resource requirements of the exchange, reserve more space/quota to an
existing transaction, and kick off the actual exchange.  The rest will
be added in a later patch in preparation for repairing xattrs and
directories.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/scrub.c
fs/xfs/scrub/scrub.h
fs/xfs/scrub/tempexch.h [new file with mode: 0644]
fs/xfs/scrub/tempfile.c
fs/xfs/scrub/trace.h