xfstests-dev.git
17 months agocommon/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
Gao Xiang [Fri, 12 Jun 2020 01:40:18 +0000 (09:40 +0800)]
common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify

When stressing xfs/083, I found it sometimes fails as the following:

+++ touch 50000 files
setfattr: /home/fsgqa/scratchmnt/INOBT/20627: Operation not permitted
./common/fuzzy: line 18: /home/fsgqa/scratchmnt/INOBT/20627: Operation not permitted
mv: cannot move '/home/fsgqa/scratchmnt/INOBT/20627' to '/home/fsgqa/scratchmnt/INOBT/20627.longer': Operation not permitted
...
xfs_repair did not fix everything

It's simply that INOBT/20627 was an immutable file generated from
fuzzing. Therefore, this patch tries to clear append, immutable flag
first before modification. Note that it clears dax flag as well
since it prevents immutable flag from clearing.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
17 months agoREADME: add note about 123456-fsgqa user creation step
Aurelien Aptel [Thu, 11 Jun 2020 12:41:33 +0000 (14:41 +0200)]
README: add note about 123456-fsgqa user creation step

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
17 months agoxfs/096: filter out the "Discarding..." output
Zorro Lang [Tue, 9 Jun 2020 08:24:42 +0000 (16:24 +0800)]
xfs/096: filter out the "Discarding..." output

Latest xfsprogs mkfs.xfs prints "Discarding blocks...Done" if the
disk supports the trim. That breaks the golden image, cause
unexpected failure, so filter out it.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
17 months agoext4: add empty lines to mkfs_filter
Harshad Shirwadkar [Fri, 5 Jun 2020 23:31:03 +0000 (16:31 -0700)]
ext4: add empty lines to mkfs_filter

Mkfs program can dump empty lines if encounters warnings and results
in test to fail. One of the case when this happens is when we are
trying to create a big file system (> 4T) and if "big" is not present
in /etc/mke2fs.conf. Ignore those empty lines too.

Before the fix, test generic/472 failed with following diff

diff /root/xfstests/tests/generic/472.out /root/xfstests/results//generic/472.out.bad
@@ -1,6 +1,6 @@
 QA output created by 472
 +
 +
  regular swap
  too long swap
  tiny swap
After the fix, test generic/472 passed
Ran generic/472
Passed all 1 tests

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
17 months agofstests: modify user name beginning with non-digit
Yong Sun [Fri, 5 Jun 2020 03:12:38 +0000 (11:12 +0800)]
fstests: modify user name beginning with non-digit

openSUSE and SLE don't support username begin with digit, so it will
skip test generic/597 and generic/598 by lack of 123456-fsgqa user.
generic/597 and 598 are not test username begin with digit on purpose
(different with generic/381). It's will be helpful to use an username
begin with non-digit in this case.

Signed-off-by: Sun Yong <yosun@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
17 months agogeneric: verify ciphertext of IV_INO_LBLK_32 encryption policies
Eric Biggers [Thu, 4 Jun 2020 02:25:01 +0000 (19:25 -0700)]
generic: verify ciphertext of IV_INO_LBLK_32 encryption policies

Verify the ciphertext for v2 encryption policies that use the
IV_INO_LBLK_32 flag and that use AES-256-XTS to encrypt file contents
and AES-256-CTS-CBC to encrypt file names.

The IV_INO_LBLK_32 encryption policy flag modifies the IV generation and
key derivation to be optimized for use with inline encryption hardware
that only accepts 32-bit IVs.  It is similar to IV_INO_LBLK_64 (which is
tested by generic/592), but it uses a trick to get the IV down to 32
bits.  For more information, see kernel commit e3b1078bedd3 ("fscrypt:
add support for IV_INO_LBLK_32 policies").

This test required adding SipHash support to fscrypt-crypt-util.

Running this test requires a kernel containing the above commit, e.g.
the latest mainline (which will become v5.8 and later).  For ext4, it
also needs an e2fsprogs version that supports the stable_inodes feature,
e.g. the latest git master branch (which will become v1.46 and later).

Signed-off-by: Eric Biggers <ebiggers@google.com>
17 months agobtrfs: test if the capability is kept on incremental send
Marcos Paulo de Souza [Mon, 1 Jun 2020 19:48:45 +0000 (16:48 -0300)]
btrfs: test if the capability is kept on incremental send

This test exercises full send and incremental send operations for cases
where files have capabilities, ensuring the capabilities aren't lost in
the process.

There was a problem with kernel <=5.7 that was making capabilities
to be lost after a combination of full + incremental send. This
behavior was fixed by commit 89efda52e6b6 ("btrfs: send: emit file
capabilities after chown").

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: individual user grace period extension via xfs_quota
Eric Sandeen [Mon, 18 May 2020 20:01:08 +0000 (15:01 -0500)]
fstests: individual user grace period extension via xfs_quota

Test that we can extend an individual user's grace time once they
reach their soft limit.

[Eryu: add "Slilence is golden" output]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: individual user grace period extension via setquota
Eric Sandeen [Mon, 18 May 2020 20:00:36 +0000 (15:00 -0500)]
fstests: individual user grace period extension via setquota

Test that we can extend an individual user's grace time once they
reach their soft limit.

[Eryu: add "Silence is golden" output]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: test data integrity for rdonly remount
Chengguang Xu [Tue, 19 May 2020 08:09:29 +0000 (16:09 +0800)]
fstests: test data integrity for rdonly remount

This test checks data integrity when remounting from rw to ro mode.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric/484: add _require_xfs_io_command "syncfs"
Yang Xu [Thu, 28 May 2020 07:32:59 +0000 (15:32 +0800)]
generic/484: add _require_xfs_io_command "syncfs"

When using old xfsprogs version, xfs_io doesn't support syncfs command.
It was not fixed until xfsprogs commit eb24bcffc0("xfs_io: fix missing syncfs command").
Add a require for this so that we can skip this case if xfs_io doesn't
support syncfs command.

Reported-by: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agooverlay/031: fix failure with whiteout inode sharing
Amir Goldstein [Wed, 20 May 2020 08:53:44 +0000 (11:53 +0300)]
overlay/031: fix failure with whiteout inode sharing

Kernel commit c21c839b8448 "ovl: whiteout inode sharing" results in
a temp whiteout file resident inside work dir.

Test overlay/031 is a regression test for two user visible bugs:
1. Exposed whiteouts in overlay
2. Failure to remove directory

It also has a sanity tests for a harmless by-product of the bug -
a residue file in work dir.

The new temp whiteout file looks like a residue and causes the test
to fail.

Drop this sanity test, because it is not vital to the regression test.
We could also check if the residue is a single whiteout, but that is
not really needed, so best not poke into overlay internal work dir.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agobtrfs: Add a test for dead looping balance after balance cancel
Qu Wenruo [Thu, 21 May 2020 00:52:15 +0000 (08:52 +0800)]
btrfs: Add a test for dead looping balance after balance cancel

Test if canceling a running balance can cause later balance to dead
loop.

The fix is titled "btrfs: relocation: Clear the DEAD_RELOC_TREE bit for
 orphan roots to prevent runaway balance".

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agobtrfs: Add a test for leaking root crash at unmount time
Qu Wenruo [Wed, 20 May 2020 11:44:42 +0000 (19:44 +0800)]
btrfs: Add a test for leaking root crash at unmount time

Test if canceled balance could lead to root leakage.
If the kernel has CONFIG_BTRFS_DEBUG compiled, unmount time root leakge
check would detect it, and cause NULL pointer dereference as the pages
of the leaked root are already freed.

The fix is titled "btrfs: relocation: Fix reloc root leakage and the NULL
 pointer reference caused by the leakage".

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: renumber tests after merge
Eryu Guan [Sun, 24 May 2020 16:07:45 +0000 (00:07 +0800)]
fstests: renumber tests after merge

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs: test sunit/swidth updates
Darrick J. Wong [Thu, 23 Apr 2020 23:32:15 +0000 (16:32 -0700)]
xfs: test sunit/swidth updates

Add one test to make sure that we can update sunit without blowing up
the filesystem.  This is a regression test for 13eaec4b2adf ("xfs: don't
commit sunit/swidth updates to disk if that would cause repair
failures").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs: make sure our default quota warning limits and grace periods survive quotacheck
Darrick J. Wong [Thu, 23 Apr 2020 23:32:08 +0000 (16:32 -0700)]
xfs: make sure our default quota warning limits and grace periods survive quotacheck

Make sure that the default quota grace period and maximum warning limits
set by the administrator survive quotacheck.  This is a regression test
for 5885539f0af371 ("xfs: preserve default grace interval during
quotacheck").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs: race freeze and fsmap for a while to see if we livelock
Darrick J. Wong [Thu, 23 Apr 2020 23:32:02 +0000 (16:32 -0700)]
xfs: race freeze and fsmap for a while to see if we livelock

Run fsfreeze and fsmap against each other in a loop to see if we observe
any livelocks, crashes, or odd slowness from either operation.  This is
a regression test for 27fb5a72f50aa77 ("xfs: prohibit fs freezing when
using empty transactions").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs: test that reflink forces the log if mounted with wsync
Darrick J. Wong [Thu, 23 Apr 2020 23:31:53 +0000 (16:31 -0700)]
xfs: test that reflink forces the log if mounted with wsync

A code inspection revealed that reflink does not force the log to disk
even if the filesystem is mounted with wsync.  Add a regression test for
commit 5833112df7e9a ("xfs: reflink should force the log out if mounted
with wsync").

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: check for unknown flag result in _require_xfs_io_command
Eric Sandeen [Mon, 18 May 2020 16:18:08 +0000 (11:18 -0500)]
fstests: check for unknown flag result in _require_xfs_io_command

If we are testing for "xfs_io -c chattr $FOO" be sure to catch any
unknown flag output and _notrun

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: add _require_mknod
Eric Sandeen [Mon, 18 May 2020 16:16:47 +0000 (11:16 -0500)]
fstests: add _require_mknod

Add a _require_mknod test so that filesystems with no ->mknod
operation will _notrun instead of fail, and add the helper to
all necessary tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: test restricted file access sysctls
Eric Sandeen [Mon, 18 May 2020 16:15:34 +0000 (11:15 -0500)]
fstests: test restricted file access sysctls

This tests the fs.protected_regular and fs.protected_fifos
sysctls which restrict access behavior in sticky world-writable
directories as documented in the kernel at
Documentation/admin-guide/sysctl/fs.rst

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: test restricted symlinks & hardlinks sysctls
Eric Sandeen [Mon, 18 May 2020 16:14:43 +0000 (11:14 -0500)]
fstests: test restricted symlinks & hardlinks sysctls

This tests the fs.protected_symlinks and fs.protected_hardlinks
sysctls which restrict links behavior in sticky world-writable
directories as documented in the kernel at
Documentation/admin-guide/sysctl/fs.rst

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: add _require_sysctl_variable helper
Eric Sandeen [Mon, 18 May 2020 16:11:31 +0000 (11:11 -0500)]
fstests: add _require_sysctl_variable helper

New _require_sysctl_variable test to ensure that the sysctl we wish to
test is available on the system.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agobtrfs/14{2,3}: use dm-dust instead of fail_make_request
Omar Sandoval [Wed, 15 Apr 2020 20:54:31 +0000 (13:54 -0700)]
btrfs/14{2,3}: use dm-dust instead of fail_make_request

These two tests test direct I/O and buffered read repair, respectively,
with fail_make_request. However, by using "fail_make_request/times",
they rely on repair having a specific I/O pattern. My pending Btrfs
direct I/O refactoring patch series changes this I/O pattern and thus
breaks this test.

The dm-dust target (added in v5.2) emulates a device with bad blocks
that are fixed when written to (like a device that remaps bad blocks).
This is exactly what we want for testing repair. Add some common dm-dust
helpers and update the tests to use dm-dust.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agooverlay: test for whiteout inode sharing
Chengguang Xu [Wed, 13 May 2020 19:23:38 +0000 (22:23 +0300)]
overlay: test for whiteout inode sharing

This is a test for whiteout inode sharing feature.

[Amir] added check for whiteout sharing support
       and whiteout of lower dir.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofstests: update sparse file & negative timestamp tests for exfat
Eric Sandeen [Wed, 6 May 2020 22:16:50 +0000 (17:16 -0500)]
fstests: update sparse file & negative timestamp tests for exfat

exfat cannot do sparse files or negative timestamps, so exclude
tests which require these.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric/506: fix _require test, use xfs_io vs chattr
Eric Sandeen [Fri, 8 May 2020 03:25:51 +0000 (22:25 -0500)]
generic/506: fix _require test, use xfs_io vs chattr

_require_prjquota doesn't work on xfs unless the scratch device has
been mounted with project quota, so do that prior to the test.

older chattr/lsattr don't understand project quotas, so use xfs_io
instead for compatibility on older systems.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric: test reporting of wb errors via syncfs
Jeff Layton [Thu, 30 Apr 2020 11:59:02 +0000 (07:59 -0400)]
generic: test reporting of wb errors via syncfs

Add a test for new syncfs error reporting behavior. When an inode fails
to be written back, ensure that a subsequent call to syncfs() will also
report an error.

Kernel with the following patches should pass the test:

  vfs: track per-sb writeback errors and report them to syncfs
  buffer: record blockdev write errors in super_block that it backs

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agosrc/fssum: Fix duplicate CLI arguments
Arvind Raghavan [Thu, 30 Apr 2020 00:13:54 +0000 (20:13 -0400)]
src/fssum: Fix duplicate CLI arguments

fssum currently has a duplicate '-x' flag, which is used for both
excluding paths and including xattrs. As the former is the only one
currently used in xfstests, this patch renames the latter to use '-t'.

Signed-off-by: Arvind Raghavan <raghavan.arvind@gmail.com>
Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
Signed-off-by: Vijay Chidambaram <vijay@cs.utexas.edu>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoext4/308: Fix misspelling in comment
mafeng 00292095 [Tue, 28 Apr 2020 14:18:50 +0000 (22:18 +0800)]
ext4/308: Fix misspelling in comment

Just fix three word misspellings in one commet.

Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs/122: fix for linux 5.7 stuff
Darrick J. Wong [Thu, 23 Apr 2020 23:31:42 +0000 (16:31 -0700)]
xfs/122: fix for linux 5.7 stuff

Fix some regressions on xfsprogs 5.7.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs/30[78]: fix regressions due to strengthened AGF checks
Darrick J. Wong [Thu, 23 Apr 2020 23:31:36 +0000 (16:31 -0700)]
xfs/30[78]: fix regressions due to strengthened AGF checks

Reorder the order in which we tweak AGF fields to avoid falling afoul of
the new AGF sanity checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric/570: don't run this test on systems supporting userspace hibernate
Darrick J. Wong [Thu, 23 Apr 2020 23:31:30 +0000 (16:31 -0700)]
generic/570: don't run this test on systems supporting userspace hibernate

It turns out that userspace actually does need the ability to write to
an active swapfile if userspace hibernation (uswsusp) is enabled.
Therefore, this test doesn't apply under those conditions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric/590: fix the xfs feature detection logic
Darrick J. Wong [Thu, 23 Apr 2020 23:31:18 +0000 (16:31 -0700)]
generic/590: fix the xfs feature detection logic

The setup code in this regression test case tries to figure out if
certain features known to be incompatible with realtime are known to
mkfs, and if so, to forcibly disable them.

Unfortunately, the reflink feature detection logic here is broken,
because we have no way of distinguishing between the helper function
_scratch_mkfs_xfs_supported returning nonzero because reflink isn't
compatible with mkfs's defaults (e.g. your mkfs has rmapbt=1 by default)
vs. reflink isn't recognized at all vs. something else broke.

However, we can grep the mkfs output to look for reflink support, and if
we find it then we disable it.  That's fine for this test, since on XFS
it's trying to set up the exact conditions to test a known bug.

Second, rmapbt isn't currently compatible with realtime either, so we
need to detect and mask that off too.

Third, the test only needs to perform this feature detection if the test
runner didn't set SCRATCH_RTDEV, because we require that if the runner
configured SCRATCH_RTDEV, they also set MKFS_OPTIONS appropriately.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agobtrfs: add a test for fsync of file with prealloc extents crossing eof
Filipe Manana [Tue, 21 Apr 2020 10:25:39 +0000 (11:25 +0100)]
btrfs: add a test for fsync of file with prealloc extents crossing eof

Test that if we fsync a file with prealloc extents that start before and
after the file's size, we don't end up with missing parts of the extents
and implicit file holes after a power failure. Test both without and with
the NO_HOLES feature.

It is fixed commit f135cea30de5 ("btrfs: fix partial loss of
prealloc extent past i_size after fsync")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agoxfs/126: make blocktrash work reliably on attrleaf blocks
Anthony Iliopoulos [Tue, 21 Apr 2020 11:36:43 +0000 (13:36 +0200)]
xfs/126: make blocktrash work reliably on attrleaf blocks

Running xfs/126 sometimes fails due to output mismatch. Due to the
randomized nature of the test, periodically the selected bits are not
relevant to the test, or the selected bits are not flipped. Supply an
offset that is close to the start of the metadata block, so that the
test will reliably corrupt the header.

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Link: https://lore.kernel.org/linux-xfs/20200116160323.GC2149943@magnolia
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofsx: move range generation logic into a common helper
Filipe Manana [Mon, 20 Apr 2020 17:09:31 +0000 (18:09 +0100)]
fsx: move range generation logic into a common helper

We have very similar code that generates the destination range for clone,
dedupe and copy_file_range operations, so avoid duplicating the code three
times and move it into a helper function.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofsx: fix infinite/too long loops when generating ranges for copy_file_range
Filipe Manana [Mon, 20 Apr 2020 17:09:17 +0000 (18:09 +0100)]
fsx: fix infinite/too long loops when generating ranges for copy_file_range

While running generic/521 I've had fsx taking a lot of CPU time and not
making any progress for several hours. Attaching gdb to the fsx process
revealed that fsx was in the loop that generates the ranges for a
copy_file_range operation, in particular the loop seemed to never end
because the range defined by 'offset2' kept overlapping with the range
defined by 'offset'.
So far this happened one time only in one of my test VMs with generic/521.

Fix this by breaking out of the loop after trying 30 times, like we
currently do for dedupe operations, which results in logging the operation
as skipped.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofsx: fix infinite/too long loops when generating ranges for clone operations
Filipe Manana [Mon, 20 Apr 2020 17:09:05 +0000 (18:09 +0100)]
fsx: fix infinite/too long loops when generating ranges for clone operations

While running generic/457 I've had fsx taking a lot of CPU time and not
making any progress for over an hour. Attaching gdb to the fsx process
revealed that fsx was in the loop that generates the ranges for a clone
operation, in particular the loop seemed to never end because the range
defined by 'offset2' kept overlapping with the range defined by 'offset'.
So far this happened two times in one of my test VMs with generic/457.

Fix this by breaking out of the loop after trying 30 times, like we
currently do for dedupe operations, which results in logging the operation
as skipped.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agofsx: allow zero range operations to cross eof
Filipe Manana [Mon, 20 Apr 2020 17:07:38 +0000 (18:07 +0100)]
fsx: allow zero range operations to cross eof

Currently we are limiting the range for zero range operations to stay
within the i_size boundary. This is not optimal because like this we lose
coverage of the filesystem's zero range implementation, since zero range
operations are allowed to cross the i_size. Fix this by limiting the range
to 'maxfilelen' and not 'file_size', and update the 'file_size' after each
zero range operation if needed.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agogeneric/456: document the other kernel commit
Yang Xu [Mon, 20 Apr 2020 08:18:17 +0000 (16:18 +0800)]
generic/456: document the other kernel commit

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agooverlay: another test for dropping nlink below zero
Amir Goldstein [Mon, 20 Apr 2020 10:34:53 +0000 (13:34 +0300)]
overlay: another test for dropping nlink below zero

This is a variant on test overlay/034.

This variant is mangling upper hardlinks instead of lower hardlinks
and does not require the inodes index feature.

This is a regression test for kernel commit 83552eacdfc0
("ovl: fix WARN_ON nlink drop to zero")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 months agooverlay/029: fix test failure with nfs_export feature enabled
Amir Goldstein [Mon, 20 Apr 2020 10:27:31 +0000 (13:27 +0300)]
overlay/029: fix test failure with nfs_export feature enabled

When overlayfs nfs_export feature is enabled by default in either kernel
config or module parameters, this test fails:

    mount: /tmp/8751/mnt: mount(2) system call failed: Stale file handle.
    cat: /tmp/8751/mnt/bar: No such file or directory

The reason is that nfs_export depends on index feature and with index
feature enabled, an upper/work dirs cannot be reused for mounting with
a different lower layer.

To reproduce the failure do:
  echo Y > /sys/module/overlay/parameters/index
  echo Y > /sys/module/overlay/parameters/nfs_export
before running the test.

Fix the failure by explicitly re-creating upper/work dirs.

Reported-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agogeneric/594: require setquota tool supports project quota
Zorro Lang [Sun, 19 Apr 2020 10:49:36 +0000 (18:49 +0800)]
generic/594: require setquota tool supports project quota

The old setquota tool doesn't support project quota, it doesn't has
"-P, --project" option. So _notrun the test to avoid a failure.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agobtrfs: snapshot creation with qgroup inherit would mark qgroup inconsistent
Qu Wenruo [Wed, 15 Apr 2020 06:49:16 +0000 (14:49 +0800)]
btrfs: snapshot creation with qgroup inherit would mark qgroup inconsistent

Test that a new snapshot created with qgroup inherit passed should
mark qgroup numbers inconsistent.

Such inconsistent flag is required to show that we need a qgroup
rescan to make qgroup numbers correct again.

This is unavoidable since snapshot creation with qgroup inherit acts
as snapshot creation + qgroup relationship assign.

See btrfs(5) for why such operation needs qgroup rescan.

This test failed on current kernel, the fix is submitted to the btrfs
mail list titled:

  "btrfs: qgroup: Mark qgroup inconsistent if we're inherting snapshot to a new qgroup"

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agofstests: exclude exfat from tests which require metadata journaling
Eric Sandeen [Wed, 15 Apr 2020 20:22:49 +0000 (15:22 -0500)]
fstests: exclude exfat from tests which require metadata journaling

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agofstests: test for fallocate capability in more tests
Eric Sandeen [Wed, 15 Apr 2020 20:21:55 +0000 (15:21 -0500)]
fstests: test for fallocate capability in more tests

These 3 tests explicitly call xfs_io's fallocate command, test whether
it works before running the test.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agofstests: add _require_hardlinks for all necessary tests
Eric Sandeen [Wed, 15 Apr 2020 20:20:33 +0000 (15:20 -0500)]
fstests: add _require_hardlinks for all necessary tests

Add a new _require function for hardlinks, to test hardlink support
in all tests which need it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agofstests: use _require_symlinks on all necessary tests
Eric Sandeen [Wed, 15 Apr 2020 20:18:27 +0000 (15:18 -0500)]
fstests: use _require_symlinks on all necessary tests

Consistently use _require_symlinks on all generic tests which
create a symlink when they run.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agofstests: rename _require_test_symlinks
Eric Sandeen [Wed, 15 Apr 2020 20:17:46 +0000 (15:17 -0500)]
fstests: rename _require_test_symlinks

Generally these tests are not restricted to one device or the other;
testing the test device will suffice to determine the capability
but it doesn't need to be named that way.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agobtrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()
Filipe Manana [Tue, 14 Apr 2020 16:22:42 +0000 (17:22 +0100)]
btrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()

In btrfs-progs v4.10 we had a behaviour change where starting a balance
operation without any filters results in a delay of 10 seconds and a
warning is printed to stdout that warns that a full balance is about to
be made and that it can be a slow operation. The new flag '--full-balance'
was added in that release to avoid the 10 seconds delay and the warning
message.

Our existing helper _run_btrfs_balance_start() uses that new balance flag
if we are running a btrfs-progs version that has it, to avoid that 10
seconds wait.

Make all existing btrfs tests that trigger balance operations use the
_run_btrfs_balance_start() helper, so that we avoid wasting time and
speed up some of the tests. In particular test btrfs/014 is now about 10x
faster and tests btrfs/060 to btrfs/064 3 to 5 times faster (depending
on the fsstress random load).

Besides speeding up many tests that do balance operations it also fixes
functional problems:

1) Since btrfs-progs v4.10 the test case btrfs/014 got broken, because
   its purpose is to run balance and snapshot creation in parallel,
   and that wasn't happening anymore because all snapshots were being
   created during the 10 seconds delay of the first balance operation,
   so balance and snapshot creation was being serialized instead of
   running in parallel.

   Fixing this test to avoid the 10 seconds delay immediately
   exposes a regression that went into kernel 5.7-rc1 which is fixed
   by the following commit

   aec7db3b13a0 ("btrfs: fix setting last_trans for reloc roots")

2) Test cases btrfs/060 to btrfs/064 now spend much more time running
   fsstress, balance and other operations in parallel, there's no
   longer intervals of 10 seconds where balance is not running
   concurrently with those other operations, making the tests a lot
   more useful again.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agobtrfs: stop using run_check in _run_btrfs_balance_start
Filipe Manana [Tue, 14 Apr 2020 16:22:32 +0000 (17:22 +0100)]
btrfs: stop using run_check in _run_btrfs_balance_start

The use of run_check() immediately stops a test because it calls the
_fail() function when execution of its argument fails. This is
generally not encouraged in fstests as it prevents a test from
detecting further problems after that failure.

Since the next patch in this series updates other tests to use
_run_btrfs_balance_start() for which a failure to run balance can be
expected (btrfs/187 for example), remove the use of run_check() from
_run_btrfs_balance_start(). Existing tests that use
_run_btrfs_balance_start() now redirect standard output to the
test's .full file for debugging purposes. In case balance fails the
tests will fail due to unexpected output from the standard error.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agobtrfs: add several tests to the balance group
Filipe Manana [Tue, 14 Apr 2020 16:22:21 +0000 (17:22 +0100)]
btrfs: add several tests to the balance group

Some tests exercise balance but are not included in the 'balance' group,
so just add them to that group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agogeneric: assign a few tests to additional groups
Vladimir Zapolskiy [Mon, 13 Apr 2020 07:24:49 +0000 (10:24 +0300)]
generic: assign a few tests to additional groups

The rationale behind the proposed changes is to correct and improve
granularity of some generic tests, so it becomes possible to control
lists of run tests better, if there is given additional information
about a test environment and tested filesystems.

* generic/459 test is added to freeze group
* generic/482 test is added to thin group
* generic/529 test is added to acl group
* generic/530 test is added to shutdown group

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agobtrfs: check that cloning an inline extent does not lead to data loss
Filipe Manana [Mon, 6 Apr 2020 10:51:34 +0000 (11:51 +0100)]
btrfs: check that cloning an inline extent does not lead to data loss

We have a bug in the current kernel merge window (for 5.7) that results
in data loss when cloning an inline extent into a new file (or an empty
file. This change adds a test for such case into the existing test case
btrfs/205, because it's the test case that tests all the supported
scenarios for cloning inline extents in btrfs.

Linux kernel commit 4fdb688c7071 ("btrfs: fix lost i_size update
after cloning inline extent") fixes the regression.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
19 months agooverlay/06[89]: fix test run with nfs_export feature enabled by default
Amir Goldstein [Thu, 9 Apr 2020 14:09:21 +0000 (17:09 +0300)]
overlay/06[89]: fix test run with nfs_export feature enabled by default

The tests were checking that nfs_export feature was successfully enabled
by greping for nfs_export=on option in /proc/mounts.

This check was incorrect if the module default was nfs_export enabled
and caused test to not run with the message:
    cannot enable nfs_export feature on nested overlay

Use a helper that checks this condition correctly.

Reported-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric: test PF_MEMALLOC interfering with accounting file write
Eric Biggers [Fri, 3 Apr 2020 03:33:55 +0000 (20:33 -0700)]
generic: test PF_MEMALLOC interfering with accounting file write

Add a regression test for the bug fixed by commit 10a98cb16d80 ("xfs:
clear PF_MEMALLOC before exiting xfsaild thread").

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric: test fscrypt key eviction racing with inode dirtying
Eric Biggers [Mon, 23 Mar 2020 16:40:34 +0000 (09:40 -0700)]
generic: test fscrypt key eviction racing with inode dirtying

Add a regression test for a bug in the FS_IOC_REMOVE_ENCRYPTION_KEY
ioctl fixed by commit 2b4eae95c736 ("fscrypt: don't evict dirty inodes
after removing key").

This ioctl is also tested by generic/580 and generic/581, but they
didn't cover the case where this bug occurs.

This test detects the bug on ext4, f2fs, and ubifs.  The multi-threaded
part of the test actually still fails on ubifs even with the fix, due to
another kernel bug which I'm working on fixing.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/565: change to use filter _filter_testdir_and_scratch
Yongcheng Yang [Fri, 3 Apr 2020 00:32:31 +0000 (08:32 +0800)]
generic/565: change to use filter _filter_testdir_and_scratch

If $TEST_DIR is a substring of $SCRATCH_MNT (like /mnt and /mnt2),
this test always fail. Change to use _filter_testdir_and_scratch
which will filter the longer string first if the other string is a
substring of the longer one.

Signed-off-by: Yongcheng Yang <yongcheng.yang@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/571: skip test on filesystems that don't support F_SETLEASE fcntl
Scott Mayhew [Wed, 1 Apr 2020 17:26:59 +0000 (13:26 -0400)]
generic/571: skip test on filesystems that don't support F_SETLEASE fcntl

Add an option to the locktest program to check for fcntl setlease
support, and skip the generic/571 test on filesystems where the
check returns EINVAL.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agoxfs/191: update mkfs.xfs input results
Yang Xu [Fri, 27 Mar 2020 10:17:50 +0000 (18:17 +0800)]
xfs/191: update mkfs.xfs input results

When I run xfs/191 with upstream xfsprogs, I get the following
errors because mkfs.xfs binary has changed a lot(use loop device
to avoid stripe alignment affect).

-------------------------
pass -n size=2b /dev/loop0
pass -d agsize=8192b /dev/loop0
pass -d agsize=65536s /dev/loop0
pass -d su=0,sw=64 /dev/loop0
pass -d su=4096s,sw=64 /dev/loop0
pass -d su=4096b,sw=64 /dev/loop0
pass -l su=10b /dev/loop0
fail -n log=15 /dev/loop0
fail -r rtdev=/mnt/xfstests/test/191-input-validation.img /dev/loop0
fail -r size=65536,rtdev=/mnt/xfstests/test/191-input-validation.img /dev/loop0
fail -i log=10 /dev/loop
--------------------------

"pass -d su=0,sw=64 /dev/loop0", expect fail, this behavior has been
fixed by commit 16adcb88(mkfs: more sunit/swidth sanity checking).

"fail -n log=15 /dev/sda11" "fail -i log=10 /dev/sda11", expect pass,
this option has been removed since commit 2cf637c(mkfs: remove
logarithm based CLI option).

"fail -r size=65536,rtdev=$fsimg /dev/sda11" "fail -r rtdev=$fsimg
/dev/sda11" works well if we disable reflink, fail if we enable
reflink. It fails because reflink was not supported in realtime
devices since commit bfa66ec(mkfs: don't create realtime filesystems
with reflink enabled).

Since xfsprogs v4.15.0-rc1(commit 68344ba0f mkfs: introduce default
configuration structure), we have deault sectorsize and blocksize.
So some cases without 's' or 'b' suffix trun into pass.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric: per-type quota timers set/get test
Zorro Lang [Sun, 29 Mar 2020 05:18:01 +0000 (13:18 +0800)]
generic: per-type quota timers set/get test

Set different grace time, make sure each of quota (user, group and
project) timers can be set (by setquota) and get (by repquota)
correctly.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/258: check filesystem support for negative timestamps
Luis Henriques [Wed, 4 Mar 2020 16:11:20 +0000 (16:11 +0000)]
generic/258: check filesystem support for negative timestamps

Some filesystems do not support negative c/m/atime timestamps. And
for these filesystems, generic/258 will fail.

Since there's currently no way to check sb->s_time_min from
userspace, this patch adds a new common/rc function
_require_negative_timestamps() that will _notrun depending on the
$FSTYP variable.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/587: fix rounding error in quota/stat block comparison
Darrick J. Wong [Wed, 18 Mar 2020 20:11:36 +0000 (13:11 -0700)]
generic/587: fix rounding error in quota/stat block comparison

It turns out that repquota (which reports in units of 1k blocks) reports
rounded up numbers when the fs blocksize is 512 bytes.  However, xfs_io
stat always reports block counts in units of 512 bytes.  If the number
of (512b) file blocks is not an even number, the "$3 / 2" expression
will round down, causing the test to fail.  Round up to the nearest 1k
to match repquota's behavior.

Reported-by: zlang@redhat.com
Fixes: 6b04ed05456fc6c ("generic: test unwritten extent conversion extent mapping quota accounting")
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/310: slightly improve check for dmesg error
Paulo Alcantara (SUSE) [Tue, 17 Mar 2020 01:54:39 +0000 (22:54 -0300)]
generic/310: slightly improve check for dmesg error

The 'grep -c "error"' check was causing false positive results for
cifs.ko when running it with 'echo 1 > /proc/fs/cifs/cifsFYI'.

That is, the test would fail when cifs.ko prints out a non-error
message like this:

  [ 2320.903987] fs/cifs/smb2maperror.c: Mapping SMB2 status code 0x80000006 to POSIX err -61

Signed-off-by: Paulo Alcantara (SUSE) <pc@cjr.nz>
Suggested-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agooverlay/07[01]: use existing char/block devices
Amir Goldstein [Mon, 16 Mar 2020 18:53:20 +0000 (20:53 +0200)]
overlay/07[01]: use existing char/block devices

If the arbitrary char/block devices 1:1 do not exist in the system,
the tests fail.

Use /dev/zero and loop device instead of made up device numbers.

Reposted-by: Miklos Szeredi <miklos@szeredi.hu>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agobtrfs: test power fail after a ranged fsync when not using the no-holes feature
Filipe Manana [Fri, 6 Mar 2020 17:51:02 +0000 (17:51 +0000)]
btrfs: test power fail after a ranged fsync when not using the no-holes feature

Test a scenario were we fsync a range of a file and have a power
failure.  We want to check that after a power failure and mounting
the filesystem, we do not end up with a missing file extent
representing a hole. This applies only when not using the NO_HOLES
feature.

This currently fails on btrfs but it is fixed by a patch for the kernel
that has the following subject:

  "Btrfs: fix missing file extent item for hole after ranged fsync"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agobtrfs: Test subvolume delete --subvolid feature
Marcos Paulo de Souza [Mon, 9 Mar 2020 10:39:56 +0000 (07:39 -0300)]
btrfs: Test subvolume delete --subvolid feature

Now btrfs can delete subvolumes based in ther subvolume id. This
makes easy for the user willing to delete a subvolume that cannot be
accessed by the mount point, since btrfs allows to mount a specific
subvolume and hiding the other from the mount point.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agobtrfs/177: fix for nodesize 64K and type single
Anand Jain [Tue, 10 Mar 2020 04:22:32 +0000 (12:22 +0800)]
btrfs/177: fix for nodesize 64K and type single

In the blockgroup type single with nodesize 64K, the relocation of
the bg containing the swapfile is not being attempted during the
resize. So due to this the resize is successful and does not
generate the required 'Text file busy' error message as in the
golden output and so the testcase fails.

Fix this by replacing the mkfs created chunk with the bigger kernel
created chunk using balance, and then fill it up to the full. Upsize
to 3x of fssize once instead of first to 2G and then to 3G. Also
drop the unnecessary downsize to 2G step.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agobtrfs/177: check for minsize of the scratch device
Anand Jain [Tue, 10 Mar 2020 04:20:04 +0000 (21:20 -0700)]
btrfs/177: check for minsize of the scratch device

This test case needs at least 3g scratch device space, check for it
before starting the test case.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agoxfs/513: fix allocsize on archs with pagesize larger than blocksize
Anthony Iliopoulos [Sat, 7 Mar 2020 10:54:57 +0000 (11:54 +0100)]
xfs/513: fix allocsize on archs with pagesize larger than blocksize

The minimum accepted allocsize mount option value is page size, which
causes the particular test to fail in architectures where page size >
block size. Fix it by basing the value on the platform page size rather
than the block size as obtained from mkfs. In addition add a filter so
that different values can be used without breaking the golden output.

Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agofsx: fix bug where zero range operations never use the keep size flag
Filipe Manana [Fri, 6 Mar 2020 12:35:17 +0000 (12:35 +0000)]
fsx: fix bug where zero range operations never use the keep size flag

We are never using the FALLOC_FL_KEEP_SIZE flag for zero range operations
even when we intend to use it. So fix it by setting that flag for the
call to fallocate(2) if the 'keep_size' parameter is true.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agoxfs: make sure xfs_db/xfs_quota commands are documented
Darrick J. Wong [Wed, 4 Mar 2020 02:46:47 +0000 (18:46 -0800)]
xfs: make sure xfs_db/xfs_quota commands are documented

Make sure all the xfs_db/xfs_quota commands are documented.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agoxfs: refactor calls to xfs_admin
Darrick J. Wong [Wed, 4 Mar 2020 02:46:40 +0000 (18:46 -0800)]
xfs: refactor calls to xfs_admin

Create a helper to run xfs_admin on the scratch device, then
refactor all tests to use it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agogeneric/402: skip test if xfs_io can't parse the date value
Darrick J. Wong [Wed, 4 Mar 2020 02:46:34 +0000 (18:46 -0800)]
generic/402: skip test if xfs_io can't parse the date value

If xfs_io's utimes command cannot interpret the arguments that are
given to it, it will print out "Bad value for [am]time".  Detect
when this happens and drop the file out of the test entirely.

This is particularly noticeable on 32-bit platforms and the largest
timestamp seconds supported by the filesystem is INT_MAX.  In this
case, the maximum value we can cram into tv_sec is INT_MAX, and
there is no way to actually test setting a timestamp of INT_MAX + 1
to test the clamping.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
20 months agobtrfs: add test for large direct I/O w/ RAID
Omar Sandoval [Fri, 6 Mar 2020 01:03:12 +0000 (17:03 -0800)]
btrfs: add test for large direct I/O w/ RAID

Apparently we don't have any tests which exercise the code path in
Btrfs that has to split up direct I/Os for RAID stripes. Add one to
catch the bug fixed by "btrfs: fix RAID direct I/O reads with
alternate csums".

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agofstests: transport two ext4 tests from LTP
Yong Sun [Thu, 27 Feb 2020 10:35:07 +0000 (18:35 +0800)]
fstests: transport two ext4 tests from LTP

Recently LTP upstream removed some ext4 tests[1].  And two of them
is still valid to keep. So I transport those two tests here.

ext4-nsec-timestamps, which is used to test nanosec timestamps of
ext4, rewrite into ext4/043 and 044.  ext4-subdir-limit, which is
used to test subdirectory limit of ext4, rewrite into ext4/045.

[1] https://marc.info/?l=linux-fsdevel&m=157190623919681&w=2

Signed-off-by: Sun Yong <yosun@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoxfs/300: modify test to work on any fs block size
Jeff Moyer [Thu, 20 Feb 2020 20:06:32 +0000 (15:06 -0500)]
xfs/300: modify test to work on any fs block size

The test currently assumes a file system block size of 4k.  It will
work just fine on any user-specified block size, though.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agosrc/t_mmap_collision: fix hard-coded page size
Jeff Moyer [Thu, 20 Feb 2020 20:06:31 +0000 (15:06 -0500)]
src/t_mmap_collision: fix hard-coded page size

Fix the test to run on non-4k page size systems.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agodax/dm: disable testing on devices that don't support dax
Jeff Moyer [Thu, 20 Feb 2020 20:06:30 +0000 (15:06 -0500)]
dax/dm: disable testing on devices that don't support dax

Move the check for dax from the individual target scripts into
_require_dm_target.  This fixes up a couple of missed tests that are
failing due to the lack of dax support (such as tests requiring
dm-snapshot).

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agofstests: fix up filters & expected output for latest xfs_repair
Eric Sandeen [Fri, 28 Feb 2020 04:50:49 +0000 (20:50 -0800)]
fstests: fix up filters & expected output for latest xfs_repair

A handful of minor changes went into xfs_repair output in the
last push, so add a few more filters and change the resulting
expected output.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoext4/021: make sure the fdatasync subprocess exits
zhangyi (F) [Wed, 26 Feb 2020 03:22:56 +0000 (11:22 +0800)]
ext4/021: make sure the fdatasync subprocess exits

Now we just kill fdatasync_work process and wait nothing after the
test, so a busy unmount failure may appear if the fdatasync syscall
doesn't return in time.

  umount: /tmp/scratch: target is busy.
  mount: /tmp/scratch: /dev/sdb already mounted on /tmp/scratch.
  !!! failed to remount /dev/sdb on /tmp/scratch

This patch waits the xfs_io fdatasync subprocess exit to make sure
_check_scratch_fs success.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agofstests: remove generic/484
Christoph Hellwig [Mon, 24 Feb 2020 22:29:26 +0000 (14:29 -0800)]
fstests: remove generic/484

Generic/484 tests functionality that isn't really related to file
systems, and has failed every since it was added.  Remove it as it
serves no puropse in xfstests.

[Eryu: also remove src/t_locks_execve.c and its entries in
src/Makefile and .gitignore]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agofstests: add a another gap extent testcase for btrfs
Josef Bacik [Thu, 20 Feb 2020 14:38:55 +0000 (09:38 -0500)]
fstests: add a another gap extent testcase for btrfs

This is a testcase for a corner that I missed when trying to fix gap
extents for btrfs.  We would end up with gaps if we hole punched past
isize and then extended past the gap in a specific way.  This is a
simple reproducer to show the problem, and has been properly fixed by my
patches now.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agobtrfs: test newly supported cases of cloning inline extents
Filipe Manana [Wed, 19 Feb 2020 14:06:41 +0000 (14:06 +0000)]
btrfs: test newly supported cases of cloning inline extents

Test several scenarios of cloning operations where the source range
includes inline extents. They used to not be supported on btrfs
because their implementation was not straightforward, and therefore
these operations used to fail with errno EOPNOTSUPP on older
kernels.

This currently fails on any released kernel. It passes only when the
patch with the following subject is applied:

  "Btrfs: implement full reflink support for inline extents"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agobtrfs/112: remove some tests for cloning inline extents
Filipe Manana [Wed, 19 Feb 2020 14:06:27 +0000 (14:06 +0000)]
btrfs/112: remove some tests for cloning inline extents

This test case, btrfs/112, tests that some clone operations that have a
range covering inline extents fail with either -EOPNOTSUPP or -EINVAL.
These cases were unsupported on btrfs because they used to lead to file
corruptions and were not trivial to implement.

But there's now a patchset that adds support for them, and the relevant
patch of that patchset has the following subject:

  "Btrfs: implement full reflink support for inline extents"

So just remove these tests from test case btrfs/112, since this test
case is about testing only the unsupported reflink operations. A new
test case that verifies that these cases now work, as long as some other
new cases, will follow in another patch.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agofstests: add an eio group
Theodore Ts'o [Fri, 21 Feb 2020 18:43:09 +0000 (13:43 -0500)]
fstests: add an eio group

This allows us to run all those tests which simulate disk failures
using dmerror.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoxfs/044: Remove useless _filter_logprint
Yang Xu [Thu, 20 Feb 2020 07:58:48 +0000 (15:58 +0800)]
xfs/044: Remove useless _filter_logprint

xfs/044 has customized  _filter_logprint function, but it was never
used. So remove it.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoxfs/029: filter out "extended-header: cycle: 1" from output
Yang Xu [Thu, 20 Feb 2020 07:58:47 +0000 (15:58 +0800)]
xfs/029: filter out "extended-header: cycle: 1" from output

When I test this case(default lsunit 256k), this case will fail,
as below:
cycle: 1        version: 2              lsn: 1,0        tail_lsn: 1,0
length of Log Record: 258048    prev offset: -1         num ops: 1

...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extended-header: cycle: 1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
...

It reports this info because xfs_logprint only read 32k header every time, so it
needs to read more times. We can filter this useless info.

common/log also has _filter_logprint function. only library function is
prefixed with "_", remove '_'.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoext4/002: remove EXT4_EOFBLOCKS_FL test
Eric Whitney [Fri, 14 Feb 2020 16:42:49 +0000 (11:42 -0500)]
ext4/002: remove EXT4_EOFBLOCKS_FL test

This test exercises obsolete ext4-specific functionality that will be
removed in the kernel's 5.7 release.  Once that happens, ext4/002 will
always fail, so remove the test to avoid the noise.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agobtrfs/179: call sync qgroup counts
Anand Jain [Wed, 12 Feb 2020 09:35:09 +0000 (17:35 +0800)]
btrfs/179: call sync qgroup counts

On some systems btrfs/179 fails because the check finds that there
is difference in the qgroup counts.

So as the intention of the test case is to test any hang like
situation during heavy snapshot create/delete operation with quota
enabled, so make sure the qgroup counts are consistent at the end of
the test case, so to make the check happy.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoxfs: xfs mount option sanity test
Zorro Lang [Wed, 29 Jan 2020 05:22:47 +0000 (13:22 +0800)]
xfs: xfs mount option sanity test

XFS is changing to suit the new mount API, so add this case to make
sure the changing won't bring in regression issue on xfs mount
option parse phase, and won't change some default behaviors either.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agocommon/btrfs: Improve _require_btrfs_command
Marcos Paulo de Souza [Fri, 7 Feb 2020 13:19:50 +0000 (10:19 -0300)]
common/btrfs: Improve _require_btrfs_command

Now _require_btrfs_command can also check for subfuntion options, like
"subvolume delete --subvolid".

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agogeneric: test adding filesystem-level fscrypt key via key_id
Eric Biggers [Mon, 3 Feb 2020 18:18:55 +0000 (10:18 -0800)]
generic: test adding filesystem-level fscrypt key via key_id

Add a test which tests adding a key to a filesystem's fscrypt keyring
via an "fscrypt-provisioning" keyring key.  This is an alternative to
the normal method where the raw key is given directly.

For more details, see kernel commit 93edd392cad7 ("fscrypt: support
passing a keyring key to FS_IOC_ADD_ENCRYPTION_KEY").

This test depends on an xfs_io patch which adds the '-k' option to the
'add_enckey' command, e.g.:

xfs_io -c "add_enckey -k KEY_ID" MOUNTPOINT

This test is skipped if the needed kernel or xfs_io support is absent.

This has been tested on ext4, f2fs, and ubifs.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agocommon/encrypt: move constant test key to common code
Eric Biggers [Mon, 3 Feb 2020 18:18:54 +0000 (10:18 -0800)]
common/encrypt: move constant test key to common code

For some encryption tests it's helpful to always use the same key so
that the test's output is always the same.

generic/580 already defines such a key, so move it into common/encrypt
so that other tests can use it too.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agocommon/rc: handle option with argument in _require_xfs_io_command()
Eric Biggers [Mon, 3 Feb 2020 18:18:53 +0000 (10:18 -0800)]
common/rc: handle option with argument in _require_xfs_io_command()

Fix _require_xfs_io_command() to handle options that take arguments when
the argument is shown in the help text.  E.g., it didn't work to run:

_require_xfs_io_command "add_enckey" "-k"

because the relevant line of the help text is:

-k KEY_ID -- ID of fscrypt-provisioning key containing the raw key

... but the grep command only matched "-k --", not "-k KEY_ID --".

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoREADME: fsgqa needs a home directory too
Christian Kujau [Fri, 31 Jan 2020 21:22:49 +0000 (13:22 -0800)]
README: fsgqa needs a home directory too

generic/128 whould fail with:

     QA output created by 128
    +su: warning: cannot change directory to /home/fsgqa: No such file or directory

Adjust README to create a home directory too. And (totally unrelated),
fix the 404 for the udf_test tool.

Signed-off-by: Christian Kujau <lists@nerdbynature.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agoshared/032: add options for reiser4
Christian Kujau [Fri, 31 Jan 2020 20:55:47 +0000 (12:55 -0800)]
shared/032: add options for reiser4

Last night I had xfstests running and after a while it hung at
shared/032 because I had reiser4progs installed and it was waiting
for input:

-----------------------------------------------------------------
mkfs -t reiser4 /dev/ram0
mkfs.reiser4 1.2.1
Format release: 4.0.2
Copyright (C) 2001-2005 by Hans Reiser, licensing governed by
reiser4progs/COPYING.

Block size 4096 will be used.
Linux 5.5.0-rc5-amd64 is detected.
Uuid 2006a590-832a-49f5-9317-cf91bf866dd7 will be used.
Reiser4 is going to be created on /dev/ram0.
(Yes/No):
-----------------------------------------------------------------

The patch below adds an option (cf. reiserfs the line above) so that
the test continues.

Curiously enough the test still "succeeds" for reiser{fs,4} (and jfs
too) because the userspace tools don't appear to have a routine to
check for "contains an existing filesystem", but that could be
addressed in a different patch.

Signed-off-by: Christian Kujau <lists@nerdbynature.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
21 months agobtrfs: test unaligned punch hole at ENOSPC
Anand Jain [Fri, 31 Jan 2020 05:09:57 +0000 (13:09 +0800)]
btrfs: test unaligned punch hole at ENOSPC

Try to punch hole with unaligned size and offset when the FS is full
and mounted with nodatacow option.

Mainly holes are punched at locations which are unaligned with the
file extent boundaries when the FS is full by data.  As the punching
holes at unaligned location will involve truncating blocks instead
of just dropping the extents, it shall involve reserving data and
metadata space for delalloc and so data alloc fails as the FS is
full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents, without truncating data extent blocks.

This test was orignally merged as btrfs/172 (commit 4c2c678cd), then
Iremoved by commit 538d8a4bcc78. But it's decided to bring back this
test case, now the problem is better understood and the fix is
available in the ML as below.

Link: https://patchwork.kernel.org/patch/11357415/
Reviewed-by: Filipe Manana <fdmanana@suse.com>
(cherry picked from commit 4c2c678cd56a81a210cb16f9f9347073e91e2fb0)
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>