Shin'ichiro Kawasaki [Tue, 14 Jan 2025 03:48:31 +0000 (12:48 +0900)]
fsx: fix compile error for preadv2()
Commit d6b9d8eff076 ("fsx: add support for RWF_DONTCACHE") introduced
preadv2() calls in ltp/fsx.c. However, sys/uio.h is not included to the
source file, which causes compile errors with the gcc option
-Werror-implicit-function-declaration:
fsx.c: In function 'test_dontcache_io':
fsx.c:1956:15: error: implicit declaration of function 'preadv2'; did you mean 'pread64'? [-Wimplicit-function-declaration]
1956 | ret = preadv2(fd, &iov, 1, 0, RWF_DONTCACHE);
| ^~~~~~~
| pread64
fsx.c: In function 'fsx_rw':
fsx.c:2836:31: error: implicit declaration of function 'pwritev2'; did you mean 'pwrite64'? [-Wimplicit-function-declaration]
2836 | ret = pwritev2(fd, &iov, 1, offset, flags);
| ^~~~~~~~
| pwrite64
To fix it, add the include directive.
Fixes: d6b9d8eff076 ("fsx: add support for RWF_DONTCACHE") Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
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.
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.
Christoph Hellwig [Thu, 30 Jan 2025 04:44:16 +0000 (05:44 +0100)]
xfs: skip various tests on zoned devices
Various tests don't work with underlying zoned devices because either the
device mapper maps don't align to zone boundaries, or in one case the test
creates an ext2 file system that doesn't support zoned devices.
Christoph Hellwig [Tue, 19 Nov 2024 17:24:50 +0000 (18:24 +0100)]
xfs: skip filestreams test 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.
Christoph Hellwig [Sun, 24 Nov 2024 13:56:44 +0000 (14:56 +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.
Christoph Hellwig [Sun, 19 Jan 2025 05:41:52 +0000 (06:41 +0100)]
common: skip tests using LVM when the device is no known
LVM has a lot of elaborate code to make the users life painful. This
includes claiming the device type is unknown if it doesn't match it's
elaborately crafted internal list instead of just letting the user use
it. Skip tests using LVM if this is the case to avoid arcane failures
due to missing lvm devices when using null_blk.
Christoph Hellwig [Sun, 8 Dec 2024 06:23:45 +0000 (15:23 +0900)]
xfs/614: query correct direct I/O alignment
When creating XFS file systems on files, mkfs will query the file system
for the minimum alignment, which can be larger than that of the
underlying device. Do the same to link the right output file.
Christoph Hellwig [Sun, 18 Aug 2024 04:52:39 +0000 (06:52 +0200)]
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.
Christoph Hellwig [Mon, 27 Jan 2025 08:09:34 +0000 (09:09 +0100)]
TEMP: disable direct I/O in _create_loop_device
The loop driver picks the block device based on sb->s_bdev, which
is incorrect for XFS file systems with a RT device. Until this is
fixed in the loop driver, disable direct I/O support entirely.
Darrick J. Wong [Thu, 21 Nov 2024 00:27:33 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:33 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:31 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:31 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:30 +0000 (16:27 -0800)]
xfs: skip tests if formatting small filesystem fails
There are a few tests that try to exercise XFS functionality with an
unusually small (< 500MB) filesystem. Formatting can fail if the test
configuration also specifies a very large realtime device because mkfs
hits ENOSPC when allocating the realtime metadata. The test proceeds
anyway (which causes an immediate mount failure) so we might as well
skip these.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:30 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:30 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:30 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:29 +0000 (16:27 -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>
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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:29 +0000 (16:27 -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>
Darrick J. Wong [Tue, 17 Dec 2024 18:32:00 +0000 (10:32 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:28 +0000 (16:27 -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>
Darrick J. Wong [Wed, 27 Nov 2024 21:01:15 +0000 (13:01 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:26 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:26 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:25 +0000 (16:27 -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>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:25 +0000 (16:27 -0800)]
punch-alternating: detect xfs realtime files with large allocation units
For files on the XFS realtime volume, it's possible that the file
allocation unit (aka the minimum size we have to punch to deallocate
file blocks) could be greater than a single fs block. This utility
assumed that it's always possible to punch a single fs block, but for
these types of files, all that does is zeroes the page cache. While
that's what most *user applications* want, fstests uses punching to
fragment file mapping metadata and/or fragment free space, so adapt this
test for that purpose by detecting realtime files.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:24 +0000 (16:27 -0800)]
common/populate: use metadump v2 format by default for fs metadata snapshots
When we're snapshotting filesystem metadata after creating a populated
filesystem, force the creation of metadump v2 files by default to
exercise the new format, since xfs_metadump continues to use the v1
format unless told otherwise.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:24 +0000 (16:27 -0800)]
common/ext4: reformat external logs during mdrestore operations
The e2image file format doesn't support the capture of external log
devices, which means that mdrestore ought to reformat the external log
to get the restored filesystem to work again. The common/populate code
could already do this, so push it to the common ext4 helper.
While we're at it, fix the uncareful usage of SCRATCH_LOGDEV in the
populate code.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:24 +0000 (16:27 -0800)]
common/populate: refactor caching of metadumps to a helper
Hoist out of _scratch_populate_cached all the code that we use to save a
metadump of the populated filesystem. We're going to make this more
involved for XFS in the next few patches so that we can take advantage
of the new support for external devices in metadump/mdrestore.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Fri, 22 Nov 2024 21:18:18 +0000 (13:18 -0800)]
xfs/122: disable this test for any codebase that knows about metadir
All of the ondisk structure size checks from this test were copied to
the build time checks in xfs_ondisk.h. This means that the kernel and
xfsprogs build processes check the structure sizes, which means that
fstests no longer needs to do that.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:22 +0000 (16:27 -0800)]
xfs/509: adjust inumbers accounting for metadata directories
The INUMBERS ioctl exports data from the inode btree directly -- the
number of inodes it reports is taken from ir_freemask and includes all
the files in the metadata directory tree. BULKSTAT, on the other hand,
only reports non-metadata files. When metadir is enabled, this will
(eventually) cause a discrepancy in the inode counts that is large
enough to exceed the tolerances, thereby causing a test failure.
Correct this by counting the files in the metadata directory and
subtracting that from the INUMBERS totals.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:22 +0000 (16:27 -0800)]
xfs/{050,144,153,299,330}: update quota reports to handle metadir trees
Prior to the new metadir feature in XFS, the rtbitmap and rtsummary
files were included in icount, though their bcount contribution is zero
due to rt and quota not being supported together. With the new metadir
feature in XFS, no files in the metadata directory tree are counted in
quota.
Hence we must adjust the icount of any quota report down by two to avoid
breaking golden outputs.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:21 +0000 (16:27 -0800)]
common/repair: patch up repair sb inode value complaints
Now that we've refactored xfs_repair to be more consistent in how it
reports unexpected superblock inode pointer values, we have to fix up
the fstests repair filters to emulate the old golden output.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:21 +0000 (16:27 -0800)]
xfs/{030,033,178}: forcibly disable metadata directory trees
The golden output for thests tests encode the xfs_repair output when we
fuzz various parts of the filesystem. With metadata directory trees
enabled, however, the golden output changes dramatically to reflect
reconstruction of the metadata directory tree.
To avoid regressions, add a helper to force metadata directories off via
MKFS_OPTIONS.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 21 Nov 2024 00:27:21 +0000 (16:27 -0800)]
various: fix finding metadata inode numbers when metadir is enabled
There are a number of tests that use xfs_db to examine the contents of
metadata inodes to check correct functioning. The logic is scattered
everywhere and won't work with metadata directory trees, so make a
shared helper to find these inodes.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 16 Jan 2025 20:18:05 +0000 (12:18 -0800)]
xfs/349: reclassify this test as not dangerous
This test creates a filesystem with all known types of metadata. It
doesn't fuzz anything, nor does it actually repair anything. Hence we
can put it in the auto group and drop the dangerous tags.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 23 Jan 2025 17:00:02 +0000 (09:00 -0800)]
xfs/28[56]: add to the auto group
Enable /some/ testing of online fsck for everybody by adding these two
stress tests to the autogroup. At this time I don't have any plans to
do the same for the other scrub stress tests.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 16 Jan 2025 19:44:03 +0000 (11:44 -0800)]
misc: remove the dangerous_scrub group
Now that online fsck has been in the upstream kernel for 8 months, I
think it's stabilized enough that the scrub functionality tests don't
need to hide behind the "dangerous" label anymore. Move them all to the
scrub group and delete the dangerous_scrub group.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Darrick J. Wong [Thu, 16 Jan 2025 20:02:09 +0000 (12:02 -0800)]
misc: fix misclassification of xfs_repair fuzz tests
All the tests in the "fuzzers_repair" group actually test xfs_repair,
not scrub. Therefore, we should remove them all from 'dangerous_scrub'
and put them in the 'repair' group.
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>