]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
10 months agorepair: stop preallocating blocks in mk_rbmino and mk_rsumino xfs-rt-refactor
Christoph Hellwig [Mon, 29 Jul 2024 21:56:56 +0000 (14:56 -0700)]
repair: stop preallocating blocks in mk_rbmino and mk_rsumino

Now that repair is using libxfs_rtfile_initialize_blocks to write to the
rtbitmap and rtsummary inodes, space allocation is already taken care of
that helper and there is no need to preallocate it.  Remove the code to
do so.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agorepair: use libxfs_rtfile_initialize_blocks
Christoph Hellwig [Mon, 29 Jul 2024 21:46:29 +0000 (14:46 -0700)]
repair: use libxfs_rtfile_initialize_blocks

Use libxfs_rtfile_initialize_blocks to write the re-computed rtbitmap
and rtsummary contents.  This removes duplicate code and prepares for
even more sharing once the rtgroup features adds a metadata header to
the rtbitmap and rtsummary blocks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agorepair: factor out a xfs_rootrec_inodes_inuse helper
Christoph Hellwig [Thu, 11 Jul 2024 12:21:43 +0000 (14:21 +0200)]
repair: factor out a xfs_rootrec_inodes_inuse helper

Ensure only one place needs to be found and modified when changing the
number of "static" sb rooted inodes, saving copious debug time when
doing so.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agomkfs: use xfs_rtfile_initialize_blocks
Christoph Hellwig [Sun, 14 Jul 2024 16:29:28 +0000 (18:29 +0200)]
mkfs: use xfs_rtfile_initialize_blocks

Use the new libxfs helper for initializing the rtbitmap/summary files
for rtgroup-enabled file systems.  Also skip the zeroing of the blocks
for rtgroup file systems as we'll overwrite every block instantly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agomkfs: remove a pointless rtfreesp_init forward declaration
Christoph Hellwig [Thu, 11 Jul 2024 06:06:37 +0000 (08:06 +0200)]
mkfs: remove a pointless rtfreesp_init forward declaration

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: factor out rtbitmap/summary initialization helpers
Christoph Hellwig [Tue, 30 Jul 2024 01:05:06 +0000 (18:05 -0700)]
xfs: factor out rtbitmap/summary initialization helpers

Source kernel commit: 50eb06188e917fdc52cefbd70bbb221e4f52366a

Add helpers to libxfs that can be shared by growfs and mkfs for
initializing the rtbitmap and summary, and by passing the optional
data pointer also by repair for rebuilding them.  This will become
even more useful when the rtgroups feature adѕ a metadata header
to each block, which means even more shared code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: add bounds checking to xfs_rt{bitmap,summary}_read_buf
Christoph Hellwig [Mon, 29 Jul 2024 21:15:54 +0000 (14:15 -0700)]
xfs: add bounds checking to xfs_rt{bitmap,summary}_read_buf

Source kernel commit: 62e01705d7eab570947effb123c56d64ba173c90

Add a corruption check for passing an invalid block number, which is a
lot easier to understand than the xfs_bmapi_read failure later on.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: assert a valid limit in xfs_rtfind_forw
Christoph Hellwig [Mon, 29 Jul 2024 21:15:31 +0000 (14:15 -0700)]
xfs: assert a valid limit in xfs_rtfind_forw

Source kernel commit: 1bad5ccef903f0b583f6101d2cff27692c139614

Protect against developers passing stupid limits when refactoring the
RT code once again.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: remove the limit argument to xfs_rtfind_back
Christoph Hellwig [Mon, 29 Jul 2024 21:15:23 +0000 (14:15 -0700)]
xfs: remove the limit argument to xfs_rtfind_back

Source kernel commit: bc19cf503beb9871681538687fe5bd79f407902f

All callers pass a 0 limit to xfs_rtfind_back, so remove the argument
and hard code it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agorepair: use xfs_validate_rt_geometry
Christoph Hellwig [Mon, 29 Jul 2024 23:54:37 +0000 (16:54 -0700)]
repair: use xfs_validate_rt_geometry

Use shared libxfs code with the kernel instead of reimplementing it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: factor out a xfs_validate_rt_geometry helper
Christoph Hellwig [Mon, 29 Jul 2024 23:53:24 +0000 (16:53 -0700)]
xfs: factor out a xfs_validate_rt_geometry helper

Source kernel commit: 62c60ca7eb49d4c548f8c365c8e36451cd5cde15

Split the RT geometry validation in the early mount code into a
helper than can be reused by repair (from which this code was
apparently originally stolen anyway).

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agoxfs: remove xfs_validate_rtextents
Christoph Hellwig [Mon, 29 Jul 2024 21:14:13 +0000 (14:14 -0700)]
xfs: remove xfs_validate_rtextents

Source kernel commit: a11775da16b3968c60d26782a9dbc77b19484f1a

Replace xfs_validate_rtextents with an open coded check for 0
rtextents.  The name for the function implies it does a lot more
than a zero check, which is more obvious when open coded.

Signed-off-by: Christoph Hellwig <hch@lst.de>
10 months agomkfs: add a utility to generate protofiles
Darrick J. Wong [Wed, 3 Jul 2024 21:21:56 +0000 (14:21 -0700)]
mkfs: add a utility to generate protofiles

Add a new utility to generate mkfs protofiles from a directory tree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agomkfs.xfs: enable metadata directories
Darrick J. Wong [Wed, 3 Jul 2024 21:21:56 +0000 (14:21 -0700)]
mkfs.xfs: enable metadata directories

Enable formatting filesystems with metadata directories.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: allow sysadmins to add metadata directories
Darrick J. Wong [Wed, 3 Jul 2024 21:21:56 +0000 (14:21 -0700)]
xfs_repair: allow sysadmins to add metadata directories

Allow the sysadmin to use xfs_repair to upgrade an existing filesystem
to support metadata directories.  This will be needed to upgrade
filesystems to support realtime rmap and reflink.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: do not count metadata directory files when doing quotacheck
Darrick J. Wong [Wed, 3 Jul 2024 21:21:56 +0000 (14:21 -0700)]
xfs_repair: do not count metadata directory files when doing quotacheck

Previously, we stated that files in the metadata directory tree are not
counted in the dquot information.  Fix the offline quotacheck code in
xfs_repair and xfs_check to reflect this.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: truncate and unmark orphaned metadata inodes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:55 +0000 (14:21 -0700)]
xfs_repair: truncate and unmark orphaned metadata inodes

If an inode claims to be a metadata inode but wasn't linked in either
directory tree, remove the attr fork and reset the data fork if the
contents weren't regular extent mappings before moving the inode to the
lost+found.

We don't ifree the inode, because it's possible that the inode was not
actually a metadata inode but simply got corrupted due to bitflips or
something, and we'd rather let the sysadmin examine what's left of the
file instead of photorec'ing it.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: drop all the metadata directory files during pass 4
Darrick J. Wong [Wed, 3 Jul 2024 21:21:55 +0000 (14:21 -0700)]
xfs_repair: drop all the metadata directory files during pass 4

Drop the entire metadata directory tree during pass 4 so that we can
reinitialize the entire tree in phase 6.  The existing metadata files
(rtbitmap, rtsummary, quotas) will be reattached to the newly rebuilt
directory tree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: metadata dirs are never plausible root dirs
Darrick J. Wong [Wed, 3 Jul 2024 21:21:55 +0000 (14:21 -0700)]
xfs_repair: metadata dirs are never plausible root dirs

Metadata directories are never candidates to be the root of the
user-accessible directory tree.  Update has_plausible_rootdir to ignore
them all, as well as detecting the case where the superblock incorrectly
thinks both trees have the same root.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: adjust keep_fsinos to handle metadata directories
Darrick J. Wong [Wed, 3 Jul 2024 21:21:55 +0000 (14:21 -0700)]
xfs_repair: adjust keep_fsinos to handle metadata directories

In keep_fsinos, mark the root of the metadata directory tree as inuse.
The realtime bitmap and summary files still come after the root
directories, so this is a fairly simple change to the loop test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: mark space used by metadata files
Darrick J. Wong [Wed, 3 Jul 2024 21:21:54 +0000 (14:21 -0700)]
xfs_repair: mark space used by metadata files

Track space used by metadata files as a separate incore extent type.
This ensures that we can warn about cross-linked metadata files, even
though we are going to rebuild the entire metadata directory tree in the
end.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: pass private data pointer to scan_lbtree
Darrick J. Wong [Wed, 3 Jul 2024 21:21:54 +0000 (14:21 -0700)]
xfs_repair: pass private data pointer to scan_lbtree

Pass a private data pointer through scan_lbtree.  We'll use this
later when scanning the rtrmapbt to keep track of scan state.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: update incore metadata state whenever we create new files
Darrick J. Wong [Wed, 3 Jul 2024 21:21:54 +0000 (14:21 -0700)]
xfs_repair: update incore metadata state whenever we create new files

Make sure that we update our incore metadata inode bookkeepping whenever
we create new metadata files.  There will be many more of these later.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: don't let metadata and regular files mix
Darrick J. Wong [Wed, 3 Jul 2024 21:21:54 +0000 (14:21 -0700)]
xfs_repair: don't let metadata and regular files mix

Track whether or not inodes thought they were metadata inodes.  We
cannot allow metadata inodes to appear in the regular directory tree,
and we cannot allow regular inodes to appear in the metadata directory
tree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: rebuild the metadata directory
Darrick J. Wong [Wed, 3 Jul 2024 21:21:54 +0000 (14:21 -0700)]
xfs_repair: rebuild the metadata directory

Check the dirents in metadata directories for problems and repair them
if necessary.  Also make sure that the sb-rooted inodes (root, metadir
root, rt bitmap, rt summary) are always allocated in that order.

Note that xfs_repair will always rebuild the metadata directory tree
itself, so we only need to report problems, not fix them.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: check metadata inode flag
Darrick J. Wong [Wed, 3 Jul 2024 21:21:53 +0000 (14:21 -0700)]
xfs_repair: check metadata inode flag

Check whether or not the metadata inode flag is set appropriately.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: refactor grabbing realtime metadata inodes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:53 +0000 (14:21 -0700)]
xfs_repair: refactor grabbing realtime metadata inodes

Create a helper function to grab a realtime metadata inode.  When
metadir arrives, the bitmap and summary inodes can float, so we'll
turn this function into a "load or allocate" function.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: refactor root directory initialization
Darrick J. Wong [Wed, 3 Jul 2024 21:21:53 +0000 (14:21 -0700)]
xfs_repair: refactor root directory initialization

Refactor root directory initialization into a separate function we can
call for both the root dir and the metadir.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: refactor marking of metadata inodes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:53 +0000 (14:21 -0700)]
xfs_repair: refactor marking of metadata inodes

Refactor the mechanics of marking a metadata inode into a helper
function so that we don't have to open-code that for every single
metadata inode.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: refactor fixing dotdot
Darrick J. Wong [Wed, 3 Jul 2024 21:21:52 +0000 (14:21 -0700)]
xfs_repair: refactor fixing dotdot

Pull the code that fixes a directory's dot-dot entry into a separate
helper function so that we can call it on the rootdir and (later) the
metadir.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: dont check metadata directory dirent inumbers
Darrick J. Wong [Wed, 3 Jul 2024 21:21:52 +0000 (14:21 -0700)]
xfs_repair: dont check metadata directory dirent inumbers

Phase 6 always rebuilds the entire metadata directory tree, and repair
quietly ignores all the DIFLAG2_METADATA directory inodes that it finds.
As a result, none of the metadata directories are marked inuse in the
incore data.  Therefore, the is_inode_free checks are not valid for
anything we find in a metadata directory.

Therefore, avoid checking is_inode_free when scanning metadata directory
dirents.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: preserve the metadirino field when zeroing supers
Darrick J. Wong [Wed, 3 Jul 2024 21:21:52 +0000 (14:21 -0700)]
xfs_repair: preserve the metadirino field when zeroing supers

The metadata directory root inumber is now the last field in the
superblock, so extend the zeroing code to know about that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_scrub: re-run metafile scrubbers during phase 5
Darrick J. Wong [Wed, 3 Jul 2024 21:21:52 +0000 (14:21 -0700)]
xfs_scrub: re-run metafile scrubbers during phase 5

For metadata files on a metadir filesystem, re-run the scrubbers during
phase 5 to ensure that the metadata files are still connected.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_scrub: scan metadata directories during phase 3
Darrick J. Wong [Wed, 3 Jul 2024 21:21:52 +0000 (14:21 -0700)]
xfs_scrub: scan metadata directories during phase 3

Scan metadata directories for correctness during phase 3.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_spaceman: report health of metadir inodes too
Darrick J. Wong [Wed, 3 Jul 2024 21:21:51 +0000 (14:21 -0700)]
xfs_spaceman: report health of metadir inodes too

If the filesystem has a metadata directory tree, we should include those
inodes in the health report.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_io: support scrubbing metadata directory paths
Darrick J. Wong [Wed, 3 Jul 2024 21:21:51 +0000 (14:21 -0700)]
xfs_io: support scrubbing metadata directory paths

Support invoking the metadata directory path scrubber from xfs_io for
testing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_io: support the bulkstat metadata directory flag
Darrick J. Wong [Wed, 3 Jul 2024 21:21:51 +0000 (14:21 -0700)]
xfs_io: support the bulkstat metadata directory flag

Support the new XFS_BULK_IREQ_METADIR flag for bulkstat commands.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_db: show the metadata root directory when dumping superblocks
Darrick J. Wong [Wed, 3 Jul 2024 21:21:51 +0000 (14:21 -0700)]
xfs_db: show the metadata root directory when dumping superblocks

Show the metadirino field when appropriate.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_db: support metadata directories in the path command
Darrick J. Wong [Wed, 3 Jul 2024 21:21:50 +0000 (14:21 -0700)]
xfs_db: support metadata directories in the path command

Teach the path command to traverse the metadata directory tree by
passing a '\' as the first letter in the path.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_db: don't obfuscate metadata directories and attributes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:50 +0000 (14:21 -0700)]
xfs_db: don't obfuscate metadata directories and attributes

Don't obfuscate the directory and attribute names of metadata inodes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_db: report metadir support for version command
Darrick J. Wong [Wed, 3 Jul 2024 21:21:50 +0000 (14:21 -0700)]
xfs_db: report metadir support for version command

Report metadir support if we have it enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_db: disable xfs_check when metadir is enabled
Darrick J. Wong [Wed, 3 Jul 2024 21:21:50 +0000 (14:21 -0700)]
xfs_db: disable xfs_check when metadir is enabled

As of July 2024, xfs_repair can detect more types of corruptions than
xfs_check does.  I don't think it makes sense to maintain the xfs_check
code anymore, so let's just turn it off for any filesystem that has
metadata directory trees.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_io: support scrubbing metadata directory paths
Darrick J. Wong [Wed, 3 Jul 2024 21:21:49 +0000 (14:21 -0700)]
xfs_io: support scrubbing metadata directory paths

Support invoking the metadata directory path scrubber from xfs_io for
testing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agolibfrog: allow METADIR in xfrog_bulkstat_single5
Darrick J. Wong [Wed, 3 Jul 2024 21:21:49 +0000 (14:21 -0700)]
libfrog: allow METADIR in xfrog_bulkstat_single5

This is a valid flag for a single-file bulkstat, so add that to the
filter.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agolibfrog: report metadata directories in the geometry report
Darrick J. Wong [Wed, 3 Jul 2024 21:21:49 +0000 (14:21 -0700)]
libfrog: report metadata directories in the geometry report

Report the presence of a metadata directory tree in the geometry report.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: enable metadata directory feature
Darrick J. Wong [Wed, 3 Jul 2024 21:21:49 +0000 (14:21 -0700)]
xfs: enable metadata directory feature

Enable the metadata directory feature.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: check metadata directory file path connectivity
Darrick J. Wong [Wed, 3 Jul 2024 21:21:49 +0000 (14:21 -0700)]
xfs: check metadata directory file path connectivity

Create a new scrubber type that checks that well known metadata
directory paths are connected to the metadata inode that the incore
structures think is in use.  IOWs, check that "/quota/user" in the
metadata directory tree actually points to
mp->m_quotainfo->qi_uquotaip->i_ino.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: record health problems with the metadata directory
Darrick J. Wong [Wed, 29 May 2024 04:11:03 +0000 (21:11 -0700)]
xfs: record health problems with the metadata directory

Make a report to the health monitoring subsystem any time we encounter
something in the metadata directory tree that looks like corruption.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: adjust xfs_bmap_add_attrfork for metadir
Darrick J. Wong [Wed, 29 May 2024 04:11:02 +0000 (21:11 -0700)]
xfs: adjust xfs_bmap_add_attrfork for metadir

Online repair might use the xfs_bmap_add_attrfork to repair a file in
the metadata directory tree if (say) the metadata file lacks the correct
parent pointers.  In that case, it is not correct to check that the file
is dqattached -- metadata files must be not have /any/ dquot attached at
all.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: allow bulkstat to return metadata directories
Darrick J. Wong [Wed, 3 Jul 2024 21:21:48 +0000 (14:21 -0700)]
xfs: allow bulkstat to return metadata directories

Allow the V5 bulkstat ioctl to return information about metadata
directory files so that xfs_scrub can find and scrub them, since they
are otherwise ordinary directories.

(Metadata files of course require per-file scrub code and hence do not
need exposure.)

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: advertise metadata directory feature
Darrick J. Wong [Wed, 3 Jul 2024 21:21:47 +0000 (14:21 -0700)]
xfs: advertise metadata directory feature

Advertise the existence of the metadata directory feature; this will be
used by scrub to decide if it needs to scan the metadir too.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: disable the agi rotor for metadata inodes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:47 +0000 (14:21 -0700)]
xfs: disable the agi rotor for metadata inodes

Ideally, we'd put all the metadata inodes in one place if we could, so
that the metadata all stay reasonably close together instead of
spreading out over the disk.  Furthermore, if the log is internal we'd
probably prefer to keep the metadata near the log.  Therefore, disable
AGI rotoring for metadata inode allocations.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: read and write metadata inode directory tree
Darrick J. Wong [Wed, 29 May 2024 04:10:58 +0000 (21:10 -0700)]
xfs: read and write metadata inode directory tree

Plumb in the bits we need to load metadata inodes from a named entry in
a metadir directory, create (or hardlink) inodes into a metadir
directory, create metadir directories, and flag inodes as being metadata
files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: enforce metadata inode flag
Darrick J. Wong [Wed, 29 May 2024 04:10:57 +0000 (21:10 -0700)]
xfs: enforce metadata inode flag

Add checks for the metadata inode flag so that we don't ever leak
metadata inodes out to userspace, and we don't ever try to read a
regular inode as metadata.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: load metadata directory root at mount time
Darrick J. Wong [Wed, 3 Jul 2024 21:21:46 +0000 (14:21 -0700)]
xfs: load metadata directory root at mount time

Load the metadata directory root inode into memory at mount time and
release it at unmount time.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: define the on-disk format for the metadir feature
Darrick J. Wong [Wed, 29 May 2024 04:10:55 +0000 (21:10 -0700)]
xfs: define the on-disk format for the metadir feature

Define the on-disk layout and feature flags for the metadata inode
directory feature.  Add a xfs_sb_version_hasmetadir for benefit of
xfs_repair, which needs to know where the new end of the superblock
lies.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: iget for metadata inodes
Darrick J. Wong [Wed, 29 May 2024 04:10:54 +0000 (21:10 -0700)]
xfs: iget for metadata inodes

Create a xfs_imeta_iget function for metadata inodes to ensure that when
we try to iget a metadata file, the inobt thinks a metadata inode is in
use and that the file type matches what we are expecting.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: pass the icreate args object to xfs_dialloc
Darrick J. Wong [Wed, 3 Jul 2024 21:21:45 +0000 (14:21 -0700)]
xfs: pass the icreate args object to xfs_dialloc

Pass the xfs_icreate_args object to xfs_dialloc since we can extract the
relevant mode (really just the file type) and parent inumber from there.
This simplifies the calling convention in preparation for the next
patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: upgrade an existing filesystem to have parent pointers
Darrick J. Wong [Wed, 3 Jul 2024 21:21:45 +0000 (14:21 -0700)]
xfs_repair: upgrade an existing filesystem to have parent pointers

Upgrade an existing filesystem to have parent pointers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: allow sysadmins to add reverse mapping indexes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:45 +0000 (14:21 -0700)]
xfs_repair: allow sysadmins to add reverse mapping indexes

Allow the sysadmin to use xfs_repair to upgrade an existing filesystem
to support the reverse mapping btree index.  This is needed for online
fsck.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: allow sysadmins to add reflink
Darrick J. Wong [Wed, 3 Jul 2024 21:21:45 +0000 (14:21 -0700)]
xfs_repair: allow sysadmins to add reflink

Allow the sysadmin to use xfs_repair to upgrade an existing filesystem
to support the reference count btree, and therefore reflink.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_repair: allow sysadmins to add free inode btree indexes
Darrick J. Wong [Wed, 3 Jul 2024 21:21:45 +0000 (14:21 -0700)]
xfs_repair: allow sysadmins to add free inode btree indexes

Allow the sysadmin to use xfs_repair to upgrade an existing filesystem
to support the free inode btree.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_io: add atomic file update commands to exercise file commit range
Darrick J. Wong [Wed, 3 Jul 2024 21:21:44 +0000 (14:21 -0700)]
xfs_io: add atomic file update commands to exercise file commit range

Add three commands to xfs_io so that we can exercise atomic file updates
as provided by reflink and the start-commit / commit-range functionality.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_io: add a commitrange option to the exchangerange command
Darrick J. Wong [Wed, 3 Jul 2024 21:21:44 +0000 (14:21 -0700)]
xfs_io: add a commitrange option to the exchangerange command

Teach the xfs_io exchangerange command to be able to use the commit
range functionality so that we can test it piece by piece.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs_fsr: port to new file exchange library function
Darrick J. Wong [Wed, 3 Jul 2024 21:21:43 +0000 (14:21 -0700)]
xfs_fsr: port to new file exchange library function

Port fsr to use the new libfrog library functions to handle exchanging
mappings between the target and donor files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agolibfrog: add support for commit range ioctl family
Darrick J. Wong [Wed, 3 Jul 2024 21:21:43 +0000 (14:21 -0700)]
libfrog: add support for commit range ioctl family

Add some library code to support the new file range commit ioctls.  This
will be used to test the atomic file commit functionality in fstests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoman: document file range commit ioctls
Darrick J. Wong [Wed, 3 Jul 2024 21:21:43 +0000 (14:21 -0700)]
man: document file range commit ioctls

Document the two new ioctls to support committing arbitrary dirty data
ranges of two files.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: introduce new file range commit ioctls
Darrick J. Wong [Wed, 3 Jul 2024 21:21:43 +0000 (14:21 -0700)]
xfs: introduce new file range commit ioctls

This patch introduces two more new ioctls to manage atomic updates to
file contents -- XFS_IOC_START_COMMIT and XFS_IOC_COMMIT_RANGE.  The
commit mechanism here is exactly the same as what XFS_IOC_EXCHANGE_RANGE
does, but with the additional requirement that file2 cannot have changed
since some sampling point.  The start-commit ioctl performs the sampling
of file attributes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: validate inumber in xfs_iget
Darrick J. Wong [Tue, 9 Jul 2024 14:17:56 +0000 (07:17 -0700)]
xfs: validate inumber in xfs_iget

Actually use the inumber validator to check the argument passed in here.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agomkfs: break up the rest of the rtinit() function
Darrick J. Wong [Wed, 3 Jul 2024 21:21:44 +0000 (14:21 -0700)]
mkfs: break up the rest of the rtinit() function

Break up this really long function into smaller functions that each do
one thing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agomkfs: clean up the rtinit() function
Darrick J. Wong [Wed, 3 Jul 2024 21:21:44 +0000 (14:21 -0700)]
mkfs: clean up the rtinit() function

Clean up some of the warts in this function, like the inconsistent use
of @i for @error, missing comments, and make this more visually pleasing
by adding some whitespace between major sections.  Some things are left
untouched for the next patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: get rid of xfs_ag_resv_rmapbt_alloc
Long Li [Tue, 16 Jul 2024 21:57:26 +0000 (14:57 -0700)]
xfs: get rid of xfs_ag_resv_rmapbt_alloc

Source kernel commit: 49cdc4e834e46d7c11a91d7adcfa04f56d19efaf

The pag in xfs_ag_resv_rmapbt_alloc() is already held when the struct
xfs_btree_cur is initialized in xfs_rmapbt_init_cursor(), so there is no
need to get pag again.

On the other hand, in xfs_rmapbt_free_block(), the similar function
xfs_ag_resv_rmapbt_free() was removed in commit 92a005448f6f ("xfs: get
rid of unnecessary xfs_perag_{get,put} pairs"), xfs_ag_resv_rmapbt_alloc()
was left because scrub used it, but now scrub has removed it. Therefore,
we could get rid of xfs_ag_resv_rmapbt_alloc() just like the rmap free
block, make the code cleaner.

Signed-off-by: Long Li <leo.lilong@huawei.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
10 months agoxfs: background AIL push should target physical space
Dave Chinner [Tue, 16 Jul 2024 21:57:26 +0000 (14:57 -0700)]
xfs: background AIL push should target physical space

Source kernel commit: b50b4c49d8d79af05ac3bb3587f58589713139cc

Currently the AIL attempts to keep 25% of the "log space" free,
where the current used space is tracked by the reserve grant head.
That is, it tracks both physical space used plus the amount reserved
by transactions in progress.

When we start tail pushing, we are trying to make space for new
reservations by writing back older metadata and the log is generally
physically full of dirty metadata, and reservations for modifications
in flight take up whatever space the AIL can physically free up.

Hence we don't really need to take into account the reservation
space that has been used - we just need to keep the log tail moving
as fast as we can to free up space for more reservations to be made.
We know exactly how much physical space the journal is consuming in
the AIL (i.e. max LSN - min LSN) so we can base push thresholds
directly on this state rather than have to look at grant head
reservations to determine how much to physically push out of the
log.

This also allows code that needs to know if log items in the current
transaction need to be pushed or re-logged to simply sample the
current target - they don't need to calculate the current target
themselves. This avoids the need for any locking when doing such
checks.

Further, moving to a physical target means we don't need "push all
until empty semantics" like were introduced in the previous patch.
We can now test and clear the "push all" as a one-shot command to
set the target to the current head of the AIL. This allows the
xfsaild to maximise the use of log space right up to the point where
conditions indicate that the xfsaild is not keeping up with load and
it needs to work harder, and as soon as those constraints go away
(i.e. external code no longer needs everything pushed) the xfsaild
will return to maintaining the normal 25% free space thresholds.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
10 months agoxfs: AIL doesn't need manual pushing
Dave Chinner [Tue, 16 Jul 2024 21:57:26 +0000 (14:57 -0700)]
xfs: AIL doesn't need manual pushing

Source kernel commit: 9adf40249e6cfd7231c2973bb305f6c20902bfd9

We have a mechanism that checks the amount of log space remaining
available every time we make a transaction reservation. If the
amount of space is below a threshold (25% free) we push on the AIL
to tell it to do more work. To do this, we end up calculating the
LSN that the AIL needs to push to on every reservation and updating
the push target for the AIL with that new target LSN.

This is silly and expensive. The AIL is perfectly capable of
calculating the push target itself, and it will always be running
when the AIL contains objects.

What the target does is determine if the AIL needs to do
any work before it goes back to sleep. If we haven't run out of
reservation space or memory (or some other push all trigger), it
will simply go back to sleep for a while if there is more than 25%
of the journal space free without doing anything.

If there are items in the AIL at a lower LSN than the target, it
will try to push up to the target or to the point of getting stuck
before going back to sleep and trying again soon after.`

Hence we can modify the AIL to calculate it's own 25% push target
before it starts a push using the same reserve grant head based
calculation as is currently used, and remove all the places where we
ask the AIL to push to a new 25% free target. We can also drop the
minimum free space size of 256BBs from the calculation because the
25% of a minimum sized log is *always going to be larger than
256BBs.

This does still require a manual push in certain circumstances.
These circumstances arise when the AIL is not full, but the
reservation grants consume the entire of the free space in the log.
In this case, we still need to push on the AIL to free up space, so
when we hit this condition (i.e. reservation going to sleep to wait
on log space) we do a single push to tell the AIL it should empty
itself. This will keep the AIL moving as new reservations come in
and want more space, rather than keep queuing them and having to
push the AIL repeatedly.

The reason for using the "push all" when grant space runs out is
that we can run out of grant space when there is more than 25% of
the log free. Small logs are notorious for this, and we have a hack
in the log callback code (xlog_state_set_callback()) where we push
the AIL because the *head* moved) to ensure that we kick the AIL
when we consume space in it because that can push us over the "less
than 25% available" available that starts tail pushing back up
again.

Hence when we run out of grant space and are going to sleep, we have
to consider that the grant space may be consuming almost all the log
space and there is almost nothing in the AIL. In this situation, the
AIL pins the tail and moving the tail forwards is the only way the
grant space will come available, so we have to force the AIL to push
everything to guarantee grant space will eventually be returned.
Hence triggering a "push all" just before sleeping removes all the
nasty corner cases we have in other parts of the code that work
around the "we didn't ask the AIL to push enough to free grant
space" condition that leads to log space hangs...

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
10 months agoFrom 94a0333b9212a114d19096a77903f76d0d5bca26 Mon Sep 17 00:00:00 2001
Zizhi Wo [Mon, 1 Jul 2024 06:02:36 +0000 (14:02 +0800)]
From 94a0333b9212a114d19096a77903f76d0d5bca26 Mon Sep 17 00:00:00 2001
Subject: xfs: Avoid races with cnt_btree lastrec updates

A concurrent file creation and little writing could unexpectedly return
-ENOSPC error since there is a race window that the allocator could get
the wrong agf->agf_longest.

Write file process steps:
1) Find the entry that best meets the conditions, then calculate the start
   address and length of the remaining part of the entry after allocation.
2) Delete this entry and update the -current- agf->agf_longest.
3) Insert the remaining unused parts of this entry based on the
   calculations in 1), and update the agf->agf_longest again if necessary.

Create file process steps:
1) Check whether there are free inodes in the inode chunk.
2) If there is no free inode, check whether there has space for creating
   inode chunks, perform the no-lock judgment first.
3) If the judgment succeeds, the judgment is performed again with agf lock
   held. Otherwire, an error is returned directly.

If the write process is in step 2) but not go to 3) yet, the create file
process goes to 2) at this time, it may be mistaken for no space,
resulting in the file system still has space but the file creation fails.

We have sent two different commits to the community in order to fix this
problem[1][2]. Unfortunately, both solutions have flaws. In [2], I
discussed with Dave and Darrick, realized that a better solution to this
problem requires the "last cnt record tracking" to be ripped out of the
generic btree code. And surprisingly, Dave directly provided his fix code.
This patch includes appropriate modifications based on his tmp-code to
address this issue.

The entire fix can be roughly divided into two parts:
1) Delete the code related to lastrec-update in the generic btree code.
2) Place the process of updating longest freespace with cntbt separately
   to the end of the cntbt modifications. Move the cursor to the rightmost
   firstly, and update the longest free extent based on the record.

Note that we can not update the longest with xfs_alloc_get_rec() after
find the longest record, as xfs_verify_agbno() may not pass because
pag->block_count is updated on the outside. Therefore, use
xfs_btree_get_rec() as a replacement.

[1] https://lore.kernel.org/all/20240419061848.1032366-2-yebin10@huawei.com
[2] https://lore.kernel.org/all/20240604071121.3981686-1-wozizhi@huawei.com

Reported by: Ye Bin <yebin10@huawei.com>

Signed-off-by: Zizhi Wo <wozizhi@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanbabu@kernel.org>
10 months agoxfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c
Darrick J. Wong [Wed, 3 Jul 2024 21:21:43 +0000 (14:21 -0700)]
xfs: move xfs_refcount_update_defer_add to xfs_refcount_item.c

Move the code that adds the incore xfs_refcount_update_item deferred
work data to a transaction live with the CUI log item code.  This means
that the refcount code no longer has to know about the inner workings of
the CUI log items.

As a consequence, we can get rid of the _{get,put}_group helpers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: simplify usage of the rcur local variable in xfs_refcount_finish_one
Darrick J. Wong [Wed, 3 Jul 2024 21:21:42 +0000 (14:21 -0700)]
xfs: simplify usage of the rcur local variable in xfs_refcount_finish_one

Only update rcur when we know the final *pcur value.

Inspired-by: Christoph Hellwig <hch@lst.de>
[djwong: don't leave the caller with a dangling ref]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one
Darrick J. Wong [Wed, 3 Jul 2024 21:21:42 +0000 (14:21 -0700)]
xfs: don't bother calling xfs_refcount_finish_one_cleanup in xfs_refcount_finish_one

In xfs_refcount_finish_one we know the cursor is non-zero when calling
xfs_refcount_finish_one_cleanup and we pass a 0 error variable.  This
means xfs_refcount_finish_one_cleanup is just doing a
xfs_btree_del_cursor.

Open code that and move xfs_refcount_finish_one_cleanup to
fs/xfs/xfs_refcount_item.c.

Inspired-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: reuse xfs_refcount_update_cancel_item
Darrick J. Wong [Wed, 3 Jul 2024 21:21:42 +0000 (14:21 -0700)]
xfs: reuse xfs_refcount_update_cancel_item

Reuse xfs_refcount_update_cancel_item to put the AG/RTG and free the
item in a few places that currently open code the logic.

Inspired-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: add a ci_entry helper
Darrick J. Wong [Wed, 3 Jul 2024 21:21:42 +0000 (14:21 -0700)]
xfs: add a ci_entry helper

Add a helper to translate from the item list head to the
refcount_intent_item structure and use it so shorten assignments and
avoid the need for extra local variables.

Inspired-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: clean up refcount log intent item tracepoint callsites
Darrick J. Wong [Wed, 3 Jul 2024 21:21:42 +0000 (14:21 -0700)]
xfs: clean up refcount log intent item tracepoint callsites

Pass the incore refcount intent structure to the tracepoints instead of
open-coding the argument passing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: prepare refcount btree tracepoints for widening
Darrick J. Wong [Wed, 3 Jul 2024 21:21:41 +0000 (14:21 -0700)]
xfs: prepare refcount btree tracepoints for widening

Prepare the rest of refcount btree tracepoints for use with realtime
reflink by making them take the btree cursor object as a parameter.
This will save us a lot of trouble later on.

Remove the xfs_refcount_recover_extent tracepoint since it's already
covered by other refcount tracepoints.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: create specialized classes for refcount tracepoints
Darrick J. Wong [Wed, 3 Jul 2024 21:21:41 +0000 (14:21 -0700)]
xfs: create specialized classes for refcount tracepoints

The only user of the "ag" tracepoint event classes is the refcount
btree, so rename them to make that obvious and make them take the btree
cursor to simplify the arguments.  This will save us a lot of trouble
later on.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: give refcount btree cursor error tracepoints their own class
Darrick J. Wong [Wed, 3 Jul 2024 21:21:41 +0000 (14:21 -0700)]
xfs: give refcount btree cursor error tracepoints their own class

Convert all the refcount tracepoints to use the btree error tracepoint
class.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c
Darrick J. Wong [Wed, 3 Jul 2024 21:21:41 +0000 (14:21 -0700)]
xfs: move xfs_rmap_update_defer_add to xfs_rmap_item.c

Move the code that adds the incore xfs_rmap_update_item deferred work
data to a transaction live with the RUI log item code.  This means that
the rmap code no longer has to know about the inner workings of the RUI
log items.

As a consequence, we can get rid of the _{get,put}_group helpers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: simplify usage of the rcur local variable in xfs_rmap_finish_one
Christoph Hellwig [Wed, 3 Jul 2024 21:21:41 +0000 (14:21 -0700)]
xfs: simplify usage of the rcur local variable in xfs_rmap_finish_one

Only update rcur when we know the final *pcur value.

Signed-off-by: Christoph Hellwig <hch@lst.de>
[djwong: don't leave the caller with a dangling ref]
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: don't bother calling xfs_rmap_finish_one_cleanup in xfs_rmap_finish_one
Christoph Hellwig [Wed, 3 Jul 2024 21:21:40 +0000 (14:21 -0700)]
xfs: don't bother calling xfs_rmap_finish_one_cleanup in xfs_rmap_finish_one

In xfs_rmap_finish_one we known the cursor is non-zero when calling
xfs_rmap_finish_one_cleanup and we pass a 0 error variable.  This means
xfs_rmap_finish_one_cleanup is just doing a xfs_btree_del_cursor.

Open code that and move xfs_rmap_finish_one_cleanup to
fs/xfs/xfs_rmap_item.c.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[djwong: minor porting changes]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: reuse xfs_rmap_update_cancel_item
Christoph Hellwig [Wed, 3 Jul 2024 21:21:40 +0000 (14:21 -0700)]
xfs: reuse xfs_rmap_update_cancel_item

Reuse xfs_rmap_update_cancel_item to put the AG/RTG and free the item in
a few places that currently open code the logic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: add a ri_entry helper
Christoph Hellwig [Wed, 3 Jul 2024 21:21:40 +0000 (14:21 -0700)]
xfs: add a ri_entry helper

Add a helper to translate from the item list head to the
rmap_intent_item structure and use it so shorten assignments
and avoid the need for extra local variables.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: clean up rmap log intent item tracepoint callsites
Darrick J. Wong [Wed, 3 Jul 2024 21:21:40 +0000 (14:21 -0700)]
xfs: clean up rmap log intent item tracepoint callsites

Pass the incore rmap structure to the tracepoints instead of open-coding
the argument passing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: prepare rmap btree tracepoints for widening
Darrick J. Wong [Wed, 3 Jul 2024 21:21:39 +0000 (14:21 -0700)]
xfs: prepare rmap btree tracepoints for widening

Prepare the rmap btree tracepoints for use with realtime rmap btrees by
making them take the btree cursor object as a parameter.  This will save
us a lot of trouble later on.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: give rmap btree cursor error tracepoints their own class
Darrick J. Wong [Wed, 3 Jul 2024 21:21:39 +0000 (14:21 -0700)]
xfs: give rmap btree cursor error tracepoints their own class

Create a new tracepoint class for btree-related errors, then convert all
the rmap tracepoints to use it.  Also fix the one tracepoint that was
abusing the old class by making it a separate tracepoint.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: move xfs_extent_free_defer_add to xfs_extfree_item.c
Darrick J. Wong [Wed, 3 Jul 2024 21:21:39 +0000 (14:21 -0700)]
xfs: move xfs_extent_free_defer_add to xfs_extfree_item.c

Move the code that adds the incore xfs_extent_free_item deferred work
data to a transaction live with the EFI log item code.  This means that
the allocator code no longer has to know about the inner workings of the
EFI log items.

As a consequence, we can get rid of the _{get,put}_group helpers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: remove xfs_defer_agfl_block
Christoph Hellwig [Wed, 3 Jul 2024 21:21:39 +0000 (14:21 -0700)]
xfs: remove xfs_defer_agfl_block

xfs_free_extent_later can handle the extra AGFL special casing with
very little extra logic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: remove duplicate asserts in xfs_defer_extent_free
Christoph Hellwig [Wed, 3 Jul 2024 21:21:39 +0000 (14:21 -0700)]
xfs: remove duplicate asserts in xfs_defer_extent_free

The bno/len verification is already done by the calls to
xfs_verify_rtbext / xfs_verify_fsbext, and reporting a corruption error
seem like the better handling than tripping an assert anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: reuse xfs_extent_free_cancel_item
Christoph Hellwig [Wed, 3 Jul 2024 21:21:38 +0000 (14:21 -0700)]
xfs: reuse xfs_extent_free_cancel_item

Reuse xfs_extent_free_cancel_item to put the AG/RTG and free the item in
a few places that currently open code the logic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: add a xefi_entry helper
Christoph Hellwig [Wed, 3 Jul 2024 21:21:38 +0000 (14:21 -0700)]
xfs: add a xefi_entry helper

Add a helper to translate from the item list head to the
xfs_extent_free_item structure and use it so shorten assignments
and avoid the need for extra local variables.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: pass the fsbno to xfs_perag_intent_get
Christoph Hellwig [Wed, 3 Jul 2024 21:21:38 +0000 (14:21 -0700)]
xfs: pass the fsbno to xfs_perag_intent_get

All callers of xfs_perag_intent_get have a fsbno and need boilerplate
code to turn that into an agno.  Just pass the fsbno to
xfs_perag_intent_get and look up the agno there.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: convert "skip_discard" to a proper flags bitset
Darrick J. Wong [Wed, 3 Jul 2024 21:21:38 +0000 (14:21 -0700)]
xfs: convert "skip_discard" to a proper flags bitset

Convert the boolean to skip discard on free into a proper flags field so
that we can add more flags in the next patch.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
10 months agoxfs: clean up extent free log intent item tracepoint callsites
Darrick J. Wong [Wed, 3 Jul 2024 21:21:38 +0000 (14:21 -0700)]
xfs: clean up extent free log intent item tracepoint callsites

Pass the incore EFI structure to the tracepoints instead of open-coding
the argument passing.  This cleans up the call sites a bit.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>