Qu Wenruo [Fri, 28 Jan 2022 00:27:00 +0000 (08:27 +0800)]
btrfs: autodefrag with regular and hole extents
In v5.11~v5.15 kernels, there is a regression in autodefrag that if
a cluster (up to 256K in size) has even a single hole, the whole
cluster will be rejected.
This will greatly reduce the efficiency of autodefrag.
The behavior is fixed in v5.16 by a full rework, although the rework
itself has other problems, it at least solves the problem.
Here we add a test case to reproduce the case, where we have a 128K
cluster, the first half is fragmented extents which can be
defragged. The second half is hole.
Qu Wenruo [Fri, 28 Jan 2022 00:26:59 +0000 (08:26 +0800)]
btrfs: defrag with regular and preallocated extents
Recent v5.16 has some regression around btrfs autodefrag mount
option, and the extra scrutiny around defrag code exposes some
questionable behavior from the old code.
One behavior is to defrag extents along with the next preallocated
extent.
This behavior will cause extra IO and convert all the preallocated
extent to regular zero filled extents, rendering the preallocated
extent useless.
The kernel fix is titled:
btrfs: defrag: don't try to merge regular extents with preallocated extents
Zorro Lang [Sat, 29 Jan 2022 04:44:31 +0000 (12:44 +0800)]
fsx: disable allocsp_calls if -F is specified
As the fsx.c source code says:
int fallocate_calls = 1; /* -F flag disables */
int allocsp_calls = 1; /* -F flag disables */
The allocsp_calls and fallocate_calls should be disabled, if the -F
option is specified. But current fsx forgets to disable allocsp_calls
as is documented.
Signed-off-by: Zorro Lang <zlang@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Theodore Ts'o [Tue, 1 Feb 2022 23:19:36 +0000 (18:19 -0500)]
common: handle old versions of modprobe which don't support --help
There exists versions of modprobe out there which are so old that
modprobe --help isn't a thing. They're certainly not going to support
modprobe --remove-patiently, so test to make sure modprobe --help
works to avoid causing all tests to fail due to the error message
to stderr showing up in $seq.out.
Anthony Iliopoulos [Fri, 21 Jan 2022 13:58:02 +0000 (14:58 +0100)]
common/dump: add explicit requirement for specific users and groups
Make the requirement for daemon:sys and bin:bin explicit, so that the
xfs tests that source common/dump and rely on _do_create_dumpdir_fill
and _create_dumpdir_symlinks do not fail on chown when those
users/groups are missing.
Anthony Iliopoulos [Fri, 21 Jan 2022 13:58:01 +0000 (14:58 +0100)]
common/rc: fix group detection regex to strictly match required name
_require_group greps for the required group string in /etc/group but
this can partially match other groups or group member names and falsely
return success where it should fail.
Make the regex more specific so that it can unambigiously match only the
exact group name rather than any other group that happens to match as a
substring or any matching username from the group member list field.
Darrick J. Wong [Mon, 24 Jan 2022 18:37:35 +0000 (10:37 -0800)]
generic/273: use _get_file_block_size
This test calculates the amount of free space on a filesystem and uses
the block size to spread the work of filling the free space among a
bunch of threads. Unfortunately, the test /should/ be using the
allocation unit size, not the fs block size, which is why this test
fails on configurations such as XFS realtime with a 28k extent size.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Leah Rumancik <leah.rumancik@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Christian Brauner [Tue, 18 Jan 2022 14:13:24 +0000 (15:13 +0100)]
idmapped-mounts: always run generic vfs tests
Make it possible to always run all the tests in the testsuite that don't
require idmapped mounts. Now all filesystems can benefit from the
generic vfs tests that we currently implement. This means setgid
inheritance and other tests will be run for all filesystems not matter
if they support idmapped mounts or not.
To this end, the binary makes use of the fs_allow_idmap() helper we
introduced earlier to dynamically determine whether the underlying
filesystem supports idmapped mounts or not. It is therefore safe for
callers to call the binary even if the tested filesystem doesn't support
idmapped mounts.
Most of the tests that call the idmapped mount binary require idmapped
mount support and so they will continue to call
_require_idmapped_mounts. This will also ensure that we log a proper
message about skipping a whole test.
However, the generic/633 test includes idmapped mount specific and
generic tests. The generic tests can and should always be executed as
they test core vfs functionality that isn't tested anywhere else in
fstests. So here we can remove the _require_idmapped_mounts check from
the test and rely on the binary doing the right thing.
Christian Brauner [Tue, 18 Jan 2022 14:13:23 +0000 (15:13 +0100)]
idmapped-mounts: add fs_allow_idmap() helper
Move the check whether the underlying filesystem supports idmapped
mounts into a separate helper. We will use it in the following patch to
make it possible to always run all tests that don't require idmapped
mounts.
Lukas Czerner [Thu, 20 Jan 2022 10:20:25 +0000 (11:20 +0100)]
ext4/053: Test remount without changing mount options
With the recent ext4 mount api change we discovered a bugs that weren't
caught by this test. It was triggered by remounting the file system
either with the same mount options, or without specifying any mount
options at all. In this case we would expect the original mount options
to remain the same, however this was either not the case, or the remount
failed.
Add a remount test after a regular mount. Remount once with specifying
the original mount option and remount second time without specifying
anything. Test the active options after each test.
Additionally include all the combinations of data= options in the
remount test for the sake of completeness.
Filipe Manana [Tue, 18 Jan 2022 16:36:52 +0000 (16:36 +0000)]
btrfs: test that defrag on small files does not hang or crashes
Test that defragging files with very small sizes works and does not
result in any crash, hang or corruption.
This is motivated by a regression introduced in kernel 5.16 where
attempting to defrag a file with a size of 1 byte would result in
the kernel code hitting an "infinite" loop (iterating from 0 to
(u64)-1 in increments of 256K, which in practice is an eternity).
The regression is fixed by a patch with the following subject:
"btrfs: fix too long loop when defragging a 1 byte file"
Shin'ichiro Kawasaki [Wed, 19 Jan 2022 02:25:31 +0000 (11:25 +0900)]
btrfs: add test for quota disable in parallel with balance
Test quota disable during btrfs balance and confirm it does not
cause kernel hang. This is a regression test for the problem
reported to linux-btrfs list [1].
The hang was recreated using the test case and memory backed
null_blk device with 5GB size as the scratch device, and fixed by
kernel patch titled
btrfs: fix deadlock between quota disable and qgroup rescan worker
Darrick J. Wong [Thu, 20 Jan 2022 00:49:44 +0000 (16:49 -0800)]
xfs/107: fix formatting failures
Zorro Lang reported that the _scratch_mkfs_sized call in the new xfs/107
fstest sometimes fails on more exotic storage due to insufficient log
size on account of raid stripes, etc. These are side effects of the
filesystem being too small.
Change the filesystem size to 256M to avoid these problems, and change
the allocstale parameters to use the same file size (16M) as before.
Given that ALLOCSP produces stale disk contents pretty quickly this
shouldn't affect the test runtime too much.
Reported-by: Zorro Lang <zlang@redhat.com> 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 [Tue, 18 Jan 2022 18:29:10 +0000 (10:29 -0800)]
iogen: upgrade to fallocate
Update this utility to use fallocate to preallocate/reserve space to a
file so that we're not so dependent on legacy XFS ioctls. Fix a minor
whitespace error while we're at it.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Yang Xu [Mon, 17 Jan 2022 07:36:54 +0000 (15:36 +0800)]
src/ext4_resize.c: set errno to 0 before the strtoull call
On my test machine, ext4/033 fails even use the non-overflow size.
It reports invalid new size when using strtoull because errno is 1.
As man-pages said "Since strtoul() can legitimately return 0 or ULONG_MAX
(ULLONG_MAX for strtoull()) on both success and failure, the calling program
should set errno to 0 before the call, and then determine if an error occurred
by checking whether errno has a nonzero value after the call".
So add a step to set errno to 0 before strtoull call.
Fixes: 92b9c0dedace ("ext4/033: test EXT4_IOC_RESIZE_FS by calling the ioctl directly") Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Tue, 11 Jan 2022 21:50:30 +0000 (13:50 -0800)]
xfs: test fixes for new 5.17 behaviors
xfs/308 and xfs/130 are two tests that tried to mess with the refcount
btree to try to trip up the COW recovery code. Now that we've made COW
recovery only happen during log recovery, we must adjust these tests to
force a log recovery. Older kernels should be ok with this, since they
unconditionally try to recover COW on mount.
Add a helper function to unmount the filesystem with a dirty log and
convert the two tests to use it. While we're at it, remove an xfs_check
test because xfs_check refuses to run on a dirty fs, and nobody cares
about xfs_check anymore.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Tue, 11 Jan 2022 21:50:24 +0000 (13:50 -0800)]
xfs/220: fix quotarm syscall test
In commit 6ba125c9, we tried to adjust this fstest to deal with the
removal of the ability to turn off quota accounting via the Q_XQUOTAOFF
system call.
Unfortunately, the changes made to this test make it nonfunctional on
those newer kernels, since the Q_XQUOTARM command returns EINVAL if
quota accounting is turned on, and the changes filter out the EINVAL
error string.
Doing this wasn't /incorrect/, because, very narrowly speaking, the
intent of this test is to guard against Q_XQUOTARM returning ENOSYS when
quota has been enabled. However, this also means that we no longer test
Q_XQUOTARM's ability to truncate the quota files at all.
So, fix this test to deal with the loss of quotaoff in the same way that
the others do -- if accounting is still enabled after the 'off' command,
cycle the mount so that Q_XQUOTARM actually truncates the files.
While we're at it, enhance the test to check that XQUOTARM actually
truncated the quota files.
Fixes: 6ba125c9 ("xfs/220: avoid failure when disabling quota accounting is not supported") Cc: xuyang2018.jy@fujitsu.com Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by:Yang Xu <xuyang2018.jy@fujitsu.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Tue, 11 Jan 2022 21:50:19 +0000 (13:50 -0800)]
common/rc: fix unicode checker detection in xfs_scrub
_check_xfs_scrub_does_unicode is still less than adequate -- if running
ldd to report the xfs_scrub binary's dynamic library dependencies
doesn't work, we could still detect support by grepping for strings that
only appear when the unicode checker is built.
Note that this isn't the final word on all of this; I will make this
easier to discover in a future xfs_scrub release.
Cc: Theodore Ts'o <tytso@mit.edu> Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Qu Wenruo [Tue, 11 Jan 2022 00:36:46 +0000 (08:36 +0800)]
btrfs/011: continue the test if we failed to cancel the replace
Btrfs/011 test case has exposed quite some bugs in the past, but it also
has some tendency to cause false alert, as its way testing replace
cancel require the replace to be still running when we send the cancel
request.
But on a lot of cases, the replace can finish way faster than the wait
time, and cause false alert.
Commit fa85aa64 ("btrfs/011: Fill the fs to ensure we have enough data for
dev-replace") tries to address the problem by filling the fs, but there
is still no guarantee.
Although there is still some discussion on how to properly solve the
problem, there is one thing sure that we should continue the test
instead of abort, if the replace cancel failed.
A quick abort caused by finished replace will leave other profiles
untested, reducing the coverage.
This patch will still mark the test failed for a finished replace, but
at least ensure we have run the test for all the profiles.
Shiyang Ruan [Wed, 12 Jan 2022 09:28:46 +0000 (17:28 +0800)]
generic/670: allow _mread_range() races with reflink_range()
mread copies data one-byte-at-a-time, so it may races with
reflink_range() who invalidates page cache of the dest file.
Allow this race by adjusting the egrep regexp.
Reported-by: Darrick J. Wong <djwong@kernel.org> Suggested-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Theodore Ts'o [Sun, 9 Jan 2022 19:59:35 +0000 (14:59 -0500)]
common/rc: fix _check_xfs_scrub_does_unicode on newer versions of libc-bin
Debian 10 uses ldd from glibc 2.28, where as Debian 11 uses ldd from
glibc 2.31. Sometime between glibc 2.28 and 2.31, ldd has been
changed so that the message "not a dynamic executable" is sent stderr,
where before it was sent to stdout. As a result, it caused
regressions for tests such as generic/453 which uses
_check_xfs_scurb_does_unicode:
generic/453 5s ... [22:42:03] [22:42:08]- output mismatch (see /results/xfs/results-4k/generic/453.out.bad)
--- tests/generic/453.out 2022-01-08 15:15:15.000000000 -0500
+++ /results/xfs/results-4k/generic/453.out.bad 2022-01-08 22:42:08.596982251 -0500
@@ -4,3 +4,4 @@
Test files
Uniqueness of inodes?
Test XFS online scrub, if applicable
+ not a dynamic executable
...
Fix this by sending stderr from ldd to /dev/null. This is not a
perfect solution, since it means that even if xfs_scrub was compiled
with libicui18n, we will skip the online scrub portion of generic/453.
However, this fixes the regression when runtime OS is changed from
Debian Buster to Debian Bullseye when xfsprogs is built statically.
In the long run, it would be nice if we could determine whether
xfs_scrub has unicode support without using ldd --- perhaps by
signally this in the output of xfs_scrub -V --- but we'll need to
discuss this with the xfsprogs maintainers.
Signed-off-by: Theodore Ts'o <tytso@mit.edu> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Christian Brauner [Fri, 7 Jan 2022 14:58:18 +0000 (15:58 +0100)]
idmapped-mounts: add missing ownership comparisons to setgid tests
In some setgid tests we missed to check ownership right after file or
directory creation in order to verify whether gid ownership inheritance
from the parent directory to the newly created file or directory works
correctly. Add the missing ones.
Cc: Seth Forshee <sforshee@digitalocean.com> Cc: Eryu Guan <guaneryu@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Cc: fstests@vger.kernel.org Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Jeff Layton [Thu, 6 Jan 2022 13:30:49 +0000 (08:30 -0500)]
ceph/001-003: skip if test_dummy_encryption is enabled
Some tests on ceph require changing the layout of new files, which
is forbidden when the files are encrypted. Skip these tests if the
test_dummy_encryption mount option is being used.
Generalize the _exclude_scratch_mount_option code and add a new
_exclude_test_mount_option call as well. Call the new function from the
ceph tests that should exclude test_dummy_encryption.
Cc: Luis Henriques <lhenriques@suse.de> Cc: Eric Biggers <ebiggers@kernel.org> Signed-off-by: Jeff Layton <jlayton@kernel.org> Reviewed-by: Eric Biggers <ebiggers@google.com> Reviewed-by: Luis Henriques <lhenriques@suse.de> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Darrick J. Wong [Tue, 4 Jan 2022 02:04:17 +0000 (18:04 -0800)]
xfs/014: try a few times to create speculative preallocations
This test checks that speculative file preallocations are transferred to
threads writing other files when space is low. Since we have background
threads to clear those preallocations, it's possible that the test
program might not get a speculative preallocation on the first try.
This problem has become more pronounced since the introduction of
background inode inactivation since userspace no longer has direct
control over the timing of file blocks being released from unlinked
files. As a result, the author has seen an increase in sporadic
warnings from this test about speculative preallocations not appearing.
Therefore, modify the function to try up to five times to create the
speculative preallocation before emitting warnings that then cause
golden output failures.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Anand Jain [Wed, 5 Jan 2022 06:03:20 +0000 (14:03 +0800)]
btrfs/254: fix non-unique fsid issue
This test case needs two scratch fs. For debugging purposes, a fsid is
kept known. However, mkfs-btrfs has a stringent and inconsistent
approach, to check if that fsid is already present on any of the other
disks in the system. (This does not apply to the virtual devices in the
system).
To avoid running into the non-unique fsid found error, remove the known
fsid.
Darrick J. Wong [Tue, 4 Jan 2022 02:07:46 +0000 (18:07 -0800)]
xfs/107: remove long-broken test
This poorly implemented test runs fsstress and embeds xfs_quota output
in the golden output. This means that it breaks as soon as anyone adds
a new operation to fsstress, since that perturbs the sequence of
operations that it runs, which will make the project quota report output
change.
Normally I'd just fix the test, but the golden output also encodes
output strings that xfs_quota hasn't printed since 2010. Clearly
nobody's running this test (including me, who has had it turned off for
five+ years) so just get rid of it.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Zorro Lang <zlang@redhat.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Anand Jain [Fri, 10 Dec 2021 18:14:41 +0000 (02:14 +0800)]
btrfs: test cleaning up of the stale device
Recreating a new filesystem or adding a device to a mounted the
filesystem should remove the device entries under its previous fsid
even when confused with different device paths to the same device.
Shiyang Ruan [Tue, 14 Dec 2021 08:19:11 +0000 (16:19 +0800)]
generic: add mmap CoW test for mixed&source extents
Ensuring that copy on write in mmap mode works when the CoW range
originally covers multiple extents, mixed with reflinked, unwritten,
hole, regular and delalloc blocks.
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:19:10 +0000 (16:19 +0800)]
generic: add direct-io CoW test for mixed&source extents
Ensuring that copy on write in direct-io mode works when the CoW
range originally covers multiple extents, mixed with reflinked,
unwritten, hole, regular and delalloc blocks.
Shiyang Ruan [Tue, 14 Dec 2021 08:19:09 +0000 (16:19 +0800)]
generic: add buffered-io CoW test for mixed&source extents
Ensuring that copy on write in buffered mode works when the CoW
range originally covers multiple extents, mixed with reflinked,
unwritten, hole, regular and delalloc blocks.
Shiyang Ruan [Tue, 14 Dec 2021 08:19:08 +0000 (16:19 +0800)]
generic: add mmap CoW test for delalloc&source extents
Ensuring that copy on write in mmap mode to the source file when the CoW range
covers delalloc blocks and regular shared blocks.
(MMAP version of generic/293,295)
Shiyang Ruan [Tue, 14 Dec 2021 08:19:07 +0000 (16:19 +0800)]
generic: add mmap CoW test for holes&source extents
Ensuring that copy on write in mmap mode to the source file when the CoW range
covers holes and regular shared blocks.
(MMAP version of generic/291,292)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:19:06 +0000 (16:19 +0800)]
generic: add mmap CoW test for unwritten&source extents
Ensuring that copy on write in mmap mode to the source file when the CoW range
covers unwritten and regular shared blocks.
(MMAP version of generic/289,290)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:19:05 +0000 (16:19 +0800)]
generic: add mmap CoW test for regular&source extents
Ensuring that copy on write in mmap mode to the source file when the
CoW range covers regular unshared and regular shared blocks. (MMAP
version of generic/284,287)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:19:04 +0000 (16:19 +0800)]
generic: add mmap CoW test for mixed&destination extents
Ensuring that copy on write in mmap mode works when the CoW range
originally covers multiple extents, mixed with reflinked, unwritten,
hole, regular and delalloc blocks. (MMAP version of generic/200,199)
Shiyang Ruan [Tue, 14 Dec 2021 08:19:03 +0000 (16:19 +0800)]
generic: add mmap CoW test for delalloc&destination extents
Ensuring that copy on write in mmap mode works when the CoW range
originally covers multiple extents, some delalloc, some not. (MMAP
version of generic/195,194)
Shiyang Ruan [Tue, 14 Dec 2021 08:19:01 +0000 (16:19 +0800)]
generic: add mmap CoW test for holes&destination extents
Ensuring that copy on write in mmap mode works when the CoW range
originally covers multiple extents, some holes, some not. (MMAP
version of generic/191,190)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:19:00 +0000 (16:19 +0800)]
generic: add mmap CoW test for unwritten&destination extents
Ensuring that copy on write in mmap mode works when the CoW range
originally covers multiple extents, some unwritten, some not. (MMAP
version of generic/189,188)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 14 Dec 2021 08:18:59 +0000 (16:18 +0800)]
generic: add mmap CoW test for regular&destination extents
Ensuring that copy on write in mmap mode works when the CoW range originally
covers multiple extents, some regular, some not.
(MMAP version of generic/197,196)
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Theodore Ts'o [Mon, 20 Dec 2021 20:40:59 +0000 (15:40 -0500)]
ext4/033: test EXT4_IOC_RESIZE_FS by calling the ioctl directly
E2fsprogs commits 4ea80d031c7e ("resize2fs: adjust new size of the
file system to allow a successful resize") and 50088b1996cc
("resize2fs: attempt to keep the # of inodes valid by removing the
last bg") will automatically reduce the requested new size of the file
system by up to a single block group to avoid overflowing the 32-bit
inode count. This interferes with ext4/033's test of kernel commit 4f2f76f75143 ("ext4: Forbid overflowing inode count when # resizing".)
Address this by creating a new test program, ext4_resize which calls
the EXT4_IOC_RESIZE_FS ioctl directly so we can correctly test the
kernel's online resize code.
Sun Ke [Thu, 16 Dec 2021 09:32:19 +0000 (17:32 +0800)]
ext4: illegal memory access caused by quota index information error
The quota index information in the image is tampered, causing
illegal memory access.
It is a regression test for kernel commits
- 9bf3d2033129 quota: check block number when reading the block in quota file
- d0e36a62bd4c quota: correct error number in free_dqentry()
Signed-off-by: Sun Ke <sunke32@huawei.com> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Brian Foster [Fri, 17 Dec 2021 17:18:26 +0000 (12:18 -0500)]
xfs: test COW writeback failure when overlapping non-shared blocks
Test that COW writeback that overlaps non-shared delalloc blocks
does not leave around stale delalloc blocks on I/O failure. This
triggers assert failures and free space accounting corruption on
XFS.
Fixed by upstream kernel commit 5ca5916b6bc9 ("xfs: punch out data
fork delalloc blocks on COW writeback failure").
Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Theodore Ts'o [Sun, 19 Dec 2021 04:16:38 +0000 (23:16 -0500)]
common/filter: add _filter_bash()
This is needed to account for bash 5.1 adding line number annotation
when executing a command via the -c option and it fails. For example,
"bash -c 'echo foo > /'" will cause bash 5.1 to report:
Filipe Manana [Thu, 9 Dec 2021 14:44:06 +0000 (14:44 +0000)]
generic/335: explicitly fsync file foo when running on btrfs
The test is relying on the fact that an fsync on directory "a" will
result in persisting the changes of its subdirectory "b", namely the
rename of "/a/b/foo" to "/c/foo". For this particular filesystem layout,
that will happen on btrfs, because all the directory entries end up in
the same metadata leaf. However that is not a behaviour we can always
guarantee on btrfs. For example, if we add more files to directory
"a" before and after creating subdirectory "b", like this:
mkdir $SCRATCH_MNT/a
for ((i = 0; i < 1000; i++)); do
echo -n > $SCRATCH_MNT/a/file_$i
done
mkdir $SCRATCH_MNT/a/b
for ((i = 1000; i < 2000; i++)); do
echo -n > $SCRATCH_MNT/a/file_$i
done
mkdir $SCRATCH_MNT/c
touch $SCRATCH_MNT/a/b/foo
sync
# The rest of the test remains unchanged...
(...)
Then after fsyncing only directory "a", the rename of file "foo" from
"/a/b/foo" to "/c/foo" is not persisted.
Guaranteeing that on btrfs would be expensive on large directories, as
it would require scanning for every subdirectory. It's also not required
by posix for the fsync on a directory to persist changes inside its
subdirectories. So add an explicit fsync on file "foo" when the filesystem
being tested is btrfs.
Darrick J. Wong [Wed, 8 Dec 2021 16:45:18 +0000 (08:45 -0800)]
fsstress: consistently index the ops array by OP_ type
A mismerge during a git rebase some time ago broke fsstress in my
development tree, because it added OP_XCHGRANGE into the opt_y typedef
definition at a different offset than the actual entry in the ops array.
This broke the relationship ops[i].op == i.
Since most of fsstress.c blindly assumes that it's ok to index the ops
array by OP_ type, this off-by-one error meant that when I created an
fstest with "-f unlink=1", it actually set the frequency of the adjacent
operation (unresvsp) to 1. I didn't notice this until I started to
investigate how a filesystem created with "-z -f creat=4 -f unlink=4"
could end up with 1.8 million files after 30 seconds.
Eliminate the possibility for future screwups like this by using indexed
array initializers. This enables us to remove the separate op field in
struct opdesc, for a minor savings of memory footprint and reduction in
footgun opportunity.
While we're at it, reformat the ops table to be more pleasing to the
eye.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Luis Chamberlain [Mon, 15 Nov 2021 23:28:34 +0000 (15:28 -0800)]
common/module: fix patient module remover when module is not present
When module is not present and the open coded patient module
remover is called we'll end up in a loop which never ends.
Fix this.
I actually found this issue not in fstests, but when applying this
open coded solution to blktests. In fstest we tend to only call
module remove when we have a module loaded. blktests is different,
and so I immediately spotted the issue there.
Stefan Roesch [Fri, 3 Dec 2021 21:55:56 +0000 (13:55 -0800)]
btrfs: Add new test for setting the chunk size.
Add new testcase for testing the new btrfs sysfs knob to change the
chunk size. The new knob uses /sys/fs/btrfs/<UUID>/allocation/<block
type>/chunk_size.
The test case implements three different cases:
- Test allocation with the default chunk size
- Test allocation after increasing the chunk size
- Test allocation when the free space is smaller than the chunk size.
Note: this test needs to force the allocation of space. It uses the
/sys/fs/btrfs/<UUID>/allocation/<block type>/force_chunk_alloc knob.
Testing:
The test has been run with volumes of different sizes.
Signed-off-by: Stefan Roesch <shr@fb.com> Reviewed-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Filipe Manana [Thu, 2 Dec 2021 10:19:47 +0000 (10:19 +0000)]
btrfs: test balance and send running in parallel
Test that send and balance can run in parallel, without failures and
producing correct results.
Before kernel 5.3 it was possible to run both operations in parallel,
however it was buggy and caused sporadic failures due to races, so it was
disabled in kernel 5.3 by commit 9e967495e0e0ae ("Btrfs: prevent send
failures and crashes due to concurrent relocation"). There is a now a
patch that enables both operations to safely run in parallel, and it has
the following subject:
"btrfs: make send work with concurrent block group relocation"
This also serves the purpose of testing a succession of incremental send
operations, where we have a bunch of snapshots of the same subvolume and
we keep doing an incremental send using the previous snapshot as the
parent.
Josef Bacik [Mon, 22 Nov 2021 22:08:10 +0000 (17:08 -0500)]
generic/260: don't fail for certain fstrim ops on btrfs
We have always failed generic/260, because it tests to see if the file
system will reject a trim range that is above the reported fs size.
However for btrfs we will happily remap logical byte offsets within the
file system, so you can end up with bye offsets past the end of the
reported end of the file system. Thus we do not fail these weird
ranges. We also don't have the concept of allocation groups, so the
other test that tries to catch overflow doesn't apply to us either.
Fix this by simply using an offset that will fail (once a related
kernel path is applied) for btrfs. This will allow us to test the
different overflow cases that do apply to btrfs, and not muddy up
test results by giving us a false negative for the cases that do not
apply to btrfs.
Signed-off-by: Josef Bacik <josef@toxicpanda.com> Acked-by: David Sterba <dsterba@suse.cz> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Josef Bacik [Mon, 29 Nov 2021 15:27:58 +0000 (10:27 -0500)]
btrfs/156: require no compress
This test fails on my overnight tests that use zlib, because the
data usage doesn't get high enough for the fstrim math to work out.
We are testing that fstrim properly trims the while file system when the
block groups are relocated to > total_bytes. However it tries to
validate this by making sure that we trim > total_bytes / 2, which we
won't with compression on because we won't actually allocate total_bytes
/ 2. The free extents that are trimmed in the first go around don't get
trimmed the second time. With some compression algorithms we move the
free extents around enough that they'll get re-trimmed and thus pass,
but others it won't work out properly. Simply require that we don't
have compression enabled so that the results are consistent.
chenlong [Mon, 29 Nov 2021 06:21:23 +0000 (14:21 +0800)]
ext4: verify ext4 when the starting block of index and leaf are inconsistent
Insert the extent entry in ext4_ext_insert_extent() (to be inserted at
the beginning of the block). In the stage of updating the starting block
number of the parent index block, an error happened
in ext4_ext_correct_indexes()->ext4_ext_get_access(), which caused the
index update of the parent index node to fail. The ext4_ext_insert_extent()
function exits directly and does not roll back the extent entry of
the leaf block. Eventually, the extent starting block numbers in
the index block and leaf block are inconsistent, triggering bugon.
This is a regression test for three kernel commit:
1. 0f2f87d51aebc (ext4: prevent partial update of the extent blocks)
2. 9c6e071913792 (ext4: check for inconsistent extents between index
and leaf block)
3. 8dd27fecede55 (ext4: check for out-of-order index extents in
ext4_valid_extent_entries())
suy.fnst@fujitsu.com [Mon, 29 Nov 2021 01:26:48 +0000 (01:26 +0000)]
generic/571: skip test if locktest -t on NFS returns EAGAIN
As kernel commit e93a5e9306a5 ("NFSv4: Add support for application
leases underpinned by a delegation") describes, NFS now supports
file leases only after delegations. However, fstests lacks many NFS
functionalities including delegation.
So let's skip generic/571 if locktest -t on NFS returns EAGAIN
because of commit df2c7b951f43 ("NFSv4: setlease should return
EAGAIN if locks are not available").
Qu Wenruo [Thu, 25 Nov 2021 06:05:29 +0000 (14:05 +0800)]
btrfs: add regression test for compress-force mount options
Since kernel commit d4088803f511 ("btrfs: subpage: make lzo_compress_pages()
compatible"), lzo compression no longer respects the max compressed page
limit, and can cause kernel crash.
The upstream fix is 6f019c0e0193 ("btrfs: fix a out-of-bound access in
copy_compressed_data_to_page()").
This patch will add such regression test for all possible compress-force
mount options, including lzo, zstd and zlib.
And since we're here, also make sure the content of the file matches
after a mount cycle.
Josef Bacik [Tue, 23 Nov 2021 15:14:23 +0000 (10:14 -0500)]
generic/274: require no compress
We hit spurious errors with generic/274 with compression on because we
attempt to fill up the disk with small writes, and these writes end up
taking up metadata space instead of data space. Thus when we go to
write into the preallocated area we get an ENOSPC, but from the metadata
side and not the data side. Simply skip this test if we have
compression enabled.
Josef Bacik [Mon, 22 Nov 2021 14:53:41 +0000 (09:53 -0500)]
btrfs: redirect device replace output to $seqres.full
The btrfs utils are printing a status message about TRIM'ing device on
replace and this is throwing off the golden output, redirect stdout from
'device replace start' to $seqres.full so we don't get false negatives.
Josef Bacik [Wed, 24 Nov 2021 15:17:40 +0000 (10:17 -0500)]
btrfs/176: redirect _format_swapfile to null
Since bb0ab7b2 ("common/rc: Enable _format_swapfile to return the swap
size") we started echo'ing out the swap file size, which is polluting
the golden output for btrfs/176 causing it to fail. Fix this by
redirecting the output to /dev/null.
Darrick J. Wong [Tue, 23 Nov 2021 19:58:06 +0000 (11:58 -0800)]
xfs/122: update for 5.16 typedef removal
In 5.16 we removed the xfs_dsb, xfs_dqblk, and xfs_dinode typedefs,
which means that we need to list the non-typedef struct definitions
explictly in the golden output for this test.
Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Eryu Guan <guaneryu@gmail.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Josef Bacik [Mon, 22 Nov 2021 20:50:29 +0000 (15:50 -0500)]
btrfs/099: use the qgroupid for qgroup limit
A change to btrfs-progs uncovered a problem with btrfs/099, we weren't
specifying the qgroupid with the subvol id. This technically worked
before but only by accident, and all other tests properly specify the
qgroupid for qgroup limit commands. Fix this test to specify the
qgroupid, which will work with older versions of btrfs-progs and newer
ones as well.
Christian Brauner [Fri, 19 Nov 2021 19:42:09 +0000 (20:42 +0100)]
generic: test idmapped mount circular mappings
This is a regression test for the fix in [1]. The test makes sure that
setattr behaves correctly on idmapped mounts that make use of circular
mappings. Such mappings may e.g. be used to allow two users to share
home directories through the same idmapped mount. The tests are
explained in detail in code comments.
Josef Bacik [Mon, 15 Nov 2021 16:29:29 +0000 (11:29 -0500)]
fstests: detect btrfs compression and disable certain tests
Our nightly xfstests runs exposed a set of tests that always fail if we
have compression enabled. This is because compression obviously messes
with the amount of data space allocated on disk, and these tests are
testing either that quota is doing the correct thing, or that we're able
to completely fill the file system.
Add a helper to check to see if we have any of our compression related
mount options set and simply _not_run for these specific tests.
Josef Bacik [Thu, 18 Nov 2021 14:53:20 +0000 (09:53 -0500)]
btrfs: redirect 'btrfs device add' output to seqres.full
I updated btrfs-progs on all my test runners and started failing tests
because I was getting the TRIM messages in the golden output. There
were fixes that went in recently to properly detect TRIM support which
resulted in extra messages being printed. Fix this by redirecting
stdout to $seqres.full for all 'btrfs device add' calls. If anything
fails we'll still pollute the output, but normal status messages will
get properly eaten.
Kent Overstreet [Sat, 13 Nov 2021 21:00:03 +0000 (16:00 -0500)]
generic/544: fix inode number ordering code
The code that creates files and moves them to low/high inode number
files writes different file contents before doing the move - leading to
non-reproducible results.
Fix this by writing the file contents after moving them to high/low
inode number files.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Shiyang Ruan [Tue, 9 Nov 2021 03:21:10 +0000 (11:21 +0800)]
generic: add mmap CoW test for 'mixed' case
Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the surrounding blocks vary between unwritten/regular/delalloc/hole.
(MMAP version of generic/229,238)
Qu Wenruo [Sun, 14 Nov 2021 12:51:01 +0000 (20:51 +0800)]
btrfs: make nospace_cache related test cases to work with latest v2 cache
In the coming btrfs-progs v5.15 release, mkfs.btrfs will change to
use v2 cache by default.
However nospace_cache mount option will not work with v2 cache, as
it would make v2 cache out of sync with on-disk used space.
So mounting a btrfs with v2 cache using "nospace_cache" will make
btrfs to reject the mount.
There are quite some test cases relying on nospace_cache to prevent
v1 cache to take up data space.
For those test cases, we no longer need the "nospace_cache" mount
option if the filesystem is already using v2 cache. Since v2 cache
is using metadata space, it will no longer take up data space, thus
no extra mount options for those test cases.
By this, we can keep those existing tests to run without problem for
both v1 and v2 cache.
Josef Bacik [Fri, 12 Nov 2021 21:10:27 +0000 (16:10 -0500)]
fstests: check if the scratch device is an lv device for certain tests
I use lvm to carve up a large disk so I can run the btrfs raid related xfstests.
However this messes with tests that try to greate lvm devices ontop of
SCRATCH_DEV. Handle this by adding a _require_scratch_nolvm helper to skip
tests that are going to try and create lvm devices.
Josef Bacik [Fri, 12 Nov 2021 20:37:48 +0000 (15:37 -0500)]
fstests: print symbolic names for fiemap flags
My nightly btrfs tests are failing on my configs with -o compress because the
extents have FIEMAP_EXTENT_ENCODED set, which throws the golden output off.
Fix this by changing the filter helper to spit out symbolic names for SHARED and
LAST (these tests only care about SHARED). Then change the golden output to
match the new output of the filter. With this patch my -o compress configs now
pass these tests.
Carlos Maiolino [Wed, 10 Nov 2021 12:41:19 +0000 (13:41 +0100)]
generic/643: Fix for 1k block sizes for ext2 and ext3
Currently this test fails on ext2 and ext3 filesystems using 1k block sizes,
because we set the maximum swap size the kernel is allowed to map according to
the mapping kernel created when enabling the original swap file.
But the translation from indirect block mapping to iomap extents associated with
the page alignment requirements imposed by iomap_swapfile_add_extent(), causes
this test to fail. The kernel end up mapping way less pages than the file
actually has.
After the file is extended by the test, the page alignment is not a problem
anymore and the kernel can use the whole space available in the swapfile,
written in its header, and this creates a variance bigger than what the current
test allows, making the tolerance check within the test to fail.
Fix this by using the swap size recorded in the swapfile header (reported by
mkswap), as the maximum swap size the kernel is allowed to map, instead of
reading the swap size mapped by the kernel from /proc. This also makes
the first swap{on/off} cycle unnecessary, so remove it.
Since the size hardcoded in the swapfile header is the limit allowed for the
kernel to map as swap area, this is the real limit the kernel can't map beyond,
and what this test should be checking for.
This patch also slightly changes the way the test check the swap size
'after' the swap file is extended. Instead of retrieving the information
from /proc/swaps directly, the test now relies on 'swapon' tool. This
enables the test to retrieve the swap size in bytes directly, same unit
returned by _format_swapfile. This avoid possible miscalculations caused by
retrieving swap size in different units.
Carlos Maiolino [Wed, 10 Nov 2021 12:41:18 +0000 (13:41 +0100)]
common/rc: Enable _format_swapfile to return the swap size
Once the kernel is free to not map the full swap file during a swapon call,
it can be useful to know the exact size of the swap area created during
_format_swapfile().
To achieve this, it is needed to change other _format_swapfile() callers to drop
the return value if not required, otherwise, it will be printed to stdout making
such tests to fail.
Lukas Czerner [Mon, 8 Nov 2021 15:19:16 +0000 (16:19 +0100)]
ext4: add test for all ext4/ext3/ext2 mount options
Add test to validate that all the ext4, ext3 and ext2 are properly
recognized, validate and applied to avoid regressions as ext4 moves to
the new mount API.
Yang Xu [Wed, 10 Nov 2021 03:21:13 +0000 (11:21 +0800)]
ext4/051: correct kernel commit
ext4/051 fails on my test machine, but I can't find commit in
e2fsprogs according to commit log that said it is a e2fsprog
regression test. Actually, it is a kernel regression test. So
remind user it is a kernel regression test and use correct fix
kernel commit[1].
Eric Biggers [Mon, 8 Nov 2021 04:36:20 +0000 (20:36 -0800)]
generic/574: remove invalid test of read completely past EOF
One of the test cases in generic/574 tests that if a file of length
130999 has fs-verity enabled, and if bytes 131000..131071 (i.e. some
bytes past EOF and in the same block as EOF) are corrupted with nonzero
values, then reads of the corrupted part should fail with EIO.
This isn't a valid test case, because reads that start at or past EOF
are allowed to simply return 0 without doing any I/O.
Therefore, don't run this test case.
This fixes a test failure caused by the kernel commit 8c8387ee3f55
("mm: stop filemap_read() from grabbing a superfluous page").
Note that the other test cases for this same corrupted file remain
valid, including testing that an error is reported during full file
reads and during mmap "reads". This is because the fs-verity Merkle
tree is defined over full blocks, so the file's last block won't be
readable if it contains corrupted (nonzero) bytes past EOF. This may
seem odd, but it's working as intended, especially considering that
bytes past EOF in a file's last block are exposed to userspace in mmaps.
This test output makes it looks like $testfile was created *before* the
'date' command was executed. What really happen was that btime was
truncated according to the granularity defined by filesystem (I've seen
this with both ext4 and xfs, but I guess others are also affected).
Since granularity can't be worse than a second, simply adjust the test
tolerance interval by 1 second.
Signed-off-by: Luís Henriques <lhenriques@suse.de> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Luis Chamberlain [Fri, 5 Nov 2021 15:59:47 +0000 (08:59 -0700)]
common/btrfs: source module file and remove duplicates
btrfs/249 fails with:
QA output created by 249
./common/btrfs: line 425: _require_loadable_fs_module: command not found
./common/btrfs: line 432: _reload_fs_module: command not found
ERROR: not a btrfs filesystem: /media/scratch
This is because the test is failing to source common/module.
Fix this by sourcing common/module in the btrfs common file.
While it it remove duplication of sourcing this file from other
tests in btrfs so that this is only done once in one place.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Reviewed-by: Nikolay Borisov <nborisov@suse.com> Signed-off-by: Eryu Guan <guaneryu@gmail.com>