]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/log
xfsprogs-dev.git
9 months agoxfs: update realtime super every time we update the primary fs super
Darrick J. Wong [Mon, 25 Nov 2024 21:14:21 +0000 (13:14 -0800)]
xfs: update realtime super every time we update the primary fs super

Source kernel commit: 76d3be00df91a56f7c05142ed500f8f8544d5457

Every time we update parts of the primary filesystem superblock that are
echoed in the rt superblock, we must update the rt super.  Avoid
changing the log to support logging to the rt device by using ordered
buffers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: define the format of rt groups
Darrick J. Wong [Mon, 25 Nov 2024 21:14:21 +0000 (13:14 -0800)]
xfs: define the format of rt groups

Source kernel commit: 96768e91511bfced6e9e537f4891157d909b13ee

Define the ondisk format of realtime group metadata, and a superblock
for realtime volumes.  rt supers are conditionally enabled by a
predicate function so that they can be disabled if we ever implement
zoned storage support for the realtime volume.

For rt group enabled file systems there is a separate bitmap and summary
file for each group and thus the number of bitmap and summary blocks
needs to be calculated differently.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibfrog: add memchr_inv
Darrick J. Wong [Thu, 21 Nov 2024 00:24:27 +0000 (16:24 -0800)]
libfrog: add memchr_inv

Add this kernel function so we can use it in userspace.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
[hch: split from a larger patch]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: make RT extent numbers relative to the rtgroup
Christoph Hellwig [Mon, 25 Nov 2024 21:14:20 +0000 (13:14 -0800)]
xfs: make RT extent numbers relative to the rtgroup

Source kernel commit: f220f6da5f4ad7da538c39075cf57e829d5202f7

To prepare for adding per-rtgroup bitmap files, make the xfs_rtxnum_t
type encode the RT extent number relative to the rtgroup.  The biggest
part of this to clearly distinguish between the relative extent number
that gets masked when converting from a global block number and length
values that just have a factor applied to them when converting from
file system blocks.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: refactor xfs_rtsummary_blockcount
Christoph Hellwig [Mon, 25 Nov 2024 21:14:20 +0000 (13:14 -0800)]
xfs: refactor xfs_rtsummary_blockcount

Source kernel commit: f8c5a8415f6e23fa5b6301635d8b451627efae1c

Make xfs_rtsummary_blockcount take all the required information from
the mount structure and return the number of summary levels from it
as well.  This cleans up many of the callers and prepares for making the
rtsummary files per-rtgroup where they need to look at different value.

This means we recalculate some values in some callers, but as all these
calculations are outside the fast path and cheap, which seems like a
price worth paying.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: refactor xfs_rtbitmap_blockcount
Christoph Hellwig [Mon, 25 Nov 2024 21:14:20 +0000 (13:14 -0800)]
xfs: refactor xfs_rtbitmap_blockcount

Source kernel commit: 5a7566c8d6b9b5c0aac34882f30448d29d9deafc

Rename the existing xfs_rtbitmap_blockcount to
xfs_rtbitmap_blockcount_len and add a new xfs_rtbitmap_blockcount wrapper
around it that takes the number of extents from the mount structure.

This will simplify the move to per-rtgroup bitmaps as those will need to
pass in the number of extents per rtgroup instead.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: support creating per-RTG files in growfs
Christoph Hellwig [Mon, 25 Nov 2024 21:14:20 +0000 (13:14 -0800)]
xfs: support creating per-RTG files in growfs

Source kernel commit: ae897e0bed0f5461a6b1c3259c7d899759ba2a62

To support adding new RT groups in growfs, we need to be able to create
the per-RT group files.  Add a new xfs_rtginode_create helper to create
a given per-RTG file.  Most of the code for that is shared, but the
details of the actual file are abstracted out using a new create method
in struct xfs_rtginode_ops.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: move RT bitmap and summary information to the rtgroup
Christoph Hellwig [Mon, 25 Nov 2024 21:14:20 +0000 (13:14 -0800)]
xfs: move RT bitmap and summary information to the rtgroup

Source kernel commit: e3088ae2dcae3c15d03d7970d4926c8095fd8c7c

Move the pointers to the RT bitmap and summary inodes as well as the
summary cache to the rtgroups structure to prepare for having a
separate bitmap and summary inodes for each rtgroup.

Code using the inodes now needs to operate on a rtgroup.  Where easily
possible such code is converted to iterate over all rtgroups, else
rtgroup 0 (the only one that can currently exist) is hardcoded.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add a xfs_bmap_free_rtblocks helper
Christoph Hellwig [Mon, 25 Nov 2024 21:14:19 +0000 (13:14 -0800)]
xfs: add a xfs_bmap_free_rtblocks helper

Source kernel commit: 9c3cfb9c96eee7f1656ef165e1471e1778510f6f

Split the RT extent freeing logic from xfs_bmap_del_extent_real because
it will become more complicated when adding RT group.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: support caching rtgroup metadata inodes
Darrick J. Wong [Mon, 25 Nov 2024 21:14:19 +0000 (13:14 -0800)]
xfs: support caching rtgroup metadata inodes

Source kernel commit: 65b1231b8cea7fbe7362dceecfda76026d335536

Create the necessary per-rtgroup infrastructure that we need to load
metadata inodes into memory.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add a lockdep class key for rtgroup inodes
Darrick J. Wong [Mon, 25 Nov 2024 21:14:19 +0000 (13:14 -0800)]
xfs: add a lockdep class key for rtgroup inodes

Source kernel commit: c29237a65c8dbfade3c032763b66d495b8e8cb7a

Add a dynamic lockdep class key for rtgroup inodes.  This will enable
lockdep to deduce inconsistencies in the rtgroup metadata ILOCK locking
order.  Each class can have 8 subclasses, and for now we will only have
2 inodes per group.  This enables rtgroup order and inode order checks
when nesting ILOCKs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: define locking primitives for realtime groups
Darrick J. Wong [Mon, 25 Nov 2024 21:14:19 +0000 (13:14 -0800)]
xfs: define locking primitives for realtime groups

Source kernel commit: 0e4875b3fb24c5bfdf685876c76713cda5a23b65

Define helper functions to lock all metadata inodes related to a
realtime group.  There's not much to look at now, but this will become
important when we add per-rtgroup metadata files and online fsck code
for them.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: create incore realtime group structures
Darrick J. Wong [Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)]
xfs: create incore realtime group structures

Source kernel commit: 87fe4c34a383d51ec75f254240bcd08828f4ce5a

Create an incore object that will contain information about a realtime
allocation group.  This will eventually enable us to shard the realtime
section in a similar manner to how we shard the data section, but for
now just a single object for the entire RT subvolume is created.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agomkfs: add a utility to generate protofiles
Darrick J. Wong [Thu, 21 Nov 2024 00:24:23 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agomkfs: support copying in xattrs
Darrick J. Wong [Thu, 21 Nov 2024 00:24:23 +0000 (16:24 -0800)]
mkfs: support copying in xattrs

Update the protofile code to import extended attributes from the source
files.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agomkfs: support copying in large or sparse files
Darrick J. Wong [Thu, 21 Nov 2024 00:24:23 +0000 (16:24 -0800)]
mkfs: support copying in large or sparse files

Restructure the protofile code to handle sparse files and files that are
larger than the program's address space.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibxfs: resync libxfs_alloc_file_space interface with the kernel
Darrick J. Wong [Thu, 21 Nov 2024 00:24:22 +0000 (16:24 -0800)]
libxfs: resync libxfs_alloc_file_space interface with the kernel

Make the userspace xfs_alloc_file_space behave (more or less) like the
kernel version, at least as far as the interface goes.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agomkfs.xfs: enable metadata directories
Darrick J. Wong [Thu, 21 Nov 2024 00:24:22 +0000 (16:24 -0800)]
mkfs.xfs: enable metadata directories

Enable formatting filesystems with metadata directories.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: refactor generate_rtinfo
Christoph Hellwig [Thu, 21 Nov 2024 00:24:22 +0000 (16:24 -0800)]
xfs_repair: refactor generate_rtinfo

Move the allocation of the computed values into generate_rtinfo, and thus
make the variables holding them private in rt.c, and clean up a few
formatting nits.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
[djwong: move functions to fix build errors]
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: do not count metadata directory files when doing quotacheck
Darrick J. Wong [Thu, 21 Nov 2024 00:24:21 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: truncate and unmark orphaned metadata inodes
Darrick J. Wong [Thu, 21 Nov 2024 00:24:21 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: drop all the metadata directory files during pass 4
Darrick J. Wong [Thu, 21 Nov 2024 00:24:21 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: metadata dirs are never plausible root dirs
Darrick J. Wong [Thu, 21 Nov 2024 00:24:21 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: adjust keep_fsinos to handle metadata directories
Darrick J. Wong [Thu, 21 Nov 2024 00:24:20 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: mark space used by metadata files
Darrick J. Wong [Thu, 21 Nov 2024 00:24:20 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: pass private data pointer to scan_lbtree
Darrick J. Wong [Thu, 21 Nov 2024 00:24:20 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: update incore metadata state whenever we create new files
Darrick J. Wong [Thu, 21 Nov 2024 00:24:20 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: don't let metadata and regular files mix
Darrick J. Wong [Thu, 21 Nov 2024 00:24:20 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: rebuild the metadata directory
Darrick J. Wong [Thu, 21 Nov 2024 00:24:19 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: use libxfs_metafile_iget for quota/rt inodes
Darrick J. Wong [Thu, 21 Nov 2024 00:24:19 +0000 (16:24 -0800)]
xfs_repair: use libxfs_metafile_iget for quota/rt inodes

Use the new iget function for these metadata files so that we can check
types, etc.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: check metadata inode flag
Darrick J. Wong [Thu, 21 Nov 2024 00:24:19 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: refactor grabbing realtime metadata inodes
Darrick J. Wong [Thu, 21 Nov 2024 00:24:19 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: refactor root directory initialization
Darrick J. Wong [Thu, 21 Nov 2024 00:24:18 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: refactor marking of metadata inodes
Darrick J. Wong [Thu, 21 Nov 2024 00:24:18 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: refactor fixing dotdot
Darrick J. Wong [Thu, 21 Nov 2024 00:24:18 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: dont check metadata directory dirent inumbers
Darrick J. Wong [Thu, 21 Nov 2024 00:24:18 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_repair: handle sb_metadirino correctly when zeroing supers
Darrick J. Wong [Thu, 21 Nov 2024 00:24:17 +0000 (16:24 -0800)]
xfs_repair: handle sb_metadirino correctly 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_scrub: re-run metafile scrubbers during phase 5
Darrick J. Wong [Thu, 21 Nov 2024 00:24:17 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_scrub: scan metadata directories during phase 3
Darrick J. Wong [Thu, 21 Nov 2024 00:24:17 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_scrub: tread zero-length read verify as an IO error
Darrick J. Wong [Thu, 21 Nov 2024 00:24:17 +0000 (16:24 -0800)]
xfs_scrub: tread zero-length read verify as an IO error

While doing some chaos testing on the xfs_scrub read verify code, I
noticed that if the device under a live filesystem gets resized while
scrub is running a media scan, reads will start returning 0.  This
causes read_verify() to run around in an infinite loop instead of
erroring out like it should.

Cc: <linux-xfs@vger.kernel.org> # v5.3.0
Fixes: 27464242956fac ("xfs_scrub: fix read verify disk error handling strategy")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_spaceman: report health of metadir inodes too
Darrick J. Wong [Thu, 21 Nov 2024 00:24:17 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_io: support scrubbing metadata directory paths
Darrick J. Wong [Thu, 21 Nov 2024 00:24:16 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_io: support flag for limited bulkstat of the metadata directory
Darrick J. Wong [Thu, 21 Nov 2024 00:24:16 +0000 (16:24 -0800)]
xfs_io: support flag for limited bulkstat of the metadata directory

Support the new XFS_BULK_IREQ_METADIR flag for bulkstat commands.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: drop the metadata checking code from blockget
Darrick J. Wong [Wed, 11 Dec 2024 22:48:33 +0000 (14:48 -0800)]
xfs_db: drop the metadata checking code from blockget

Drop the check subcommand and all the metadata checking code from
xfs_db.  We haven't shipped xfs_check in xfsprogs in a decade and the
last known user (fstests) stopped calling it back in July 2024.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: display di_metatype
Darrick J. Wong [Thu, 21 Nov 2024 00:24:16 +0000 (16:24 -0800)]
xfs_db: display di_metatype

Print the metadata file type if available.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: show the metadata root directory when dumping superblocks
Darrick J. Wong [Thu, 21 Nov 2024 00:24:16 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: support metadata directories in the path command
Darrick J. Wong [Thu, 21 Nov 2024 00:24:15 +0000 (16:24 -0800)]
xfs_db: support metadata directories in the path command

Teach various directory tree debugger commands to traverse the metadata
directory tree by adding a -m switch to select that tree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: don't obfuscate metadata directories and attributes
Darrick J. Wong [Thu, 21 Nov 2024 00:24:15 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: report metadir support for version command
Darrick J. Wong [Thu, 21 Nov 2024 00:24:15 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_db: disable xfs_check when metadir is enabled
Darrick J. Wong [Thu, 21 Nov 2024 00:24:15 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs_io: support scrubbing metadata directory paths
Darrick J. Wong [Thu, 21 Nov 2024 00:24:14 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibfrog: allow METADIR in xfrog_bulkstat_single5
Darrick J. Wong [Thu, 21 Nov 2024 00:24:14 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibfrog: report metadata directories in the geometry report
Darrick J. Wong [Thu, 21 Nov 2024 00:24:14 +0000 (16:24 -0800)]
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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoman: update scrub ioctl documentation for metadir
Darrick J. Wong [Thu, 21 Nov 2024 00:24:14 +0000 (16:24 -0800)]
man: update scrub ioctl documentation for metadir

Update the scrub ioctl manpage to reflect the new metadir path scrubber.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoman2: document metadata directory flag in fsgeom ioctl
Darrick J. Wong [Thu, 21 Nov 2024 00:24:13 +0000 (16:24 -0800)]
man2: document metadata directory flag in fsgeom ioctl

Document the additions to the fsgeometry ioctl for metadata directory
trees.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibxfs: enforce metadata inode flag
Darrick J. Wong [Thu, 21 Nov 2024 00:24:12 +0000 (16:24 -0800)]
libxfs: 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibxfs: load metadata directory root at mount time
Darrick J. Wong [Thu, 21 Nov 2024 00:24:12 +0000 (16:24 -0800)]
libxfs: 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agolibxfs: constify the xfs_inode predicates
Darrick J. Wong [Thu, 21 Nov 2024 00:24:11 +0000 (16:24 -0800)]
libxfs: constify the xfs_inode predicates

Change the xfs_inode predicates to take a const struct xfs_inode pointer
because they do not change the inode.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: check metadata directory file path connectivity
Darrick J. Wong [Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)]
xfs: check metadata directory file path connectivity

Source kernel commit: b3c03efa5972f084e40104307dbe432359279cf2

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.  For example, 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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: record health problems with the metadata directory
Darrick J. Wong [Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)]
xfs: record health problems with the metadata directory

Source kernel commit: be42fc1393d66024eb6415c92f45fab5d1878c3e

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: adjust xfs_bmap_add_attrfork for metadir
Darrick J. Wong [Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)]
xfs: adjust xfs_bmap_add_attrfork for metadir

Source kernel commit: 61b6bdb30a4bee1f3417081aedfe9e346538f897

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.  Adjust the assertions appropriately.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: allow bulkstat to return metadata directories
Darrick J. Wong [Mon, 25 Nov 2024 21:14:18 +0000 (13:14 -0800)]
xfs: allow bulkstat to return metadata directories

Source kernel commit: df866c538ff098baa210b407b822818a415a6e7e

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: advertise metadata directory feature
Darrick J. Wong [Mon, 25 Nov 2024 21:14:17 +0000 (13:14 -0800)]
xfs: advertise metadata directory feature

Source kernel commit: 688828d8f8cdf8b1b917de938a1ce86a93fdbba9

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: disable the agi rotor for metadata inodes
Darrick J. Wong [Mon, 25 Nov 2024 21:14:17 +0000 (13:14 -0800)]
xfs: disable the agi rotor for metadata inodes

Source kernel commit: 8651b410ae781cc607159c51dbb0b317b23543b1

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: read and write metadata inode directory tree
Darrick J. Wong [Mon, 25 Nov 2024 21:14:17 +0000 (13:14 -0800)]
xfs: read and write metadata inode directory tree

Source kernel commit e0f091c40bf1287a122dcddd8aa4e6ad06ce441f

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: enforce metadata inode flag
Darrick J. Wong [Mon, 25 Nov 2024 21:14:17 +0000 (13:14 -0800)]
xfs: enforce metadata inode flag

Source kernel commit: 7297fd0bebbd70efd12f72632a0f3ac49a8f59fe

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: iget for metadata inodes
Darrick J. Wong [Mon, 25 Nov 2024 21:14:17 +0000 (13:14 -0800)]
xfs: iget for metadata inodes

Source kernel commit df2e495bb92c84a401b6b90c835a9d1be84a3a0f

Create a xfs_trans_metafile_iget function for metadata inodes to ensure
that when we try to iget a metadata file, the inode is allocated and its
file mode matches the metadata file type the caller expects.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: define the on-disk format for the metadir feature
Darrick J. Wong [Mon, 25 Nov 2024 21:14:16 +0000 (13:14 -0800)]
xfs: define the on-disk format for the metadir feature

Source kernel commit: 4f3d4dd1b04b2ba0bf236fbaa3c3c0c669aa5a47

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: rename metadata inode predicates
Darrick J. Wong [Mon, 25 Nov 2024 21:14:16 +0000 (13:14 -0800)]
xfs: rename metadata inode predicates

Source kernel commit: 4d272929a5258074328dae206c935634e0fd1a54

The predicate xfs_internal_inum tells us if an inumber refers to one of
the inodes rooted in the superblock.  Soon we're going to have internal
inodes in a metadata directory tree, so this helper should be renamed
to capture its limited scope.

Ondisk inodes will soon have a flag to indicate that they're metadata
inodes.  Head off some confusion by renaming the xfs_is_metadata_inode
predicate to xfs_is_internal_inode.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: constify the xfs_sb predicates
Darrick J. Wong [Mon, 25 Nov 2024 21:14:16 +0000 (13:14 -0800)]
xfs: constify the xfs_sb predicates

Source kernel commit: 8d939f4bd7b225d8b157b1329881d2719c0ecb29

Change the xfs_sb predicates to take a const struct xfs_sb pointer
because they do not change the superblock.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: store a generic group structure in the intents
Christoph Hellwig [Mon, 25 Nov 2024 21:14:16 +0000 (13:14 -0800)]
xfs: store a generic group structure in the intents

Source kernel commit: e5e5cae05b71aa5b5e291c0e74b4e4d98a0b05d4

Replace the pag pointers in the extent free, bmap, rmap and refcount
intent structures with a pointer to the generic group to prepare
for adding intents for realtime groups.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add group based bno conversion helpers
Christoph Hellwig [Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)]
xfs: add group based bno conversion helpers

Source kernel commit: 759cc1989a53024066b0f2ea52c206b4ff8f522c

Add/move the blocks, blklog and blkmask fields to the generic groups
structure so that code can work with AGs and RTGs by just using the
right index into the array.

Then, add convenience helpers to convert block numbers based on the
generic group.  This will allow writing code that doesn't care if it is
used on AGs or the upcoming realtime groups.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add a generic group pointer to the btree cursor
Christoph Hellwig [Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)]
xfs: add a generic group pointer to the btree cursor

Source kernel commit: 77a530e6c49d22bd4a221d2f059db24fc30094db

Replace the pag pointers in the type specific union with a generic
xfs_group pointer.  This prepares for adding realtime group support.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: convert busy extent tracking to the generic group structure
Christoph Hellwig [Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)]
xfs: convert busy extent tracking to the generic group structure

Source kernel commit: adbc76aa0fedcb6da2d1ceb1ce786d1f963afee8

Split busy extent tracking from struct xfs_perag into its own private
structure, which can be pointed to by the generic group structure.

Note that this structure is now dynamically allocated instead of embedded
as the upcoming zone XFS code doesn't need it and will also have an
unusually high number of groups due to hardware constraints.  Dynamically
allocating the structure this is a big memory saver for this case.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: move the online repair rmap hooks to the generic group structure
Christoph Hellwig [Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)]
xfs: move the online repair rmap hooks to the generic group structure

Source kernel commit: eb4a84a3c2bd09efe770fa940fb68e349f90c8c6

Prepare for the upcoming realtime groups feature by moving the online
repair rmap hooks to based to the generic xfs_group structure.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: move draining of deferred operations to the generic group structure
Christoph Hellwig [Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)]
xfs: move draining of deferred operations to the generic group structure

Source kernel commit: 34cf3a6f3952ecabd54b4fe3d431aa44ce98fe45

Prepare supporting the upcoming realtime groups feature by moving the
deferred operation draining to the generic xfs_group structure.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: move metadata health tracking to the generic group structure
Christoph Hellwig [Mon, 25 Nov 2024 21:14:14 +0000 (13:14 -0800)]
xfs: move metadata health tracking to the generic group structure

Source kernel commit: 5c8483cec3fe261a5c1ede7430bab042ed156361

Prepare for also tracking the health status of the upcoming realtime
groups by moving the health tracking code to the generic xfs_group
structure.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: switch perag iteration from the for_each macros to a while based iterator
Christoph Hellwig [Mon, 25 Nov 2024 21:14:14 +0000 (13:14 -0800)]
xfs: switch perag iteration from the for_each macros to a while based iterator

Source kernel commit: 86437e6abbd2ef040f42ef190264819db6118415

The current for_each_perag* macros are a bit annoying in that they
require the caller to both provide an object and an index iterator, and
also somewhat obsfucate the underlying control flow mechanism.

Switch to open coded while loops using new xfs_perag_next{,_from,_range}
helpers that return the next pag structure to iterate on based on the
previous one or NULL for the loop start.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add a xfs_group_next_range helper
Christoph Hellwig [Mon, 25 Nov 2024 21:14:14 +0000 (13:14 -0800)]
xfs: add a xfs_group_next_range helper

Source kernel commit: 819928770bd91960f88f5a4dfa21b35a1bade61b

Add a helper to iterate over iterate over all groups, which can be used
as a simple while loop:

struct xfs_group                *xg = NULL;

while ((xg = xfs_group_next_range(mp, xg, 0, MAX_GROUP))) {
...
}

This will be wrapped by the realtime group code first, and eventually
replace the for_each_rtgroup_from and for_each_rtgroup_range helpers.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: factor out a generic xfs_group structure
Christoph Hellwig [Mon, 25 Nov 2024 21:14:14 +0000 (13:14 -0800)]
xfs: factor out a generic xfs_group structure

Source kernel commit: e9c4d8bfb26c13c41b73fdf4183d3df2d392101e

Split the lookup and refcount handling of struct xfs_perag into an
embedded xfs_group structure that can be reused for the upcoming
realtime groups.

It will be extended with more features later.

Note that he xg_type field will only need a single bit even with
realtime group support.  For now it fills a hole, but it might be
worth to fold it into another field if we can use this space better.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: insert the pag structures into the xarray later
Christoph Hellwig [Mon, 25 Nov 2024 21:14:13 +0000 (13:14 -0800)]
xfs: insert the pag structures into the xarray later

Source kernel commit: d66496578b2a099ea453f56782f1cd2bf63a8029

Cleaning up is much easier if a structure can't be looked up yet, so only
insert the pag once it is fully set up.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: split xfs_initialize_perag
Christoph Hellwig [Mon, 25 Nov 2024 21:14:13 +0000 (13:14 -0800)]
xfs: split xfs_initialize_perag

Source kernel commit: 201c5fa342af75adaf762fd6c63380bb8001762d

Factor out a xfs_perag_alloc helper that allocates a single perag
structure.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: convert remaining trace points to pass pag structures
Christoph Hellwig [Mon, 25 Nov 2024 21:14:13 +0000 (13:14 -0800)]
xfs: convert remaining trace points to pass pag structures

Source kernel commit: c4ae021bcb6bf8bbb329ce8ef947a43009bc2fe4

Convert all tracepoints that take [mp,agno] tuples to take a pag argument
instead so that decoding only happens when tracepoints are enabled and to
clean up the callers.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: pass objects to the xfs_irec_merge_{pre,post} trace points
Christoph Hellwig [Mon, 25 Nov 2024 21:14:13 +0000 (13:14 -0800)]
xfs: pass objects to the xfs_irec_merge_{pre,post} trace points

Source kernel commit: 487092ceaa72448ca3a82ea9fb89768c88f6abec

Pass the perag structure and the irec to these tracepoints so that the
decoding is only done when tracing is actually enabled and the call sites
look a lot neater.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: pass a perag structure to the xfs_ag_resv_init_error trace point
Christoph Hellwig [Mon, 25 Nov 2024 21:14:13 +0000 (13:14 -0800)]
xfs: pass a perag structure to the xfs_ag_resv_init_error trace point

Source kernel commit: 835ddb592fab75ed96828ee3f12ea44496882d6b

And remove the single instance class indirection for it.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: pass a pag to xfs_extent_busy_{search,reuse}
Christoph Hellwig [Mon, 25 Nov 2024 21:14:12 +0000 (13:14 -0800)]
xfs: pass a pag to xfs_extent_busy_{search,reuse}

Source kernel commit: b6dc8c6dd2d3f230e1a554f869d6df4568a2dfbb

Replace the [mp,agno] tuple with the perag structure, which will become
more useful later.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add a xfs_agino_to_ino helper
Christoph Hellwig [Mon, 25 Nov 2024 21:14:12 +0000 (13:14 -0800)]
xfs: add a xfs_agino_to_ino helper

Source kernel commit: 6abd82ab6ea48430c13caebaad436ca6b5f2c34d

Add a helpers to convert an agino to an ino based on a pag structure.

This provides a simpler conversion and better type safety compared to the
existing code that passes the mount structure and the agno separately.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: add xfs_agbno_to_fsb and xfs_agbno_to_daddr helpers
Christoph Hellwig [Mon, 25 Nov 2024 21:14:12 +0000 (13:14 -0800)]
xfs: add xfs_agbno_to_fsb and xfs_agbno_to_daddr helpers

Source kernel commit: 856a920ac2bbb2352ef6aa9e1e052f2e80677df7

Add helpers to convert an agbno to a daddr or fsbno based on a pag
structure.

This provides a simpler conversion and better type safety compared to the
existing code that passes the mount structure and the agno separately.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: remove the agno argument to xfs_free_ag_extent
Christoph Hellwig [Mon, 25 Nov 2024 21:14:12 +0000 (13:14 -0800)]
xfs: remove the agno argument to xfs_free_ag_extent

Source kernel commit: db129fa01113f767d5b7a6fd339114a962023464

xfs_free_ag_extent already has a pointer to the pag structure through
the agf buffer.  Use that instead of passing the redundant argument,
and do the same for the tracepoint.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: pass a pag to xfs_difree_inode_chunk
Christoph Hellwig [Mon, 25 Nov 2024 21:14:11 +0000 (13:14 -0800)]
xfs: pass a pag to xfs_difree_inode_chunk

Source kernel commit: 67ce5ba575354da1542e0579fb8c7a871cbf57b3

We'll want to use more than just the agno field in a bit.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: remove the unused pag_active_wq field in struct xfs_perag
Christoph Hellwig [Mon, 25 Nov 2024 21:14:11 +0000 (13:14 -0800)]
xfs: remove the unused pag_active_wq field in struct xfs_perag

Source kernel commit: 9943b45732905a70496fc44368ab85b230c70db4

pag_active_wq is only woken, but never waited for.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: remove the unused pagb_count field in struct xfs_perag
Christoph Hellwig [Mon, 25 Nov 2024 21:14:11 +0000 (13:14 -0800)]
xfs: remove the unused pagb_count field in struct xfs_perag

Source kernel commit: 4e071d79e477189a6c318f598634799e50921994

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: sb_spino_align is not verified
Dave Chinner [Mon, 25 Nov 2024 21:14:11 +0000 (13:14 -0800)]
xfs: sb_spino_align is not verified

Source kernel commit: 59e43f5479cce106d71c0b91a297c7ad1913176c

It's just read in from the superblock and used without doing any
validity checks at all on the value.

Fixes: fb4f2b4e5a82 ("xfs: add sparse inode chunk alignment superblock field")
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfs: remove the redundant xfs_alloc_log_agf
Long Li [Mon, 25 Nov 2024 21:14:11 +0000 (13:14 -0800)]
xfs: remove the redundant xfs_alloc_log_agf

Source kernel commit: 8b9b261594d8ef218ef4d0e732dad153f82aab49

There are two invocations of xfs_alloc_log_agf in xfs_alloc_put_freelist.
The AGF does not change between the two calls. Although this does not pose
any practical problems, it seems like a small mistake. Therefore, fix it
by removing the first xfs_alloc_log_agf invocation.

Signed-off-by: Long Li <leo.lilong@huawei.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoman: document the -n parent mkfs option
Darrick J. Wong [Wed, 27 Nov 2024 22:13:50 +0000 (14:13 -0800)]
man: document the -n parent mkfs option

Document the -n parent option to mkfs.xfs so that users will actually
know how to turn on directory parent pointers.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoman: fix ioctl_xfs_commit_range man page install
Jan Palus [Thu, 5 Dec 2024 20:43:54 +0000 (12:43 -0800)]
man: fix ioctl_xfs_commit_range man page install

INSTALL_MAN uses first symbol in .SH NAME section for both source and
destination filename hence it needs to match current filename. since
ioctl_xfs_commit_range.2 documents both ioctl_xfs_start_commit as well
as ioctl_xfs_commit_range ensure they are listed in order INSTALL_MAN
expects.

Signed-off-by: Jan Palus <jpalus@fastmail.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
9 months agoxfs_repair: fix maximum file offset comparison
Darrick J. Wong [Thu, 21 Nov 2024 00:24:22 +0000 (16:24 -0800)]
xfs_repair: fix maximum file offset comparison

When running generic/525 with rtinherit=1 and rextsize=28k, generic/525
trips over the following block mapping:

data offset 2251799813685247 startblock 7 (0/7) count 1 flag 0
data offset 2251799813685248 startblock 8 (0/8) count 6 flag 1

with this error:

inode 155 - extent exceeds max offset - start 2251799813685248, count 6,
physical block 8

This is due to an incorrect check in xfs_repair, which tries to validate
that a block mapping cannot exceed what it thinks is the maximum file
offset.  Unfortunately, the check is wrong, because only br_startoff is
subject to the 2^52-1 limit -- not br_startoff + br_blockcount.

Nowadays libxfs provides a symbol XFS_MAX_FILEOFF for the maximum
allowable file block offset that can be mapped into a file.  Use this
instead of the open-coded logic in versions.c and correct all the other
checks.  Note that this problem only surfaced when rtgroups were enabled
because hch changed xfs_repair to use the same tree-based block state
data structure that we use for AGs when rtgroups are enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
9 months agoxfsprogs: Release v6.12.0 v6.12.0
Andrey Albershteyn [Mon, 2 Dec 2024 21:40:29 +0000 (22:40 +0100)]
xfsprogs: Release v6.12.0

Update all the necessary files for a v6.12.0 release.

Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
10 months agoxfs_io: add support for atomic write statx fields
Catherine Hoang [Wed, 20 Nov 2024 02:35:44 +0000 (18:35 -0800)]
xfs_io: add support for atomic write statx fields

Add support for the new atomic_write_unit_min, atomic_write_unit_max, and
atomic_write_segments_max fields in statx for xfs_io. In order to support builds
against old kernel headers, define our own internal statx structs. If the
system's struct statx does not have the required atomic write fields, override
the struct definitions with the internal definitions in statx.h.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: John Garry <john.g.garry@oracle.com>
10 months agoxfs_repair: synthesize incore inode tree records when required
Darrick J. Wong [Thu, 14 Nov 2024 23:53:24 +0000 (15:53 -0800)]
xfs_repair: synthesize incore inode tree records when required

On a filesystem with 64k fsblock size, xfs/093 fails with the following:

Phase 3 - for each AG...
        - scan and clear agi unlinked lists...
found inodes not in the inode allocation tree
found inodes not in the inode allocation tree
        - process known inodes and perform inode discovery...
        - agno = 0
xfs_repair: dino_chunks.c:1166: process_aginodes: Assertion `num_inos == igeo->ialloc_inos' failed.
./common/xfs: line 392: 361225 Aborted                 (core dumped) $XFS_REPAIR_PROG $SCRATCH_OPTIONS $* $SCRATCH_DEV

In this situation, the inode size is 512b, which means that two inobt
records map to a single fs block.  However, the inobt walk didn't find
the second record, so it didn't create a second incore ino_tree_node_t
object.  The assertion trips, and we fail to repair the filesystem.

To fix this, synthesize incore inode records when we know that they must
exist.  Mark the inodes as in use so that they will not be purged from
parent directories or moved to lost+found if the directory tree is also
compromised.

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