]> www.infradead.org Git - users/hch/xfsprogs.git/log
users/hch/xfsprogs.git
4 months agolibxfs-apply: drop Cc: to stable release list
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:34 +0000 (15:50 +0100)]
libxfs-apply: drop Cc: to stable release list

These Cc: tags are intended for kernel commits which need to be
backported to stable kernels. Maintainers of stable kernel aren't
interested in xfsprogs syncs.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agorelease.sh: add -f to generate for-next update email
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:33 +0000 (15:50 +0100)]
release.sh: add -f to generate for-next update email

Add --for-next/-f to generate ANNOUNCE email for for-next branch
update. This doesn't require new commit/tarball/tags, so skip it.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agorelease.sh: generate ANNOUNCE email
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:32 +0000 (15:50 +0100)]
release.sh: generate ANNOUNCE email

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agogit-contributors: make revspec required and shebang fix
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:31 +0000 (15:50 +0100)]
git-contributors: make revspec required and shebang fix

Without default value script will show help instead of just hanging
waiting for input on stdin.

Shebang fix for system with different python location than the
/usr/bin one.

Cut leading delimiter from the final CC string.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agogit-contributors: better handling of hash mark/multiple emails
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:30 +0000 (15:50 +0100)]
git-contributors: better handling of hash mark/multiple emails

Better handling of hash mark, tags with multiple emails and not
quoted names in emails. See comments in the script.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agoAdd git-contributors script to notify about merges
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:29 +0000 (15:50 +0100)]
Add git-contributors script to notify about merges

Add python script used to collect emails over all changes merged in
the next release.

CC: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agorelease.sh: update version files make commit optional
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:28 +0000 (15:50 +0100)]
release.sh: update version files make commit optional

Based on ./VERSION script updates all other files. For
./doc/changelog script asks maintainer to fill it manually as not
all changes goes into changelog.

--no-commit|-n flag is handy when something got into the version commit
and need to be changed manually. Then ./release.sh -c will use fixed
history

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agorelease.sh: add --kup to upload release tarball to kernel.org
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:27 +0000 (15:50 +0100)]
release.sh: add --kup to upload release tarball to kernel.org

Add kup support so that the maintainer can push the newly formed
release tarballs to kernel.org.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agorelease.sh: add signing and fix outdated commands
Andrey Albershteyn [Wed, 26 Feb 2025 14:50:26 +0000 (15:50 +0100)]
release.sh: add signing and fix outdated commands

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agoxfsprogs: Fix mismatched return type of filesize()
Pavel Reichl [Fri, 21 Feb 2025 18:57:57 +0000 (19:57 +0100)]
xfsprogs: Fix mismatched return type of filesize()

The function filesize() was declared with a return type of 'long' but
defined with 'off_t'. This mismatch caused build issues due to type
incompatibility.

This commit updates the declaration to match the definition, ensuring
consistency and preventing potential compilation errors.

Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")
Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cem@kernel.org>
Fixes: 73fb78e5ee8 ("mkfs: support copying in large or sparse files")
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
4 months agolibxfs-apply: allow stgit users to force-apply a patch
Darrick J. Wong [Thu, 20 Feb 2025 16:49:33 +0000 (08:49 -0800)]
libxfs-apply: allow stgit users to force-apply a patch

Currently, libxfs-apply handles merge conflicts in the auto-backported
patches in a somewhat unfriendly way -- either it applies completely
cleanly, or the user has to ^Z, find the raw diff file in /tmp, apply it
by hand, resume the process, and then tell it to skip the patch.

This is annoying, and I've long worked around that by using my handy
stg-force-import script that imports the patch with --reject, undoes the
partially-complete diff, uses patch(1) to import as much of the diff as
possible, and then starts an editor so the caller can clean up the rest.

When patches are fuzzy, patch(1) is /much/ less strict about applying
changes than stg-import.  Since Carlos sent in his own workaround for
guilt, I figured I might as well port stg-force-import into libxfs-apply
and contribute that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agolibxfs-apply: fix stgit detection
Andrey Albershteyn [Thu, 20 Feb 2025 17:56:01 +0000 (18:56 +0100)]
libxfs-apply: fix stgit detection

stgit top doesn't seem to return 0 if stack is created for a branch
but no patches applied. The code is 2 as when no 'stgit init' was
run.

Replace top with log which always has at least "initialize" action.

Stacked Git 2.4.12

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agoxfs_io: don't fail FS_IOC_FSGETXATTR on filesystems that lack support
Anthony Iliopoulos [Sat, 22 Feb 2025 15:08:32 +0000 (16:08 +0100)]
xfs_io: don't fail FS_IOC_FSGETXATTR on filesystems that lack support

Not all filesystems implement the FS_IOC_FSGETXATTR ioctl, and in those
cases -ENOTTY will be returned. There is no need to return with an error
when this happens, so just silently return.

Without this fstest generic/169 fails on NFS that doesn't implement the
fileattr_get inode operation.

Fixes: e6b48f451a5d ("xfs_io: allow foreign FSes to show FS_IOC_FSGETXATTR details")
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
4 months agoconfigure: additionally get icu-uc from pkg-config
Alyssa Ross [Fri, 14 Feb 2025 08:45:10 +0000 (09:45 +0100)]
configure: additionally get icu-uc from pkg-config

Upstream libicu changed its pkgconfig files[0] in version 76 to require
callers to call out to each .pc file they need for the libraries they
want to link against.  This apparently reduces overlinking, at a cost of
needing the world to fix themselves up.

This patch fixes the following build error with icu 76, also seen by
Fedora[1]:

    /bin/ld: unicrash.o: undefined reference to symbol 'uiter_setString_76'
    /bin/ld: /lib/libicuuc.so.76: error adding symbols: DSO missing from command line
    collect2: error: ld returned 1 exit status
    make[2]: *** [../include/buildrules:65: xfs_scrub] Error 1
    make[1]: *** [include/buildrules:35: scrub] Error 2

Link: https://github.com/unicode-org/icu/commit/199bc827021ffdb43b6579d68e5eecf54c7f6f56
Link: https://src.fedoraproject.org/rpms/xfsprogs/c/624b0fdf7b2a31c1a34787b04e791eee47c97340
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
4 months agoxfs_scrub: use the display mountpoint for reporting file corruptions
Darrick J. Wong [Mon, 24 Feb 2025 18:22:08 +0000 (10:22 -0800)]
xfs_scrub: use the display mountpoint for reporting file corruptions

In systemd service mode, we make systemd bind-mount the target
mountpoint onto /tmp/scrub (/tmp is private to the service) so that
updates to the global mountpoint in the shared mount namespace don't
propagate into our service container and vice versa, and pass the path
to the bind mount to xfs_scrub via -M.  This solves races such as
unmounting of the target mount point after service container creation
but before process invocation that result in the wrong filesystem being
scanned.

IOWs, to scrub /usr, systemd runs "xfs_scrub -M /tmp/scrub /usr".
Pretend that /usr is a separate filesystem.

However, when xfs_scrub snapshots the handle of /tmp/scrub, libhandle
remembers that /tmp/scrub the beginning of the path, not the pathname
that we want to use for reporting (/usr).  This means that
handle_to_path returns /tmp/scrub and not /usr as well, with the
unfortunate result that file corrupts are reported with the pathnames in
the xfs_scrub@ service container, not the global ones.

Put another way, xfs_scrub should complain that /usr/bin/X is corrupt,
not /tmp/scrub/bin/X.

Therefore, modify scrub_render_ino_descr to manipulate the path buffer
during error reporting so that the user always gets the mountpoint
passed in, even if someone tells us to use another path for the actual
open() call in phase 1.

Cc: <linux-xfs@vger.kernel.org> # v6.10.0
Fixes: 9a8b09762f9a52 ("xfs_scrub: use parent pointers when possible to report file operations")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_scrub: don't warn about zero width joiner control characters
Darrick J. Wong [Mon, 24 Feb 2025 18:22:08 +0000 (10:22 -0800)]
xfs_scrub: don't warn about zero width joiner control characters

The Unicode code point for "zero width joiners" (aka 0x200D) is used to
hint to renderers that a sequence of simple code points should be
combined into a more complex rendering.  This is how compound emoji such
as "wounded heart" are composed out of "heart" and "bandaid"; and how
complex glyphs are rendered in Malayam.

Emoji in filenames are a supported usecase, so stop warning about the
mere existence of ZWJ.  We already warn about ZWJ that are used to
produce confusingly rendered names in a single namespace, so we're not
losing any robustness here.

Cc: <linux-xfs@vger.kernel.org> # v6.10.0
Fixes: d43362c78e3e37 ("xfs_scrub: store bad flags with the name entry")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_scrub: fix buffer overflow in string_escape
Darrick J. Wong [Mon, 24 Feb 2025 18:22:08 +0000 (10:22 -0800)]
xfs_scrub: fix buffer overflow in string_escape

Need to allocate one more byte for the null terminator, just in case the
/entire/ input string consists of non-printable bytes e.g. emoji.

Cc: <linux-xfs@vger.kernel.org> # v4.15.0
Fixes: 396cd0223598bb ("xfs_scrub: warn about suspicious characters in directory/xattr names")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: add command to copy directory trees out of filesystems
Darrick J. Wong [Mon, 24 Feb 2025 18:22:08 +0000 (10:22 -0800)]
xfs_db: add command to copy directory trees out of filesystems

Aheada of deprecating V4 support in the kernel, let's give people a way
to extract their files from a filesystem without needing to mount.  The
libxfs code won't be removed from the kernel until 2030 and xfsprogs
effectively builds with XFS_SUPPORT_V4=y so that'll give us five years
of releases for archaeologists to draw from.  Also, doing this in
userspace gives people a way to recover files in an unprivileged
container for better safety.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: make listdir more generally useful
Darrick J. Wong [Mon, 24 Feb 2025 18:22:07 +0000 (10:22 -0800)]
xfs_db: make listdir more generally useful

Enhance the current directory entry iteration code in xfs_db to be more
generally useful by allowing callers to pass around a transaction, a
callback function, and a private pointer.  This will be used in the next
patch to iterate directories when we want to copy their contents out of
the filesystem into a directory.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agoxfs_db: use an empty transaction to try to prevent livelocks in path_navigate
Darrick J. Wong [Mon, 24 Feb 2025 18:22:07 +0000 (10:22 -0800)]
xfs_db: use an empty transaction to try to prevent livelocks in path_navigate

A couple of patches from now we're going to reuse the path_walk code in
a new xfs_db subcommand that tries to recover directory trees from
old/damaged filesystems.  Let's pass around an empty transaction to try
too avoid livelocks on malicious/broken metadata.  This is not
completely foolproof, but it's quick enough for most purposes.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agoxfs_db: pass const pointers when we're not modifying them
Darrick J. Wong [Mon, 24 Feb 2025 18:22:07 +0000 (10:22 -0800)]
xfs_db: pass const pointers when we're not modifying them

Pass a const pointer to path_walk since we don't actually modify the
contents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andrey Albershteyn <aalbersh@kernel.org>
4 months agomkfs: enable reflink on the realtime device
Darrick J. Wong [Mon, 24 Feb 2025 18:22:07 +0000 (10:22 -0800)]
mkfs: enable reflink on the realtime device

Allow the creation of filesystems with both reflink and realtime volumes
enabled.  For now we don't support a realtime extent size > 1.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agomkfs: validate CoW extent size hint when rtinherit is set
Darrick J. Wong [Mon, 24 Feb 2025 18:22:07 +0000 (10:22 -0800)]
mkfs: validate CoW extent size hint when rtinherit is set

Extent size hints exist to nudge the behavior of the file data block
allocator towards trying to make aligned allocations.  Therefore, it
doesn't make sense to allow a hint that isn't a multiple of the
fundamental allocation unit for a given file.

This means that if the sysadmin is formatting with rtinherit set on the
root dir, validate_cowextsize_hint needs to check the hint value on a
simulated realtime file to make sure that it's correct.  This hasn't
been necessary in the past since one cannot have a CoW hint without a
reflink filesystem, and we previously didn't allow rt reflink
filesystems.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_logprint: report realtime CUIs
Darrick J. Wong [Mon, 24 Feb 2025 18:22:06 +0000 (10:22 -0800)]
xfs_logprint: report realtime CUIs

Decode the CUI format just enough to report if an CUI targets the
realtime device or not.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: validate CoW extent size hint on rtinherit directories
Darrick J. Wong [Mon, 24 Feb 2025 18:22:06 +0000 (10:22 -0800)]
xfs_repair: validate CoW extent size hint on rtinherit directories

XFS allows a sysadmin to change the rt extent size when adding a rt
section to a filesystem after formatting.  If there are any directories
with both a cowextsize hint and rtinherit set, the hint could become
misaligned with the new rextsize.  Offer to fix the problem if we're in
modify mode and the verifier didn't trip.  If we're in dry run mode,
we let the kernel fix it.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: allow realtime files to have the reflink flag set
Darrick J. Wong [Mon, 24 Feb 2025 18:22:06 +0000 (10:22 -0800)]
xfs_repair: allow realtime files to have the reflink flag set

Now that we allow reflink on the realtime volume, allow that combination
of inode flags if the feature's enabled.  Note that we now allow inodes
to have rtinherit even if there's no realtime volume, since the kernel
has never restricted that.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: rebuild the realtime refcount btree
Darrick J. Wong [Mon, 24 Feb 2025 18:22:06 +0000 (10:22 -0800)]
xfs_repair: rebuild the realtime refcount btree

Use the collected reference count information to rebuild the btree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: reject unwritten shared extents
Darrick J. Wong [Mon, 24 Feb 2025 18:22:06 +0000 (10:22 -0800)]
xfs_repair: reject unwritten shared extents

We don't allow sharing of unwritten extents, which means that repair
should reject an unwritten extent if someone else has already claimed
the space.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: check existing realtime refcountbt entries against observed refcounts
Darrick J. Wong [Mon, 24 Feb 2025 18:22:05 +0000 (10:22 -0800)]
xfs_repair: check existing realtime refcountbt entries against observed refcounts

Once we've finished collecting reverse mapping observations from the
metadata scan, check those observations against the realtime refcount
btree (particularly if we're in -n mode) to detect rtrefcountbt
problems.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: compute refcount data for the realtime groups
Darrick J. Wong [Mon, 24 Feb 2025 18:22:05 +0000 (10:22 -0800)]
xfs_repair: compute refcount data for the realtime groups

At the end of phase 4, compute reference count information for realtime
groups from the realtime rmap information collected, just like we do for
AGs in the data section.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: find and mark the rtrefcountbt inode
Darrick J. Wong [Mon, 24 Feb 2025 18:22:05 +0000 (10:22 -0800)]
xfs_repair: find and mark the rtrefcountbt inode

Make sure that we find the realtime refcountbt inode and mark it
appropriately, just in case we find a rogue inode claiming to
be an rtrefcount, or just plain garbage in the superblock field.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: use realtime refcount btree data to check block types
Darrick J. Wong [Mon, 24 Feb 2025 18:22:05 +0000 (10:22 -0800)]
xfs_repair: use realtime refcount btree data to check block types

Use the realtime refcount btree to pre-populate the block type information
so that when repair iterates the primary metadata, we can confirm the
block type.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: allow CoW staging extents in the realtime rmap records
Darrick J. Wong [Mon, 24 Feb 2025 18:22:05 +0000 (10:22 -0800)]
xfs_repair: allow CoW staging extents in the realtime rmap records

Don't flag the rt rmap btree as having errors if there are CoW staging
extent records in it and the filesystem supports reflink.  As far as
reporting leftover staging extents, we'll report them when we scan the
rt refcount btree, in a future patch.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_spaceman: report health of the realtime refcount btree
Darrick J. Wong [Mon, 24 Feb 2025 18:22:04 +0000 (10:22 -0800)]
xfs_spaceman: report health of the realtime refcount btree

Report the health of the realtime reference count btree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: add rtrefcount reservations to the rgresv command
Darrick J. Wong [Mon, 24 Feb 2025 18:22:04 +0000 (10:22 -0800)]
xfs_db: add rtrefcount reservations to the rgresv command

Report rt refcount btree reservations in the rgresv subcommand output.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: copy the realtime refcount btree
Darrick J. Wong [Mon, 24 Feb 2025 18:22:04 +0000 (10:22 -0800)]
xfs_db: copy the realtime refcount btree

Copy the realtime refcountbt when we're metadumping the filesystem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: support the realtime refcountbt
Darrick J. Wong [Mon, 24 Feb 2025 18:22:04 +0000 (10:22 -0800)]
xfs_db: support the realtime refcountbt

Wire up various parts of xfs_db for realtime refcount support so that we
can dump the rt refcount btree contents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: display the realtime refcount btree contents
Darrick J. Wong [Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)]
xfs_db: display the realtime refcount btree contents

Implement all the code we need to dump rtrefcountbt contents, starting
from the inode root.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoman: document userspace API changes due to rt reflink
Darrick J. Wong [Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)]
man: document userspace API changes due to rt reflink

Update documentation to describe userspace ABI changes made for realtime
reflink support.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibfrog: enable scrubbing of the realtime refcount data
Darrick J. Wong [Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)]
libfrog: enable scrubbing of the realtime refcount data

Add a new entry so that we can scrub the rtrefcountbt and its metadata
directory tree path.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibxfs: apply rt extent alignment constraints to CoW extsize hint
Darrick J. Wong [Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)]
libxfs: apply rt extent alignment constraints to CoW extsize hint

The copy-on-write extent size hint is subject to the same alignment
constraints as the regular extent size hint.  Since we're in the process
of adding reflink (and therefore CoW) to the realtime device, we must
apply the same scattered rextsize alignment validation strategies to
both hints to deal with the possibility of rextsize changing.

Therefore, fix the inode validator to perform rextsize alignment checks
on regular realtime files, and to remove misaligned directory hints.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibxfs: add a realtime flag to the refcount update log redo items
Darrick J. Wong [Mon, 24 Feb 2025 18:22:03 +0000 (10:22 -0800)]
libxfs: add a realtime flag to the refcount update log redo items

Extend the refcount update (CUI) log items with a new realtime flag that
indicates that the updates apply against the realtime refcountbt.  We'll
wire up the actual refcount code later.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibxfs: compute the rt refcount btree maxlevels during initialization
Darrick J. Wong [Mon, 24 Feb 2025 18:22:02 +0000 (10:22 -0800)]
libxfs: compute the rt refcount btree maxlevels during initialization

Compute max rt refcount btree height information when we set up libxfs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agomkfs: create the realtime rmap inode
Darrick J. Wong [Mon, 24 Feb 2025 18:22:02 +0000 (10:22 -0800)]
mkfs: create the realtime rmap inode

Create a realtime rmapbt inode if we format the fs with realtime
and rmap.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_logprint: report realtime RUIs
Darrick J. Wong [Mon, 24 Feb 2025 18:22:02 +0000 (10:22 -0800)]
xfs_logprint: report realtime RUIs

Decode the RUI format just enough to report if an RUI targets the
realtime device or not.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: reserve per-AG space while rebuilding rt metadata
Darrick J. Wong [Mon, 24 Feb 2025 18:22:02 +0000 (10:22 -0800)]
xfs_repair: reserve per-AG space while rebuilding rt metadata

Realtime metadata btrees can consume quite a bit of space on a full
filesystem.  Since the metadata are just regular files, we need to
make the per-AG reservations to avoid overfilling any of the AGs while
rebuilding metadata.  This avoids the situation where a filesystem comes
straight from repair and immediately trips over not having enough space
in an AG.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: rebuild the bmap btree for realtime files
Darrick J. Wong [Mon, 24 Feb 2025 18:22:02 +0000 (10:22 -0800)]
xfs_repair: rebuild the bmap btree for realtime files

Use the realtime rmap btree information to rebuild an inode's data fork
when appropriate.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: check for global free space concerns with default btree slack levels
Darrick J. Wong [Mon, 24 Feb 2025 18:22:01 +0000 (10:22 -0800)]
xfs_repair: check for global free space concerns with default btree slack levels

It's possible that before repair was started, the filesystem might have
been nearly full, and its metadata btree blocks could all have been
nearly full.  If we then rebuild the btrees with blocks that are only
75% full, that expansion might be enough to run out of free space.  The
solution to this is to pack the new blocks completely full if we fear
running out of space.

Previously, we only had to check and decide that on a per-AG basis.
However, now that XFS can have filesystems with metadata btrees rooted
in inodes, we have a global free space concern because there might be
enough space in each AG to regenerate the AG btrees at 75%, but that
might not leave enough space to regenerate the inode btrees, even if we
fill those blocks to 100%.

Hence we need to precompute the worst case space usage for all btrees in
the filesystem and compare /that/ against the global free space to
decide if we're going to pack the btrees maximally to conserve space.
That decision can override the per-AG determination.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: rebuild the realtime rmap btree
Darrick J. Wong [Mon, 24 Feb 2025 18:22:01 +0000 (10:22 -0800)]
xfs_repair: rebuild the realtime rmap btree

Rebuild the realtime rmap btree file from the reverse mapping records we
gathered from walking the inodes.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: always check realtime file mappings against incore info
Darrick J. Wong [Mon, 24 Feb 2025 18:22:01 +0000 (10:22 -0800)]
xfs_repair: always check realtime file mappings against incore info

Curiously, the xfs_repair code that processes data fork mappings of
realtime files doesn't actually compare the mappings against the incore
state map during the !check_dups phase (aka phase 3).  As a result, we
lose the opportunity to clear damaged realtime data forks before we get
to crosslinked file checking in phase 4, which results in ondisk
metadata errors calling do_error, which aborts repair.

Split the process_rt_rec_state code into two functions: one to check the
mapping, and another to update the incore state.  The first one can be
called to help us decide if we're going to zap the fork, and the second
one updates the incore state if we decide to keep the fork.  We already
do this for regular data files.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: check existing realtime rmapbt entries against observed rmaps
Darrick J. Wong [Mon, 24 Feb 2025 18:22:01 +0000 (10:22 -0800)]
xfs_repair: check existing realtime rmapbt entries against observed rmaps

Once we've finished collecting reverse mapping observations from the
metadata scan, check those observations against the realtime rmap btree
(particularly if we're in -n mode) to detect rtrmapbt problems.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: find and mark the rtrmapbt inodes
Darrick J. Wong [Mon, 24 Feb 2025 18:22:01 +0000 (10:22 -0800)]
xfs_repair: find and mark the rtrmapbt inodes

Make sure that we find the realtime rmapbt inodes and mark them
appropriately, just in case we find a rogue inode claiming to be an
rtrmap, or garbage in the metadata directory tree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: refactor realtime inode check
Darrick J. Wong [Mon, 24 Feb 2025 18:22:00 +0000 (10:22 -0800)]
xfs_repair: refactor realtime inode check

Refactor the realtime bitmap and summary checks into a helper function.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: create a new set of incore rmap information for rt groups
Darrick J. Wong [Mon, 24 Feb 2025 18:22:00 +0000 (10:22 -0800)]
xfs_repair: create a new set of incore rmap information for rt groups

Create a parallel set of "xfs_ag_rmap" structures to cache information
about reverse mappings for the realtime groups.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: use realtime rmap btree data to check block types
Darrick J. Wong [Mon, 24 Feb 2025 18:22:00 +0000 (10:22 -0800)]
xfs_repair: use realtime rmap btree data to check block types

Use the realtime rmap btree to pre-populate the block type information
so that when repair iterates the primary metadata, we can confirm the
block type.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: flag suspect long-format btree blocks
Darrick J. Wong [Mon, 24 Feb 2025 18:22:00 +0000 (10:22 -0800)]
xfs_repair: flag suspect long-format btree blocks

Pass a "suspect" counter through scan_lbtree just like we do for
short-format btree blocks, and increment its value when we encounter
blocks with bad CRCs or outright corruption.  This makes it so that
repair actually catches bmbt blocks with bad crcs or other verifier
errors.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_repair: tidy up rmap_diffkeys
Darrick J. Wong [Mon, 24 Feb 2025 18:21:59 +0000 (10:21 -0800)]
xfs_repair: tidy up rmap_diffkeys

Tidy up the comparison code in this function to match the kernel.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_spaceman: report health status of the realtime rmap btree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:59 +0000 (10:21 -0800)]
xfs_spaceman: report health status of the realtime rmap btree

Add reporting of the rt rmap btree health to spaceman.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: add an rgresv command
Darrick J. Wong [Mon, 24 Feb 2025 18:21:59 +0000 (10:21 -0800)]
xfs_db: add an rgresv command

Create a command to dump rtgroup btree space reservations.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: make fsmap query the realtime reverse mapping tree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:59 +0000 (10:21 -0800)]
xfs_db: make fsmap query the realtime reverse mapping tree

Extend the 'fsmap' debugger command to support querying the realtime
rmap btree via a new -r argument.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: copy the realtime rmap btree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:58 +0000 (10:21 -0800)]
xfs_db: copy the realtime rmap btree

Copy the realtime rmapbt when we're metadumping the filesystem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: support the realtime rmapbt
Darrick J. Wong [Mon, 24 Feb 2025 18:21:58 +0000 (10:21 -0800)]
xfs_db: support the realtime rmapbt

Wire up various parts of xfs_db for realtime rmap support so that we can
dump the btree contents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: display the realtime rmap btree contents
Darrick J. Wong [Mon, 24 Feb 2025 18:21:58 +0000 (10:21 -0800)]
xfs_db: display the realtime rmap btree contents

Implement all the code we need to dump rtrmapbt contents, starting
from the inode root.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: don't abort when bmapping on a non-extents/bmbt fork
Darrick J. Wong [Mon, 24 Feb 2025 18:21:58 +0000 (10:21 -0800)]
xfs_db: don't abort when bmapping on a non-extents/bmbt fork

We're going to introduce new fork formats, so let's fix the problem that
xfs_db's bmap command aborts when the fork format isn't one of the
existing ones.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs_db: compute average btree height
Darrick J. Wong [Mon, 24 Feb 2025 18:21:58 +0000 (10:21 -0800)]
xfs_db: compute average btree height

Compute the btree height assuming that the blocks are 75% full.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoman: document userspace API changes due to rt rmap
Darrick J. Wong [Mon, 24 Feb 2025 18:21:57 +0000 (10:21 -0800)]
man: document userspace API changes due to rt rmap

Update documentation to describe userspace ABI changes made for realtime
rmap support.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibfrog: enable scrubbing of the realtime rmap
Darrick J. Wong [Mon, 24 Feb 2025 18:21:57 +0000 (10:21 -0800)]
libfrog: enable scrubbing of the realtime rmap

Add a new entry so that we can scrub the rtrmapbt and its metadata
directory tree path too.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibxfs: add a realtime flag to the rmap update log redo items
Darrick J. Wong [Mon, 24 Feb 2025 18:21:57 +0000 (10:21 -0800)]
libxfs: add a realtime flag to the rmap update log redo items

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agolibxfs: compute the rt rmap btree maxlevels during initialization
Darrick J. Wong [Mon, 24 Feb 2025 18:21:57 +0000 (10:21 -0800)]
libxfs: compute the rt rmap btree maxlevels during initialization

Compute max rt rmap btree height information when we set up libxfs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs/libxfs: replace kmalloc() and memcpy() with kmemdup()
Mirsad Todorovac [Mon, 24 Feb 2025 18:21:56 +0000 (10:21 -0800)]
xfs/libxfs: replace kmalloc() and memcpy() with kmemdup()

Source kernel commit: 9d9b72472631262b35157f1a650f066c0e11c2bb

The source static analysis tool gave the following advice:

./fs/xfs/libxfs/xfs_dir2.c:382:15-22: WARNING opportunity for kmemdup

→ 382         args->value = kmalloc(len,
383                          GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL);
384         if (!args->value)
385                 return -ENOMEM;
386
→ 387         memcpy(args->value, name, len);
388         args->valuelen = len;
389         return -EEXIST;

Replacing kmalloc() + memcpy() with kmemdump() doesn't change semantics.
Original code works without fault, so this is not a bug fix but proposed improvement.

Link: https://lwn.net/Articles/198928/
Fixes: 94a69db2367ef ("xfs: use __GFP_NOLOCKDEP instead of GFP_NOFS")
Fixes: 384f3ced07efd ("[XFS] Return case-insensitive match for dentry cache")
Fixes: 2451337dd0439 ("xfs: global error sign conversion")
Cc: Carlos Maiolino <cem@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Chandan Babu R <chandanbabu@kernel.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: linux-xfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
4 months agoxfs: constify feature checks
Christoph Hellwig [Mon, 24 Feb 2025 18:21:56 +0000 (10:21 -0800)]
xfs: constify feature checks

Source kernel commit: 183d988ae9e7ada9d7d4333e2289256e74a5ab5b

They will eventually be needed to be const for zoned growfs, but even
now having such simpler helpers as const as possible is a good thing.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
4 months agoxfs: remove XFS_ILOG_NONCORE
Christoph Hellwig [Mon, 24 Feb 2025 18:21:56 +0000 (10:21 -0800)]
xfs: remove XFS_ILOG_NONCORE

Source kernel commit: 415dee1e06da431f3d314641ceecb9018bb6fa53

XFS_ILOG_NONCORE is not used in the kernel code or xfsprogs, remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
4 months agoxfs: mark xfs_dir_isempty static
Christoph Hellwig [Mon, 24 Feb 2025 18:21:56 +0000 (10:21 -0800)]
xfs: mark xfs_dir_isempty static

Source kernel commit: 23ebf63925989adbe4c4277c8e9b04e0a37f6005

And return bool instead of a boolean condition as int.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
4 months agoxfs: fix the entry condition of exact EOF block allocation optimization
Jinliang Zheng [Mon, 24 Feb 2025 18:21:56 +0000 (10:21 -0800)]
xfs: fix the entry condition of exact EOF block allocation optimization

Source kernel commit: 915175b49f65d9edeb81659e82cbb27b621dbc17

When we call create(), lseek() and write() sequentially, offset != 0
cannot be used as a judgment condition for whether the file already
has extents.

Furthermore, when xfs_bmap_adjacent() has not given a better blkno,
it is not necessary to use exact EOF block allocation.

Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Jinliang Zheng <alexjlzheng@tencent.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
4 months agoxfs: scrub the metadir path of rt refcount btree files
Darrick J. Wong [Mon, 24 Feb 2025 18:21:55 +0000 (10:21 -0800)]
xfs: scrub the metadir path of rt refcount btree files

Source kernel commit: ca757af07fccf527f91ad49f3b6648e6783b0bc8

Add a new XFS_SCRUB_METAPATH subtype so that we can scrub the metadata
directory tree path to the refcount btree file for each rt group.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: scrub the realtime refcount btree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:55 +0000 (10:21 -0800)]
xfs: scrub the realtime refcount btree

Source kernel commit: c27929670de144ec76a0dab2f3a168cb4897b314

Add code to scrub realtime refcount btrees.  Similar to the refcount
btree checking code for the data device, we walk the rmap btree for each
refcount record to confirm that the reference counts are correct.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: report realtime refcount btree corruption errors to the health system
Darrick J. Wong [Mon, 24 Feb 2025 18:21:55 +0000 (10:21 -0800)]
xfs: report realtime refcount btree corruption errors to the health system

Source kernel commit: 026c8ed8d4580228949f177445c605d475880c93

Whenever we encounter corrupt realtime refcount btree blocks, we should
report that to the health monitoring system for later reporting.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: enable extent size hints for CoW operations
Darrick J. Wong [Mon, 24 Feb 2025 18:21:55 +0000 (10:21 -0800)]
xfs: enable extent size hints for CoW operations

Source kernel commit: 8e84e8052bc283ebb37f929eb9fb97483ea7385e

Wire up the copy-on-write extent size hint for realtime files, and
connect it to the rt allocator so that we avoid fragmentation on rt
filesystems.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: apply rt extent alignment constraints to CoW extsize hint
Darrick J. Wong [Mon, 24 Feb 2025 18:21:54 +0000 (10:21 -0800)]
xfs: apply rt extent alignment constraints to CoW extsize hint

Source kernel commit: 4de1a7ba4171db681691bd80506d0cf43c5cb46a

The copy-on-write extent size hint is subject to the same alignment
constraints as the regular extent size hint.  Since we're in the process
of adding reflink (and therefore CoW) to the realtime device, we must
apply the same scattered rextsize alignment validation strategies to
both hints to deal with the possibility of rextsize changing.

Therefore, fix the inode validator to perform rextsize alignment checks
on regular realtime files, and to remove misaligned directory hints.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: fix xfs_get_extsz_hint behavior with realtime alwayscow files
Darrick J. Wong [Mon, 24 Feb 2025 18:21:54 +0000 (10:21 -0800)]
xfs: fix xfs_get_extsz_hint behavior with realtime alwayscow files

Source kernel commit: 6853d23badd0f1852d3b711128924e2456d27634

Currently, we (ab)use xfs_get_extsz_hint so that it always returns a
nonzero value for realtime files.  This apparently was done to disable
delayed allocation for realtime files.

However, once we enable realtime reflink, we can also turn on the
alwayscow flag to force CoW writes to realtime files.  In this case, the
logic will incorrectly send the write through the delalloc write path.

Fix this by adjusting the logic slightly.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: recover CoW leftovers in the realtime volume
Darrick J. Wong [Mon, 24 Feb 2025 18:21:54 +0000 (10:21 -0800)]
xfs: recover CoW leftovers in the realtime volume

Source kernel commit: 51e232674975ff138d0e892272fdde9bc444c572

Scan the realtime refcount tree at mount time to get rid of leftover
CoW staging extents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: allow inodes to have the realtime and reflink flags
Darrick J. Wong [Mon, 24 Feb 2025 18:21:54 +0000 (10:21 -0800)]
xfs: allow inodes to have the realtime and reflink flags

Source kernel commit: c3d3605f9661a2451c437a037d338dc79fb78f37

Now that we can share blocks between realtime files, allow this
combination.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: compute rtrmap btree max levels when reflink enabled
Darrick J. Wong [Mon, 24 Feb 2025 18:21:54 +0000 (10:21 -0800)]
xfs: compute rtrmap btree max levels when reflink enabled

Source kernel commit: c2694ff678c9b667ab4cb7c0b45d45309c4dd64b

Compute the maximum possible height of the realtime rmap btree when
reflink is enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: update rmap to allow cow staging extents in the rt rmap
Darrick J. Wong [Mon, 24 Feb 2025 18:21:53 +0000 (10:21 -0800)]
xfs: update rmap to allow cow staging extents in the rt rmap

Source kernel commit: 0bada82331238bd366aaa0566d125c6338b42590

Don't error out on CoW staging extent records when realtime reflink is
enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: create routine to allocate and initialize a realtime refcount btree inode
Darrick J. Wong [Mon, 24 Feb 2025 18:21:53 +0000 (10:21 -0800)]
xfs: create routine to allocate and initialize a realtime refcount btree inode

Source kernel commit: 4ee3113aaf3f6a3c24fcf952d8489363f56ab375

Create a library routine to allocate and initialize an empty realtime
refcountbt inode.  We'll use this for growfs, mkfs, and repair.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: wire up realtime refcount btree cursors
Darrick J. Wong [Mon, 24 Feb 2025 18:21:53 +0000 (10:21 -0800)]
xfs: wire up realtime refcount btree cursors

Source kernel commit: e5a171729baf61b703069b11fa0d2955890e9b6b

Wire up realtime refcount btree cursors wherever they're needed
throughout the code base.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: wire up a new metafile type for the realtime refcount
Darrick J. Wong [Mon, 24 Feb 2025 18:21:53 +0000 (10:21 -0800)]
xfs: wire up a new metafile type for the realtime refcount

Source kernel commit: f0415af60f482a2192065be8b334b409495ca8a3

Plumb in the pieces we need to embed the root of the realtime refcount
btree in an inode's data fork, complete with metafile type and on-disk
interpretation functions.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: add metadata reservations for realtime refcount btree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:52 +0000 (10:21 -0800)]
xfs: add metadata reservations for realtime refcount btree

Source kernel commit: bf0b99411335db18a9ed4fcef278ce9e313f6076

Reserve some free blocks so that we will always have enough free blocks
in the data volume to handle expansion of the realtime refcount btree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: add realtime refcount btree inode to metadata directory
Darrick J. Wong [Mon, 24 Feb 2025 18:21:52 +0000 (10:21 -0800)]
xfs: add realtime refcount btree inode to metadata directory

Source kernel commit: eaed472c40527e526217aff3737816b44b08b363

Add a metadir path to select the realtime refcount btree inode and load
it at mount time.  The rtrefcountbt inode will have a unique extent format
code, which means that we also have to update the inode validation and
flush routines to look for it.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: add a realtime flag to the refcount update log redo items
Darrick J. Wong [Mon, 24 Feb 2025 18:21:52 +0000 (10:21 -0800)]
xfs: add a realtime flag to the refcount update log redo items

Source kernel commit: fd9300679ccec20c6ee1b95458ab0bcf0db628d5

Extend the refcount update (CUI) log items with a new realtime flag that
indicates that the updates apply against the realtime refcountbt.  We'll
wire up the actual refcount code later.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: prepare refcount functions to deal with rtrefcountbt
Darrick J. Wong [Mon, 24 Feb 2025 18:21:52 +0000 (10:21 -0800)]
xfs: prepare refcount functions to deal with rtrefcountbt

Source kernel commit: 01cef1db246ee8b094fca6df23ea6d4335748181

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: add realtime refcount btree operations
Darrick J. Wong [Mon, 24 Feb 2025 18:21:52 +0000 (10:21 -0800)]
xfs: add realtime refcount btree operations

Source kernel commit: 1a6f88ea538db9b3d8aef86112894e7e6d098287

Implement the generic btree operations needed to manipulate rtrefcount
btree blocks. This is different from the regular refcountbt in that we
allocate space from the filesystem at large, and are neither constrained
to the free space nor any particular AG.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: realtime refcount btree transaction reservations
Darrick J. Wong [Mon, 24 Feb 2025 18:21:51 +0000 (10:21 -0800)]
xfs: realtime refcount btree transaction reservations

Source kernel commit: 2003c6a8754e307970c101a20baf8fb67d0588f2

Make sure that there's enough log reservation to handle mapping
and unmapping realtime extents.  We have to reserve enough space
to handle a split in the rtrefcountbt to add the record and a second
split in the regular refcountbt to record the rtrefcountbt split.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: introduce realtime refcount btree ondisk definitions
Darrick J. Wong [Mon, 24 Feb 2025 18:21:51 +0000 (10:21 -0800)]
xfs: introduce realtime refcount btree ondisk definitions

Source kernel commit: 9abe03a0e4f978615a2b1b484b8d09ca84c16ea0

Add the ondisk structure definitions for realtime refcount btrees. The
realtime refcount btree will be rooted from a hidden inode so it needs
to have a separate btree block magic and pointer format.

Next, add everything needed to read, write and manipulate refcount btree
blocks. This prepares the way for connecting the btree operations
implementation, though the changes to actually root the rtrefcount btree
in an inode come later.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: namespace the maximum length/refcount symbols
Darrick J. Wong [Mon, 24 Feb 2025 18:21:51 +0000 (10:21 -0800)]
xfs: namespace the maximum length/refcount symbols

Source kernel commit: 70fcf6866578e69635399e806273376f5e0b8e2b

Actually namespace these variables properly, so that readers can tell
that this is an XFS symbol, and that it's for the refcount
functionality.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: create a shadow rmap btree during realtime rmap repair
Darrick J. Wong [Mon, 24 Feb 2025 18:21:51 +0000 (10:21 -0800)]
xfs: create a shadow rmap btree during realtime rmap repair

Source kernel commit: 4a61f12eb11958f157e054d386466627445644cd

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: online repair of the realtime rmap btree
Darrick J. Wong [Mon, 24 Feb 2025 18:21:50 +0000 (10:21 -0800)]
xfs: online repair of the realtime rmap btree

Source kernel commit: 6a849bd81b69ccbda5b766cc700f0be86194e4d1

Repair the realtime rmap btree while mounted.  Similar to the regular
rmap btree repair code, we walk the data fork mappings of every realtime
file in the filesystem to collect reverse-mapping records in an xfarray.
Then we sort the xfarray, and use the btree bulk loader to create a new
rtrmap btree ondisk.  Finally, we swap the btree roots, and reap the old
blocks in the usual way.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: online repair of realtime bitmaps for a realtime group
Darrick J. Wong [Mon, 24 Feb 2025 18:21:50 +0000 (10:21 -0800)]
xfs: online repair of realtime bitmaps for a realtime group

Source kernel commit: 8defee8dff2b202702cdf33f6d8577adf9ad3e82

For a given rt group, regenerate the bitmap contents from the group's
realtime rmap btree.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: scrub the metadir path of rt rmap btree files
Darrick J. Wong [Mon, 24 Feb 2025 18:21:50 +0000 (10:21 -0800)]
xfs: scrub the metadir path of rt rmap btree files

Source kernel commit: 366243cc99b7e80236a19d7391b68d0f47677f4f

Add a new XFS_SCRUB_METAPATH subtype so that we can scrub the metadata
directory tree path to the rmap btree file for each rt group.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
4 months agoxfs: scrub the realtime rmapbt
Darrick J. Wong [Mon, 24 Feb 2025 18:21:50 +0000 (10:21 -0800)]
xfs: scrub the realtime rmapbt

Source kernel commit: 9a6cc4f6d081fddc0d5ff96744a2507d3559f949

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>