summaryrefslogtreecommitdiff
path: root/fs/xfs/scrub
AgeCommit message (Collapse)Author
2021-12-15xfs: convert symlink repair to use swapextrepair-symlink-swapext_2021-12-15Darrick J. Wong
Convert the symlink repair code to use extent swapping. This means we can eliminate the problem of symlinks with crosslinked blocks. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: merge the two symlink inode_operationsDarrick J. Wong
It's really awkward that we maintain two separate VFS inode operations structures and functions for handling symlinks, because that means online repair potentially has to switch iops after fixing a symlink. Merge them into one to obviate the need for this. Furthermore, this fixes the issue of the VFS readlink functions retaining a pointer to if_data after the inode has been recycled; protects XFS against the VFS altering the contents of internal metadata buffers (if_data); and shuts down complaints about us accessing the inode data fork without taking any locks. In the past, we've skirted these issues because symlink targets are basically immutable, but this won't be the case with online repair. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: move remote symlink target read function to libxfsDarrick J. Wong
Move xfs_readlink_bmap_ilocked to xfs_symlink_remote.c so that the swapext code can use it to convert a remote format symlink back to shortform format after a metadata repair. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: move xfs_symlink_remote.c declarations to xfs_symlink_remote.hDarrick J. Wong
Move declarations for libxfs symlink functions into a separate header file like we do for most everything else. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: don't freeze fs for rmap repairsrepair-rmap-live_2021-12-15Darrick J. Wong
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: hook live realtime rmap operations during a repair operationDarrick J. Wong
Hook the regular realtime rmap code when an rtrmapbt repair operation is running so that we can unlock the AGF buffer to scan the filesystem and keep the in-memory btree up to date during the scan. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: hook live rmap operations during a repair operationDarrick J. Wong
Hook the regular rmap code when an rmapbt repair operation is running so that we can unlock the AGF buffer to scan the filesystem and keep the in-memory btree up to date during the scan. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: create a shadow rmap btree during realtime rmap repairDarrick J. Wong
Create an in-memory btree of rmap records instead of an array. This enables us to do live record collection instead of freezing the fs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: create a shadow rmap btree during rmap repairDarrick J. Wong
Create an in-memory btree of rmap records instead of an array. This enables us to do live record collection instead of freezing the fs. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: connect in-memory btrees to xfilesDarrick J. Wong
Add to our stubbed-out in-memory btrees the ability to connect them with an actual in-memory backing file (aka xfiles) and the necessary pieces to track free space in the xfile and flush dirty xfbtree buffers on demand, which we'll need for online repair. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: support in-memory btreesDarrick J. Wong
Adapt the generic btree cursor code to be able to create a btree whose buffers come from a (presumably in-memory) buftarg with a header block that's specific to in-memory btrees. We'll connect this to other parts of online scrub in the next patches. Note that in-memory btrees always have a block size matching the system memory page size for efficiency reasons. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: support in-memory buffer cache targetsDarrick J. Wong
Allow the buffer cache to target in-memory files by connecting it to xfiles. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: dump xfiles for debugging purposesDarrick J. Wong
Add a debug function to dump an xfile's contents for debug purposes. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: allow userspace to rebuild metadata structuresdefrag-freespace_2021-12-15Darrick J. Wong
Add a new (superuser-only) flag to the online metadata repair ioctl to force it to rebuild structures, even if they're not broken. We will use this to move metadata structures out of the way during a free space defragmentation operation. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: allow queued AG intents to drain before scrubbingscrub-drain-intents_2021-12-15Darrick J. Wong
Currently, online scrub isn't sufficiently careful about quiescing allocation groups before checking them. While scrub does take the AG header locks, it doesn't serialize against chains of AG update intents that are being processed concurrently. If there's a collision, cross-referencing between data structures (e.g. rmapbt and refcountbt) can yield false corruption events; if repair is running, this results in incorrect repairs. Fix this by adding to the perag structure the count of active intents and make scrub wait until there aren't any to continue. This is a little stupid since transactions can queue intents without taking buffer locks, but we'll also wait for those transactions. XXX: should have instead a per-ag rwsem that gets taken as soon as the AG[IF] are locked and stays held until the transaction commits or moves on to the next AG? would we rather have a six lock so that intents can take an ix lock, and not have to upgrade to x until we actually want to make changes to that ag? is that how those even work?? Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: move files to orphanage instead of letting nlinks drop to zeroDarrick J. Wong
If we encounter an inode with a nonzero link count but zero observed links, move it to the orphanage. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: teach repair to fix file nlinksscrub-nlinks_2021-12-15Darrick J. Wong
Fix the nlinks now too. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: teach scrub to check file nlinksDarrick J. Wong
Copy-pasta the online quotacheck code to check inode link counts too. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: experiment with dontcache when scanning inodesvectorized-scrub_2021-12-15Darrick J. Wong
Add some experimental flags to drop inodes from the cache after a scan. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: introduce vectored scrub modeDarrick J. Wong
Introduce a variant on XFS_SCRUB_METADATA that allows for vectored mode. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: whine to dmesg when we encounter errorsDarrick J. Wong
Forward everything scrub whines about to dmesg. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: repair inodes that have a refcount btree in the data forkDarrick J. Wong
Plumb knowledge of refcount btrees into the inode core repair code. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: online repair of the realtime refcount btreeDarrick J. Wong
Port the data device's refcount btree repair code to the realtime refcount btree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: capture realtime CoW staging extents when rebuilding rt rmapbtDarrick J. Wong
Walk the realtime refcount btree to find the CoW staging extents when we're rebuilding the realtime rmap btree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: walk the rt reference count tree when rebuilding rmapDarrick J. Wong
When we're rebuilding the data device rmap, if we encounter a "refcount" format fork, we have to walk the (realtime) refcount btree inode to build the appropriate mappings. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: check new rtbitmap records against rt refcount btreeDarrick J. Wong
When we're rebuilding the realtime bitmap, check the proposed free extents against the rt refcount btree to make sure we don't commit any grievous errors. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: detect and repair misaligned rtinherit directory cowextsize hintsDarrick J. Wong
If we encounter a directory that has been configured to pass on a CoW extent size hint to a new realtime file and the hint isn't an integer multiple of the rt extent size, we should flag the hint for administrative review and/or turn it off because that is a misconfiguration. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: allow dquot rt block count to exceed rt blocks on reflink fsDarrick J. Wong
Update the quota scrubber to allow dquots where the realtime block count exceeds the block count of the rt volume if reflink is enabled. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: check reference counts of gaps between rt refcount recordsDarrick J. Wong
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: cross-reference chceks with the rt refcount btreeDarrick J. Wong
Use the realtime refcount btree to cross-reference other data structures. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: scrub the realtime refcount btreeDarrick J. Wong
Add code to scrub realtime refcount btrees. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: allow inodes to have the realtime and reflink flagsDarrick J. Wong
Now that we can share blocks between realtime files, allow this combination. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: prepare refcount functions to deal with rtrefcountbtDarrick J. Wong
Prepare the high-level refcount functions to deal with the new realtime refcountbt and its slightly different conventions. Provide the ability to talk to either refcountbt or rtrefcountbt formats from the same high level code. Note that we leave the _recover_cow_leftovers functions for a separate patch so that we can convert it all at once. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: introduce realtime refcount btree definitionsDarrick J. Wong
Add new realtime refcount btree definitions. The realtime refcount btree will be rooted from a hidden inode, but has its own shape and therefore needs to have most of its own separate types. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: widen xfs_refcount_irec fields to handle realtime refcountbtDarrick J. Wong
Change the startblock and blockcount fields of xfs_refcount_irec to be 64 bits wide. This enables us to use the same high level refcount code for either tree. We'll also collect all the resulting breakage fixes here. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: create a noalloc mode for allocation groupsDarrick J. Wong
Create a new noalloc state for the per-AG structure that will disable block allocation in this AG. We accomplish this by subtracting from fdblocks all the free blocks in this AG, hiding those blocks from the allocator, and preventing freed blocks from updating fdblocks until we're ready to lift noalloc mode. Note that we reduce the free block count of the filesystem so that we can prevent transactions from entering the allocator looking for "free" space that we've turned off incore. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: online repair of the realtime rmap btreeDarrick J. Wong
Repair the realtime rmap btree while mounted. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: online repair of realtime bitmapsDarrick J. Wong
Rebuild the realtime bitmap from the realtime rmap btree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: repair inodes that have realtime extentsDarrick J. Wong
Plumb into the inode core repair code the ability to search for extents on realtime devices. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: online repair of realtime file bmapsDarrick J. Wong
Repair the block mappings of realtime files. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: walk the rt reverse mapping tree when rebuilding rmapDarrick J. Wong
When we're rebuilding the data device rmap, if we encounter an "rmap" format fork, we have to walk the (realtime) rmap btree inode to build the appropriate mappings. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: scan rt rmap when we're doing an intense rmap checkDarrick J. Wong
Teach the bmbt scrubber how to perform a comprehensive check that the rmapbt does not contain /any/ mappings that are not described by bmbt records when it's dealing with a realtime file. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: cross-reference the realtime rmapbtDarrick J. Wong
Teach the data fork and realtime bitmap scrubbers to cross-reference information with the realtime rmap btree. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: cross-reference realtime bitmap to realtime rmapbt scrubberDarrick J. Wong
When we're checking the realtime rmap btree entries, cross-reference those entries with the realtime bitmap too. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: scrub the realtime rmapbtDarrick J. Wong
Check the realtime reverse mapping btree against the rtbitmap, and modify the rtbitmap scrub to check against the rtrmapbt. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: fix scrub tracepoints when inode-rooted btrees are involvedDarrick J. Wong
Fix a couple of minor mistakes in the scrub tracepoints that can manifest when inode-rooted btrees are enabled. The existing code worked fine for bmap btrees, but we should tighten the code up to be less sloppy. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: add a realtime flag to the rmap update log redo itemsDarrick J. Wong
Extend the rmap update (RUI) log items with a new realtime flag that indicates that the updates apply against the realtime rmapbt. We'll wire up the actual rmap code later. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: introduce realtime rmap btree definitionsDarrick J. Wong
Add new realtime rmap btree definitions. The realtime rmap btree will be rooted from a hidden inode, but has its own shape and therefore needs to have most of its own separate types. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: widen xfs_rmap_irec fields to handle realtime rmapbtDarrick J. Wong
Change the startblock and blockcount fields of xfs_rmap_irec to be 64 bits wide. This enables us to use the same high level rmap code for either tree. We'll also collect all the resulting breakage fixes here. Signed-off-by: Darrick J. Wong <djwong@kernel.org>
2021-12-15xfs: convert "skip_discard" to a proper flags bitsetextfree-intent-cleanups_2021-12-15Darrick J. Wong
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>