]> www.infradead.org Git - users/hch/xfstests-dev.git/log
users/hch/xfstests-dev.git
2 weeks agoxfs: test zoned GC file defragmentation for sequential writers
Christoph Hellwig [Sun, 24 Nov 2024 07:10:20 +0000 (08:10 +0100)]
xfs: test zoned GC file defragmentation for sequential writers

Test that zoned GC defragments sequential writers forced into the same
zone.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: test zoned ENOSPC behavior with multiple writers
Christoph Hellwig [Fri, 22 Nov 2024 17:27:23 +0000 (18:27 +0100)]
xfs: test zoned ENOSPC behavior with multiple writers

Test that multiple parallel writers can't accidentally dip into the reserved
space pool.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: test zone stream separation for two buffered writers
Christoph Hellwig [Fri, 22 Nov 2024 17:19:49 +0000 (18:19 +0100)]
xfs: test zone stream separation for two buffered writers

Check that two parallel buffered sequential writers are separated into
different zones when writeback happens before closing the files.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: test zone stream separation for two direct writers
Christoph Hellwig [Fri, 22 Nov 2024 17:03:25 +0000 (18:03 +0100)]
xfs: test zone stream separation for two direct writers

Check that two parallel direct sequential writers are separated into
different zones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add a test for writeback after close
Christoph Hellwig [Fri, 22 Nov 2024 09:18:48 +0000 (10:18 +0100)]
xfs: add a test for writeback after close

Test that files written back after closing are packed tightly instead of
using up open zone resources.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add a test for write lifetime hints
Christoph Hellwig [Fri, 22 Nov 2024 06:47:15 +0000 (07:47 +0100)]
xfs: add a test for write lifetime hints

Test that the zone allocator actually places by temperature bucket.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoadd a new rw_hint helper
Christoph Hellwig [Fri, 22 Nov 2024 07:13:20 +0000 (08:13 +0100)]
add a new rw_hint helper

Add a tool to set the life time hint via fcntl.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add a test to check that data growfs fails with internal rt device
Christoph Hellwig [Fri, 22 Nov 2024 06:30:14 +0000 (07:30 +0100)]
xfs: add a test to check that data growfs fails with internal rt device

The internal RT device directly follows the data device on the same
block device.  This implies the data device can't be grown, and growfs
should handle this gracefully.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add test to check for block layer reordering
Christoph Hellwig [Mon, 18 Nov 2024 12:21:07 +0000 (13:21 +0100)]
xfs: add test to check for block layer reordering

Zoned writes using zone append can be easily fragmented when the block
layer or the driver reorders I/O.  Check that a simple sequential
direct write creates a single extent.  This was broken in the kernel
until recently when using the ->commit_rqs interface on devices with
a relatively small max_hw_sectors / max_zone_append_sectors.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add a test for zoned block accounting after remount
Christoph Hellwig [Tue, 22 Oct 2024 07:41:56 +0000 (09:41 +0200)]
xfs: add a test for zoned block accounting after remount

Test for a problem with an earlier version of the zoned XFS mount code
where freeded blocks in an open zone weren't properly accounted for.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: add a zoned growfs test
Christoph Hellwig [Tue, 22 Oct 2024 08:58:49 +0000 (10:58 +0200)]
xfs: add a zoned growfs test

Zoned file systems require zone aligned RT volume sizes.  Because of
that xfs/596 won't work as-is.  Copy it and test two zone capacity
aligned values.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agocommon: notrun in mkfs_dev for too small zoned file systems
Christoph Hellwig [Wed, 22 Jan 2025 04:48:19 +0000 (05:48 +0100)]
common: notrun in mkfs_dev for too small zoned file systems

Similar to the regular scratch_mkfs, skip the test if the file system
would be so small that there's not enough zones.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: check for zoned-specific errors in _try_scratch_mkfs_xfs
Christoph Hellwig [Wed, 21 Feb 2024 16:15:48 +0000 (17:15 +0100)]
xfs: check for zoned-specific errors in _try_scratch_mkfs_xfs

Check for a few errors issued for unsupported zoned configurations in
_try_scratch_mkfs_xfs so that the test is not run instead of failed.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agocommon: support internal RT devices in scratch_mkfs_sized
Christoph Hellwig [Sat, 23 Nov 2024 07:26:24 +0000 (08:26 +0100)]
common: support internal RT devices in scratch_mkfs_sized

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agocommon: support internal RT device in _require_realtime
Christoph Hellwig [Sat, 23 Nov 2024 06:54:15 +0000 (07:54 +0100)]
common: support internal RT device in _require_realtime

If SCRATCH_DEV is a zoned device it implies an internal zoned RT device
and should not be skipped in _require_realtime.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 weeks agoxfs: remove the post-EOF prealloc tests from the auto and quick groups
Christoph Hellwig [Thu, 30 Jan 2025 04:44:00 +0000 (05:44 +0100)]
xfs: remove the post-EOF prealloc tests from the auto and quick groups

These fail for various non-default configs like DAX, alwayscow and
small block sizes.

Signed-off-by: Christoph Hellwig <hch@lst.de>
4 weeks agoxfs/235: add to the auto group
Christoph Hellwig [Mon, 17 Mar 2025 05:51:38 +0000 (06:51 +0100)]
xfs/235: add to the auto group

xfs/235 is the only test effectively exercising the temporary enabling
of SB_ACTIVE during log recovery.  Add it to the auto group to increase
coverage.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agofstests: test for CONFIG_QFMT_V2 in _require_quota
Eric Sandeen [Fri, 14 Mar 2025 15:44:16 +0000 (10:44 -0500)]
fstests: test for CONFIG_QFMT_V2 in _require_quota

When CONFIG_QUOTA is enabled but CONFIG_QFMT_V2 is disabled in the
kernel config, many quota tests on ext4 will fail in odd ways,
when in fact they should be _notrun. Add a CONFIG_QFMT_V2 test to
_require_quota() to catch this for filesystems that require it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agofstests: btrfs: zoned: verify RAID conversion with write pointer mismatch
Johannes Thumshirn [Wed, 19 Mar 2025 11:09:47 +0000 (12:09 +0100)]
fstests: btrfs: zoned: verify RAID conversion with write pointer mismatch

Recently we had a bug report about a kernel crash that happened when the
user was converting a filesystem to use RAID1 for metadata, but for some
reason the device's write pointers got out of sync.

Test this scenario by manually injecting de-synchronized write pointer
positions and then running conversion to a metadata RAID1 filesystem.

In the testcase also repair the broken filesystem and check if both system
and metadata block groups are back to the default 'DUP' profile
afterwards.

Link: https://lore.kernel.org/linux-btrfs/CAB_b4sBhDe3tscz=duVyhc9hNE+gu=B8CrgLO152uMyanR8BEA@mail.gmail.com/
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
4 weeks agobtrfs/058: fix test to actually have an open tmpfile during the send operation
Filipe Manana [Wed, 19 Mar 2025 12:13:28 +0000 (12:13 +0000)]
btrfs/058: fix test to actually have an open tmpfile during the send operation

The test's goal is to exercise a send operation while there's a tmpfile in
the snapshot, but that doesn't happen since the background xfs_io process
that created the tmpfile ends up exiting before we create the snapshot, so
the snapshot nevers gets a tmpfile.

Fix this by using a different approach, with a fifo and tailing it to the
stdin of a background xfs_io process and then writing to the fifo to
create the tmpfile. This keeps the xfs_io process running with the tmpfile
open while we snapshot and run the send operation.

While at it also add code to verify we have the tmpfile (an orphan inode
item) in the snapshot's tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
4 weeks agogeneric: test fsync of file with no more hard links
Filipe Manana [Tue, 25 Mar 2025 12:24:40 +0000 (12:24 +0000)]
generic: test fsync of file with no more hard links

Test that if we fsync a file that has no more hard links, power fail and
then mount the filesystem, after the journal/log is replayed, the file
doesn't exists anymore.

This exercises a bug recently found and fixed by the following patch for
the linux kernel:

   btrfs: fix fsync of files with no hard links not persisting deletion

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/206: filter out the zoned line from mkfs output
Christoph Hellwig [Fri, 21 Mar 2025 07:21:42 +0000 (08:21 +0100)]
xfs/206: filter out the zoned line from mkfs output

So that the test still passes with a zone enabled mkfs.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/049: skip on zoned devices
Christoph Hellwig [Fri, 21 Mar 2025 07:21:41 +0000 (08:21 +0100)]
xfs/049: skip on zoned devices

This tes creates an ext2 file system, which doesn't support zoned
devices.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: skip various tests when using the zoned allocator
Christoph Hellwig [Fri, 21 Mar 2025 07:21:40 +0000 (08:21 +0100)]
xfs: skip various tests when using the zoned allocator

Various file system features tested are incompatible with the zoned
allocator.  Add a _require_xfs_scratch_non_zoned to guard them.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: skip filestreams tests on internal RT devices
Christoph Hellwig [Fri, 21 Mar 2025 07:21:39 +0000 (08:21 +0100)]
xfs: skip filestreams tests on internal RT devices

The filestreams tests using _test_streams force a run on the data
section, but for internal RT zoned devices the data section can be tiny
and might not provide enough space.  Skip these tests as they aren't
really useful when testing a zoned config anyway.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: xfs_copy doesn't like RT sections
Christoph Hellwig [Fri, 21 Mar 2025 07:21:38 +0000 (08:21 +0100)]
xfs: xfs_copy doesn't like RT sections

internal or external..

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: no quota support with internal rtdev
Christoph Hellwig [Fri, 21 Mar 2025 07:21:37 +0000 (08:21 +0100)]
xfs: no quota support with internal rtdev

Same as regular zoned, but the previous check didn't work.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: handle zoned file systems in _scratch_xfs_force_no_metadir
Christoph Hellwig [Fri, 21 Mar 2025 07:21:36 +0000 (08:21 +0100)]
xfs: handle zoned file systems in _scratch_xfs_force_no_metadir

Zoned file systems required the metadir feature.  If the tests are run
on a conventional block device as the RT device, we can simply remove
the zoned flag an run the test, but if the file systems sits on a zoned
block device there is no way to run a test that wants a non-metadir
file system.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: add helpers to require zoned/non-zoned file systems
Christoph Hellwig [Fri, 21 Mar 2025 07:21:35 +0000 (08:21 +0100)]
xfs: add helpers to require zoned/non-zoned file systems

Looking at the max_open_zones sysfs attribute to see if a file system is
zoned or not, as various tests depend on that.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon: allow _require_non_zoned_device without an argument
Christoph Hellwig [Fri, 21 Mar 2025 07:21:34 +0000 (08:21 +0100)]
common: allow _require_non_zoned_device without an argument

So that callers can pass $SCRATCH_RTDEV directly without needing to check
that it actually is set.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon: extend the zoned device checks in _require_dm_target
Christoph Hellwig [Fri, 21 Mar 2025 07:21:33 +0000 (08:21 +0100)]
common: extend the zoned device checks in _require_dm_target

Also check for zoned log and rt devices in _require_dm_target

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/540: use _scratch_mkfs_xfs
Christoph Hellwig [Fri, 21 Mar 2025 07:21:32 +0000 (08:21 +0100)]
xfs/540: use _scratch_mkfs_xfs

So that the test is _notrun instead of failed for conflicting options
like -r zoned or specific RT group configurations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/419: use _scratch_mkfs_xfs
Christoph Hellwig [Fri, 21 Mar 2025 07:21:31 +0000 (08:21 +0100)]
xfs/419: use _scratch_mkfs_xfs

So that the test is _notrun instead of failed for conflicting options
like -r zoned or specific RT group configurations.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/177: force a small file system size
Christoph Hellwig [Fri, 21 Mar 2025 07:21:30 +0000 (08:21 +0100)]
xfs/177: force a small file system size

This test make assumptions about the number of metadata inodes.  When
using small realtime group size (e.g. the customary 256MB for SMR
hard drives) this assumption gets violated even with modest file system
size.  Force a small file system size to side-step this issue.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/818: fix some design issues
Darrick J. Wong [Fri, 21 Mar 2025 21:28:26 +0000 (14:28 -0700)]
xfs/818: fix some design issues

While QA'ing zoned filesystem support, I discovered some design errors
in this test:

1) Since we're test formatting a sparse file on an xfs filesystem,
there's no need to play games with optimal device size; we can create
a totally sparse file that's the same size as SCRATCH_DEV.

2) mkfs.xfs cannot create realtime files, so if it fails with that,
there's no need to continue the test.

3) If mkfs -p fails for none of the proscribed reasons, it should exit
the test.  The final cat $tmp.mkfs will take care of tweaking the golden
output to register the test failure for further investigation.

Cc: fstests@vger.kernel.org # v2025.03.09
Fixes: 6d39dc34e61e11 ("xfs: test filesystem creation with xfs_protofile")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/populate: drop fallocate mode 0 requirement
Darrick J. Wong [Fri, 21 Mar 2025 21:28:10 +0000 (14:28 -0700)]
common/populate: drop fallocate mode 0 requirement

None of the _scratch_$FSTYP_populate functions use fallocate mode 0 (aka
preallocation) to run, so drop the _require check.  This enables xfs/349
and friends to work on always-cow xfs filesystems.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agogeneric/537: disable quota mount options for pre-metadir rt filesystems
Darrick J. Wong [Fri, 21 Mar 2025 21:27:54 +0000 (14:27 -0700)]
generic/537: disable quota mount options for pre-metadir rt filesystems

Fix this regression in generic/537:

mount: /opt: permission denied.
       dmesg(1) may have more information after failed mount system call.
mount -o uquota,gquota,pquota, -o ro,norecovery -ortdev=/dev/sdb4 /dev/sda4 /opt failed
mount -o uquota,gquota,pquota, -o ro,norecovery -ortdev=/dev/sdb4 /dev/sda4 /opt failed
(see /var/tmp/fstests/generic/537.full for details)

for reasons explained in the giant comment.  TLDR: quota and rt aren't
compatible on older xfs filesystems so we have to work around that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs/614: determine the sector size of the fs image by doing a test format
Darrick J. Wong [Fri, 21 Mar 2025 21:27:38 +0000 (14:27 -0700)]
xfs/614: determine the sector size of the fs image by doing a test format

In some cases (such as xfs always_cow=1), the configuration of the test
filesystem determines the sector size of the filesystem that we're going
to simulate formatting.  Concretely, even if TEST_DEV is a block device
with 512b sectors, the directio geometry can specify 4k writes to avoid
nasty RMW cycles.  When this happens, mkfs.xfs will set the sector size
to that 4k accordingly, but the golden output selection is wrong.  Fix
this.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agogeneric/45[34]: add colored emoji variants to unicode tests
Darrick J. Wong [Fri, 21 Mar 2025 21:27:23 +0000 (14:27 -0700)]
generic/45[34]: add colored emoji variants to unicode tests

Ted told me this morning about a recent problem with kernel Unicode name
casefolding vs. emoji -- initially, someone decided that zero-width
joiners should be stripped out of filenames during comparisons, which
lead to malicious git pulls of branches containing "<zwj>.git/config"
files overwriting git repo config files.  A quick fix was to stop
ignoring the "ignorable" code points, but that broke emoji in filenames,
because emoji use zero-width joiners to combine simpler emoji into more
complex ones, or alter skin tones, or colors, etc.  Reportedly the
casefolding code will also fold a red heart into a black one.

So.  To our filename support test, let's add various colors of heart
emoji and various skin tones of heart-hands; and compound emoji
consisting of multiple emoji glued together with zero width joiners.
This actually caused a buffer overflow in the string-escaping functions
of xfs_scrub phase 5 because I hadn't anticipated that we'd end up with
a filename consisting *entirely* of nonprinting bytes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agoxfs: test filesystem recovery with rdump
Darrick J. Wong [Fri, 21 Mar 2025 21:27:07 +0000 (14:27 -0700)]
xfs: test filesystem recovery with rdump

Test how well we can dump a fully populated filesystem's contents.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agof2fs: test dirty status handling on database file
Chao Yu [Tue, 25 Mar 2025 08:34:28 +0000 (16:34 +0800)]
f2fs: test dirty status handling on database file

This is a regression testcase to check whether we will handle database
inode dirty status correctly:
1. create a regular file, and write data into the file
2. start transaction on the file (via F2FS_IOC_START_ATOMIC_WRITE)
3. write transaction data to the file
4. rename the file
5. commit and end the transaction (via F2FS_IOC_COMMIT_ATOMIC_WRITE)
6. drop caches in order to call f2fs_evict_inode()
It expects kernel panic will gone after we apply commit 03511e936916
("f2fs: fix inconsistent dirty state of atomic file").

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Cc: Daeho Jeong <daehojeong@google.com>
Cc: Jianan Huang <huangjianan@xiaomi.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agof2fs: new test to detect and repair nlink corruption
Chao Yu [Tue, 25 Mar 2025 12:58:24 +0000 (20:58 +0800)]
f2fs: new test to detect and repair nlink corruption

This is a regression test to check whether fsck can handle corrupted
nlinks correctly, it uses inject.f2fs to inject nlinks w/ wrong value,
and expects fsck.f2fs can detect such corruption and do the repair.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/rc: introduce _check_f2fs_filesystem()
Chao Yu [Tue, 25 Mar 2025 12:58:23 +0000 (20:58 +0800)]
common/rc: introduce _check_f2fs_filesystem()

_check_generic_filesystem() will fail the test once it detects
corruption, let's introduce _check_f2fs_filesystem() to just check
filesystem w/ --dry-run option, and return the error number, then
let caller to decide whether the corruption is as expected or not.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/rc: use -f for mkfs.f2fs by default
Chao Yu [Tue, 25 Mar 2025 12:58:22 +0000 (20:58 +0800)]
common/rc: use -f for mkfs.f2fs by default

Otherwise, mkfs will fail due to there is an existing filesystem
in the image.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/config: export F2FS_FSCK_PROG
Chao Yu [Tue, 25 Mar 2025 12:58:21 +0000 (20:58 +0800)]
common/config: export F2FS_FSCK_PROG

Let's export F2FS_FSCK_PROG, then we can use it in
_check_f2fs_filesystem() later.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/config: export F2FS_INJECT_PROG
Chao Yu [Tue, 25 Mar 2025 12:58:20 +0000 (20:58 +0800)]
common/config: export F2FS_INJECT_PROG

export F2FS_INJECT_PROG w/ inject.f2fs, it can be used for fault injection.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agocommon/config: remove redundant export variables
Chao Yu [Tue, 25 Mar 2025 12:58:19 +0000 (20:58 +0800)]
common/config: remove redundant export variables

F2FS_IO_PROG and TIMEOUT_PROG are exported twice, remove the redudant
one.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agofstests: remove run_setsid test way from check
Zorro Lang [Thu, 20 Mar 2025 19:28:12 +0000 (03:28 +0800)]
fstests: remove run_setsid test way from check

This patch partially revert most of the 88d60f434 ("common: fix pkill
by running test program in a separate session"), it does:
1. Remove run_setsid script
2. Remove all run_setsid related things from check
3. Keep the change in _scratch_xfs_stress_scrub_cleanup() which is a
   bug fix for xfs_scrub test.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
4 weeks agofstests: remove privatens test way from check
Zorro Lang [Thu, 20 Mar 2025 19:28:11 +0000 (03:28 +0800)]
fstests: remove privatens test way from check

This patch totally revert:
  ce7f796ad check: remove the deprecation of sessionid
  336784e3d check: disable HAVE_PRIVATENS by default
  949bdf8ea check: deprecate using process sessions to isolate test instances
and partially revert:
  247ab01fa check: run tests in a private pid/mount namespace

So it does:
1. Remove "run_privatens" related things from xfstests/check, due to
   check doesn't need that test way.
2. Keep run_privatens script and related changes for check-parallel.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agocommon/rc: explicitly test for engine availability in _require_fio
Eric Sandeen [Fri, 14 Mar 2025 18:37:45 +0000 (13:37 -0500)]
common/rc: explicitly test for engine availability in _require_fio

The current test in _require_fio (--warnings-fatal --showcmd) does not
fail if an invalid/unavailable io engine is specified.

Add an explicit test that every requested io engine in the job file
is actually available.

Also, remove the "ioe_e4defrag" entries in the [global] stanza of several
ext4 tests which use fio jobfiles. While ioengines can be set in the
[global] section, they can also be overridden in individual, subsequent
stanzas. In each affected test (ext4/301, ext4/302, ext4/303, and
ext4/304) every individual stanza after [global]re-specifies an ioengine;
either with ioengine=e4defrag or ioengine=libaio.

Because of this re-specification, the ioengine in the [global] section
is ignored. This is a good thing, because ioe_e4defrag is not a valid
ioengine, and would fail this new hand-rolled check, even though fio
did not complain.

So rather than over-complicate this new check, simply remove the unused,
invalid "ioengine=ioe_e4defrag" lines in these tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agolib: make a few symbols static
Eric Sandeen [Mon, 10 Mar 2025 18:29:08 +0000 (13:29 -0500)]
lib: make a few symbols static

There are a few symbols in lib/tlibio.c which should be static,
and sparse notices this so fix it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agolib: replace aiocb_t with struct aiocb
Eric Sandeen [Mon, 10 Mar 2025 18:29:07 +0000 (13:29 -0500)]
lib: replace aiocb_t with struct aiocb

aiocb_t isn't defined anywhere, use struct aiocb instead,
to make sparse happy.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agolib: fix empty arg function prototypes
Eric Sandeen [Mon, 10 Mar 2025 18:29:06 +0000 (13:29 -0500)]
lib: fix empty arg function prototypes

Several function prototypes used () when in fact they take
arguments. Fix those to make sparse happy.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agolib: Fix non-ANSI function declarations
Eric Sandeen [Mon, 10 Mar 2025 18:29:05 +0000 (13:29 -0500)]
lib: Fix non-ANSI function declarations

lib/ was full of non-ANSI function declarations, fix them to make
sparse happier.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agotreewide: check for #ifdef __linux__ not linux
Eric Sandeen [Tue, 11 Mar 2025 13:46:48 +0000 (08:46 -0500)]
treewide: check for #ifdef __linux__ not linux

There are several #ifdef linux guards in the code, which caused
a few sparse warnings, because while gcc defines both linux
and __linux__, sparse defines only __linux__. So, switch our
guards to check for __linux__ which is defined by both gcc
and sparse.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agofstests: enable sparse checking with make C=[12]
Eric Sandeen [Mon, 10 Mar 2025 18:29:03 +0000 (13:29 -0500)]
fstests: enable sparse checking with make C=[12]

Enable "make C=1" sparse checking when files get rebuilt. To check
all files, run "make clean" first.

Enable "make C=2" sparse checking of all files without rebuilding them.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
6 weeks agocommon/rc: use getent when available
Eric Sandeen [Mon, 10 Mar 2025 17:55:51 +0000 (12:55 -0500)]
common/rc: use getent when available

Zorro noticed that on systems using nss-altfiles, some tests failed when
trying to parse /etc/passwd directly. The "getent" command does the
right thing in this case, so let's use it as long as it's available.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agogeneric: add missed _require_idmapped_mounts check
Anthony Iliopoulos [Tue, 4 Mar 2025 23:48:19 +0000 (00:48 +0100)]
generic: add missed _require_idmapped_mounts check

Skip the test on older kernels that don't implement mount_setattr and
open_tree syscalls, instead of failing.

Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agosrc/locktest: add missing struct cast with syscall getsockname()
Luis Henriques [Tue, 4 Mar 2025 12:21:19 +0000 (12:21 +0000)]
src/locktest: add missing struct cast with syscall getsockname()

The usage of variable 'myAddr' (struct sockaddr_in) is being casted into a
'struct sockaddr' when used with bind() and with connect().  This patch
adds that cast when used with getsockname() as well, otherwise we'll get the
following error:

locktest.c: In function 'main':
locktest.c:1155:39: error: passing argument 2 of 'getsockname' from incompatible pointer type [-Wincompatible-pointer-types]
 1155 |                 if (getsockname(s_fd, &myAddr, &addr_len)) {
      |                                       ^~~~~~~
      |                                       |
      |                                       struct sockaddr_in *
In file included from /usr/include/fortify/sys/socket.h:23,
                 from locktest.c:19:
/usr/include/sys/socket.h:391:23: note: expected 'struct sockaddr * restrict' but argument is of type 'struct sockaddr_in *'
  391 | int getsockname (int, struct sockaddr *__restrict, socklen_t *__restrict);
      |                       ^

Signed-off-by: Luis Henriques <luis@igalia.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofstests: remove old tools from tools directory
Dave Chinner [Thu, 6 Mar 2025 21:34:50 +0000 (08:34 +1100)]
fstests: remove old tools from tools directory

ag-wipe, db-walk, fs-walk and interop are all old 2000s era SGI QA
scripts that are either not usable anymore of have been superceded
by much more recent functionality.

interop only runs on machines with the host named "bruce" or
"whack", requires NFS mounts from a machine named "snort" and access
to a specific user's home dir. I know what all these were; they were
test and build machines in SGI's engineering office in Melbourne,
Australia. That went away in ~2009....

ag-wipe is unused and has been superceded by multiple different sets of
functionality (e.g. ./check --large-fs).

db-walk is unused by fstests and now is native xfs_db functionality.

fs-walk is dumping the md5sum and stat info of every file in a
directory heirachy and only used by the interop script....

Remove them all.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofstests: remove tools/auto-qa
Dave Chinner [Thu, 6 Mar 2025 21:34:49 +0000 (08:34 +1100)]
fstests: remove tools/auto-qa

This is a 2000s era SGI test script that no-one uses anymore. It
likely doesn't even work because it is dependent on CVS and/or
the SGI proprietary ptools revision control system for source
control. Hence it clearly hasn't been used for years, so remove it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofstests: remove crash script
Dave Chinner [Thu, 6 Mar 2025 21:34:48 +0000 (08:34 +1100)]
fstests: remove crash script

This is an old, early 2000s SGI era script for crash and recovery
testing XFS filesystems. We have much better ways of doing this
today with tools like dm-error, dm-flakey, etc. Nobody has been
using this script for years, so remove it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofstests: remove old soak script
Dave Chinner [Thu, 6 Mar 2025 21:34:47 +0000 (08:34 +1100)]
fstests: remove old soak script

There is an old script for soak testing using check in the source
tree called "soak". All it does is run fsstress in a loop on the
scratch device, but to do that it needs to include the entire
fstests config/setup scripts.

These days we have much better soak testing capabilities (e.g. the
soak and stress groups, with controllable iterations, durations,
load, etc) so there's no point in keeping old scripts like this
around that add weird dependencies to the core infrastructure.

Remove it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofstests: remove setup script
Dave Chinner [Thu, 6 Mar 2025 21:34:46 +0000 (08:34 +1100)]
fstests: remove setup script

THere is a script that will echo the current setup of the fstests
directory. This is largely the same output as running 'check -n' to
do a dry-run outputs. Hence this script is redundant, not likely to
be widely used and is easily replaced with check itself. Remove it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocheck: remove the deprecation of sessionid
Zorro Lang [Thu, 6 Mar 2025 09:49:24 +0000 (17:49 +0800)]
check: remove the deprecation of sessionid

As "privatens" way isn't recommended temporarily, it can't replace
"sessionid" way for now. So remove the deprecation.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocheck: disable HAVE_PRIVATENS by default
Zorro Lang [Thu, 6 Mar 2025 09:49:23 +0000 (17:49 +0800)]
check: disable HAVE_PRIVATENS by default

Currently we have 3 ways to run a test case in _run_seq():

  if [ -n "${HAVE_PRIVATENS}" ]; then
      ./tools/run_privatens "./$seq"
      ...
  elif [ -n "${HAVE_SYSTEMD_SCOPES}" ]; then
      systemd-run --quiet --unit "${unit}" --scope \
             ./tools/run_setsid "./$seq" &
      ...
  else
      ./tools/run_setsid "./$seq" &
      ...
  fi

The "privatens" way brings in some regressions. We need more time
to develop and test this way, it's not time let it to be the
first default choice, so isolate the HAVE_PRIVATENS initialization
by a TRY_PRIVATENS parameter, and disable it by default.

Set TRY_PRIVATENS=yes to give "privatens" a try, otherwise run in
old ways. This patch can be removed after "privatens" way is stable.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section
Darrick J. Wong [Thu, 20 Feb 2025 21:47:15 +0000 (13:47 -0800)]
common/xfs: fix _xfs_get_file_block_size when rtinherit is set and no rt section

It's possible for the sysadmin to set rtinherit on the directory tree
even if there isn't a realtime section attached to the filesystem.  When
this is the case, the realtime flag is /not/ passed to new files, and
file data is written to the data device.  The file allocation unit for
the file is the fs blocksize, and it is not correct to use the rt
extent.

fstests can be fooled into doing the incorrect thing if test runner puts
'-d rtinherit=1 -r extsize=28k' into MKFS_OPTIONS without configuring a
realtime device.  This causes many tests to do the wrong thing because
they think they must operate on units of 28k (and not 4k).  Fix this.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agogeneric/331,xfs/240: support files that skip delayed allocation
Darrick J. Wong [Thu, 20 Feb 2025 21:47:15 +0000 (13:47 -0800)]
generic/331,xfs/240: support files that skip delayed allocation

The goal of this test is to ensure that log recovery finishes a copy on
write operation in the event of temporary media errors.  It's important
that the test observe some sort of IO error once we switch the scratch
device to fail all IOs, but regrettably the test encoded the specific
behavior of XFS and btrfs when the test was written -- the aio write
to the page cache doesn't have to touch the disk and succeeds, and the
fdatasync flushes things to disk and hits the IO error.

However, this is not how things work on the XFS realtime device.  There
is no delalloc on realtime when the rt extent size > 1 fsblock (or on
any file with extent size hints), so the aio write allocates an
unwritten extent to stage the write.  The allocation fails due to EIO,
so it's the write call that fails.  Therefore, all we need to do is to
detect an IO error at any point between the write and the fdatasync call
to be satisfied that the test does what we want to do.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: remove xfs/131 now that we allow reflink on realtime volumes
Darrick J. Wong [Thu, 20 Feb 2025 21:47:14 +0000 (13:47 -0800)]
xfs: remove xfs/131 now that we allow reflink on realtime volumes

Remove this test, since we now support reflink on the rt volume.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: race fsstress with realtime refcount btree scrub and repair
Darrick J. Wong [Thu, 20 Feb 2025 21:47:14 +0000 (13:47 -0800)]
xfs: race fsstress with realtime refcount btree scrub and repair

Race checking and rebuilding realtime refcount btrees with fsstress.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/27[24]: adapt for checking files on the realtime volume
Darrick J. Wong [Thu, 20 Feb 2025 21:47:14 +0000 (13:47 -0800)]
xfs/27[24]: adapt for checking files on the realtime volume

Adapt both tests to behave properly if the two files being tested are on
the realtime volume.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: create fuzz tests for the realtime refcount btree
Darrick J. Wong [Thu, 20 Feb 2025 21:47:14 +0000 (13:47 -0800)]
xfs: create fuzz tests for the realtime refcount btree

Create fuzz tests for the realtime refcount btree record and key/ptr
blocks.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon/populate: create realtime refcount btree
Darrick J. Wong [Thu, 20 Feb 2025 21:47:14 +0000 (13:47 -0800)]
common/populate: create realtime refcount btree

Populate a realtime refcount btree when we're creating a sample fs.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofuzzy: create missing fuzz tests for rt rmap btrees
Darrick J. Wong [Thu, 20 Feb 2025 21:47:13 +0000 (13:47 -0800)]
fuzzy: create missing fuzz tests for rt rmap btrees

Back when I first created the fuzz tests for the realtime rmap btree, I
forgot a couple of things.  Add tests to fuzz rtrmap btree leaf records,
and node keys.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agopopulate: check that we created a realtime rmap btree of the given height
Darrick J. Wong [Thu, 20 Feb 2025 21:47:13 +0000 (13:47 -0800)]
populate: check that we created a realtime rmap btree of the given height

Make sure that we actually create an rt rmap btree of the desired height
somewhere in the filesystem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agopopulate: adjust rtrmap calculations for rtgroups
Darrick J. Wong [Thu, 20 Feb 2025 21:47:13 +0000 (13:47 -0800)]
populate: adjust rtrmap calculations for rtgroups

Now that we've sharded the realtime volume and created per-group rmap
btrees, we need to adjust downward the size of rtrmapbt records since
the block counts are now 32-bit instead of 64-bit.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/443: use file allocation unit, not dbsize
Darrick J. Wong [Thu, 20 Feb 2025 21:47:13 +0000 (13:47 -0800)]
xfs/443: use file allocation unit, not dbsize

We can only punch in units of file allocation boundaries, so update this
test to use that instead of the fs blocksize.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/104: use _scratch_mkfs_sized
Darrick J. Wong [Thu, 20 Feb 2025 21:47:12 +0000 (13:47 -0800)]
xfs/104: use _scratch_mkfs_sized

Use _scratch_mkfs_sized instead of opencoding the small fs creation
logic because the helper scales down the size of the rt volume to match
the data volume.  This means the format won't fail if SCRATCH_RTDEV is
quite large.

Also fix some incorrect bash usage of "$@" and remove the leading
underscore because it's a private test function.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/291: use _scratch_mkfs_sized instead of opencoding the logic
Darrick J. Wong [Thu, 20 Feb 2025 21:47:12 +0000 (13:47 -0800)]
xfs/291: use _scratch_mkfs_sized instead of opencoding the logic

Now that _scratch_mkfs_xfs_sized accepts arbitrary mkfs arguments, this
test doesn't need to open-code the helper just to add the dir block and
log size arguments.  Clean this up, which will also help us to avoid
problems with rtrmap if the rt devices is large enough to cause format
failures with the 133M data device size.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/3{43,32}: adapt tests for rt extent size greater than 1
Darrick J. Wong [Thu, 20 Feb 2025 21:47:12 +0000 (13:47 -0800)]
xfs/3{43,32}: adapt tests for rt extent size greater than 1

Both of these tests for the realtime volume can fail when the rt extent
size is larger than a single block.

332 is a read-write functionality test that encodes md5sum in the
output, so we need to skip it if $blksz isn't congruent with the extent
size, because the fcollapse call will fail.

343 is a test of the rmap btree, so the fix here is simpler -- make
$blksz the file allocation unit, and get rid of the md5sum in the
golden output.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/341: update test for rtgroup-based rmap
Darrick J. Wong [Thu, 20 Feb 2025 21:47:12 +0000 (13:47 -0800)]
xfs/341: update test for rtgroup-based rmap

Now that we're sharding the realtime volume into multiple allocation
groups, update this test to reflect the new reality.  The realtime rmap
btree record and key sizes have shrunk, and we can't guarantee that a
quick file write actually hits the same rt group as the one we fuzzed,
so eliminate the file write test since we're really only curious if
xfs_repair will fix the problem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix various problems with fsmap detecting the data device
Darrick J. Wong [Thu, 20 Feb 2025 21:47:11 +0000 (13:47 -0800)]
xfs: fix various problems with fsmap detecting the data device

Various tests of realtime rmap functionality assumed that the data
device could be picked out from the GETFSMAP output by looking for
static fs metadata.  This is no longer true, since rtgroups filesystems
write a superblock header at the start of the rt device, so update these
tests.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: race fsstress with realtime rmap btree scrub and repair
Darrick J. Wong [Thu, 20 Feb 2025 21:47:11 +0000 (13:47 -0800)]
xfs: race fsstress with realtime rmap btree scrub and repair

Race checking and rebuilding realtime rmap btrees with fsstress.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agofuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file
Darrick J. Wong [Thu, 20 Feb 2025 21:47:11 +0000 (13:47 -0800)]
fuzz: for fuzzing the rtrmapbt, find the path to the rt rmap btree file

The fs population code creates a realtime rmap btree in /some/ realtime
group with at least two levels.  This rmapbt file isn't necessarily the
one for group 0, so we need to find it programmatically.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/336: port to common/metadump
Darrick J. Wong [Thu, 20 Feb 2025 21:47:11 +0000 (13:47 -0800)]
xfs/336: port to common/metadump

xfs/336 does this somewhat sketchy thing where it mdrestores into a
regular file, and then does this to validate the restored metadata:

SCRATCH_DEV=$TEST_DIR/image _scratch_mount

Unfortunately, commit 1a49022fab9b4d causes the following regression:

 --- /tmp/fstests/tests/xfs/336.out      2024-11-12 16:17:36.733447713 -0800
 +++ /var/tmp/fstests/xfs/336.out.bad    2025-01-04 19:10:39.861871114 -0800
 @@ -5,4 +5,5 @@ Create big file
  Explode the rtrmapbt
  Create metadump file
  Restore metadump
 -Check restored fs
 +Usage: _set_fs_sysfs_attr <mounted_device> <attr> <content>
 +(see /var/tmp/fstests/xfs/336.full for details)

This is due to the fact that SCRATCH_DEV is temporarily reassigned to
the regular file.  That path is passed straight through _scratch_mount
to _xfs_prepare_for_eio_shutdown, but that helper _fails because the
"dev" argument isn't actually a path to a block device.

Fix this by porting it to the new common/metadump code that we merged
last year.

Cc: <fstests@vger.kernel.org> # v2024.12.08
Fixes: 1a49022fab9b4d ("fstests: always use fail-at-unmount semantics for XFS")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix tests that try to access the realtime rmap inode
Darrick J. Wong [Thu, 20 Feb 2025 21:47:10 +0000 (13:47 -0800)]
xfs: fix tests that try to access the realtime rmap inode

The realtime rmap tests were added to fstests a long time ago.  Since
they were added, we decided to create a metadata file directory
structure instead of adding more fields to the superblock.  Therefore,
fix all the tests that try to access these paths.

While we're at it, fix xfs/409 to run the *online* scrub program like
it's supposed to.  xfs/408 is the fuzzer for xfs_repair testing.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon: test statfs reporting with project quota
Darrick J. Wong [Thu, 20 Feb 2025 21:47:10 +0000 (13:47 -0800)]
common: test statfs reporting with project quota

Create a test to check that statfs on a directory tree with a project
quota will report the quota limit and available blocks; and that the
available blocks reported doesn't exceed that of the whole filesystem.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: regression testing of quota on the realtime device
Darrick J. Wong [Thu, 20 Feb 2025 21:47:10 +0000 (13:47 -0800)]
xfs: regression testing of quota on the realtime device

Make sure that quota accounting and enforcement work correctly for
realtime volumes on XFS.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix quota tests to adapt to realtime quota
Darrick J. Wong [Thu, 20 Feb 2025 21:47:10 +0000 (13:47 -0800)]
xfs: fix quota tests to adapt to realtime quota

Fix or limit the scope of tests so that we can turn on testing for
realtime quotas.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon: enable testing of realtime quota when supported
Darrick J. Wong [Thu, 20 Feb 2025 21:47:09 +0000 (13:47 -0800)]
common: enable testing of realtime quota when supported

If the kernel advertises realtime quota support, test it.

However, this has a plot twist -- because rt quota only works if the xfs
is formatted with rtgroups, we have to mount a filesystem to see if
rtquota is actually supported.  Since it's time consuming to format and
mount the scratch filesystem, we'll assume that the test and scratch
fses have the same support.

This will cause problems if one sets SCRATCH_RTDEV but not TEST_RTDEV.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix tests for persistent qflags
Darrick J. Wong [Thu, 20 Feb 2025 21:47:09 +0000 (13:47 -0800)]
xfs: fix tests for persistent qflags

Fix the tests that now break with persistent quota flags.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix quota detection in fuzz tests
Darrick J. Wong [Thu, 20 Feb 2025 21:47:09 +0000 (13:47 -0800)]
xfs: fix quota detection in fuzz tests

With metadir, quota options persist until they are changed by mount
options.  Therefore, we can set the quota flags in MKFS_OPTIONS and
needn't supply them in MOUNT_OPTIONS.  Unfortunately, this means that we
cannot grep the MOUNT_OPTIONS anymore; we must mount the fs and run
src/feature to determine if quotas are enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: test persistent quota flags
Darrick J. Wong [Thu, 20 Feb 2025 21:47:09 +0000 (13:47 -0800)]
xfs: test persistent quota flags

Test the persistent quota flags that come with the metadir feature.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: update tests for quota files in the metadir
Darrick J. Wong [Thu, 20 Feb 2025 21:47:09 +0000 (13:47 -0800)]
xfs: update tests for quota files in the metadir

Update fstests to handle quota files in the metadir.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs: fix fuzz tests of rtgroups bitmap and summary files
Darrick J. Wong [Thu, 20 Feb 2025 21:47:08 +0000 (13:47 -0800)]
xfs: fix fuzz tests of rtgroups bitmap and summary files

With rtgroups, the rt bitmap and summary files are now per-group, so
adjust the fuzz and fsck tests to find the new locations.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon/fuzzy: adapt the scrub stress tests to support rtgroups
Darrick J. Wong [Thu, 20 Feb 2025 21:47:08 +0000 (13:47 -0800)]
common/fuzzy: adapt the scrub stress tests to support rtgroups

Adapt the scrub stress testing framework to support checking realtime
group metadata.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agocommon/xfs: capture realtime devices during metadump/mdrestore
Darrick J. Wong [Thu, 20 Feb 2025 21:47:08 +0000 (13:47 -0800)]
common/xfs: capture realtime devices during metadump/mdrestore

If xfs_metadump supports the -r switch to capture the contents of
realtime devices and there is a realtime device, add the option to the
command line to enable preservation.

Similarly, if the dump file could restore to an external scratch rtdev,
pass the -r option to mdrestore so that we can restore rtdev contents.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/271,xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands
Darrick J. Wong [Thu, 20 Feb 2025 21:47:08 +0000 (13:47 -0800)]
xfs/271,xfs/556: fix tests to deal with rtgroups output in bmap/fsmap commands

Fix these tests to deal with the xfs_io bmap and fsmap commands printing
out realtime group numbers if the feature is enabled.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/449: update test to know about xfs_db -R
Darrick J. Wong [Thu, 20 Feb 2025 21:47:07 +0000 (13:47 -0800)]
xfs/449: update test to know about xfs_db -R

The realtime groups feature added a -R flag to xfs_db so that users can
pass in the realtime device.  Since we've now modified the
_scratch_xfs_db to use this facility, we can update the test to do exact
comparisons of the xfs_db info command against the mkfs output.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
7 weeks agoxfs/185: update for rtgroups
Darrick J. Wong [Thu, 20 Feb 2025 21:47:07 +0000 (13:47 -0800)]
xfs/185: update for rtgroups

This old test is a bit too fixated on exact rt allocator behavior.  With
rtgroups enabled, we can end up with one large contiguous region that's
split into multiple bmbt mappings to avoid crossing rtgroup boundaries.
The realtime superblock throws another twist into the mix because the
first rtx will always be in use, which can shift the start of the
physical space mappings by up to 1 rtx.

Also fix a bug where we'd try to fallocate the total number of rtx,
whereas we should be asking for the number of free rtx to avoid ENOSPC
errors.

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