Chao Yu [Sat, 21 May 2022 03:16:21 +0000 (11:16 +0800)]
generic: adjust strict SPO recovery testcases for f2fs
Testcases like generic 342/502/526/527 expect that filesystems will
recover all related metadata changes to the file which was fsynced
before sudden power off.
This patch adjusts to use "fsync_mode=strict" mountoption for f2fs
to pass these testcases.
Signed-off-by: Chao Yu <chao@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christoph Hellwig [Fri, 27 May 2022 08:19:15 +0000 (10:19 +0200)]
btrfs: test direct I/O read repair with interleaved corrupted sectors
Test that repair handles the case where it needs to read from more than
a single mirror on the raid1c3 profile and needs to take turns over the
mirrors to recover data for the whole read.
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christoph Hellwig [Fri, 27 May 2022 08:19:14 +0000 (10:19 +0200)]
btrfs: test buffered I/O read repair with interleaved corrupted sectors
Test that repair handles the case where it needs to read from more than
a single mirror on the raid1c3 profile and needs to take turns over the
mirrors to recover data for the whole read.
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christoph Hellwig [Fri, 27 May 2022 08:19:06 +0000 (10:19 +0200)]
btrfs: add a helpers for read repair testing
Add a few helpers to consolidate code for btrfs read repair testing:
- _btrfs_get_first_logical() gets the btrfs logical address for the
first extent in a file
- _btrfs_get_device_path and _btrfs_get_physical use the
btrfs-map-logical tool to find the device path and physical address
for btrfs logical address for a specific mirror
- _btrfs_direct_read_on_mirror and _btrfs_buffered_read_on_mirror
read the data from a specific mirror
These will be used to consolidate the read repair tests and avoid
duplication for new tests.
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Darrick J. Wong [Tue, 24 May 2022 19:52:19 +0000 (12:52 -0700)]
xfs/545: check for fallocate support before running test
This test fails when alwayscow mode is enabled:
QA output created by 545
+fallocate: Operation not supported
Creating directory system to dump using fsstress.
Fix this by checking for fallocate support first.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Zorro Lang [Thu, 26 May 2022 01:23:17 +0000 (09:23 +0800)]
tests: remove redundant common/$FSTYP importing
As fstests intensively source specific common/$FSTYP files in
common/rc, at the beginning of ./check running. Each single case
doesn't need to import that again.
Signed-off-by: Zorro Lang <zlang@kernel.org> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Zorro Lang [Wed, 25 May 2022 07:34:26 +0000 (15:34 +0800)]
common: source base fs specific common file
When tests overlayfs, sometimes we need the underlying fs specific
helpers, e.g. common/rc has:
_filesystem_timestamp_range $OVL_BASE_TEST_DEV $OVL_BASE_FSTYP
So when we source common/overlay, better to source OVL_BASE_FSTYP
too.
Signed-off-by: Zorro Lang <zlang@kernel.org> Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Luís Henriques [Tue, 24 May 2022 09:42:56 +0000 (10:42 +0100)]
ceph/001: skip metrics check if no copyfrom mount option is used
Checking the metrics is only valid if 'copyfrom' mount option is
explicitly set, otherwise the kernel won't be doing any remote object
copies. Fix the logic to skip this metrics checking if 'copyfrom' isn't
used.
Signed-off-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Zorro Lang <zlang@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Amir Goldstein [Fri, 20 May 2022 14:32:49 +0000 (17:32 +0300)]
xfs: annotate fix commits for upcoming 5.10.y backports
In preparation for backporting xfs fixes to stable kernel 5.10.y,
annotate some of the tests that pass after applying the backports.
Most of the annotated tests have the fix commit documented either
in comment or in commit message already.
All tests have been verified to pass with fix commits apply, but
for a few tests, a failure was observed when running on kernel without
the documented fix commit. That is probably because failure happens
only on a specific setup.
Generic tests have also been annotated with xfs fix commits.
That may produce wrong hints if the test fails on another fs, but
that is what hints are for - to give tester a hint, so if tester is
not testing xfs, it's easy to figure out that the hint is irrelevant.
Signed-off-by: Amir Goldstein <amir73il@gmail.com> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Zorro Lang [Sat, 21 May 2022 05:32:19 +0000 (13:32 +0800)]
tools/mkgroupfile: help the cases of group.list in number order
The mkgroupfile doesn't sort cases in number order, that cause
fstests' ./new script can't find a proper number which isn't taken.
The unsorted case number might cause more problems, so fix it.
Fixes: 441606d28681 ("fstests: faster group file creation") Signed-off-by: Zorro Lang <zlang@kernel.org>
Dave Chinner [Tue, 17 May 2022 07:01:11 +0000 (17:01 +1000)]
xfs/191: remove broken test
Test has been marked broken for a long time. Original intent of
validating all mkfs.xfs input is not realistic, nobody is going to
try to make that happen.
Remove it as it serves no useful purpose except to have a whacky
unique name that nobody expects or codes for.
Signed-off-by: Dave Chinner <dchinner@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>
We then try to retreive the attr named 'a_are_bad/for_you'. The
failure is:
-Attribute "a_are_bad/for_you" had a 3 byte value for TEST_DIR/mount-148/testfile:
-heh
+attr_get: No data available
+Could not get "a_are_bad/for_you" for TEST_DIR/mount-148/testfile
The error returned is ENODATA - the xattr does not exist. While the
name might exist in the attr leaf block:
xattrs are not looked up by name matches when in leaf or node form
like they are in short form. They are looked up by *name hash*
matches, and if the hash is not found, then the name does not exist.
Only if the has match is found, then it goes and retrieves the xattr
pointed to by the hash and checks the name.
At this point, it should be obvious that the hash of
"a_are_bad_for_you" is different to "a_a_are_bad/for_you". Hence the
leaf lookup is always rejected at the hash match stage and never
gets to the name compare stage.
IOWs, this test can *never* pass when the xattr is in leaf/node
form, only when it is in short form.
The reason the attr fork is in leaf form is that we are using
"-m crc=0" and so the inodes are only 256 bytes in size and can only
hold ~150 bytes in the literal area. That leaves ~100 bytes maximum
for shortform attr data. The test consumes ~80 bytes of shortform
space, so it should fit and the test pass.
Yes, I run the fstests with selinux enabled on some of test
machines. The selinux attr pushes the attr fork way over the size
that can fit in the shortform literal area, and so it moves to leaf
form as the attrs are initially added and the test fails.
Fix this by forcing the test to use 512 byte inodes, so as to
provide around 350 bytes of usable attr fork literal area so it's
not affected by security attributes.
While there, clean up the silly conditional loop device cleanup
code.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Dave Chinner [Tue, 17 May 2022 07:01:02 +0000 (17:01 +1000)]
xfs/348: golden output is not correct
The output of xfs/348 encodes the observed behaviour at the time the
test was written, not the correct behaviour that should occur.
Recent improvements in verification checking in the upstream kernel
(1eb70f54c445 "xfs: validate inode fork size against fork format")
have resulted in the kernel having correct behaviour and now the
test fails. Fix the test output to reflect correct behaviour.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Dave Chinner [Tue, 17 May 2022 07:01:00 +0000 (17:01 +1000)]
fstests: filter quota warnings
Quota warning code has been removed from the upstream kernel and now
returns -EINVAL errors. Seeing as we can't set warnings anymore and
they have always been non-functional in the kernel, just remove the
calls to set warnings filter those errors out so those tests pass
again.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Dave Chinner [Fri, 20 May 2022 01:23:36 +0000 (11:23 +1000)]
common/rc: fix test init performance regression on XFS
I've been having problems over the past month with tests randomly
running much slower than they should. The overall effect has been
that running an auto group iterate has blown out from about 3
hours to almost 5 hours.
The problem has been that the root disks have been thrashing.
Thousands of iops and the backing store getting IO bound so all test
vms with root drive images hosted on that backing store then also
go slow.
I finally got to the bottom of it - it looked for all the world like
a qemu image format write amplification problem, because I couldn't
capture anything unusual from inside the guest. I converted all
the root images to raw format on fast SSD storage, and the problem
didn't go away - while some tests were faster, other tests were
still randomly slow.
Finally I tracked it down with blktrace/blkparse. All the IO was
coming from processes with the command line like:
A quick grep then pointed me at common/rc::init_rc() where there is
a test for XFS specific on-disk format behaviour that uses that
exact command line.
init_rc() is run from _begin_fstest() so it is executed on every
test start. We run mkfs to create a 512MB filesystem in $tmp on
every test start. That's ..... not smart. And we do it so we can
change the setup of $XFS_COPY_PROG, which is only used in a handful
of tests. That's also .... not smart.
And then the penny dropped: we recently increased the default log
size of small filesystems, so this is now zeroing a 64MB log instead
of a 5-10MB log. And, of course it's on the root drive because of
the $tmp image prefix, which in this case is ext3, and it's
fragmenting the crap out of the writes and so it increases runtime
of the mkfs.xfs execution from nothing to 5-10s.
Then when one of these mkfs invocations co-incides with journal
flushing driven writeback, everything just stops until the writeback
stops thrashing. And so all tests are 5-10s slows, and random tests
take anywhere between 20-100s longer to start up....
Fix it by moving the setup of XFS_COPY_PROG to _require_xfs_copy()
so only the tests that use xfs_copy run this code.
Signed-off-by: Dave Chinner <dchinner@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>
Dave Chinner [Fri, 20 May 2022 01:23:35 +0000 (11:23 +1000)]
fstests: tests should not source common/rc directly
_begin_fstest() does this as every test needs it, so remove it from
all the tests that source it a second time.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Eric Biggers [Sat, 14 May 2022 18:01:46 +0000 (11:01 -0700)]
generic/556: add test case for top-level dir rename
Test renaming a casefolded directory located in the top-level directory,
while the cache is cold. When $MOUNT_OPTIONS contains
test_dummy_encryption, this detects an f2fs bug.
Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Gabriel Krisman Bertazi [Fri, 20 May 2022 17:18:52 +0000 (13:18 -0400)]
generic/556: Filter touch error message
Coreutils commit d435cfc0bc55 ("touch: fix wrong
diagnostic (Bug#48106)"), released in coreutils v9.0, changed the error
reported by the tool when openat() fails with EINVAL. Instead of
reporting a generic message for the failure of either openat() or the
following utimensat(), it now differentiates both failures with
different messages.
This change breaks generic/556, which relied on the parsing of that
message. This test was originally developed by me on a Debian
Buster (coreutils v8.x), so I used the generic error message. Now that
I tried to run it on a more modern distro, it reports a different error
message, which fails the test, as shown below:
-touch: setting times of 'SCRATCH_MNT/strict/corac'$'\314\247\303': Invalid argument
-touch: setting times of 'SCRATCH_MNT/strict/cora'$'\303\247\303': Invalid argument
+touch: cannot touch 'SCRATCH_MNT/strict/corac'$'\314\247\303': Invalid argument
+touch: cannot touch 'SCRATCH_MNT/strict/cora'$'\303\247\303': Invalid argument
...
The fix filters out the touch-specific parts of the touch error
messages, to prevent breakage from future changes, but preserves the
return code information, which is actually useful (and more stable).
There is no change in behavior on the kernel side, just a broken test.
On both older and new distros, the kernel correctly rejects this invalid
sequence with -EINVAL, as shown in the strace hunk below:
Tested on Debian sid (coreutils v8.32) and Fedora (coreutils 9.0).
Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christoph Hellwig [Tue, 17 May 2022 06:35:02 +0000 (08:35 +0200)]
fstests: add a btrfs read_repair group
Add a new group to run all tests the exercise the btrfs read_repair code.
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Zorro Lang [Mon, 9 May 2022 17:17:22 +0000 (01:17 +0800)]
generic: soft quota limits testing within grace time
After soft limits are exceeded, within the grace time, fs quota
should allow more space allocation before exceeding hard limits,
even if allocating many small files.
This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump
warning counts when we send warnings"). And will help to expose
later behavior changes on this side.
Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@redhat.com>
Ojaswin Mujoo [Mon, 16 May 2022 08:45:05 +0000 (14:15 +0530)]
common/rc: Modify _require_batched_discard to improve test coverage
A recent ext4 patch discussed [1] that some devices (eg LVMs) can
have a discard granularity as big as 42MB which makes it larger
than the group size of ext4 FS with 1k BS. This causes the FITRIM
IOCTL to fail.
This case was not correctly handled by this test since
"_require_batched_discard" incorrectly interpreted the FITRIM
failure as SCRATCH_DEV not supporting the IOCTL. This caused the test
to report "not run" instead of "failed" in case of large discard granularity.
Fix "_require_batched_discard" to use a more accurate method
to determine if discard is supported.
[1] commit 173b6e383d2
ext4: avoid trim error on fs with small groups
Christian Brauner [Thu, 12 May 2022 16:52:50 +0000 (18:52 +0200)]
vfs/idmapped-mounts: remove invalid test
The threaded mount interaction test validates that the idmapping of a
mount behaves correctly when changed while another process already has a
writable file descriptor to that mount. In newer kernels it isn't
possible to change a mount's idmapped if someone has a writable file
descriptor to that mount.
Link: e1bbcd277a53 ("fs: hold writers when changing mount's idmapping") Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:49 +0000 (18:52 +0200)]
vfstest: split out remaining idmapped mount tests
Split out all the remaining idmapped mount tests into the idmapped
mounts source file.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:48 +0000 (18:52 +0200)]
vfstest: split out btrfs idmapped mounts test
Split the btrfs specific idmapped mounts test into a separate source
file.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:47 +0000 (18:52 +0200)]
vfstest: split idmapped mount tests into separate suite
Now that we finished restructuring split the core idmapped mounts test
suite into a separate source file.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:46 +0000 (18:52 +0200)]
utils: add struct test_suite
Provide a convenient wrapper struct which provides the tests and the
number of tests. The struct can be kept local to each source file so we
are sure that the tests and number of tests is correct.
In vfstest.c we provide a run_suite() function which expects a struct
test_suite and runs the tests provided by that suite.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:45 +0000 (18:52 +0200)]
missing: move sys_execveat() to missing.h
The missing.h header provides syscalls potentially missing from the used
libc. Move the sys_execveat() definition into it. It doesn't belong into
vfstest.c.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:44 +0000 (18:52 +0200)]
utils: move helpers into utils
In order to split the test suite into multiple source files we need to
be able to access generic helpers in all source files not just one. So
move all generic helpers into utils.{c,h}.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:43 +0000 (18:52 +0200)]
utils: add struct vfstest_info
So far we were able to rely on global variables as the idmapped mount
test suite was a single source file. But that gets messy when we split
it into multiple source files in the following patches. Instead of
global variables introduce struct vfstest_info which provides all
information about the test suite run and pass it to all tests.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:42 +0000 (18:52 +0200)]
utils: add missing global.h include
Make sure that utils.{c,h} have access to the necessary defines created
during the configure stage when building xfstests.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:41 +0000 (18:52 +0200)]
vfstest: rename struct t_idmapped_mounts
The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.
As was discussed upstream it's time to rename it to something that
reflects its generic nature.
Rename the basic structure used for the tests from struct
t_idmapped_mounts to struct test_struct.
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:40 +0000 (18:52 +0200)]
src/vfs: rename idmapped-mounts.c file
The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.
As was discussed upstream it's time to rename it to something that
reflects its generic nature. So rename the source file from
idmapped-mounts.c to vfstest.c before we split it into multiple source
files in the next patches.
[Zorro: fix generic/689]
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:39 +0000 (18:52 +0200)]
src: rename idmapped-mounts folder
The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.
As was discussed upstream it's time to rename it to something that
reflects its generic nature. So rename it from idmapped-mounts to vfs.
[Zorro: fix generic/689 and add it into idmapped test group]
Acked-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Thu, 12 May 2022 16:52:38 +0000 (18:52 +0200)]
idmapped-mounts: make all tests set their required feature flags
In commit 858a19c5e9b0 ("idmapped_mounts: Prepare for support for more
features") we introduced a flag argument to check for multiple features
and then decide based on the flag argument whether a test requires a
given feature and skip it if the kernel doesn't provide it.
However, not all tests were ported to the new flag argument and still
use the old infrastructure. Port them all.
Fixes: 858a19c5e9b0 ("idmapped_mounts: Prepare for support for more features") Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Baokun Li [Wed, 11 May 2022 08:34:04 +0000 (16:34 +0800)]
common: xfstests support overlay+tmpfs
The local.config of overlay+tmpfs is as follows:
```local.config.example
export FSTYP=tmpfs
export TEST_DEV=tmpfs_test
export TEST_DIR=/tmp/test
export SCRATCH_DEV=tmpfs_scratch
export SCRATCH_MNT=/tmp/scratch
```
Run `./check -overlay tests` to execute test case on overlay+tmpfs.
Signed-off-by: Baokun Li <libaokun1@huawei.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Yang Xu [Tue, 10 May 2022 05:24:50 +0000 (13:24 +0800)]
generic/68[3-7]: Add separate sgid stripping sub-tests
Like xfstests commit 298f60c ("generic/673: Add separate sgid stripping sub-tests"),
we should also add separate sgid stripping sub-tests for each fallocate operation.
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Eric Biggers [Sat, 30 Apr 2022 19:21:30 +0000 (12:21 -0700)]
ext4/053: fix the rejected mount option testing
'not_mnt OPTIONS' seems to have been intended to test that the
filesystem cannot be mounted at all with the given OPTIONS, meaning that
the mount fails as opposed to the options being ignored. However, this
doesn't actually work, as shown by the fact that the test case 'not_mnt
test_dummy_encryption=v3' is passing in the !CONFIG_FS_ENCRYPTION case.
Actually ext4 ignores this mount option when !CONFIG_FS_ENCRYPTION.
(The ext4 behavior might be changed, but that is besides the point.)
The problem is that the do_mnt() helper function is being misused in a
context where a mount failure is expected, and it does some additional
remount tests that don't make sense in that context. So if the mount
unexpectedly succeeds, then one of these later tests can still "fail",
causing the unexpected success to be shadowed by a later failure, which
causes the overall test case to pass since it expects a failure.
Fix this by reworking not_mnt() and not_remount_noumount() to use
simple_mount() in cases where they are expecting a failure. Also fix
up some of the naming and calling conventions to be less confusing.
Finally, make sure to test that remounting fails too, not just mounting.
Signed-off-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Filipe Manana [Mon, 9 May 2022 14:31:02 +0000 (15:31 +0100)]
generic: test fsync of directory with renamed symlink
Test that if we fsync a directory, create a symlink inside it, rename
the symlink, fsync again the directory and then power fail, after the
filesystem is mounted again, the symlink exists with the new name and
it has the correct content.
This currently fails on btrfs, because the symlink ends up empty (which
is illegal on Linux), but it is fixed by kernel commit:
d0e64a981fd841 ("btrfs: always log symlinks in full mode")
Reviewed-by: David Disseldorp <ddiss@suse.de> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Yang Xu [Sat, 7 May 2022 16:01:27 +0000 (00:01 +0800)]
idmapped-mounts: Add open with O_TMPFILE operation in setgid test
Since we can create temp file by using O_TMPFILE flag and filesystem driver also
has this api, we should also check this operation whether strip S_ISGID.
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Yang Xu [Sat, 7 May 2022 16:01:26 +0000 (00:01 +0800)]
idmapped-mounts: Add mknodat operation in setgid test
Since mknodat can create file, we should also check whether strip S_ISGID.
Also add new helper caps_down_fsetid to drop CAP_FSETID because strip S_ISGID
depend on this cap and keep other cap(ie CAP_MKNOD) because create character
device needs it when using mknod.
Only test mknodat with character device in setgid_create function and the another
two functions test mknodat with whiteout device.
Since kernel commit a3c751a50 ("vfs: allow unprivileged whiteout creation") in
v5.8-rc1, we can create whiteout device in userns test. Since kernel 5.12, mount_setattr
and MOUNT_ATTR_IDMAP was supported, we don't need to detect kernel whether allow
unprivileged whiteout creation. Using fs_allow_idmap as a proxy is safe.
Tested-by: Christian Brauner (Microsoft)<brauner@kernel.org> Reviewed-by: Christian Brauner (Microsoft)<brauner@kernel.org> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Yang Xu [Sat, 7 May 2022 16:01:25 +0000 (00:01 +0800)]
idmapped-mounts: Reset errno to zero before run_test
If we run case on old kernel that doesn't support mount_setattr and
then fail on our own function before call is_setgid/is_setuid function
to reset errno, run_test will print "Function not implement" error.
We also check whether system support user namespace, so reset errno to
zero after userns check.
Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Chandan Babu R [Fri, 6 May 2022 09:57:46 +0000 (15:27 +0530)]
xfs/533: Delete test since directory's extent count can never overflow
The maximum file size that can be represented by the data fork extent counter
in the worst case occurs when all extents are 1 block in length and each block
is 1KB in size.
With XFS_MAX_EXTCNT_DATA_FORK_SMALL representing maximum extent count and with
1KB sized blocks, a file can reach upto,
(2^31) * 1KB = 2TB
This is much larger than the theoretical maximum size of a directory
i.e. XFS_DIR2_SPACE_SIZE * 3 = ~96GB.
Since a directory can never overflow its data fork extent counter, the xfs
kernel driver removed code which checked for such a situation before any
directory modification operation could be executed. Instead, the kernel driver
verifies the sanity of directory's data fork extent counter when the inode is
read from disk.
This commit removes the test xfs/533 due to the reasons mentioned above.
Signed-off-by: Chandan Babu R <chandan.babu@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Dave Chinner [Fri, 6 May 2022 05:10:17 +0000 (15:10 +1000)]
fstests: faster group file creation
We don't need to execute every test just to check it's groups are
valid. Just grab all the groups with grep, pull out the unique ones,
then check them.
This also avoids the problem of editor swap files being present in
the test directory and breaking the build because they are not
executable.
Building on a clean, already built tree so it only builds the
group lists:
$ time make
....
Building udf
[GROUP] /home/dave/src/xfstests-dev/tests/udf/group.list
Building xfs
[GROUP] /home/dave/src/xfstests-dev/tests/xfs/group.list
real 0m36.917s
user 0m15.032s
sys 0m26.219s
$
Patched:
$ time make
....
Building udf
[GROUP] /home/dave/src/xfstests-dev/tests/udf/group.list
Building xfs
[GROUP] /home/dave/src/xfstests-dev/tests/xfs/group.list
groups "frobnozzle" not mentioned in documentation.
gmake[3]: *** [../../include/buildgrouplist:8: group.list] Error 1
gmake[2]: *** [../include/buildrules:31: xfs] Error 2
gmake[1]: *** [include/buildrules:31: tests] Error 2
make: *** [Makefile:51: default] Error 2
real 0m1.751s
user 0m0.863s
sys 0m1.067s
$
Just a little bit faster, and as you can see that it still detects
groups that are not documented. There was also an open .001.swp file
in the XFS directory and that doesn't throw a failure anymore,
either.
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Zorro Lang <zlang@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Amir Goldstein [Tue, 19 Apr 2022 12:56:37 +0000 (15:56 +0300)]
common: print hints for reasons of test failures
Introduce helpers _fixed_by_{kernel,git}_commit() and
_fixed_in_{kernel_,}version() that can be used to hint testers why a
test might be failing and aid in auto-generating of expunge lists for
downstream kernel testing.
A test may be annotated with multiple hints, for example:
Annotate fix kernel commits for some overlayfs tests.
Annotate fix kernel version for some overlayfs tests testing
for legacy behavior whose fixes are not likely to be backported
to stable kernels.
This is modeled after LTP's 'make filter-known-fails' and
print_failure_hints() using struct tst_tag annotations.
Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Amir Goldstein [Tue, 19 Apr 2022 12:56:36 +0000 (15:56 +0300)]
common: support black listing fs in _supported_fs()
For example:
_supported_fs ^xfs
There is no need to specify "generic" when using a block list
"all other fs are supported" is implied.
Converted some generic tests that open code this condition without
emitting a meaningful reason.
More generic test like generic/186,187 could use a block list, but
were not converted because they emit some meaningful reason:
_notrun "Can't fragment free space on btrfs."
Signed-off-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Josef Bacik [Thu, 28 Apr 2022 15:05:00 +0000 (11:05 -0400)]
fstests: add some missing _require_loop's
Got a new box running overnight fstests and noticed a couple of failures
because I forgot to enable loop device support. Fix these two tests to
have _require_loop so they don't fail if there's no loop device support.
Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Zorro Lang [Tue, 26 Apr 2022 06:24:11 +0000 (14:24 +0800)]
fsstress: remove ALLOCSP and FREESP operations entirely
Due to upstream linux has removed ALLOCSP/FREESP ioctls by commit: 4d1b97f9ce7c0 ("xfs: kill the XFS_IOC_{ALLOC,FREE}SP* ioctls"), so
let's remove ALLOCSP/FREESP testing from fsstress, to avoid more
mismatch problems.
Due to g/070 specified "-f allocsp" and "-f freesp=0", so remove
these two lines too.
Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
fstests: btrfs: test setting compression via xattr on nodatacow files
Compression and nodatacow are mutually exclusive. Besides ioctl, there
is another way to setting compression via xattrs, and shouldn't produce
invalid combinations.
Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com> Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Eric Sandeen [Tue, 26 Apr 2022 05:14:53 +0000 (00:14 -0500)]
fstests: remove xfs/144
This test was designed to validate the quota warning limit, which in
theory was supposed to migrate from a soft quota to hard enforcement
after a certain number of warnings. However, the xfs kernel commit
which incremented the warning counter was reverted; see:
xfs: revert "xfs: actually bump warning counts when we send warnings"
in the kernel tree for an explanation of why. Due to that revert,
which removed this functionality, remove this test.
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>
generic/681, generic/682: add debugging information to $seqreq.full
These two tests are checking whether a non-privileged user causing a
block allocation while expanding a directory block when over quota
will fail with an EDQUOT error. There are three reasons why this can
fail.
* Aa test bug, where if the file system is using cluster allocation
(for example, ext4 bigalloc) the test doesn't add enough directory
entries to actually force directory grwoth.
* A file system bug, where the file system allocates blocks but for
some reason isn't charging the space quota correctly (which
currently seems to be the case in ext4 with fscrypt).
* A file system bug, where the file system is correctly charging the
space quota to the unprivileged user, but isn't failing the system
call with EDQUOT.
By adding some additional debugging information about whether
directory has grown or not (in addition to the existing repquota
output) to the the $seqres.full, it makes easier for the file system
developer to disambiguate between these possibilities. It's cheap to
do this, and it could save developer time when trying to root cause
the failure.
Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
After coreutils rebasing to 9.1, chown(1) behavior changes:
"
chown and chroot now warn about usages like "chown root.root f",
which have the nonstandard and long-obsolete "." separator that
causes problems on platforms where user names contain ".".
Applications should use ":" instead of ".".
"
https://lwn.net/Articles/891574/
With this behavior change, old format of ownership string will cause
warning like this:
"
+chown: warning: '.' should be ':': '1000.1000'
+.chown: warning: '.' should be ':': '1100.1100'
+.chown: warning: '.' should be ':': '1200.1200'
+.chown: warning: '.' should be ':': '1300.1300'
+.chown: warning: '.' should be ':': '1400.1400'
"
The new format works fine with old versions of coreutils.
Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com> Reviewed-by: Zorro Lang <zlang@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Christian Brauner [Wed, 20 Apr 2022 17:52:22 +0000 (19:52 +0200)]
generic: add test for tmpfs POSIX ACLs
Add a regression test for commit 705191b03d50 ("fs: fix acl translation").
This tests whether setting POSIX ACLs on a tmpfs mounted in a
non-initial user and mount namespace works as expected.
Note, once again the idmapped mount testsuite is grossly misnamed at
this point. It has morphed into a full-blown generic vfs feature
testsuite.
Cc: Eryu Guan <guaneryu@gmail.com> Cc: Seth Forshee <sforshee@digitalocean.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Zorro Lang <zlang@redhat.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Zorro Lang <zlang@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Darrick J. Wong [Tue, 19 Apr 2022 17:32:15 +0000 (10:32 -0700)]
xfs: make sure syncfs(2) passes back super_operations.sync_fs errors
This is a regression test to make sure that nonzero error returns from
a filesystem's ->sync_fs implementation are actually passed back to
userspace when the call stack involves syncfs(2).
[zlang@ add '_supported_fs xfs' in case]
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Rishabh Dave [Tue, 19 Apr 2022 17:58:11 +0000 (23:28 +0530)]
cephfs: add ceph-fuse suport for ceph-fuse
Currently tests in xfstests-dev can be executed against CephFS only by
mounting CephFS using kernel driver. Attempting to run tests against
CephFS using FUSE doesn't work because xfstests-dev would remount CephFS
using kernel. This patch adds the ability for xfstest-dev code to mount
CephFS using FUSE.
[Zorro add missed ";;" in common/rc]
Fixes: https://tracker.ceph.com/issues/55354 Signed-off-by: Rishabh Dave <ridave@redhat.com> Reviewed-by: Jeff Layton <jlayton@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Darrick J. Wong [Tue, 19 Apr 2022 17:32:00 +0000 (10:32 -0700)]
xfs/019: fix golden output for files created in setgid dir
A recent change to xfs/019 exposed a long-standing bug in mkfs where
it would always set the gid of a new child created in a setgid directory
to match the gid parent directory instead of what's in the protofile.
Ignoring the user's directions is not the correct behavior, so update
this test to reflect that. Also don't erase the $seqres.full file,
because that makes forensic analysis pointlessly difficult.
Cc: Catherine Hoang <catherine.hoang@oracle.com> Fixes: 7834a740 ("xfs/019: extend protofile test") Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Zorro Lang <zlang@kernel.org>
Eric Sandeen [Mon, 18 Apr 2022 17:03:26 +0000 (01:03 +0800)]
xfs: test xfsdump when an inode < root inode is present
This tests a longstanding bug where xfsdumps are not properly
created when an inode is present on the filesytsem which has
a lower number than the root inode.
Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Zorro Lang [Wed, 20 Apr 2022 16:07:56 +0000 (00:07 +0800)]
fstests: remove _wipe_fs from dump testing entirely
The _wipe_fs function in common/dump is a historical remnant of
xfstests, it's easy to cause confusion now. Now xfstests tend to
call `require_scratch && scratch_mkfs && scratch_mount` in each case
itself, we don't need to use a function to do that specially, so
remove _wipe_fs entirely.
Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Jan Kara [Thu, 31 Mar 2022 11:19:20 +0000 (13:19 +0200)]
generic/633: Avoid failure without CONFIG_USER_NS
Some tests in idmapped_mounts fail without CONFIG_USER_NS because they
have implicit dependence on user namespaces and these tests are run
despite idmapped mount support not being detected. Detect whether at
least user namespaces are supported and skip tests needing them when
they are not.
Signed-off-by: Jan Kara <jack@suse.cz> Tested-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Jan Kara [Thu, 31 Mar 2022 11:19:19 +0000 (13:19 +0200)]
idmapped_mounts: Prepare for support for more features
Currently idmapped_mounts tests fail for kernels without CONFIG_USER_NS
because some tests are run despite missing support for idmapped mounts
and they implicitely require user namespace support. Prepare
idmapped_mounts to support more features a test may require to reliably
run.
Signed-off-by: Jan Kara <jack@suse.cz> Tested-by: Christian Brauner (Microsoft) <brauner@kernel.org> Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Zorro Lang <zlang@kernel.org>
Darrick J. Wong [Mon, 11 Apr 2022 22:54:54 +0000 (15:54 -0700)]
generic: test that renaming into a directory fails with EDQUOT
Add a regression test to make sure that unprivileged userspace renaming
within a directory fails with EDQUOT when the directory quota limits have
been exceeded.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Mon, 11 Apr 2022 22:54:48 +0000 (15:54 -0700)]
generic: test that linking into a directory fails with EDQUOT
Add a regression test to make sure that unprivileged userspace linking
into a directory fails with EDQUOT when the directory quota limits have
been exceeded.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Dave Chinner [Mon, 11 Apr 2022 05:48:33 +0000 (15:48 +1000)]
generic/019: kill background processes on interrupt
If you ctrl-c generic/019, it leaves fsstress processes running.
Kill them in the cleanup function so that they don't have to be
manually killed after interrupting the test.
While touching the _cleanup() function, make it do everything that
the generic _cleanup function it overrides does and fix the
indenting.
[Eryu: unset fs_pid and fio_pid after wait]
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Mon, 11 Apr 2022 22:55:02 +0000 (15:55 -0700)]
common/rc: let xfs_scrub tell us about its unicode checker
Now that xfs_scrub can report whether or not it was built with the
Unicode name checker, rewrite _check_xfs_scrub_does_unicode to take
advantage of that. This supersedes the old method of trying to observe
dynamic library linkages and grepping the binary, neither of which
worked very well.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Luís Henriques [Wed, 23 Mar 2022 16:09:25 +0000 (16:09 +0000)]
ceph/001: add extra check for remote object copies
Ceph kernel client now has a facility to check stats for certain
operations. One of these operations is the 'copyfrom', the
operation that is used to offload to the OSDs the copy of objects
from, for example, the copy_file_range() syscall.
This patch changes ceph/001 to add an extra check to verify that the
copies performed by the test are _really_ remote copies and not
simple read+write operations.
Eric Whitney [Thu, 14 Apr 2022 14:22:58 +0000 (10:22 -0400)]
common/filter: extend _filter_xfs_io to match -nan
When run on ext4 with sufficiently fast x86_64 hardware, generic/130
sometimes fails because xfs_io can report rate values as -nan:
0.000000 bytes, 0 ops; 0.0000 sec (-nan bytes/sec and -nan ops/sec)
_filter_xfs_io matches the strings 'inf' or 'nan', but not '-nan'. In
that case it fails to convert the actual output to a normalized form
matching generic/130's golden output. Extend the regular expression
used to match xfs_io's output to fix this.
Signed-off-by: Eric Whitney <enwlinux@gmail.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Eric Biggers [Thu, 14 Apr 2022 07:19:32 +0000 (00:19 -0700)]
common/encrypt: use a sub-keyring within the session keyring
Make the encryption tests create and use a named keyring "xfstests" in
the session keyring that the tests happen to be running under, rather
than replace the session keyring using 'keyctl new_session'.
Unfortunately, the latter doesn't work when the session keyring is owned
by a non-root user, which (depending on the Linux distro) can happen if
xfstests is run in a sudo "session" rather than in a real root session.
This isn't a great solution, as the lifetime of the keyring will no
longer be tied to the tests as it should be, but it should work. The
alternative would be the weird hack of making the 'check' script
re-execute itself using something like 'keyctl session - $0 $@'.
Reported-by: Ritesh Harjani <ritesh.list@gmail.com> Signed-off-by: Eric Biggers <ebiggers@google.com>
Darrick J. Wong [Mon, 11 Apr 2022 22:54:22 +0000 (15:54 -0700)]
xfs/187: don't rely on FSCOUNTS for free space data
Currently, this test relies on the XFS_IOC_FSCOUNTS ioctl to return
accurate free space information. It doesn't. Convert it to use statfs,
which uses the accurate versions of the percpu counters. Obviously,
this only becomes a problem when we convert the free rtx count to use
(sloppier) percpu counters instead of the (more precise and previously
buggy) ondisk superblock counts.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
David Disseldorp [Wed, 13 Apr 2022 16:44:22 +0000 (18:44 +0200)]
generic/020: fix max_attrval_size output filter
The current attr -g "$max_attrval_name" output filter is broken if
$max_attrval_size isn't 16-byte aligned, due to od's duplicate
suppression behaviour.
Fix it by having od only dump one byte per line.
Signed-off-by: David Disseldorp <ddiss@suse.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
David Disseldorp [Wed, 13 Apr 2022 16:44:21 +0000 (18:44 +0200)]
generic/020: fix max_attrval_size for XFS, UDF, Btrfs and NFS
As found by Dave Chinner, fff4359d ("020: make this xattr test generic")
unintentionally changed the long attribute value length from 100K to 64
*bytes* for XFS, UDF and Btrfs.
Update XFS and UDF to use a 64K $max_attrval_size value. For Btrfs, use
the nodesize, xattr length and tree entry overhead sizes to calculate
the maximum.
NFS doesn't provide a way to find out the $max_attrval_size for the
underlying filesystem on the server, so just use a rough 1K limit.
David Disseldorp [Wed, 13 Apr 2022 16:44:20 +0000 (18:44 +0200)]
generic/020: add and use _attr_get_max()
In preparation for taking into account the attr name length when
calculating $MAX_ATTRVAL_SIZE, put the current logic in a
_attr_get_max() helper function and set local $max_attrval_size /
$max_attrs variables instead of using export.
Filipe Manana [Mon, 11 Apr 2022 14:08:38 +0000 (15:08 +0100)]
common/rc: fix _try_scratch_mount() and _test_mount() when mount fails
After the recent commit 4a7b35d7a76cd9 ("common: allow to run all tests
on idmapped mounts"), some test that use _try_scratch_mount started to
fail. For example:
btrfs/131 2s ... - output mismatch (see .../results//btrfs/131.out.bad)
--- tests/btrfs/131.out 2020-06-10 19:29:03.818519162 +0100
+++ /home/fdmanana/git/hub/xfstests/results//btrfs/131.out.bad (...)
@@ -6,8 +6,6 @@
Disabling free space cache and enabling free space tree
free space tree is enabled
Trying to mount without free space tree
-mount failed
-mount failed
Mounting existing free space tree
free space tree is enabled
...
(Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/131.out ...
btrfs/220 7s ... - output mismatch (see .../results//btrfs/220.out.bad)
--- tests/btrfs/220.out 2020-10-16 23:13:46.802162554 +0100
+++ /home/fdmanana/git/hub/xfstests/results//btrfs/220.out.bad (...)
@@ -1,2 +1,32 @@
QA output created by 220
+Option fragment=invalid should fail to mount
+umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
+Option nologreplay should fail to mount
+umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
+Option norecovery should fail to mount
+umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
...
(Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/220.out ...
Ran: btrfs/131 btrfs/220
Failures: btrfs/131 btrfs/220
Failed 2 of 2 tests
The reason is that if _try_scratch_mount() fails to mount the filesystem,
we don't return the failure, instead we call _idmapped_mount(), which
can succeed and make _try_scratch_mount() return 0 (success). The same
happens for _test_mount(), however a quick search revealed no tests
currently relying on the return value of _test_mount().
So fix that by making _try_scratch_mount() return immediately if it gets
a mount failure. Also do the same for _test_mount().
Signed-off-by: Filipe Manana <fdmanana@suse.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Zorro Lang [Mon, 11 Apr 2022 16:37:10 +0000 (00:37 +0800)]
fstests: test dirty pipe vulnerability issue of CVE-2022-0847
Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an
uninitialized "pipe_buffer.flags" variable. The bug cause a file
can be overwritten even if a user/process is not permitted to write
it. It's fixed by 9d2231c5d74e ("lib/iov_iter: initialize "flags" in
new pipe_buffer").
Cc: Max Kellermann <max.kellermann@ionos.com> Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Zorro Lang [Mon, 11 Apr 2022 16:37:09 +0000 (00:37 +0800)]
fstests: replace hexdump with od command
The "od" is one of the most fundamental commands in GNU/Linux and
most Unix-like systems. So we nearly always can count on it, don't
need to check if it's installed.
The "hexdump" isn't such fundamental as "od", some systems don't
install it by default. And as "od" nearly can replace all functions
of "hexdump", so let's use an unified command "od" to do the hexdump
job in fstests cases.
Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Christian Brauner [Thu, 7 Apr 2022 11:21:57 +0000 (13:21 +0200)]
common: allow to run all tests on idmapped mounts
In addition to the generic and filesystem-specific idmapped mount
testsuites that already exist upstream today add simple
infrastructure so any test can be run on idmapped mounts simply by
setting IDMAPPED_MOUNTS=true in the config file or section. The main
user for now will be overlay to verify it works correctly on
idmapped mounts.
Note that the infrastructure is completely generic so every
filesystem that supports idmapped mounts can simply run all of their
tests idmapped. But note that not all ways to create a mount have
been converted yet. That includes e.g. _dmthin_mount and direct
calls to _mount in various tests.
In addition, there will be corner-cases. For example, xfs doesn't
allow bulkstat on idmapped mounts because it is a filesystem wide
operation, i.e. you can retrieve information for any inode in the
filesystem so the operation cannot be scoped reasonably under a
single mount. So xfstests testing bulkstat will fail as it's
blocked. Similar for some btrfs ioctl()s.
While we could of course restrict this testmode to -overlay for
which we know things work correctly we should not do this. It would
mean that people won't start using it and so we won't see issues
unless someone sits down and goes through more than 1000 tests and
figures out for each individual one whether it needs to be skipped
or not.
So instead allow this mode but for all filesystems so people can
start running and reporting failures and we can fix them up or block
them as we detect them.
Cc: Eryu Guan <guaneryu@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: <fstests@vger.kernel.org> Reviewed-by: Amir Goldstein <amir73il@gmail.com> Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/encrypt: allow the use of 'fscrypt:' as key prefix
fscrypt keys have used the $FSTYP as prefix. However this format is being
deprecated and newer kernels are expected to use the generic 'fscrypt:'
prefix instead. This patch adds support for this new prefix, and only
uses $FSTYP on filesystems that didn't initially supported it, i.e. ext4 and
f2fs. This will allow old kernels to be tested.
Zorro Lang [Wed, 30 Mar 2022 05:25:06 +0000 (13:25 +0800)]
fsx: remove XFS_IOC_ALLOCSP operation entirely
Due to XFS_IOC_ALLOCSP is nearly retired from linux xfs, and the
ALLOCSP testing in fsx easily trigger errors. So compare with
disable it by default, I'd like to remove it entirely. So this patch
revert two patches:
cd99a499 ("fsx: disable allocsp_calls if -F is specified") a32fb1bb ("fsx: add support for XFS_IOC_ALLOCSP")
Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Pankaj Raghav [Fri, 25 Mar 2022 10:19:08 +0000 (11:19 +0100)]
btrfs/237: Use zone cap instead of zone size in fill_size and rest calculation
This test will break when zone capacity != zone size because the
calculation of the size to be filled is done using zone_size instead
of the actual capacity available per zone. Fix it by using zone
capacity.
As a zoned device can have variable capacity, use the btrfs utility
to get the zone capacity from the first data block group that the
test will be performed on.
The support to extract zone capacity was added to blkzone only from
version 2.37. So zcap will be used only when the blkzone version is
greater or equal to 2.37.