xfstests-dev.git
8 months agoxfs/107: remove long-broken test
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>
9 months agobtrfs: test cleaning up of the stale device
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.

Fixed by the kernel patch (in the ml):

  btrfs: harden identification of the stale device

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add race test that mmap write to target of reflink
Shiyang Ruan [Tue, 14 Dec 2021 08:19:14 +0000 (16:19 +0800)]
generic: add race test that mmap write to target of reflink

Test for races or FS corruption when mmap writing to a file that's also
the target of a reflink operation. (MMAP version of generic/168,170)

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>
9 months agogeneric: add race test that mmap write to source of reflink
Shiyang Ruan [Tue, 14 Dec 2021 08:19:13 +0000 (16:19 +0800)]
generic: add race test that mmap write to source of reflink

Test for races or FS corruption when mmap writing to a file that's
also the source of a reflink operation. (MMAP version of generic/167,
166)

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>
9 months agogeneric: add race test between reflink and mmap read
Shiyang Ruan [Tue, 14 Dec 2021 08:19:12 +0000 (16:19 +0800)]
generic: add race test between reflink and mmap read

Test for races or FS corruption between reflink and mmap reading the
target file. (MMAP version of generic/164,165)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add mmap CoW test for mixed&source extents
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>
9 months agogeneric: add direct-io CoW test for mixed&source extents
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.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add buffered-io CoW test for mixed&source extents
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.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add mmap CoW test for delalloc&source extents
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)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add mmap CoW test for holes&source extents
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>
9 months agogeneric: add mmap CoW test for unwritten&source extents
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>
9 months agogeneric: add mmap CoW test for regular&source extents
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>
9 months agogeneric: add mmap CoW test for mixed&destination extents
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)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add mmap CoW test for delalloc&destination extents
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)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agocommon/rc: introduce _require_scratch_delalloc()
Shiyang Ruan [Tue, 14 Dec 2021 08:19:02 +0000 (16:19 +0800)]
common/rc: introduce _require_scratch_delalloc()

Check whether delalloc is supported on current device.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric: add mmap CoW test for holes&destination extents
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>
9 months agogeneric: add mmap CoW test for unwritten&destination extents
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>
9 months agogeneric: add mmap CoW test for regular&destination extents
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>
9 months agogeneric: add mmap CoW test for ranges of two shared files
Shiyang Ruan [Tue, 14 Dec 2021 08:18:58 +0000 (16:18 +0800)]
generic: add mmap CoW test for ranges of two shared files

Ensuring that copy on write in mmap mode works when the CoW range originally
covers multiple extents. (MMAP version of generic/185,183)

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>
9 months agoext4/033: test EXT4_IOC_RESIZE_FS by calling the ioctl directly
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.

Reported-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric/228: set vars for early _cleanup
Eric Wong [Sat, 25 Dec 2021 06:03:29 +0000 (06:03 +0000)]
generic/228: set vars for early _cleanup

The `core_pattern' and `ulimit_c' variables must be set to
restore their original values in case _cleanup fires early.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric/647: add _require_odirect
Eric Wong [Sat, 25 Dec 2021 00:36:50 +0000 (00:36 +0000)]
generic/647: add _require_odirect

The mmap-rw-fault test program used by generic/647 uses O_DIRECT
unconditionally.

Signed-off-by: Eric Wong <e@80x24.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agoext4: illegal memory access caused by quota index information error
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>
9 months agoxfs: test COW writeback failure when overlapping non-shared blocks
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>
9 months agocommon/filter: add _filter_bash()
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:

     bash: line 1: /: Is a directory

instead of:

     bash: /: Is a directory

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric/335: explicitly fsync file foo when running on btrfs
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.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agofsstress: consistently index the ops array by OP_ type
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>
9 months agocommon/module: fix patient module remover when module is not present
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.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agobtrfs: Add new test for setting the chunk size.
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>
9 months agobtrfs: test balance and send running in parallel
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.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric/260: don't fail for certain fstrim ops on btrfs
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>
9 months agobtrfs/156: require no compress
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agoext4: verify ext4 when the starting block of index and leaf are inconsistent
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())

Signed-off-by: Chen Long <chenlongcl.chen@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
9 months agogeneric/571: skip test if locktest -t on NFS returns EAGAIN
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").

Signed-off-by: Su Yue <suy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agobtrfs: add regression test for compress-force mount options
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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agobtrfs: Test proper interaction between skip_balance and paused balance
Nikolay Borisov [Thu, 25 Nov 2021 09:48:09 +0000 (11:48 +0200)]
btrfs: Test proper interaction between skip_balance and paused balance

Ensure a device can be added to a filesystem that has a paused balance
operation and has been mounted with the 'skip_balance' mount option

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric/274: require no compress
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agobtrfs: redirect device replace output to $seqres.full
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agobtrfs/176: redirect _format_swapfile to null
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agoxfs/122: update for 5.16 typedef removal
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>
10 months agobtrfs/099: use the qgroupid for qgroup limit
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric: test idmapped mount circular mappings
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.

[1]: commit 968219708108 ("fs: handle circular mappings correctly")
Cc: Seth Forshee <seth.forshee@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>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agofstests: detect btrfs compression and disable certain tests
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agobtrfs: redirect 'btrfs device add' output to seqres.full
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agoext4/051: Add another kernel commit
Yang Xu [Thu, 18 Nov 2021 06:42:23 +0000 (14:42 +0800)]
ext4/051: Add another kernel commit

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric/544: fix inode number ordering code
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>
10 months agogeneric: add mmap CoW test for 'mixed' case
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)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric: add mmap CoW test for 'delalloc' case
Shiyang Ruan [Tue, 9 Nov 2021 03:21:09 +0000 (11:21 +0800)]
generic: add mmap CoW test for 'delalloc' case

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is delalloc.  (MMAP version of generic/222,227)

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric: add mmap CoW test for 'hole' case
Shiyang Ruan [Tue, 9 Nov 2021 03:21:08 +0000 (11:21 +0800)]
generic: add mmap CoW test for 'hole' case

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a hole.  (MMAP version of generic/218,220)

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>
10 months agogeneric: add mmap CoW test for 'unwritten' case
Shiyang Ruan [Tue, 9 Nov 2021 03:21:07 +0000 (11:21 +0800)]
generic: add mmap CoW test for 'unwritten' case

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a unwritten block.  (MMAP version of generic/216,217)

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>
10 months agogeneric: add mmap CoW test for 'regular' case
Shiyang Ruan [Tue, 9 Nov 2021 03:21:06 +0000 (11:21 +0800)]
generic: add mmap CoW test for 'regular' case

Check what happens if we MMAP CoW blocks 2-4 of a page's worth of blocks when
the second block is a regular block.  (MMAP version of generic/205,206)

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>
10 months agobtrfs: make nospace_cache related test cases to work with latest v2 cache
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.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agofstests: check if the scratch device is an lv device for certain tests
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agofstests: print symbolic names for fiemap flags
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.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric/643: Fix for 1k block sizes for ext2 and ext3
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.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agocommon/rc: Enable _format_swapfile to return the swap size
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.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agocommon/renameat2: use mktemp(1) to create temporary directory
Luís Henriques [Tue, 9 Nov 2021 17:55:55 +0000 (17:55 +0000)]
common/renameat2: use mktemp(1) to create temporary directory

Instead of using $TEST_DIR/$$, use the _correct_ way to create temporary
directories.  I've seen generic/626 failing with:

  QA output created by 626
  mkdir: cannot create directory '/media/test/471': File exists
  Silence is golden

which was likely due to another test that used the same directory name and
didn't do the clean-up.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agoext4: add test for all ext4/ext3/ext2 mount options
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.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agocommon/rc: add _require_kernel_config and _has_kernel_config
Lukas Czerner [Mon, 8 Nov 2021 21:04:23 +0000 (22:04 +0100)]
common/rc: add _require_kernel_config and _has_kernel_config

Add _require_kernel_config() and _has_kernel_config() helpers to check
whether a specific kernel configuration is enabled on the kernel.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agoext4/051: correct kernel commit
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].

[1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=b2bbb92f

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric/648: dmerror must be unmounted
Zorro Lang [Sun, 24 Oct 2021 12:05:12 +0000 (20:05 +0800)]
generic/648: dmerror must be unmounted

Sometimes g/648 fail to unmount dmerror with this error:

   umount: /mnt/xfstests/scratch: target is busy.

Even worse, it will cause all later test cases fail as:

  mount: bad usage
  Try 'mount --help' for more information.
  check: failed to mount $SCRATCH_DEV using specified options
  Interrupted!

So we shouldn't _fail directly if dmerror_unmount fails, use a while
loop to try to unmount it enough times.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agogeneric/574: remove invalid test of read completely past EOF
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.

Signed-off-by: Eric Biggers <ebiggers@google.com>
10 months agogeneric/528: take fs timestamps granularity into account in tolerance interval
Luís Henriques [Mon, 8 Nov 2021 14:49:05 +0000 (14:49 +0000)]
generic/528: take fs timestamps granularity into account in tolerance interval

Filesystems timestamps granularity can cause spurious test failures:

  QA output created by 528
  btime has value of 1635818936
  btime is NOT in range 1635818937 .. 1635818942

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>
10 months agocommon/btrfs: source module file and remove duplicates
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>
10 months agofsstress: improve error message on check_cwd() error
Luis Chamberlain [Fri, 5 Nov 2021 16:44:32 +0000 (09:44 -0700)]
fsstress: improve error message on check_cwd() error

I ran into an error with generic/083 with xfs due to check_cwd() but
why it failed is not clear because there are two types of
failures:

  o stat64() failed (likely -ENOMEM is my guess)
  o the inode actually changed

Throw a bone out to developers so that in case en error does happen
they know which rabbit hole to go into.

Cc: Anthony Iliopoulos <ailiopoulos@suse.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agofsstress: run more than 2^32 operations
Darrick J. Wong [Wed, 3 Nov 2021 16:12:06 +0000 (09:12 -0700)]
fsstress: run more than 2^32 operations

Now that storage has gotten really really fast, we have to crank up
TIME_FACTOR to amusingly huge values to do things such as 10-day soak
testing.  "Un"fortunately, fsstress uses 'int' to count operations,
which means we get close to maxing out the 2^31 limit on operations in
fsstress.  Widen it to a long long value to take us to the heat death of
the universe, like we did for fsx a while back. ;)

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
10 months agocommon/rc: Fix check for SCRATCH_DEV_POOL presence in _scratch_dev_pool_get
Nikolay Borisov [Mon, 1 Nov 2021 13:56:58 +0000 (15:56 +0200)]
common/rc: Fix check for SCRATCH_DEV_POOL presence in _scratch_dev_pool_get

Current check is buggy because it can never trigger as even if
SCRATCH_DEV_POOL is not defined config_ndevs will get a value of 0
from 'wc -w', this in turn makes 'typeset -p config_ndevs' always
return 0, triggering the existing check a noop.

Fix this by explicitly checking for the presence of SCHRATC_DEV_POOL

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agogeneric/201: fix the description
Shiyang Ruan [Sat, 30 Oct 2021 08:34:33 +0000 (16:34 +0800)]
generic/201: fix the description

This case is test for 'unlink', and there is no umount operation here.

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>
11 months agogeneric: fix description or typo in head comment
Shiyang Ruan [Sat, 30 Oct 2021 08:34:32 +0000 (16:34 +0800)]
generic: fix description or typo in head comment

1. update description according to the current testcase
2. "ENSPC" -> "ENOSPC" ,"an the end -> at the end"

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>
11 months agogeneric/138,139,140: fix the name for check file
Shiyang Ruan [Sat, 30 Oct 2021 08:34:31 +0000 (16:34 +0800)]
generic/138,139,140: fix the name for check file

The original 'file3' is used to check if the result after operation on
file2 is correct.  So, rename it to be 'file2.chk' to make it easier to
understand.

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>
11 months agobtrfs: test direct IO write on NOCOW file when low on unallocated space
Filipe Manana [Thu, 28 Oct 2021 15:04:33 +0000 (16:04 +0100)]
btrfs: test direct IO write on NOCOW file when low on unallocated space

Test that if we write to a range of a NOCOW file that has allocated
extents and there is not enough available free space for allocating new
data extents, the write succeeds. Test for direct IO and buffered IO
writes.

This currently fails on btrfs for the direct IO write scenario, only, but
while at it also test a buffered IO write, to help prevent regressions in
the future.

The patch that fixes the direct IO case has the following subject:

 "btrfs: fix ENOSPC failure when attempting direct IO write into NOCOW range"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agodmflakey: fix environment-destroying mistakes in _cleanup_flakey
Darrick J. Wong [Thu, 28 Oct 2021 20:17:39 +0000 (13:17 -0700)]
dmflakey: fix environment-destroying mistakes in _cleanup_flakey

_cleanup_flakey can be called even when _init_flakey hasn't been called.
For example, _require_flakey_with_error_writes does this.

Unfortunately, the patch to add support for external logs and rt devices
will "reset" the SCRATCH_LOGDEV/SCRATCH_RTDEV variables without noticing
that _init_flakey hasn't been called yet.  When this happens, those two
variables will be set to the empty string, with the result that the rest
of the test doesn't use those devices.

To fix this, only reset SCRATCH_LOGDEV/RTDEV to the "NON_FLAKEY" value
if we actually set one.

Fixes: 9c1f3149 ("dmflakey: support external log and realtime devices")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agofstests: _require_dm_target should not always skip DAX capable devices
Dave Chinner [Wed, 27 Oct 2021 01:38:42 +0000 (12:38 +1100)]
fstests: _require_dm_target should not always skip DAX capable devices

Recent changes have turned off all dm-error, dm-thin and dm-flakey
tests on pmem devices even when we are not explicitly testing DAX.
This is a regression resulting in a large number of log recovery
tests no longer running on my pmem-based test VMs. I added the "-o
dax=never" mount options to these test configs, only to find it
still would not run the dm tests even though the filesystem will
never use DAX.

Fix this so that the dm target DAX test explicitly ignores the
the block device DAX capability when the filesystem is mounted with
dax=never and hence we can use all the dm targets when the tests are
being run with FSDAX disabled.

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: Eryu Guan <guaneryu@gmail.com>
11 months agobtrfs/012: check size after mounted
Zhu Yifei [Mon, 25 Oct 2021 03:22:56 +0000 (11:22 +0800)]
btrfs/012: check size after mounted

move '_require_fs_space'  after mounted.

==before patch==
btrfs/012       [not run] This test requires at least 0GB free on /fs/scratch to run

==after patch==
btrfs/012 189s ...  194s
Ran: btrfs/012
Passed all 1 tests

Signed-off-by: Zhu Yifei <yifeix.zhu@intel.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agobtrfs/091: remove noinode_cache option
Ma Xinjian [Mon, 27 Sep 2021 07:20:19 +0000 (15:20 +0800)]
btrfs/091: remove noinode_cache option

inode cache feature has been removed

Link: https://www.spinics.net/lists/linux-btrfs/msg107910.html
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ma Xinjian <xinjianx.ma@intel.com>
Acked-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agobtrfs: test btrfs filesystem usage command on missing seed device
Anand Jain [Thu, 21 Oct 2021 09:17:06 +0000 (17:17 +0800)]
btrfs: test btrfs filesystem usage command on missing seed device

If there is a missing seed device in a sprout, the btrfs filesystem usage
command fails, which is fixed by the following patches:

  btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
  btrfs-progs: read fsid from the sysfs in device_is_seed

Test if it works now after these patches in the kernel and in the
btrfs-progs respectively.

Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agobtrfs: validate sysfs fsid
Anand Jain [Thu, 21 Oct 2021 09:17:05 +0000 (17:17 +0800)]
btrfs: validate sysfs fsid

Validate if the sysfs fsid is the same as fsid as obtained from the
superblock.

Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agocommon/btrfs: add _require_btrfs_sysfs_fsid helper
Anand Jain [Thu, 21 Oct 2021 09:17:04 +0000 (17:17 +0800)]
common/btrfs: add _require_btrfs_sysfs_fsid helper

It checks if the kernel has the following patch
 btrfs: sysfs add devinfo/fsid to retrieve fsid from the device
that added sysfs interface to get fsid.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agofstests: groupfile generation needs force overwrite
Dave Chinner [Sun, 10 Oct 2021 23:06:59 +0000 (10:06 +1100)]
fstests: groupfile generation needs force overwrite

Having built fstests as root as part of a run script, I get failures
then trying to run it as a user because of the group list
generation. The issue occurs because the group list files are owned
by root, and so I get an interactive prompt to overwrite them such
as:

Building btrfs
 [GROUP] /home/dave/src/xfstests-dev/tests/btrfs/group.list
mv: replace 'group.list', overriding mode 0644 (rw-r--r--)? y
Building ceph
 [GROUP] /home/dave/src/xfstests-dev/tests/ceph/group.list
mv: replace 'group.list', overriding mode 0644 (rw-r--r--)? y
Building cifs
 [GROUP] /home/dave/src/xfstests-dev/tests/cifs/group.list
mv: replace 'group.list', overriding mode 0644 (rw-r--r--)? y
Building ext4
 [GROUP] /home/dave/src/xfstests-dev/tests/ext4/group.list
...

Use 'mv -f' to ignore such trivial issues so that the new group
lists are written correctly.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agofstests: autoconf has deprecated a bunch of macros
Dave Chinner [Sun, 10 Oct 2021 23:06:58 +0000 (10:06 +1100)]
fstests: autoconf has deprecated a bunch of macros

Latest debian unstable environment results in these build warnings:

autoconf
configure.ac:8: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.ac:8: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.ac:8: the top level
configure.ac:50: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:50: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
m4/package_xfslibs.m4:95: AC_PACKAGE_NEED_XFSCTL_MACRO is expanded from...
configure.ac:50: the top level
configure.ac:63: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:63: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
acinclude.m4:19: AC_PACKAGE_WANT_FALLOCATE is expanded from...
configure.ac:63: the top level
configure.ac:64: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:64: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
acinclude.m4:32: AC_PACKAGE_WANT_OPEN_BY_HANDLE_AT is expanded from...
configure.ac:64: the top level
configure.ac:69: warning: The macro `AC_TRY_LINK' is obsolete.
configure.ac:69: You should run autoupdate.
./lib/autoconf/general.m4:2920: AC_TRY_LINK is expanded from...
m4/package_libcdev.m4:106: AC_HAVE_COPY_FILE_RANGE is expanded from...
configure.ac:69: the top level
configure.ac:107: warning: The macro `AC_CONFIG_HEADER' is obsolete.
configure.ac:107: You should run autoupdate.
./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from...
configure.ac:107: the top level

So, run autoupdate and then fix all the warnings.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agogeneric/095: align DIO read/writes with the supported sector size for the device
Luís Henriques [Mon, 11 Oct 2021 15:11:16 +0000 (16:11 +0100)]
generic/095: align DIO read/writes with the supported sector size for the device

This test creates fio DIO jobs with bs=1k, which will fail when using block
devices that have logical sector size bigger than 1k (such as zram, advanced
format HDD's with 4k sectors, DASD's on mainframes with 2k sectors, etc).

Fix the test by using _min_dio_alignment instead to get the correct size.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agobtrfs/049: remove the test
Ma Xinjian [Mon, 27 Sep 2021 07:20:18 +0000 (15:20 +0800)]
btrfs/049: remove the test

inode_cache is deprecated and will never appear in mount
options; remove it entirely

Link: https://www.spinics.net/lists/linux-btrfs/msg107910.html
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Ma Xinjian <xinjianx.ma@intel.com>
Acked-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agocommon/log: fix *_dump_log routines for ext4
Catherine Hoang [Thu, 7 Oct 2021 00:26:41 +0000 (00:26 +0000)]
common/log: fix *_dump_log routines for ext4

dumpe2fs -h displays the superblock contents, not the journal
contents.  Use the logdump utility to dump the contents of the
journal.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agocommon/log: move *_dump_log routines to common/log
Catherine Hoang [Thu, 7 Oct 2021 00:26:40 +0000 (00:26 +0000)]
common/log: move *_dump_log routines to common/log

Move _scratch_remount_dump_log and _test_remount_dump_log from
common/inject to common/log. These routines do not inject errors and
should be placed with other common log functions.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agofstests: rename _test_inject_logprint to _test_remount_dump_log
Catherine Hoang [Thu, 7 Oct 2021 00:26:39 +0000 (00:26 +0000)]
fstests: rename _test_inject_logprint to _test_remount_dump_log

Rename _test_inject_logprint to _test_remount_dump_log to better
describe what this function does. _test_remount_dump_log unmounts
and remounts the test device, dumping the log.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agofstests: rename _scratch_inject_logprint to _scratch_remount_dump_log
Catherine Hoang [Thu, 7 Oct 2021 00:26:38 +0000 (00:26 +0000)]
fstests: rename _scratch_inject_logprint to _scratch_remount_dump_log

Rename _scratch_inject_logprint to _scratch_remount_dump_log to
better describe what this function does. _scratch_remount_dump_log
unmounts and remounts the scratch device, dumping the log.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agoxfs/540: use _scratch_xfs_set_metadata_field api
Yang Xu [Thu, 30 Sep 2021 10:08:00 +0000 (18:08 +0800)]
xfs/540: use _scratch_xfs_set_metadata_field api

With older xfsprogs, xfs_db write subcmd doesn't -d option. So this
case fails.  Use _scratch_xfs_set_metadata_field api to avoid this.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agogeneric/079: make sure users 'nobody' and 'daemon' exist
Luis Henriques [Mon, 27 Sep 2021 10:58:43 +0000 (11:58 +0100)]
generic/079: make sure users 'nobody' and 'daemon' exist

Test 'src/t_immutable' assumes the existence of users 'nobody' and
'daemon' on the system.  If any of these users don't exist, the test will
fail with:

  add_acl(/media/scratch/079/immutable.f) did not set errno == EPERM
  ...

because it tries to set ACLs such as:

  u::rwx,g::rwx,o::rwx,u:daemon:rwx,m::rwx

Use the new _require_user_exists() function to ensure these users exist.

Signed-off-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
11 months agocommon/rc: add _require_user_exists() to check if a user exists
Luis Henriques [Mon, 27 Sep 2021 10:58:42 +0000 (11:58 +0100)]
common/rc: add _require_user_exists() to check if a user exists

Function _require_user() does check if a user exists *and* if it is able
to execute commands.  Add a new function to simply check if a user exists.

Signed-off-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agonew: don't allow new tests in group 'other'
Darrick J. Wong [Fri, 17 Sep 2021 00:40:06 +0000 (17:40 -0700)]
new: don't allow new tests in group 'other'

The 'other' group is vaguely defined at best -- other than what?  It's
not clear what tests belong in this group, and it has become a dumping
ground for random stuff that are classified in other groups.  Don't let
people create new other group tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agonew: standardize group name checking
Darrick J. Wong [Fri, 17 Sep 2021 00:40:00 +0000 (17:40 -0700)]
new: standardize group name checking

Use the same group name validation when reading group names from
standard input or from the command line.  Now that we require all group
names to be documented, there's no reason to leave these separate
requirements.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agonew: clean up the group name input code
Darrick J. Wong [Fri, 17 Sep 2021 00:39:55 +0000 (17:39 -0700)]
new: clean up the group name input code

Clean up the code that reads group names in from the command line to
take advantage of the read command's ability to display a prompt.  While
we're at it, we should abort the script if the group list encounters
EOF, and we can tighten up some of the other sh-isms too.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agonew: only allow documented test group names
Darrick J. Wong [Fri, 17 Sep 2021 00:39:46 +0000 (17:39 -0700)]
new: only allow documented test group names

Now that we require all group names to be listed in doc/group-names.txt,
we can use that (instead of running mkgroupfile) to check if the group
name(s) supplied by the user actually exist.  This has the secondary
effect of being a second nudge towards keeping the description of groups
up to date.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agotools: add missing license tags to my scripts
Darrick J. Wong [Fri, 17 Sep 2021 00:39:41 +0000 (17:39 -0700)]
tools: add missing license tags to my scripts

I forgot to add spdx license tags and copyright statements to some of
the tools that I've contributed to fstests.  Fix this to be explicit.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agotools: make sure that test groups are described in the documentation
Darrick J. Wong [Fri, 17 Sep 2021 00:39:35 +0000 (17:39 -0700)]
tools: make sure that test groups are described in the documentation

Create a file to document the purpose of each test group that is
currently defined in fstests, and change mkgroupfile to check that every
group mentioned in the tests is also mentioned in the documentation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agogeneric/631: change this test to use the 'whiteout' group
Darrick J. Wong [Fri, 17 Sep 2021 00:39:30 +0000 (17:39 -0700)]
generic/631: change this test to use the 'whiteout' group

This test isn't really an overlay test; it's a regression test for a bug
that someone found in xfs handling of whiteout files.  Since the
'overlay' group has one member, let's move it to 'whiteout'.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agobtrfs: fix incorrect subvolume test group name
Darrick J. Wong [Fri, 17 Sep 2021 00:39:24 +0000 (17:39 -0700)]
btrfs: fix incorrect subvolume test group name

The group for testing subvolume functionality is 'subvol', not
'subvolume'.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agoxfs: fix incorrect fuzz test group name
Darrick J. Wong [Fri, 17 Sep 2021 00:39:19 +0000 (17:39 -0700)]
xfs: fix incorrect fuzz test group name

The group name for fuzz tests is 'fuzzers'.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agoxfs: move reflink tests into the clone group
Darrick J. Wong [Fri, 17 Sep 2021 00:39:13 +0000 (17:39 -0700)]
xfs: move reflink tests into the clone group

"clone" is the group for tests that exercise FICLONERANGE, so move these
tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
12 months agoceph: re-tag copy_file_range as being in the copy_range group
Darrick J. Wong [Fri, 17 Sep 2021 00:39:08 +0000 (17:39 -0700)]
ceph: re-tag copy_file_range as being in the copy_range group

copy_range is the group name for copy_file_range tests, so reclassify
these tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>