xfstests-dev.git
2 years agobtrfs/079: fix failure to umount scratch fs due to running filefrag process
Filipe Manana [Tue, 10 Sep 2019 14:26:01 +0000 (15:26 +0100)]
btrfs/079: fix failure to umount scratch fs due to running filefrag process

The test fails sporadically when trying to unmount the scratch filesystem
because a filefrag process is still running against a file that exists on
the scrach filesystem. This is because killing the subshell running the
fiemap_work() function does not wait for any filefrag process to complete
first. We need to set a trap for the SIGTERM signal on the subshell so
that it waits for any filefrag process before exitting.

The failure resulted in error messages like the following:

  btrfs/079 57s ... umount: /home/fdmanana/btrfs-tests/scratch_1: target is busy
          (In some cases useful info about processes that
           use the device is found by lsof(8) or fuser(1).)
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  (see /home/fdmanana/git/hub/xfstests/results//btrfs/079.full for details)

Fix this by adding a trap for SIGTERM.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: test mmap write vs. hole punching
Andreas Gruenbacher [Fri, 6 Sep 2019 16:53:04 +0000 (18:53 +0200)]
generic: test mmap write vs. hole punching

On file systems with a block size smaller than the page size, hole
punching can leave the pages at the beginning and the end of the
hole partially mapped to disk blocks.  Make sure writes to those
pages are handled correctly.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/048: fix test failure when fs mounted with v2 space cache option
Filipe Manana [Thu, 5 Sep 2019 15:37:00 +0000 (16:37 +0100)]
btrfs/048: fix test failure when fs mounted with v2 space cache option

In order to check that the filesystem generation does not change
after failure to set a property, the test expects a specific
generation number of 7 in its golden output. That currently works
except when using the v2 space cache mount option (MOUNT_OPTIONS="-o
space_cache=v2"), since the filesystem generation is 8 because
creating a v2 space cache adds an additional transaction commit. So
update the test to not hardcode specific generation numbers in its
golden output and just output an unexpected message if the
generation number changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/locktest: Remove unused buf allocation
Ira Weiny [Tue, 3 Sep 2019 21:08:15 +0000 (14:08 -0700)]
src/locktest: Remove unused buf allocation

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/locktest: Update test header comment
Ira Weiny [Tue, 3 Sep 2019 21:08:14 +0000 (14:08 -0700)]
src/locktest: Update test header comment

The offset is also used as flags for the OPEN commands.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/locktest: Remove D_flag
Ira Weiny [Tue, 3 Sep 2019 21:08:13 +0000 (14:08 -0700)]
src/locktest: Remove D_flag

This flag is never set.  Furthermore, there does not seem to be any need
to set O_DIRECT for lock testing.

Remove the D_flag

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/25[02]: Increase fs size to 196 mb
Nikolay Borisov [Mon, 2 Sep 2019 08:34:18 +0000 (11:34 +0300)]
generic/25[02]: Increase fs size to 196 mb

Those 2 tests fail on btrfs on a ppc64 system with 64k pages. This is
caused by the improved minimum device size calculation in upstream
btrfs-progs (commit: 31d228a2eb98 ("btrfs-progs: mkfs: Enhance minimal
device size calculation to fix mkfs failure on small file")).i

Xfstests implicitly uses '--mixed' options for filesystems smaller than
256mb thus the minimum filesystem size require is derived from the
following equation: 2 * (4mb + nodesize << 10). On a 64k page system
this evaluates to 2 * (4m + 64m) = 136m. This resuts in failures such:
mkfs.btrfs  -b $((100 * 1048576)) btrfs-test.img

    ERROR: size 104857600 is too small to make a usable filesystem
    ERROR: minimum size for btrfs filesystem is 114294784

when running _scratch_mkfs_sized $((100 * 1048576)).

Fix this by increasing the minimum filesystem size to 196 megabytes
which makes mkfs.btrfs happy again and allows the test to proceed.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/casefold: only check for the Casefold flag
Theodore Ts'o [Mon, 26 Aug 2019 17:50:20 +0000 (13:50 -0400)]
common/casefold: only check for the Casefold flag

The _casefold_lsattr_dir function lists all of the file attributes.
As result, tests/generic/556.out has an ext4-specific assumption
that the test directories will have the Extents attribute. That
won't be true for all file systems, and it won't even be true for
ext4 file systems that do not have the extents feature enabled.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: test for failure to unlock inode after chgrp fails with EDQUOT
Darrick J. Wong [Tue, 27 Aug 2019 15:08:50 +0000 (08:08 -0700)]
generic: test for failure to unlock inode after chgrp fails with EDQUOT

This is a regression test that checks for xfs drivers that fail to
unlock the inode after changing the group id fails with EDQUOT.  It
pairs with "xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails
due to EDQUOT".

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>
2 years agot_stripealign: Fix fibmap error handling
Carlos Maiolino [Fri, 23 Aug 2019 09:25:30 +0000 (11:25 +0200)]
t_stripealign: Fix fibmap error handling

FIBMAP only returns a negative value when the underlying filesystem
does not support FIBMAP or on permission error. For the remaining
errors, i.e. those usually returned from the filesystem itself, zero
will be returned.

We can not trust a zero return from the FIBMAP, and such behavior
made generic/223 succeed when it should not.

Also, we can't use perror() only to print errors when FIBMAP failed,
or it will simply print 'success' when a zero is returned.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/500: doesn't work for btrfs
Josef Bacik [Thu, 15 Aug 2019 18:26:59 +0000 (14:26 -0400)]
generic/500: doesn't work for btrfs

Btrfs does COW, so when we unlink the file we need to update
metadata and write it to a new location, which we can't do because
the thinp is full.  This results in an EIO during a metadata write,
which makes us flip read only, thus making it impossible to fstrim
the fs.  Just make it so we skip this test for btrfs.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/322: fix bad xfs_io sync_range command
Andreas Gruenbacher [Mon, 19 Aug 2019 08:57:36 +0000 (10:57 +0200)]
generic/322: fix bad xfs_io sync_range command

Add the missing range arguments to the sync_range command in this test:
according to Josef Bacik, the sync_range command is required to make the test
reproduce the critical situation reliably.

[Eryu: fix dumping xfs_io output to $seqres.full, don't check
xfs_io's exit status]

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon: filter aiodio dmesg after fs/iomap.c to fs/iomap/ move
Darrick J. Wong [Thu, 15 Aug 2019 15:19:12 +0000 (08:19 -0700)]
common: filter aiodio dmesg after fs/iomap.c to fs/iomap/ move

Since the iomap code are moving to fs/iomap/ we have to add new
entries to the aiodio dmesg filter to reflect this.  It's still
possible for filesystems using iomap for directio to cough up
WARNings when a direct write collides with a buffered write, since
in some cases we catch that early enough to have the direct write
return EIO (which was covered by filter $warn7 previously).

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>
3 years agogeneric/561: kill duperemove directly
Darrick J. Wong [Thu, 15 Aug 2019 15:19:06 +0000 (08:19 -0700)]
generic/561: kill duperemove directly

While the kill statement added in the previous patch usually
suffices to shut down the bash loop that runs the duperemove
processes, for whatever reason this sometimes fails to kill
duperemove.  Kill the duperemove processes directly after removing
the run file, which should cause the bash loop to exit immediately.

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>
3 years agogeneric/081: fix lvm config not being cleaned up properly
Darrick J. Wong [Thu, 15 Aug 2019 15:18:59 +0000 (08:18 -0700)]
generic/081: fix lvm config not being cleaned up properly

Fix a race between _cleanup and dmeventd that causes the lvm
configuration not to be cleaned up and subsequent tests to fail.

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>
3 years agogeneric/519: Optimize overlap detection
Nikolay Borisov [Thu, 15 Aug 2019 10:22:40 +0000 (13:22 +0300)]
generic/519: Optimize overlap detection

Currently generic/519 takes around 5-10 minutes for me. This is
mainly due to the fact it uses a bunch of commands which spawn
processes. This, coupled by the fact the algorithm is O(n^2) in the
number of lines (624) for the sparse file and that test feels like
it's hung.

Fix this by re-implementing the existing logic in awk. This causes a
s single processes to be spawned and the rest of the processing is
done in-memory. This makes the test complete in 2 seconds for me.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/517: make test work on filesystems with block size greater than 4Kb
Filipe Manana [Tue, 13 Aug 2019 16:22:55 +0000 (17:22 +0100)]
generic/517: make test work on filesystems with block size greater than 4Kb

The test currently fails on filesystems with a block size greater
than 4Kb, as dedupe operations fail with -EINVAL because the file
offsets used are not multiples of such block sizes (but they are
multiples of 4Kb, 2Kb and 1Kb).

So update the test to use offsets that are multiples of 64Kb, since
that allows the test to work on filesystems with any block size
between 4Kb and 64Kb (8Kb, 16Kb, 32Kb). Verified it works as
expected on kernels that have the fixes for the issue tested by this
test case (listed in the changelog of commit
91540ef980110f78161893f98d946e2afa0c1f4a), and on systems without
those fixes (a 4.18 kernel), it fails as it is supposed to.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoseek_sanity_test: Repair check for unwritten extent support
Andreas Gruenbacher [Wed, 7 Aug 2019 11:25:14 +0000 (13:25 +0200)]
seek_sanity_test: Repair check for unwritten extent support

In test_basic_support, commit f3c1bca7fb25 ("generic: Test that
SEEK_HOLE can find a punched hole") cleverly punched a hole in the test
file in the middle of the check for unwritten extent support, making
sure we would never detect when unwritten extent support is missing.
Fix that.

While at it, explicitly check for SEEK_DATA support as well:  so far, we
were assuming that SEEK_HOLE support implies SEEK_DATA support, but it
won't hurt to actually check.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoaio-dio-regress: code clarification
Andreas Gruenbacher [Mon, 5 Aug 2019 22:49:29 +0000 (00:49 +0200)]
aio-dio-regress: code clarification

In this test, FILE_SIZE is defined as 300 but that definition isn't
used consistently.  Make the code more obvious.

(Used by generic/210.)

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/097: always mkfs with finobt enabled
Yong Sun [Wed, 7 Aug 2019 09:21:27 +0000 (09:21 +0000)]
xfs/097: always mkfs with finobt enabled

xfs/097 already requires finobt support by

_require_xfs_mkfs_finobt
_require_xfs_finobt

Always enable finobt feature at mkfs time, so test runs even finobt
is not set in MKFS_OPTIONS.

[Eryu: rewrite commit summary and log]

Signed-off-by: Yong Sun <yosun@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agolog-writes: Handle unrecognized options to prevent segfault
Qu Wenruo [Thu, 8 Aug 2019 07:29:40 +0000 (15:29 +0800)]
log-writes: Handle unrecognized options to prevent segfault

[BUG]
When using --help parameter (unrecognized) after valid --log/--replay,
log-writes just crashes:
  Starting program: replay-log --log /dev/test/test  --replay /dev/test/scratch1 --help
  /home/adam/xfstests-dev/src/log-writes/replay-log: unrecognized option '--help'

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7f5cc55 in __strlen_avx2 () from /usr/lib/libc.so.6
  (gdb) bt
  #0  0x00007ffff7f5cc55 in __strlen_avx2 () from /usr/lib/libc.so.6
  #1  0x00007ffff7e89363 in strdup () from /usr/lib/libc.so.6
  #2  0x00005555555554ac in main (argc=6, argv=0x7fffffffea78)
      at replay-log.c:219

[CAUSE]
We didn't check return value from getopt_long() for unrecognized
parameter, thus we reuse the old opt_index, and if that option needs an
parameter, we will access optarg which can be NULL and cause segfault.

[FIX]
Check return value from getopt_long() for '?' to handle unrecognized
options correctly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/quota: enable project quota correctly on f2fs
Chao Yu [Mon, 29 Jul 2019 11:56:20 +0000 (19:56 +0800)]
common/quota: enable project quota correctly on f2fs

Add a case for f2fs on _scratch_enable_pquota() to enable
dependent features of project quota by mkfs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test statfs on project quota directory
Zorro Lang [Sun, 28 Jul 2019 09:07:15 +0000 (17:07 +0800)]
xfs: test statfs on project quota directory

There's a bug on xfs cause statfs get negative f_ffree value from
a project quota directory. It's fixed by "de7243057 fs/xfs: fix
f_ffree value for statfs when project quota is set". So add statfs
testing on project quota block and inode count limit.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test new v5 bulkstat commands
Darrick J. Wong [Thu, 1 Aug 2019 01:43:10 +0000 (18:43 -0700)]
xfs: test new v5 bulkstat commands

Check that the new v5 bulkstat commands do everything the old one do,
and then make sure the new functionality actually works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/xfs: refactor agcount calculation for mounted filesystems
Darrick J. Wong [Thu, 1 Aug 2019 01:43:04 +0000 (18:43 -0700)]
common/xfs: refactor agcount calculation for mounted filesystems

Create a helper function to return the number of AGs of a mounted
filesystem so that we can get rid of the open-coded versions in various
tests.  The new helper will be used in a subsequent patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: add the new v5 bulkstat/inumbers ioctl structures
Darrick J. Wong [Thu, 1 Aug 2019 01:42:57 +0000 (18:42 -0700)]
xfs/122: add the new v5 bulkstat/inumbers ioctl structures

The new v5 bulkstat and inumbers structures are correctly padded so that
no format changes are necessary across platforms, so add them to the
output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: mask wonky ioctls
Darrick J. Wong [Thu, 1 Aug 2019 01:42:47 +0000 (18:42 -0700)]
xfs/122: mask wonky ioctls

Don't check the structure size of the inogrp/bstat/fsop_bulkreq
structures because they're incorrectly padded.  When we remove the
old typdefs the old filter stops working.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: ignore inode geometry structure
Darrick J. Wong [Thu, 1 Aug 2019 01:42:41 +0000 (18:42 -0700)]
xfs/122: ignore inode geometry structure

Ignore new in-core structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/194: unmount forced v4 fs during cleanup
Darrick J. Wong [Thu, 25 Jul 2019 18:04:13 +0000 (11:04 -0700)]
xfs/194: unmount forced v4 fs during cleanup

Unmount the V4 filesystem we forcibly created to run this test during
test cleanup so that the post-test wrapup checks won't try to remount
the filesystem with different MOUNT_OPTIONS (specifically, the ones
that get screened out by _force_xfsv4_mount_options) and fail.

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>
3 years agoxfs/033: filter out root inode nlink repair
Darrick J. Wong [Wed, 24 Jul 2019 15:56:31 +0000 (08:56 -0700)]
xfs/033: filter out root inode nlink repair

A couple of releases ago, xfs_repair was patched to set the root inode
link count correctly when messing around with lost inodes.  However, the
old xfs_repair remains in the golden output, so remove it and filter the
line so that we don't cause 'new' regressions on old software.

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>
3 years agofstests: disable quotas before running test
Darrick J. Wong [Wed, 24 Jul 2019 15:56:10 +0000 (08:56 -0700)]
fstests: disable quotas before running test

For all the tests which require that quotas be disabled, remove the
quota mount options before mounting the scratch filesystem.

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>
3 years agogeneric/506: mount scratch fs before testing for prjquota presence
Darrick J. Wong [Wed, 24 Jul 2019 15:55:43 +0000 (08:55 -0700)]
generic/506: mount scratch fs before testing for prjquota presence

On XFS, the _require_prjquota helper takes a path to a block device,
but (unintuitively) requires the block device to be mounted for the
detection to work properly.  Fix the detection code in generic/506.

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>
3 years agogeneric/561: kill duperemove after sleep_time
Darrick J. Wong [Wed, 24 Jul 2019 04:13:06 +0000 (21:13 -0700)]
generic/561: kill duperemove after sleep_time

generic/561 can take a very long time to run on XFS (45+ minutes)
because it kicks off fsstress and a lot of duperemove processes,
waits 50 seconds, and then waits for the duperemove processes to
finish.  duperemove, however, fights with fsstress for file locks
and can take a very long time to make even a single pass over the
filesystem and exit, which means the test just takes forever to run.

Once we've decided to tear down the duperemove processes let's just send
them SIGINT and then wait for them to exit.

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>
3 years agoxfs/504: fix bogus test description
Darrick J. Wong [Wed, 24 Jul 2019 04:13:00 +0000 (21:13 -0700)]
xfs/504: fix bogus test description

Fix the description of this test to reflect what it actually checks.

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>
3 years agooverlay/065: adjust test to expect EBUSY only with index=on
Amir Goldstein [Sun, 28 Jul 2019 10:21:24 +0000 (13:21 +0300)]
overlay/065: adjust test to expect EBUSY only with index=on

This is needed to support the kernel regression fix commit 0be0bfd2de9d
("ovl: fix regression caused by overlapping layers detection").

Overlayfs mount is not supposed to fail due to upper/work dir in-use
by other mount unless option index=on is enabled.

Add test variants for index=on and index=off.

Fix some wrong comments and clean noise lines in golden output.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: ceph only supports default SEEK_HOLE behavior
Jeff Layton [Fri, 26 Jul 2019 13:45:52 +0000 (09:45 -0400)]
common/rc: ceph only supports default SEEK_HOLE behavior

CephFS currently has only a very primitive SEEK_HOLE implementation,
and always sets the offset to EOF when it's used. Remove it from the
whitelist.

Cc: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: check quota sysfile feature for f2fs
Chao Yu [Tue, 23 Jul 2019 09:25:29 +0000 (17:25 +0800)]
common/rc: check quota sysfile feature for f2fs

In _require_prjquota(), f2fs missed to check whether we have enabled
quota sysfile feature in the image, add it.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/quota: support f2fs in _require_quota() and _check_quota_usage()
Chao Yu [Tue, 23 Jul 2019 09:25:28 +0000 (17:25 +0800)]
common/quota: support f2fs in _require_quota() and _check_quota_usage()

This can let f2fs pass the check of quota testcases.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: cross-device copy_file_range test
Amir Goldstein [Mon, 15 Jul 2019 12:55:16 +0000 (15:55 +0300)]
generic: cross-device copy_file_range test

Old kernels do not support cross-device copy_file_range.

This is a regression test for kernel commit:

  5dae222a5ff0 vfs: allow copy_file_range to copy across devices

[Amir] Split out cross-device copy_range test to a new test and
_notrun if kernel/filesystem do not support cross-device copy_range.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: copy_file_range bounds test
Amir Goldstein [Mon, 15 Jul 2019 12:55:15 +0000 (15:55 +0300)]
generic: copy_file_range bounds test

Test that copy_file_range will return the correct errors for various
error conditions and boundary constraints.

This is a regression test for kernel commit:

  96e6e8f4a68d ("vfs: add missing checks to copy_file_range")

[Amir] Split out cross-device copy_range test and use only test dev.
Split out immutable/swapfile test cases to reduce the requirements to
run the bounds check to minimum and get coverage for more filesystems.
Remove the tests for read past EOF and write after chmod -r,
because we decided to stick with read(2)/write(2) semantics.
Add requirements needed for large size copy tests and fifo test.
Use existing char/block devices for char/block dev tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: check support for xfs_io copy_range -f N
Amir Goldstein [Mon, 15 Jul 2019 12:55:14 +0000 (15:55 +0300)]
common/rc: check support for xfs_io copy_range -f N

Implement "_require_xfs_io_command copy_range -f" to check for
the option added by following xfsprogs commit:

  10d4ca4aeff5 ("xfs_io: allow passing an open file to copy_range")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared/011: move to generic/
Christoph Hellwig [Mon, 15 Jul 2019 08:25:23 +0000 (10:25 +0200)]
shared/011: move to generic/

Now that we run the test for all block device based file systems, there
is no reason to keep it out of generic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared/011: run for all block device based file systems
Christoph Hellwig [Mon, 15 Jul 2019 08:25:22 +0000 (10:25 +0200)]
shared/011: run for all block device based file systems

Cgroupv2 writeback support can't be easily detected.  But it is
kindof expected from block based file systems and can be easily
added, so just assume support and fail if it doesn't work.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/cgroup2: better error message if cgroup2 fs is not mounted
Christoph Hellwig [Mon, 15 Jul 2019 08:25:21 +0000 (10:25 +0200)]
common/cgroup2: better error message if cgroup2 fs is not mounted

Improve the _require_cgroup2 helper to print a more useful message
if the cgroup2 fs is not mounted.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test incremental send after deduplication on both snapshots
Filipe Manana [Wed, 17 Jul 2019 12:24:39 +0000 (13:24 +0100)]
btrfs: test incremental send after deduplication on both snapshots

Test that an incremental send operation works after deduplicating into the
same file in both the parent and send snapshots.

This currently fails on btrfs and a kernel patch to fix it was submitted
with the subject:

  Btrfs: fix incremental send failure after deduplication

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: set max label length for f2fs
Chao Yu [Thu, 18 Jul 2019 09:11:54 +0000 (17:11 +0800)]
common/rc: set max label length for f2fs

f2fs can support FS_IOC_{GET,SET}FSLABEL now, set max label length
to enable generic/492 testcase for f2fs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/119: fix MKFS_OPTIONS exporting
Darrick J. Wong [Tue, 9 Jul 2019 17:49:53 +0000 (10:49 -0700)]
xfs/119: fix MKFS_OPTIONS exporting

This test originally exported its own MKFS_OPTIONS to force the tested
filesystem config to the mkfs defaults + test-specific log size options.
This overrides whatever the test runner might have set in MKFS_OPTIONS.

In commit 2fd273886b525 ("xfs: refactor minimum log size formatting
code") we fail to export our test-specific MKFS_OPTIONS before
calculating the minimum log size, which leads to the wrong min log size
being calculated once we fixed the helper to be smarter about mkfs options.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/016: calculate minimum log size and end locations
Darrick J. Wong [Tue, 9 Jul 2019 17:49:47 +0000 (10:49 -0700)]
xfs/016: calculate minimum log size and end locations

xfs/016 looks for corruption in the log when the log wraps.  However,
it hardcodes the minimum log size and the "95%" point where it wants to
start the "nudge and check for corruption" part of the test.  New
features require larger logs, which causes the test to fail when it
can't mkfs with the smaller log size and when that 95% point doesn't put
us within 20x "_log_traffic 2"s of the end of the log.

Fix the first problem by using the new min log size helper and replace
the 95% figure with an estimate of where we need to be to guarantee that
the 20x loop wraps the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: rework min log size helper
Darrick J. Wong [Tue, 9 Jul 2019 17:49:41 +0000 (10:49 -0700)]
xfs: rework min log size helper

The recent _scratch_find_xfs_min_logblocks helper has a major thinko in
it -- it relies on feeding a too-small size to _scratch_do_mkfs so that
mkfs will tell us the minimum log size.  Unfortunately, _scratch_do_mkfs
will see that first failure and retry the mkfs without MKFS_OPTIONS,
which means that we return the minimum log size for the default mkfs
settings without MKFS_OPTIONS.

This is a problem if someone's running fstests with a set of
MKFS_OPTIONS that affects the minimum log size.  To fix this, open-code
the _scratch_do_mkfs retry behavior so that we only do the "retry
without MKFS_OPTIONS" behavior if the mkfs failed for a reason other
than the minimum log size check.

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>
3 years agobtrfs/189: make the test work on systems with a page size greater than 4Kb
Filipe Manana [Fri, 5 Jul 2019 11:26:21 +0000 (12:26 +0100)]
btrfs/189: make the test work on systems with a page size greater than 4Kb

The test currently uses offsets and lengths which are multiples of
4K, but not multiples of 64K (or any other page size between 4Kb and
64Kb). This makes the reflink calls fail with -EINVAL because
reflink only operates on ranges that are aligned to the the
filesystem's block size.

Fix this by ensuring all ranges passed to the reflink calls are
aligned to 64K, so that the test works on any system regardless of
its page size.  The test still fails without the corresponding
kernel fix applied [1] as it is supposed to.

[1] 3c850b45110950 ("Btrfs: incremental send, fix emission of invalid clone operations")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/399: don't rely on xfs_io exit status
Eric Biggers [Mon, 8 Jul 2019 20:32:39 +0000 (13:32 -0700)]
generic/399: don't rely on xfs_io exit status

Unexpectedly, 'xfs_io -f $file -c "pwrite 0 1M"' exits with failure
status if the file can't be created, but exits with success status if an
error occurs actually writing data.  As discussed previously, xfs_io's
exit status has always been broken, and it will be difficult to fix:
https://marc.info/?l=linux-xfs&m=151269053129101&w=2

Because of this, generic/399 fails on ext4 if "-I 256" (256-byte inodes)
is specified in the mkfs options, e.g. with 'kvm-xfstests -c ext4/adv
generic/399'.  This is because the test tries to fill a filesystem
entirely with 1 MiB encrypted files, and it expects the xfs_io commands
to start failing when no more files should be able to fit.  But when the
filesystem supports in-inode xattrs, no blocks need to be allocated for
the encryption xattrs, so empty encrypted files can continue to be
created even after all the filesystem's blocks are in-use.

For better or worse, the convention for xfstests is to ignore the exit
status of xfs_io and instead rely on the printed error messages.  Thus,
other tests don't run into this problem.  So for now, let's fix the test
failure by making generic/399 do the same.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/449: test xfs_info on a mounted block device
Zorro Lang [Sat, 6 Jul 2019 14:52:17 +0000 (22:52 +0800)]
xfs/449: test xfs_info on a mounted block device

There was a bug, xfs_info fails on a mounted block device:

  # xfs_info /dev/mapper/testdev
  xfs_info: /dev/mapper/testdev contains a mounted filesystem

  fatal error -- couldn't initialize XFS library

  xfsprogs has fixed it by:

    bbb43745 xfs_info: use findmnt to handle mounted block devices

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>
3 years agocommon/rc: print out kernel version too
Mauricio Faria de Oliveira [Wed, 10 Jul 2019 17:58:09 +0000 (14:58 -0300)]
common/rc: print out kernel version too

The kernel version (uname -v) may also be needed in addition to
the kernel release (uname -r) in order to properly identify and
distinguish different kernel builds in some cases/distributions.

For example, in the Ubuntu kernel package the test/debug string
is usually a suffix to the version field, not the release field.

  $ uname -rv
  4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019

  $ uname -rv
  4.15.0-51-generic #55+test20190520b1 SMP Mon May 20 11:57:40 -03 2019

Looking at other OSes uname(1) man pages it looks like '-v' is
quite standard, and the Linux man page only cites '-p' and '-i'
as non-portable, so the change should be OK. The only caller is
the 'check' script for the header print out, so it's contained.

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/553[4]: correct kernel fix commit
Yang Xu [Wed, 10 Jul 2019 11:35:22 +0000 (19:35 +0800)]
generic/553[4]: correct kernel fix commit

commit 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
adds checks for immutablefile and swapfile instead of commit a31713517d
("vfs: introduce generic_file_rw_checks()").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test cloning large exents to a file with many small extents
Filipe Manana [Fri, 28 Jun 2019 22:08:36 +0000 (23:08 +0100)]
generic: test cloning large exents to a file with many small extents

Test that if we clone a file with some large extents into a file
that has many small extents, when the fs is nearly full, the clone
operation does not fail and produces the correct result.

This is motivated by a bug found in btrfs wich is fixed by the
following patches for the linux kernel:

 [PATCH 1/2] Btrfs: factor out extent dropping code from hole punch handler
 [PATCH 2/2] Btrfs: fix ENOSPC errors, leading to transaction aborts, when
             cloning extents

The test currently passes on xfs.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared,generic: move tests using duperemove to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:10 +0000 (18:59 -0400)]
shared,generic: move tests using duperemove to generic/

Add _require_scratch_duperemove which validates that the file system
supports duperemove.  This allows us to move three tests from shared/
to generic/.  This means these tests will automatically adapt when
duperemove supports other file systems.  Tests moved are:

shared/008 --> generic/559
shared/009 --> generic/560
shared/010 --> generic/561

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared,generic: move shared/006 to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:09 +0000 (18:59 -0400)]
shared,generic: move shared/006 to generic/

The shared/006 uses _scratch_mkfs_sized to create a limited size
file system, and then creates inodes until it gets ENOSPC, and then
checks to make sure the file system is consistent.  It then remounts
the file system, removes all of the files, and makes sure the file
system is consistent afterwards. This test was marked as only being
supported on ext[234] and xfs, and so it was in shared.

Now introduce a new _require_inode_limits() rule to run test on
filesystems that have a fixed inode number, then move the test to
generic.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared,ext4: move ext[234]-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:08 +0000 (18:59 -0400)]
shared,ext4: move ext[234]-specific tests out of shared/

Move the following tests:

shared/005 --> ext4/040
shared/007 --> ext4/041
shared/289 --> ext4/042

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: add ext4 group list when testing ext2 and ext3
Theodore Ts'o [Fri, 28 Jun 2019 22:59:07 +0000 (18:59 -0400)]
check: add ext4 group list when testing ext2 and ext3

Modern kernels use the ext4 implementation to support ext2 and ext3
mounts, and a number of the ext4 tests are actually suitable for
ext2 and ext3.  We're trying to move tests out of shared anyway, so
instead of moving tests from ext4/NNN to shared, let's just include
the ext4 group list when FSTYP is ext2 or ext3.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared,ext4: move ext4-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:06 +0000 (18:59 -0400)]
shared,ext4: move ext4-specific tests out of shared/

The tests shared/{001,003,004,272} test behaviour around the ext4's
journal.  As such, they are pointless to run on ext2, and ext3 no
longer is in kernels newer than 4.3.  (And most enterprise
distributions have been using ext4 to support the ext3 file system;
that capability has been around since 2.6.33.)  So we can move these
tests out of shared and into the ext4 class of tests:

shared/001 --> ext4/036
shared/003 --> ext4/037
shared/004 --> ext4/038
shared/272 --> ext4/039

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/encrypt: check that contents encryption is usable
Eric Biggers [Mon, 1 Jul 2019 17:12:55 +0000 (10:12 -0700)]
common/encrypt: check that contents encryption is usable

In _require_encryption_policy_support(), when checking whether the
encryption policy is usable, try creating a nonempty file rather
than an empty one.  This ensures that both the contents and
filenames encryption modes are available, rather than just the
filenames mode.

On f2fs this makes generic/549 be correctly skipped, rather than
failed, when run on a kernel built from the latest fscrypt.git tree
with CONFIG_CRYPTO_SHA256=n.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: project quota ineritance flag test
Zorro Lang [Wed, 19 Jun 2019 10:10:47 +0000 (18:10 +0800)]
xfs: project quota ineritance flag test

This case is used to cover xfsprogs bug fixed by commit b136f48b19a5
("xfs_quota: fix false error reporting of project inheritance flag
is not set") at first. Then test more behavior when project
ineritance flag is set or removed.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/486: filter out irrelevant attrs
Murphy Zhou [Thu, 27 Jun 2019 09:00:59 +0000 (17:00 +0800)]
generic/486: filter out irrelevant attrs

In some setup, there could be extra attrs printed, like selinux.
They are breaking golden output and irrelevant for this test.
So focus on the attr we are testing on to avoid false alarm.
Print the output to .full for debug.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: check for COW overflows in i_delayed_blks
Darrick J. Wong [Tue, 18 Jun 2019 21:07:37 +0000 (14:07 -0700)]
xfs: check for COW overflows in i_delayed_blks

With the new copy on write functionality it's possible to reserve so
much COW space for a file that we end up overflowing i_delayed_blks.
The only user-visible effect of this is to cause totally wrong i_blocks
output in stat, so check for that.

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>
3 years agooverlay/061: remove from auto and quick groups
Amir Goldstein [Tue, 18 Jun 2019 06:43:55 +0000 (09:43 +0300)]
overlay/061: remove from auto and quick groups

In late 2016, tests overlay/01[6-8] where merged to track the
state of several ilong standing posix compliance issues on overlayfs.

This practice was somewhat of an exception for xfstests project,
which more often merges tests for issues that are expected to be
resolved in the short term.

Over the years, some test cases have been fixed and more tests
where created to cover the remaining issues (e.g. overlay/04[34]).

Currently, the only failing test from this category is overlay/061
which covers item b) in the "Non-standard behavior" section of
Documentation/filesystems/overlayfs.txt.

Since there is no clear design, roadmap nor allocated resources
to resolve this remaining issue, the test is removed from the
"auto" and "quick" groups, following a suggestion that Darrick
has made for a similarly long failing generic test.

The test was added to the new "posix" group, to allow testing
for posix compliance.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/059: also test that the file's mtime and ctime are updated
Filipe Manana [Wed, 19 Jun 2019 12:06:24 +0000 (13:06 +0100)]
generic/059: also test that the file's mtime and ctime are updated

Test as well that hole punch operations that affect a single file block
also update the file's mtime and ctime.

This is motivated by a bug a found in btrfs which is fixed by the
following patch for the linux kernel:

 "Btrfs: add missing inode version, ctime and mtime updates when
  punching hole"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test dir fsync after deleting dentry post eviction of its inode
Filipe Manana [Wed, 19 Jun 2019 12:06:08 +0000 (13:06 +0100)]
generic: test dir fsync after deleting dentry post eviction of its inode

Test that if we fsync a file, evict its inode, unlink it and then fsync
its parent directory, after a power failure the file does not exists.

This is motivated by a bug found in btrfs, which is fixed by the following
patch for the linux kernel:

 "Btrfs: fix fsync not persisting dentry deletions due to inode evictions"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agodump: _cleanup_dump should only check the scratch fs if the test required it
Darrick J. Wong [Tue, 18 Jun 2019 21:07:08 +0000 (14:07 -0700)]
dump: _cleanup_dump should only check the scratch fs if the test required it

_cleanup_dump always tries to check the scratch fs, even if the caller
didn't actually _require_scratch.  If a previous test wrote garbage to
the scratch device then the dump test will fail here when repair
stumbles over the garbage.

This was observed by running xfs/016 and xfs/036 in succession.  xfs/016
writes 0xc6 to the scratch device and tries to format a small log.  If
the log is too small the format fails and the test will _notrun.  The
subsequent xfs/036 will _notrun and then _cleanup_dump if no tape device
is set, at which point we try to check the scratch device and logprint
aborts due to the abnormal log size (0xc6c6c6c6).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/532: document the kernel commit
Murphy Zhou [Wed, 19 Jun 2019 02:28:55 +0000 (10:28 +0800)]
generic/532: document the kernel commit

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewedf-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: fix _scratch_remount with xfs_info 5.0.0
Amir Goldstein [Mon, 17 Jun 2019 13:58:43 +0000 (16:58 +0300)]
overlay: fix _scratch_remount with xfs_info 5.0.0

xfs_info version 5.0.0 started using findmnt to find the
filesystem to query. This change resulted in a regression
of _scratch_remount when testing overlay over xfs.
For example, test overlay/035, started to report:
[not run] overlay/035 -- upper fs needs to support d_type

Internally, '_overlay_scratch_mount -o remount' calls
'_supports_filetype $OVL_BASE_SCRATCH_MNT -o remount'
and with the following example mounts:

/dev/vdf /vdf xfs rw,relatime,attr2,inode64,noquota 0 0
/vdf /vdf/ovl-mnt overlay rw,lowerdir=/vdf/lower,upperdir=/vdf/upper...

'_supports_filetype /vdf' returns false and reports:
"/vdf/ovl-mnt: Not on a mounted XFS filesystem".

Regardless of the change in xfs_info, which I proposed a fix
for, there is no reason to test d_type support on remount.
Therefore, fix the regression by skipping unneeded overlayfs
mount logic on remount.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: Add tests for filename casefolding feature
Lakshmipathi.G [Wed, 12 Jun 2019 18:40:33 +0000 (14:40 -0400)]
generic: Add tests for filename casefolding feature

This new test implements verification for the per-directory
case-insensitive feature, as supported by the reference
implementation in Ext4.

Signed-off-by: Lakshmipathi.G <lakshmipathi.ganapathi@collabora.co.uk>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
  [Rewrite to support feature design]
  [Refactor to simplify implementation]
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/casefold: Add infrastructure to test filename casefold feature
Gabriel Krisman Bertazi [Wed, 12 Jun 2019 18:40:32 +0000 (14:40 -0400)]
common/casefold: Add infrastructure to test filename casefold feature

Add a set of basic helper functions to simplify the testing of
casefolding capable filesystems.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: check CAP_LINUX_IMMUTABLE capability with FS_IOC_FSSETXATTR
Amir Goldstein [Tue, 11 Jun 2019 16:08:39 +0000 (19:08 +0300)]
generic: check CAP_LINUX_IMMUTABLE capability with FS_IOC_FSSETXATTR

This is a flavor of test generic/545 with FS_IOC_FSSETXATTR ioctl
instead of FS_IOC_SETFLAGS ioctl.

Overlayfs gained support for FS_IOC_FSSETXATTR ioctl in v5.2-rc4
with buggy capability check. This change fixed the problem:

  ovl: fix wrong flags check in FS_IOC_FS[SG]ETXATTR ioctls

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: check for filesystem FS_IOC_FSSETXATTR support
Amir Goldstein [Tue, 11 Jun 2019 16:08:38 +0000 (19:08 +0300)]
fstests: check for filesystem FS_IOC_FSSETXATTR support

With "_require_xfs_io_command chattr <letter>", check that
flag can be set/cleared using FS_IOC_FSSETXATTR ioctl, similar
to "_require_chattr <letter>" and FS_IOC_SETFLAGS ioctl.

Update the documentation and the tests that use
"_require_xfs_io_command chattr" to test filesystem support
and not only xfs_io support.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: print out xfs_io parameter when command fails
Amir Goldstein [Tue, 11 Jun 2019 16:08:37 +0000 (19:08 +0300)]
common/rc: print out xfs_io parameter when command fails

In _require_xfs_io_command, when command fails for one of the
generic reasons, if command was tested with params, print out
the params of the failed command.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs/146: remove unnecessary scratch unmount to avoid test failure
Filipe Manana [Wed, 12 Jun 2019 10:05:44 +0000 (11:05 +0100)]
btrfs/146: remove unnecessary scratch unmount to avoid test failure

Right at the beginning of the test we are unmonting the scratch device,
however at this point the device was never mounted, so the unmount fails
with an error message like the following:

  umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted

Which is not expected by the golden output and therefore causes the test
to fail.

Since the device/mount point was not mounted yet in the test, and since
the test framework unmounts the scratch device after each test finishes,
just remove the call to _scratch_unmount.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: don't oom the box opening tmpfiles (take 2)
Amir Goldstein [Sun, 9 Jun 2019 17:12:29 +0000 (20:12 +0300)]
fstests: don't oom the box opening tmpfiles (take 2)

For the t_open_tmpfiles tests that run multiple jobs in parallel,
limit ourselves to half of file-max for all jobs combined,
so that we don't OOM the test machine.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/035: skip this test if DAX is in use
Theodore Ts'o [Mon, 10 Jun 2019 02:42:54 +0000 (22:42 -0400)]
ext4/035: skip this test if DAX is in use

This test creates a file system with a 1k block size.  Since there
are no architectures with a 1k page size, the test file system can
never be mounted with DAX enabled, causing the test to fail.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/554: test only copy to active swap file
Amir Goldstein [Tue, 11 Jun 2019 15:39:16 +0000 (18:39 +0300)]
generic/554: test only copy to active swap file

Depending on filesystem, copying from active swapfile may be allowed,
just as read from swapfile may be allowed.

Note the kernel fix commit in test description.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/553: fix test description
Amir Goldstein [Tue, 11 Jun 2019 15:39:15 +0000 (18:39 +0300)]
generic/553: fix test description

The test only checks copy to immutable file.
Note the kernel fix commit.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoreport: gracefully handle XML report creation when no tests are run
Theodore Ts'o [Sun, 9 Jun 2019 21:04:31 +0000 (17:04 -0400)]
report: gracefully handle XML report creation when no tests are run

If no tests are run (because they have all been excluded) then make
sure we insert a valid timestamp into the XML file, and avoid printing
an error message when reading a non-existent test summary scratch
file.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: copy_file_range swapfile test
Amir Goldstein [Sun, 2 Jun 2019 12:41:11 +0000 (15:41 +0300)]
generic: copy_file_range swapfile test

Check that we cannot copy_file_range() to/from a swapfile.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: copy_file_range immutable file test
Amir Goldstein [Sun, 2 Jun 2019 12:41:10 +0000 (15:41 +0300)]
generic: copy_file_range immutable file test

Check that we cannot copy_file_range() to/from an immutable file.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: create copy_range group
Amir Goldstein [Sun, 2 Jun 2019 12:41:09 +0000 (15:41 +0300)]
generic: create copy_range group

Move some tests to the copy_range group so they are distinct
from the copy group which refers to xfs_copy tests.

[Amir] Revert copy past EOF behavior change

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: try to insulate the test framework from oom killer
Darrick J. Wong [Tue, 4 Jun 2019 21:16:49 +0000 (14:16 -0700)]
check: try to insulate the test framework from oom killer

Some of the tests in xfstests (e.g. generic/224 with 512M of memory)
consume a lot of memory, and when this happens the OOM killer will
run around stomping on processes.  Sometimes it kills the ./check
process before it kills the actual test, which means that the test
run doesn't complete.

Therefore, make the ./check process OOM-proof while bumping up the
attractiveness of the test itself, in the hopes that even if the
test OOMs we'll still be able to continue on our way.

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>
3 years agofstests: remove obsolete xfs ioctl typedef usage
Darrick J. Wong [Tue, 4 Jun 2019 21:17:01 +0000 (14:17 -0700)]
fstests: remove obsolete xfs ioctl typedef usage

Convert 'xfs_foo_t' typedef usage to 'struct xfs_foo' in preparation
for changes to some of the xfs ioctls.

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>
3 years agoxfs/122: add new ioctl structures
Darrick J. Wong [Tue, 4 Jun 2019 21:16:55 +0000 (14:16 -0700)]
xfs/122: add new ioctl structures

Add some new ioctls that are being introduced in 5.2.

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>
3 years agogeneric: test for data loss on fsync after evicting an inode and renaming it
Filipe Manana [Thu, 6 Jun 2019 11:07:47 +0000 (12:07 +0100)]
generic: test for data loss on fsync after evicting an inode and renaming it

Check that if we write some data to a file, its inode gets evicted
(while its parent directory's inode is not evicted due to being in
use), then we rename the file and fsync it, after a power failure
the file data is not lost.

This currently passes on xfs, ext4 and f2fs but fails on btrfs. The
following patch for btrfs fixes it:

  "Btrfs: fix data loss after inode eviction, renaming it, and fsync it"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs/048: add validation of compression options
Johannes Thumshirn [Fri, 7 Jun 2019 09:09:37 +0000 (11:09 +0200)]
btrfs/048: add validation of compression options

The current btrfs/048 test-case did not check the behavior of
properties with options like compression and with the compression
level supplied.

Add test cases for compression with compression level as well so we
can be sure we don't regress there.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs/163: make readahead run on the seed device
Naohiro Aota [Fri, 7 Jun 2019 05:39:10 +0000 (14:39 +0900)]
btrfs/163: make readahead run on the seed device

There is a long lived bug that btrfs wait for readahead to finish
indefinitely when readahead zone is inserted into seed devices.

Current write size to the file "foobar" is too small to run readahead
before the replacing on seed device. So, increase the write size to
reproduce the issue.

Following patch fixes it:

"btrfs: start readahead also in seed devices"

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: Test mount error cases with overlapping layers
Amir Goldstein [Tue, 28 May 2019 08:27:14 +0000 (11:27 +0300)]
overlay: Test mount error cases with overlapping layers

Add tests for overlayfs mounts with:
- Same upperdir/lowerdir
- Overlapping upperdir/lowerdir
- Overlapping lowerdir layers
- Overlapping lowerdir with other mount upperdir/workdir

Add test for moving layer into another after mount.

Overlapping layers on mount or lookup results in ELOOP.
Overlapping lowerdir with other mount upperdir/workdir
result in EBUSY.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: fix exit code for some fsck.overlay valid cases
zhangyi (F) [Tue, 28 May 2019 15:17:23 +0000 (18:17 +0300)]
overlay: fix exit code for some fsck.overlay valid cases

Some valid test cases about fsck.overlay may be not valid enough now,
they lose the impure xattr on the parent directory of the simluated
redirect directory, and lose the whiteout which use to cover the origin
lower object. Then fsck.overlay will fix these two inconsistency which
are not those test cases want to cover, thus it will lead to
fsck.overlay return FSCK_NONDESTRUCT instead of FSCK_OK. Fix these by
complement the missing overlay related features.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: correct fsck.overlay exit code
zhangyi (F) [Tue, 28 May 2019 15:17:22 +0000 (18:17 +0300)]
overlay: correct fsck.overlay exit code

fsck.overlay should return correct exit code to show the file system
status after fsck, instead of return 0 means consistency and !0 means
inconsistency or something bad happened.

Fix the following three exit code after running fsck.overlay:

- Return FSCK_OK if the input file system is consistent,
- Return FSCK_NONDESTRUCT if the file system inconsistent errors
  corrected,
- Return FSCK_UNCORRECTED if the file system still have inconsistent
  errors.

This patch also add a helper function to run fsck.overlay and check
the return value is expected or not.

[amir] rename helper to _overlay_fsck_expect, split define of FSCK_*
to a seprate path.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: fix _repair_scratch_fs
Amir Goldstein [Tue, 28 May 2019 15:17:21 +0000 (18:17 +0300)]
overlay: fix _repair_scratch_fs

_repair_scratch_fs did not do the right thing for overlay.
Implement and call _repair_overlay_scratch_fs to repair
overlay filesystem and then fall through to repair base filesystem.

The only tests currentrly calling _repair_scratch_fs on a
./check -overlay run are generic/330 generic/332 in case the
base fs supports reflink. The rest of the tests calling
_repair_scratch_fs require that $SCRATCH_DEV is a block device.

Suggested-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: define constants for fsck exit codes
Amir Goldstein [Tue, 28 May 2019 15:17:20 +0000 (18:17 +0300)]
fstests: define constants for fsck exit codes

Define the constants for hard coded values used in _repair_scratch_fs()
to check fsck exit code.

Suggested-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: fix _repair_scratch_fs error reporting
Amir Goldstein [Tue, 28 May 2019 12:08:47 +0000 (15:08 +0300)]
common/rc: fix _repair_scratch_fs error reporting

_dump_err2() helper was introduced over two years ago and it broke
the error reporting from _repair_scratch_fs.

Every test that runs:
_repair_scratch_fs >> $seqres.full

and expect to fail if anything is written to stderr is not working
as intended.

Reported-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4: regression test for online resizing maximum blocks
Yang Xu [Fri, 31 May 2019 02:12:27 +0000 (10:12 +0800)]
ext4: regression test for online resizing maximum blocks

This adds a regression test for online resizing maximum blocks
which can trigger a BUG_ON with non-zero s_first_data_block
filesystem.

The bug was fixed by patch:
f96c3ac8dfc2 ("ext4: fix crash during online resizing")

The bug was introduced by patch:
1c6bd7173d66 ("ext4: convert file system to meta_bg if needed during
resizing")

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/278: use _scratch_xfs_repair helper instead of xfs_repair
Anthony Iliopoulos [Tue, 28 May 2019 16:27:44 +0000 (18:27 +0200)]
xfs/278: use _scratch_xfs_repair helper instead of xfs_repair

Use _scratch_xfs_repair helper instead of calling xfs_repair
directly, as local.config may want to define $XFS_REPAIR_PROG
and override the default binary in the search path.

Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs/190: Fix a typo for seqres.full
Qu Wenruo [Thu, 30 May 2019 01:28:15 +0000 (09:28 +0800)]
btrfs/190: Fix a typo for seqres.full

$seqref.full -> $seqres.full

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: aio random write and verify stress test
Zorro Lang [Mon, 13 May 2019 01:49:04 +0000 (09:49 +0800)]
generic: aio random write and verify stress test

We found some AIO write related bugs recently, so I think a AIO
random write test is needed. By the new aio-aio-write-verify.c tool,
we can do this easily.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>