xfstests-dev.git
5 years agobtrfs: Test if btrfs will commit too many transactions for balance
Qu Wenruo [Tue, 29 Jan 2019 12:32:21 +0000 (20:32 +0800)]
btrfs: Test if btrfs will commit too many transactions for balance

Kernel commit 64403612b73a ("btrfs: rework
btrfs_check_space_for_delayed_refs") is introducing a regression for
btrfs balance performance.

Since that commit will cause btrfs to commit too many transactions
for nothing during balance/relocation, it will slow balance
dramatically even we only need to relocate several megabytes.

This test case will catch the problem by using super block
generation as failure criteria.

For small chunk relocated, we will commit 6 transactions for each
block group, and the test case should only have 2 block groups, it
should only commit 12 transactions.

This test case will use 120 as the threshold to detect the failure.

And in my test environment, with kernel fix btrfs committed 14
transactions. While without the fix btrfs committed 209
transactions.

So the test case should be enough to detect the regression, while still
keep the runtime small enough for failure.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: Test if btrfs hits EDQUOT without trying to reclaim some space
Qu Wenruo [Tue, 29 Jan 2019 12:32:20 +0000 (20:32 +0800)]
btrfs: Test if btrfs hits EDQUOT without trying to reclaim some space

Commit a514d63882c3 ("btrfs: qgroup: Commit transaction in advance
to reduce early EDQUOT") is no longer forcing transaction commit to
reclaim space, and only commits transaction asynchronously in
advance to address it.

However the criteria used in async transaction commit is not
comprehensive, thus it doesn't reclaim space automatically.

This test case will check the behavior by:
1) Falloc a large padding file
   This file will take 90% of the qgroup limit

2) Sync the fs
   To reflect the qgroup changes

3) Delete the file
   Qgroup won't reclaim the space until transaction committed.

4) Try to write a file
   If kernel not fixed, qgroup will not automatically commit transaction
   to reclaim the freed space and hit EDQUOT.

This bug is going to be fixed by a patch for kernel titled:
"btrfs: qgroup: Make qgroup async transaction commit more aggressive".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/131: require support for free-space-tree
Jeff Mahoney [Mon, 21 Jan 2019 16:33:15 +0000 (11:33 -0500)]
btrfs/131: require support for free-space-tree

btrfs/131 tests the free space tree, which older kernels won't have.
We shouldn't run there.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/023: skip trying to test raid56 without kernel support
Jeff Mahoney [Mon, 21 Jan 2019 16:33:14 +0000 (11:33 -0500)]
btrfs/023: skip trying to test raid56 without kernel support

Older kernels don't support raid56.  This test is still valid for
other profiles, so skip raid56 if the kernel doesn't support it.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: require feature raid56 for raid56 tests
Jeff Mahoney [Mon, 21 Jan 2019 16:33:13 +0000 (11:33 -0500)]
btrfs: require feature raid56 for raid56 tests

btrfs/125, btrfs/148, btrfs/157, and btrfs/158 test for raid56
behavior.  We shouldn't run if the kernel doesn't have support for
them.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/010: don't run without /sys/fs/btrfs
Jeff Mahoney [Mon, 21 Jan 2019 16:33:10 +0000 (11:33 -0500)]
btrfs/010: don't run without /sys/fs/btrfs

Older kernels don't have /sys/fs/btrfs.  btrfs/010 will happily run
until it goes to check its work against sysfs and finds those files
don't exist.  This patch introduces a require check to ensure that
the sysfs files are present before running.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/081: fix killing of reader loop subshell
Filipe Manana [Fri, 25 Jan 2019 11:46:24 +0000 (11:46 +0000)]
btrfs/081: fix killing of reader loop subshell

The test creates a subshell that keeps running the 'cat' command
against a test file in an infinite loop, and after it kills the
subshell it unmounts the filesystem, after which point any 'cat'
subcommand that runs after or at that time will fail resulting in an
unexpected golden output:

  $ ./check btrfs/081
  btrfs/081 3s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/081.out.bad)
      --- tests/btrfs/081.out 2018-09-16 21:30:48.501104179 +0100
      +++ /home/fdmanana/git/hub/xfstests/results//btrfs/081.out.bad 2019-01-24 20:36:18.989746185 +0000
      @@ -206,5 +206,6 @@
       Verifying file digests after cloning
       14968c092c68e32fa35e776392d14523  SCRATCH_MNT/foo
       14968c092c68e32fa35e776392d14523  SCRATCH_MNT/bar
      +cat: /mnt/scratch/bar: No such file or directory
       Verifying target file digest after umount + mount
       14968c092c68e32fa35e776392d14523  SCRATCH_MNT/bar
      ...
      (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/081.out /home/fdmanana/git/hub/xfstests/results//btrfs/081.out.bad'  to see the entire diff)
  Ran: btrfs/081
  Failures: btrfs/081
  Failed 1 of 1 tests

Fix that by adding a proper trap to the reader loop function so that
the subshell waits for executed 'cat' commands when it receives
SIGTERM.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/081: declare local variables as local
Filipe Manana [Fri, 25 Jan 2019 11:46:11 +0000 (11:46 +0000)]
btrfs/081: declare local variables as local

Some variables inside the test's functions were used as local but
were not being declared as such. Add the local declaration for them.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/dump: disable splice from FSSTRESS_AVOID
Zorro Lang [Wed, 23 Jan 2019 07:34:55 +0000 (15:34 +0800)]
common/dump: disable splice from FSSTRESS_AVOID

New fsstress operation breaks fs dump/restore testing which use
fsstress, e.g xfs/068.

In _create_dumpdir_stress_num, disable splice in fsstress so that we
dump exactly the same set of files and directories.

Quote Dave's comments for future reference

"
fsstress is just creating regular files differently. It has no
impact on xfsdump does except to change the number of files created
and the directory layout.

If this new functionality were creating a new type of file that
xfsdump has to handle, or adding new attributes or changing the
metadata of the existing files, then we want to make sure xfsdump is
tested against that, and so we'd be changing the golden output after
careful checking that both xfsdump and xfs_restore are working
correctly and the file count is correct.

But when all we are doing is creating normal, regular files just
with a different syscall, it makes no sense to perturb the existing
test then we have to go and validate that the new set of files being
tested is actually scanned correctly, is complete and correct. Using
a blacklist to avoid unnecessary perturbation such as in cases like
this is the right thing to do because we've had to determine if the
new functionality is a useful addition to xfsdump/restore test
coverage or not.
"

[Eryu: add Dave's comments in commit log for future reference]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsstress: add splice support
Zorro Lang [Sat, 19 Jan 2019 02:42:57 +0000 (10:42 +0800)]
fsstress: add splice support

Support the splice syscall in fsstress.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay: File capabilities should not be lost over copy-up
Vivek Goyal [Wed, 16 Jan 2019 21:04:15 +0000 (16:04 -0500)]
overlay: File capabilities should not be lost over copy-up

Make sure file capabilities are not lost over copy-up when file is
opened for WRITE but nothing is actually written to it.

Following commit introduced regression where if a lower file with
CAP_SETUID is opened for writing, and capability is cleared over copy up.

bd64e57586d3 ("ovl: During copy up, first copy up metadata and then data")

A later kernel patch will fix it. This test will help avoid introducing
such regressions again.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test writepage cached mapping validity
Brian Foster [Tue, 15 Jan 2019 14:09:45 +0000 (09:09 -0500)]
generic: test writepage cached mapping validity

XFS has a bug where page writeback can end up sending data to the
wrong location due to a stale, cached file mapping. Add a test to
trigger this problem by racing background writeback with a
truncate/rewrite of the final page of the file.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test for deadlock between snapshot delete and other read-write operations
Qu Wenruo [Fri, 11 Jan 2019 05:01:51 +0000 (13:01 +0800)]
btrfs: test for deadlock between snapshot delete and other read-write operations

Commit fb235dc06fac ("btrfs: qgroup: Move half of the qgroup
accounting time out of commit trans") could cause ABBA deadlock
between backref lookup with write lock hold (subvolume deletion) and
other read/write operations.

It's going to be fixed by "btrfs: qgroup: Don't trigger backref walk
at delayed ref insert time".

This test will generate pwrite background workload, along with
constant subvolume creation and deletion to trigger the bug.

It needs some time to generate enough files to bump the tree height
to trigger the bug.

In my test environment, with 'unsafe' cache mode for the VM, it
triggers the bug at around 70~90 seconds. So I leave the default
runtime to 120s to make sure the bug will be triggered.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: Make seed device test cases into their own group
Qu Wenruo [Thu, 10 Jan 2019 06:14:14 +0000 (14:14 +0800)]
btrfs: Make seed device test cases into their own group

btrfs/16[123] are all seed device related test cases, make them into
'seed' group.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test that xattrs can have slashes in their names
Darrick J. Wong [Fri, 4 Jan 2019 23:14:48 +0000 (15:14 -0800)]
generic: test that xattrs can have slashes in their names

Eric Sandeen recently found a bug in xfs_repair that flagged extended
attribute names containing "/" as corrupt and purged them.  There's
nothing in the IRIX or Linux manuals that say anything about slashes not
being allowed (and Linux certainly allows this) so let's make sure this
continues to work.

[Eryu: use $SETFATTR and _getfattr helper]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/423: statx mask of the reference file is different from the original file
Cui Yue [Thu, 10 Jan 2019 03:14:59 +0000 (22:14 -0500)]
generic/423: statx mask of the reference file is different from the original file

When running xfstests generic/423 to test system call statx() on
hard link files of NFS, it fails.  error message:

[!] attr 'stx_mask' differs from ref file, 7ff != e0

The values of parameter "mask" between the original file and the
reference file are different.  One is STATX_ALL;
The other is STATX_ATIME | STATX_BTIME | STATX_CTIME | STATX_MTIME.

Modify the function get_reference() to pass the "mask" in, and
change STATX_ATIME | STATX_BTIME | STATX_CTIME | STATX_MTIME to
"mask".

Signed-off-by: Cui Yue <cuiyue-fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoRevert "common/config: create $RESULT_BASE before dumping kmemleak leaks"
Nikolay Borisov [Fri, 4 Jan 2019 14:31:16 +0000 (16:31 +0200)]
Revert "common/config: create $RESULT_BASE before dumping kmemleak leaks"

This commit tried to fix the brokennes of the kmemleak support but it
inadvertently broke the creation of the RESULT_BASE directory which lead to
problems creating check.time file. Turns out kmemleak support in xfstests has
more problems and it needs to be majorly refactor and this commit doesn't
really solve the problem. For the time being just revert to at least allow
older configuration files, which have explicitly set RESULT_BASE to work.

This reverts commit 7fc034868d5dce9aaf3517c9c2197221b9a772e4.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/131: wait until the server is ready or timeout
Hou Tao [Fri, 4 Jan 2019 08:19:26 +0000 (16:19 +0800)]
generic/131: wait until the server is ready or timeout

When running xfstests under KVM VM and the load of host is high,
only delaying 1s and checking the readiness of server are not
enough, and the test case will fail early.

Fix it by repeatedly checking the readiness signal until it's found,
or timeout is triggered.

[Eryu: check if lock server died or not, like v1 patch did]

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsx: check ENOSYS in test_copy_range() & test_fallocate()
Hou Tao [Fri, 4 Jan 2019 08:19:27 +0000 (16:19 +0800)]
fsx: check ENOSYS in test_copy_range() & test_fallocate()

In configure script, we only check whether or not the build of test
program succeeds, but that doesn't mean the kernel has implemented
the syscall, so checking for this case.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/139-140: skip testing on large scratch dev
Zorro Lang [Wed, 2 Jan 2019 04:03:19 +0000 (12:03 +0800)]
xfs/139-140: skip testing on large scratch dev

x/139 and x/140 makes XFS with very small agsize. That agsize is too
small for a large fs. And it's not necessary to test on large fs, so
skip it directly if scratch dev is large dev.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/474: shift target directory to a sub-dir of SCRATCH_MNT
Zorro Lang [Wed, 2 Jan 2019 04:03:18 +0000 (12:03 +0800)]
generic/474: shift target directory to a sub-dir of SCRATCH_MNT

If testing on large fs (--large-fs option), there's a huge size
.use_space file in $SCRATCH_MNT, then `fssum $SCRATCH_MNT` trys to
read whole huge file. That's wasting time, so change the target path
to a sub-dir of $SCRATCH_MNT.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: only set XFS_MKFS_HAS_NO_META_SUPPORT for XFS
Hou Tao [Fri, 4 Jan 2019 08:56:10 +0000 (16:56 +0800)]
xfs: only set XFS_MKFS_HAS_NO_META_SUPPORT for XFS

No need to set XFS_MKFS_HAS_NO_META_SUPPORT for all filesystems.

Cc: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/466: explicitly request $SCRATCH_DEV to be a block device
Hou Tao [Sat, 29 Dec 2018 02:34:51 +0000 (10:34 +0800)]
generic/466: explicitly request $SCRATCH_DEV to be a block device

so "blockdev --getsize64 $SCRATCH_DEV" will succeed.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/019: require scratch device to be a block device
Hou Tao [Sat, 29 Dec 2018 02:34:49 +0000 (10:34 +0800)]
generic/019: require scratch device to be a block device

To ensure "blockdev --getsz $SCRATCH_DEV" will succeed.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocheck: use _try_scratch_mount instead of _scratch_mount to mount SCRATCH_DEV
Hou Tao [Sat, 29 Dec 2018 02:34:48 +0000 (10:34 +0800)]
check: use _try_scratch_mount instead of _scratch_mount to mount SCRATCH_DEV

Else there won't be any error messages when mounting SCRATCH_DEV
failed, because _scratch_mount exits early by invoking _fail.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/034: adjust commit which fixes the problem tested by ext4/034
Theodore Ts'o [Wed, 26 Dec 2018 16:08:05 +0000 (11:08 -0500)]
ext4/034: adjust commit which fixes the problem tested by ext4/034

Also add a requirment that fallocate and fiemap is supported.
(Fallocate isn't the case when we are emulating ext3, for example.)

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Liu Bo <obuil.liubo@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: look for stringified constants in ftrace formats
Darrick J. Wong [Tue, 18 Dec 2018 20:36:09 +0000 (12:36 -0800)]
xfs: look for stringified constants in ftrace formats

Look for uninterpretable stringified constants in the ftrace format
description for xfs tracepoints.

[Eryu: add $CC_PROG definition and require it in test, also use
$DEBUGFS_MNT instead of hard coded path]

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>
5 years agoxfs: filter out mount options that don't work on v4 filesystems
Darrick J. Wong [Tue, 18 Dec 2018 20:36:16 +0000 (12:36 -0800)]
xfs: filter out mount options that don't work on v4 filesystems

A few tests require v4 filesystems and enforce this by disabling
crc's in the _scratch_mkfs call.  However, if the user specified
MOUNT_OPTIONS that only work with v5 filesystems, these tests fail.
If we detect a test creating a v4 scratch filesystem, filter out
incompatible mount options that don't work on v4, such as
simultaneous group/project quota.

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>
5 years agogeneric/050: fix ro blockdev mount of xfs with quota
Darrick J. Wong [Tue, 18 Dec 2018 20:36:03 +0000 (12:36 -0800)]
generic/050: fix ro blockdev mount of xfs with quota

In XFS, mounting with quota always require a writable device.  If
the block device is read only, the mount fails, which fails this
test.  Since this is expected, work around this by simulating the
golden output when we expect a mount failure.

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>
5 years agoxfs/123: fix remote symlink block size calculation
Darrick J. Wong [Tue, 18 Dec 2018 20:35:57 +0000 (12:35 -0800)]
xfs/123: fix remote symlink block size calculation

In this test we try to create a remote symlink block by creating a
symlink target buffer large enough to exceed the size of an inode.
Unfortunately we don't use the correct block size or symlink header
size, which on a 1k block filesystem causes there to be two remote
blocks.  This causes crc verification errors in xfs_db (because it's
too dumb to load both blocks as one like the kernel does) which we
don't care about because we're about to corrupt the block anyway.

So, fix the block size calculation so that we end up with one block.

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>
5 years agoxfs/111: fix golden output
Darrick J. Wong [Tue, 18 Dec 2018 20:35:50 +0000 (12:35 -0800)]
xfs/111: fix golden output

In commit f4eee5126, this test was changed to run xfs_fsr to
bulkstat its way through the filesystem until it finds the corrupt
inode.  The golden output was changed to capture xfs_fsr's output,
but neglects the fact that when fsr's output is not a tty, all the
status and error messages are sent to syslog, not stdout.
Therefore, this test consistently fails because it expects output of
"$SCRATCH_MNT start inode=0" but this never appears.

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>
5 years agocheck: fix -X exclude_file behaviour
David Disseldorp [Wed, 19 Dec 2018 15:41:55 +0000 (16:41 +0100)]
check: fix -X exclude_file behaviour

It is currently processed before FSTYP has been properly set,
leading to xfs, btrfs, etc. specific exclude_files being ignored.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon: Fix mismatched output from standard mkswap
Xiao Yang [Fri, 21 Dec 2018 09:33:28 +0000 (17:33 +0800)]
common: Fix mismatched output from standard mkswap

With older util-linux(e.g. v2.17.2), running some tests(e.g.
generic/472, generic/495) got the following output:
-------------------------------------------------------
+mkswap: /mnt/xfstests/scratch/swap: warning: don't erase bootbits sectors
+        on whole disk. Use -f to force.
+mkswap: unable to relabel /mnt/xfstests/scratch/swap to system_u:object_r:swapfile_t:s0: Operation not supported
-------------------------------------------------------

1) Before commit c1f1b30 of util-linux, standard mkswap didn't zap bootbits
   sectors and printed a warning until force option(i.e. -f) was given.  We
   define "mkswap -f" as MKSWAP_PROG and replace all standard mkswap with
   $MKSWAP_PROG.

2) With mounting default SELinux context(e.g. system_u:object_r:root_t:s0),
   standard mkswap tried to reset the type of default context to swapfile_t
   if it is not swapfile_t, and then it failed and returned ENOTSUP expectedly
   as we don't want to create any SELinux attr on purpose.  standard mkswap
   ignored this relabel error by commit d97dc0e of util-linux, but it still
   reported the error before commit d97dc0e.  We try to skip the reset step
   in standard mkswap by mounting swapfile context directly.

Note:
We just mount swapfile context in related tests, and keep default context
in the rest of tests.

[Eryu: make mkswap a non-mandatory requirement and add comments on
"-f" option]

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/config: create $RESULT_BASE before dumping kmemleak leaks
Johannes Thumshirn [Fri, 21 Dec 2018 09:16:12 +0000 (10:16 +0100)]
common/config: create $RESULT_BASE before dumping kmemleak leaks

In _init_kmemleak() we're touching a check_kmemleak file in
${RESULT_BASE} if ${DEBUGFS_MNT/kmemleak} exists as a marker that we
have to check for kmemleak output after running a test.

In 'check' we're calling _init_kmemleak() at around 60% of the file,
but ${RESULT_BASE} is created later at around 62% of the file,
causing the 'touch' in _init_kmemleak() to fail.

Create the ${RESULT_BASE} just after assigning the default value in
get_next_config()

[Eryu: check for mkdir failure and remove the $RESULT_BASE creation
in check.]

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/062, 520: Don't remove lost+found during cleanup
Xiao Yang [Tue, 11 Dec 2018 06:36:17 +0000 (14:36 +0800)]
generic/062, 520: Don't remove lost+found during cleanup

On older e2fsprogs, fsck command will check lost+found for extX,
so that it will get error if lost+found has been removed during
cleanup.  For example:
----------------------------------------------------------
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
/lost+found not found.  Create? no
...
----------------------------------------------------------
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: long fsx soak tests
Darrick J. Wong [Fri, 7 Dec 2018 06:24:45 +0000 (22:24 -0800)]
generic: long fsx soak tests

Add a few tests to implement long soak tests of fsx.

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>
5 years agocommon/dump: disable copyrange
Darrick J. Wong [Fri, 7 Dec 2018 06:24:39 +0000 (22:24 -0800)]
common/dump: disable copyrange

In _create_dumpdir_stress_num, disable copyrange in fsstress so that we
dump exactly the same set of files and directories no matter how the xfs
is configured.

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>
5 years agofsx: add copy_file_range support
Darrick J. Wong [Fri, 7 Dec 2018 06:24:33 +0000 (22:24 -0800)]
fsx: add copy_file_range support

Add support for the copy_file_range system call to fsx.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[dchinner: copy_file_range() needs to obey read/write constraints
otherwise is blows up when direct IO is used]
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsstress: add copy_file_range support
Darrick J. Wong [Fri, 7 Dec 2018 06:24:26 +0000 (22:24 -0800)]
fsstress: add copy_file_range support

Support the copy_file_range syscall in fsstress.

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>
5 years agofsx: add FIDEDUPERANGE support
Darrick J. Wong [Fri, 7 Dec 2018 06:24:20 +0000 (22:24 -0800)]
fsx: add FIDEDUPERANGE support

Add support for the dedupe range ioctl to fsx.

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>
5 years agofsx: add FICLONERANGE support
Darrick J. Wong [Fri, 7 Dec 2018 06:24:14 +0000 (22:24 -0800)]
fsx: add FICLONERANGE support

Add support for the clone range (i.e. reflink) ioctl to fsx.

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>
5 years agofsx: add five-argument logging function
Darrick J. Wong [Fri, 7 Dec 2018 06:23:58 +0000 (22:23 -0800)]
fsx: add five-argument logging function

Add a five-argument logging function to support new operations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsx: use an enum to define the operation commands
Darrick J. Wong [Fri, 7 Dec 2018 06:23:52 +0000 (22:23 -0800)]
fsx: use an enum to define the operation commands

Use an enum to define operation codes and the boundaries between
operation classes so that we can add new commands without having to
change a bunch of unrelated #defines.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsx: always check buffer after each operation
Darrick J. Wong [Fri, 7 Dec 2018 06:23:45 +0000 (22:23 -0800)]
fsx: always check buffer after each operation

Add a new option to make fsx read the file after each operation and
compare it with the good buffer to try to catch corruptions as soon as
they occur.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsx: shut up compiler warnings
Darrick J. Wong [Fri, 7 Dec 2018 06:23:39 +0000 (22:23 -0800)]
fsx: shut up compiler warnings

Fix unused variables and potential filename overflows in fsx.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsstress: check system call return values
Darrick J. Wong [Fri, 7 Dec 2018 06:23:32 +0000 (22:23 -0800)]
fsstress: check system call return values

Check the return values of various system calls and blow up if something
went wrong.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsstress: fix compiler warnings
Darrick J. Wong [Fri, 7 Dec 2018 06:23:18 +0000 (22:23 -0800)]
fsstress: fix compiler warnings

Fix all the gcc warnings in fsstress, and resize buffers to avoid
overflows.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstest: CrashMonkey 'hard link' tests ported to xfstest
Jayashree [Tue, 20 Nov 2018 23:51:04 +0000 (17:51 -0600)]
fstest: CrashMonkey 'hard link' tests ported to xfstest

This patch aims to add more tests to the xfstest suite to check
whether the target file system recovers correctly after a crash.
These test cases are generated by CrashMonkey, a
crash-consistency testing framework built at the SASLab at UT Austin.

This patch batches 37 crash-consistency tests into a xfstest test,
each of which checks the hard link behavior under different scenarios.
This test creates hard-links between files in the same directory or
across directories, while allowing fsync of either the files involved,
their parent directories, or unrelated sibling files. After each sub
test, the metadata of the persisted file is checked for the correct
link count. Additionally, each sub test is followed by fsck to check
for inconsistencies. The tests run on a 256MB file system, and
the working directory is cleaned up after every sub test.

Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/002: Fix obsolete TEST_DEV/TEST_DIR in _check_ext4_eof_flag()
Xiao Yang [Thu, 29 Nov 2018 07:15:32 +0000 (15:15 +0800)]
ext4/002: Fix obsolete TEST_DEV/TEST_DIR in _check_ext4_eof_flag()

Commit 6b06a9bb6fb0 has used SCRATCH_DEV/SCRATCH_MNT rather than
TEST_DEV/TEST_DIR for holding the test files, so we need to use
SCRATCH_DEV/SCRATCH_MNT in _check_ext4_eof_flag() as well.

Fixes: 6b06a9bb6fb0 ("ext4/002: Work with 64k block size")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/021: Work with 64k block size
Chandan Rajendra [Fri, 23 Nov 2018 05:59:30 +0000 (11:29 +0530)]
ext4/021: Work with 64k block size

For 64k blocksize, 10MiB as the filesystem size isn't sufficient to have
a journal included. Hence this commit computes the test FS size based on
the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/002: Work with 64k block size
Chandan Rajendra [Fri, 23 Nov 2018 05:59:29 +0000 (11:29 +0530)]
ext4/002: Work with 64k block size

This commit changes the script to operate on FS blocks by obtaining the
block size from the underlying filesystem and using it to perform I/O in
units of block sizes.

This commit also uses $SCRATCH_MNT rather than $TEST_DIR for holding the
test files since the FS on $TEST_DIR might be created with a different
block size than the one specified in $MKFS_OPTIONS.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: Add _require_filefrag_options() to check options for filefrag
Xiao Yang [Fri, 23 Nov 2018 05:24:23 +0000 (13:24 +0800)]
common/rc: Add _require_filefrag_options() to check options for filefrag

In generic/519, filefrag command use FIBMAP ioctl(-B option) to print
output in extent format(-e option) on purpose and sync file(-s option),
so add _require_filefrag_options() to check if the command supports
all of these options.

References:
1) filefrag supports -e option by commit 2508eaa since e2fsprogs v1.42.7.
2) filefrag supports -B option by commit 5d5e01d since e2fsprogs v1.41.9.
3) filefrag supports -s option by commit e62847c since e2fsprogs v1.41.6.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/t_stripealign.c: Use block size reported by fstatfs()
Chandan Rajendra [Wed, 21 Nov 2018 16:26:46 +0000 (21:56 +0530)]
src/t_stripealign.c: Use block size reported by fstatfs()

On ppc64le, block size reported by fstat(2) is 64k (the page size)
i.e. the "preferred I/O size". However src/t_stripealign.c requires the
actual block size of the filesystem. Hence this commit now makes use of
the block size reported by fstatfs(2) syscall.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: Fix the situation that mount operation rejects corrupted XFS
Xiao Yang [Tue, 20 Nov 2018 11:58:28 +0000 (19:58 +0800)]
xfs: Fix the situation that mount operation rejects corrupted XFS

On upstream kernel, running some tests which corrupt XFS on purpose
got the mismatched output. e.g. running xfs/087:
------------------------------------------------
 + check fs
 + corrupt image
 + mount image
-+ modify files
-broken: 1
 + repair fs
 + mount image (2)
------------------------------------------------

It is reasonable for corrupted XFS to be caught and rejected by mount
or read/write operation.

Fixes: 0828657542ea ("xfs: fix blocktrash fuzzers")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: xfs_fsr requires working preallocation support
Christoph Hellwig [Sat, 10 Nov 2018 11:51:44 +0000 (12:51 +0100)]
xfs: xfs_fsr requires working preallocation support

Check that the file system actually supports preallocation for defrag
tests that end up calling xfs_fsr, as they can't be supported in
always_cow mode.

[Eryu: add comments in code as well]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: don't assume preallocation is always supported on XFS
Christoph Hellwig [Sat, 10 Nov 2018 11:51:43 +0000 (12:51 +0100)]
xfs: don't assume preallocation is always supported on XFS

The always_cow mode can't usefull preallocate space gÑ–ven that it
always has to write out of place, and thus will reject falloc or
ioctl calls to preallocate space in a file.  Add explicit checks for
preallocation support in various XFS-specific tests to support this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: don't assume preallocation is supported when reflinks are supported
Christoph Hellwig [Sat, 10 Nov 2018 11:51:42 +0000 (12:51 +0100)]
generic: don't assume preallocation is supported when reflinks are supported

Various reflink tests currently use fallocate to preallocate space
without first checking that preallocations are supported. Add
explicit checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test send after radical changes in a complex directory hierarchy
Filipe Manana [Wed, 14 Nov 2018 18:32:56 +0000 (18:32 +0000)]
btrfs: test send after radical changes in a complex directory hierarchy

Test an incremental send operation in a scenario where the relationship
of ancestor-descendant between multiple directories is inversed, and
where multiple directories that were previously ancestors of another
directory now become descendents of multiple directories that used to be
their ancestors in the parent snapshot. This used to trigger an
infinite loop in the kernel code.

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

  "Btrfs: send, fix infinite loop due to directory rename dependencies"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/205: Fix that b2 variable is treated as octal vaule
Xiao Yang [Mon, 12 Nov 2018 08:01:03 +0000 (16:01 +0800)]
xfs/205: Fix that b2 variable is treated as octal vaule

Running xfs/205 triggers the following error:
----------------------------------------------
QA output created by 205
+./tests/xfs/205: line 61: 098: value too great for base (error token is "098")
...
----------------------------------------------

If b2 variable is a 2-digit number beginning with 0(e.g. 098),
it will be treated as octal vaule instaed of decimal value.  We
try to declare it as decimal value forcely.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay: create directory over deleted whiteout
Miklos Szeredi [Mon, 12 Nov 2018 09:48:18 +0000 (10:48 +0100)]
overlay: create directory over deleted whiteout

There's a bug in the overlayfs implementation starting from the very
first merged version that may cause an Oops of various forms if a
directory is created over a whiteout dentry, but the actual whiteout
on the upper layer was removed to the directory creation.

Reported by: kaixuxia <xiakaixu1987@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/034: filter out the specified vaule of $SCRATCH_MNT
xiaoli feng [Tue, 13 Nov 2018 10:53:15 +0000 (18:53 +0800)]
ext4/034: filter out the specified vaule of $SCRATCH_MNT

In 034.out, the $SCRATCH_MNT is specified by "/mnt/scratch". It's
not flexible. Modify it to fit the different vaule of $SCRATCH_MNT.

Signed-off-by: xiaoli feng <xifeng@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4: regression test for a ENOSPC warning
Liu Bo [Sat, 10 Nov 2018 15:14:49 +0000 (23:14 +0800)]
ext4: regression test for a ENOSPC warning

This adds a regression test for a ENOSPC warning which can be
triggered if '-odioread_nolock,nodelalloc' and quota are used.

The bug was fixed by patch

"Ext4: fix ENOSPC when both quota and dioread_nolock are enabled".

[Eryu: add comments on using syncfs instead of sync]

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/398: filter out extra string from newer mv
Xiong Murphy Zhou [Fri, 9 Nov 2018 04:19:13 +0000 (12:19 +0800)]
generic/398: filter out extra string from newer mv

mv command produces a leading string "renamed" from some time.
This breaks generic/398. Adding a _filter_mv to filter it out.
Tested this patch on Fedora 28.

sh-4.2$ rpm -qf /usr/bin/mv
coreutils-8.22-23.el7.x86_64
sh-4.2$ mv -v 1 2
‘1’ -> â€˜2’
sh-4.2$

h-4.4# rpm -qf /usr/bin/mv
coreutils-8.30-5.el8.x86_64
sh-4.4# mv -v 1 2
renamed '1' -> '2'
sh-4.4#

igned-off-by: Xiong Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test balance and resize with an active swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:42 +0000 (14:29 -0700)]
btrfs: test balance and resize with an active swap file

Make sure we don't shrink the device past an active swap file, but allow
shrinking otherwise, as well as growing and balance.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test device add/remove/replace with an active swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:41 +0000 (14:29 -0700)]
btrfs: test device add/remove/replace with an active swap file

Make sure that we don't remove or replace a device with an active swap
file but can add, remove, and replace other devices.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test swap files on multiple devices
Omar Sandoval [Fri, 2 Nov 2018 21:29:40 +0000 (14:29 -0700)]
btrfs: test swap files on multiple devices

Swap files currently need to exist on exactly one device in exactly one
place.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test invalid operations on a swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:39 +0000 (14:29 -0700)]
btrfs: test invalid operations on a swap file

Btrfs forbids some operations which should not be done on a swap file.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test swap file activation restrictions
Omar Sandoval [Fri, 2 Nov 2018 21:29:38 +0000 (14:29 -0700)]
btrfs: test swap file activation restrictions

Swap files on Btrfs have some restrictions not applicable to other
filesystems.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: fix computation of max fs size for multiple device fs tests
Filipe Manana [Tue, 6 Nov 2018 15:34:37 +0000 (15:34 +0000)]
btrfs: fix computation of max fs size for multiple device fs tests

We were sorting numerical values with the 'sort' tool without telling it
that we are sorting numbers, giving us unexpected ordering. So just pass
the '-n' option to the 'sort' tool.

Example:

$ echo -e "11\n9\n20" | sort
11
20
9

$ echo -e "11\n9\n20" | sort -n
9
11
20

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: verify FIBMAP address overlap
Zorro Lang [Tue, 6 Nov 2018 04:43:38 +0000 (12:43 +0800)]
generic: verify FIBMAP address overlap

xfstests doesn't cover FIBMAP test, it cause we brought in a
regression bug fixed by "79b3dbe4adb3 fs: fix iomap_bmap position
calculation".

Although FIBMAP is old, there're still some programs use it, likes
LILO. This case tests if there's physical address overlap returned
by FIBMAP.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agopopulate: fix leafn creation test for v4 filesystems
Darrick J. Wong [Mon, 5 Nov 2018 17:25:47 +0000 (09:25 -0800)]
populate: fix leafn creation test for v4 filesystems

The leafn creation test doesn't work on some v4 filesystems
because the field names change.  Rearrange the code somewhat so that it
works properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: add new filter for file cloning error translation
Filipe Manana [Mon, 5 Nov 2018 11:15:24 +0000 (11:15 +0000)]
btrfs: add new filter for file cloning error translation

A bug in file cloning/reflinking was recently found that afftected both
Btrfs and XFS, which was caused by allowing the cloning of an eof block
into the middle of a file when the eof is not aligned to the filesystem's
block size.

The fix consists of returning the errno -EINVAL to user space when the
arguments passed to the system call lead to the scenario of data
corruption. However this overlaps with some cases where the system call,
in Btrfs, returned -EOPNOTSUPP, which means we are trying to reflink
inline extents. That is unsupported in Btrfs due to the huge complexity
of supporting it (due to copying and trimming inline extents, deal with
eventual compression, etc).

We have a few btrfs test cases that verify that attempts to clone inline
extents result in a failure, and are currently expecting an -EINVAL error
message from the output of the cloner program. So create a filter that
converts error messages related to the -EOPNOTSUPP error to messages
related to the -EINVAL error, so that the test can run both on patched
and non-patched linux kernels.

The corresponding btrfs patch for the linux kernel is titled:

 "Btrfs: fix data corruption due to cloning of eof block"

And the VFS change that introduces the -EINVAL error return was introduced
by the following linux kernel commit (landed in 4.20-rc1):

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")

The btrfs patch is not yet in Linus' tree (it was submitted around the
same time as this change) and the VFS change was introduced in 4.10-rc1.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test attempt to reflink eof block into the middle of a file
Filipe Manana [Mon, 5 Nov 2018 11:15:01 +0000 (11:15 +0000)]
generic: test attempt to reflink eof block into the middle of a file

Test that we can not clone a range from a file A into the middle of a file B
when the range includes the last block of file A and file A's size is not
aligned with the filesystem's block size. Allowing such case would lead to
data corruption since the data between EOF and the end of its block is
undefined.

This is motivated by a bug recently found that affects both Btrfs and XFS
and is fixed by the following commits/patches for the linux kernel:

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")
 b39989009bdb ("xfs: fix data corruption w/ unaligned reflink ranges")
 Btrfs: fix data corruption due to cloning of eof block

The VFS patch landed in kernel 4.20-rc1 and the XFS patch landed in 4.19.
The Btrfs fix is very recent and it is not yet in Linus' tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test attempt to dedup eof block into the middle of a file
Filipe Manana [Mon, 5 Nov 2018 11:14:45 +0000 (11:14 +0000)]
generic: test attempt to dedup eof block into the middle of a file

Test that deduplication of an entire file that has a size that is not
aligned to the filesystem's block size into the middle of a different
file does not corrupt the destination's file data by reflinking the last
(eof) block.

This test is motivated by a bug recently found that affects both Btrfs
and XFS, and is fixed by the following commits/patches for the linux
kernel:

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")
 dceeb47b0ed6 ("xfs: fix data corruption w/ unaligned dedupe ranges")
 de02b9f6bb65 ("Btrfs: fix data corruption when deduplicating between different files")
 Btrfs: fix infinite loop on inode eviction after deduplication of eof block

The VFS patch was added to kernel 4.20-rc1 and the XFS and first Btrfs
patches were added to kernel 4.19. The second patch for Btrfs is very
recent and it is not yet in Linus' tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay: test file handle decode with multi lower layers on same fs
Amir Goldstein [Mon, 5 Nov 2018 05:18:15 +0000 (07:18 +0200)]
overlay: test file handle decode with multi lower layers on same fs

This test is for a regression that was introduced in kernel v4.17 by
commit 8b58924ad55c ("ovl: lookup in inode cache first when decoding
lower file handle").

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/{472,496}: fix swap file creation on Btrfs
Omar Sandoval [Fri, 2 Nov 2018 21:29:37 +0000 (14:29 -0700)]
generic/{472,496}: fix swap file creation on Btrfs

The swap file must be set nocow before it is written to, otherwise it is
ignored and Btrfs refuses to activate it as swap.

Fixes: 25ce9740065e ("generic: test swapfile creation, activation, and deactivation")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/{472,496,497}: fix $seeqres typo
Omar Sandoval [Fri, 2 Nov 2018 21:29:36 +0000 (14:29 -0700)]
generic/{472,496,497}: fix $seeqres typo

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agomisc: force the exact quota options coded into the test
Darrick J. Wong [Thu, 1 Nov 2018 23:19:46 +0000 (16:19 -0700)]
misc: force the exact quota options coded into the test

Several tests require setting exactly the quota mount options that are
encoded in the test.  Unfortunately, quota mount options set by the user
in MOUNT_OPTIONS can turn on other quota types, which causes the golden
outputs to be off for various reasons (quota report output, behavior
changes, etc.)

So use _qmount_option to delete all the quota mount options in these
tests so that the test itself can run with exactly the config for which
it was written.

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>
5 years agoxfs/205: update for v5 filesystems
Darrick J. Wong [Thu, 1 Nov 2018 23:19:40 +0000 (16:19 -0700)]
xfs/205: update for v5 filesystems

Update this test to work with v5 filesystems, which have a minimum block
size of 1k.  Adapt the script to sense the amount of free space reported
so that we can get close to ENOSPC instead of hardcoding.

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>
5 years agoxfs/266: fix restore summary counter when quotas are enabled
Darrick J. Wong [Thu, 1 Nov 2018 23:19:33 +0000 (16:19 -0700)]
xfs/266: fix restore summary counter when quotas are enabled

When quotas are enabled, an incremental backup has to record the quota
file updates too.  Inside a dump the quota files are stored as special
files under the root dump directory.  xfsrestore reports the dump dir
in its restore summary counts even if the dump dir was only there for
the sake of the quota updates, which makes the test fail.  Fix this by
massaging the output when quotas are turned on.

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>
5 years agodump: don't fail if multi-file dumps don't all contain quota info
Darrick J. Wong [Thu, 1 Nov 2018 23:19:27 +0000 (16:19 -0700)]
dump: don't fail if multi-file dumps don't all contain quota info

When xfsdump is making multi-file dumps, the quota information are
written into the last dump file.  However, the multi-file restore script
(as written) expects to see quota information restored by every dump
file and fails.  This is silly, so fix it.

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>
5 years agoxfs: force unlink metadata updates to disk
Darrick J. Wong [Thu, 1 Nov 2018 23:19:15 +0000 (16:19 -0700)]
xfs: force unlink metadata updates to disk

In xfs/318 and xfs/325 we inject errors on extent freeing then delete
some files to see if we can make the filesystem go offline.  However,
with the advent of deferred inode inactivation, sync won't guarantee
that unlinked inodes removal is actually pushed to disk since the "inode
needs to be deallocated" state is persisted to disk.  Freeze achieves
this, however, so inject a freeze/thaw cycle to make sure we hit the
injected error.

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>
5 years agoquota: clean out speculative preallocations when checking quota usage
Darrick J. Wong [Thu, 1 Nov 2018 23:19:09 +0000 (16:19 -0700)]
quota: clean out speculative preallocations when checking quota usage

On XFS, the only reliable way to clean out speculative post-eof
preallocations, delayed allocations, and speculative cow preallocations
is to cycle the filesystem mount.  Since we're comparing the post-test
quota counts against a freshly quotacheck to look for leaks, it's fine
to cycle the mount.  This eliminates sporadic quota count failures when
running xfstests with quotas enabled.

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>
5 years agoxfs: fuzz directories containing single leafn blocks
Darrick J. Wong [Tue, 30 Oct 2018 18:03:41 +0000 (11:03 -0700)]
xfs: fuzz directories containing single leafn blocks

Test scrub, repair, and metadata verifiers on directories containing
fuzzed single-leafn blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: test repair regression of dir w/ single leafn block
Darrick J. Wong [Tue, 30 Oct 2018 18:03:35 +0000 (11:03 -0700)]
xfs: test repair regression of dir w/ single leafn block

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>
5 years agopopulate: create leafn dir when populating xfs filesystem
Darrick J. Wong [Tue, 30 Oct 2018 18:03:28 +0000 (11:03 -0700)]
populate: create leafn dir when populating xfs filesystem

We've had some problems lately with directories containing a single
leafn directory.  It turns out that the populate script doesn't create
these, so teach it to do so.

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>
5 years agoxfs: test packaged crc32c code
Darrick J. Wong [Mon, 29 Oct 2018 18:12:42 +0000 (11:12 -0700)]
xfs: test packaged crc32c code

Use the new crc32selftest command in xfs_io to check the correct
operation of the packaged xfsprogs, on the off chance that the packages
were cross compiled on a different machine type (which means the build
time test doesn't hold much water).

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>
5 years agocheck: use full paths for diff on error
Dave Chinner [Fri, 2 Nov 2018 01:09:48 +0000 (12:09 +1100)]
check: use full paths for diff on error

i don't run fstests from the source directory, so when I get a
golden image mismatch the relative path to the golden output is
not useful:

(Run 'diff -u tests/generic/013.out /home/dave/src/xfstests-dev/results//xfs_64k/generic/013.out.bad'  to see the entire diff)

Change the output to emit the real path for the golden out so this
can be cut and pasted and run from anywhere.

(Run 'diff -u /home/dave/src/xfstests-dev/tests/generic/013.out /home/dave/src/xfstests-dev/results//xfs_64k/generic/013.out.bad'  to see the entire diff)

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstests: fix fssum to actually ignore file holes when supposed to
Filipe Manana [Mon, 29 Oct 2018 09:43:40 +0000 (09:43 +0000)]
fstests: fix fssum to actually ignore file holes when supposed to

Unless the '-s' option is passed to fssum, it should not detect file holes
and have their existence influence the computed checksum for a file. This
tool was added to test btrfs' send/receive feature, so that it checks for
any metadata and data differences between the original filesystem and the
filesystem that receives send streams.

For a long time the test btrfs/007, which tests btrfs' send/receive with
fsstress, fails sporadically reporting data differences between files.
However the md5sum/sha1sum from the reported files in the original and
new filesystems are the same. The reason why fssum fails is because even
in normal mode it still accounts for number of holes that exist in the
file and their respective lengths. This is done using the SEEK_DATA mode
of lseek. The btrfs send feature does not preserve holes nor prealloc
extents (not supported by the current protocol), so whenever a hole or
prealloc (unwritten) extent is detected in the source filesystem, it
issues a write command full of zeroes, which will translate to a regular
(written) extent in the destination filesystem. This is why fssum reports
a different checksum. A prealloc extent also counts as hole when using
lseek.

For example when passing a seed of 1540592967 to fsstress in btrfs/007,
the test fails, as file p0/d0/f7 has a prealloc extent in the original
filesystem (in the incr snapshot).

Fix this by making fssum just read the hole file and feed its data to the
digest calculation function when option '-s' is not given. If we ever get
btrfs' send/receive to support holes and fallocate, we can just change
the test and pass the '-s' option to all fssum calls.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/057: Fix false alerts due to orphan files
Qu Wenruo [Tue, 30 Oct 2018 10:18:19 +0000 (18:18 +0800)]
btrfs/057: Fix false alerts due to orphan files

For any recent kernel, there is a chance that btrfs/057 reports false
errors.

The false error would look like:
  btrfs/057 4s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/057.out.bad)
      --- tests/btrfs/057.out 2017-08-21 09:25:33.166666666 +0800
      +++ /home/adam/xfstests-dev/results//btrfs/057.out.bad 2018-10-29 14:07:28.443651293 +0800
      @@ -1,3 +1,3 @@
       QA output created by 057
       4096 4096
      -4096 4096
      +28672 28672

This is related to the fact that "btrfs subvolume sync" (or
vanilla sync) will not ensure orphan (unlinked but still exist) files to
be removed.

In fact, for that false error case, if inspecting the fs after umount,
its qgroup number is correct and btrfs check won't report qgroup error.

To fix the false alerts, just skip any manual qgroup number comparison,
and let fsck done after the test case to detect problem.

This also elimiate the necessary of using specified mount and mkfs
option, allowing us to improve coverage.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: update group file to indicate generic/456 uses {collapse,zero}_range
Theodore Ts'o [Fri, 26 Oct 2018 11:53:49 +0000 (07:53 -0400)]
generic: update group file to indicate generic/456 uses {collapse,zero}_range

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstests: add some tests to the 'log' group that use dmflakey
Filipe Manana [Sat, 27 Oct 2018 08:48:58 +0000 (09:48 +0100)]
fstests: add some tests to the 'log' group that use dmflakey

Some tests that use dmflakey to test filesystem consistency after a power
failure are in the 'log' group while others are not. So fix the
incosistency and put them all under the 'log' group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: fix classification of a couple btrfs tests
Filipe Manana [Sat, 27 Oct 2018 08:48:38 +0000 (09:48 +0100)]
btrfs: fix classification of a couple btrfs tests

Test btrfs/108 does not test collapse, in fact btrfs does not even support
the fallocate collapse operation, so remove it.
Test btrfs/159 does not test collapse either, it tests hole punching, so
replace the collapse group with the punch group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/508: fix to check inode creation time feature on scratch mountpoint
Chao Yu [Sat, 27 Oct 2018 01:55:20 +0000 (09:55 +0800)]
generic/508: fix to check inode creation time feature on scratch mountpoint

_require_btime() just check inode creation time feature on TEST_DIR
mountpoint, but generic/508 needs to do that check on SCRATCH_MNT
mountpoint. Let's add _require_scratch_btime() for that, meanwhile
handling scratch_{mkfs,mount,umount} inside the function to decouple
with caller.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test reflink side effects
Darrick J. Wong [Tue, 16 Oct 2018 03:29:13 +0000 (20:29 -0700)]
generic: test reflink side effects

Test that ctime gets updated and suid is cleared when we reflink.
Ensure we can't reflink about RLIMIT_FSIZE.  Ensure that we can't
expose stale preallocation block data when reflinking above EOF.
Make sure dedupe actually catches a single different byte.

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>
5 years agobtrfs: fix test btrfs/007 to not leave temporary files in /tmp
Filipe Manana [Mon, 15 Oct 2018 09:22:46 +0000 (10:22 +0100)]
btrfs: fix test btrfs/007 to not leave temporary files in /tmp

This test was using the "mktemp -d" command to create a temporary
directory for storing send streams and computations from fssum,
without ever deleting them when it finishes. Therefore after running
it for many times it filled up all space from /tmp.

Fix this by using a temporary directory in TEST_DEV instead, as all
the more recent send/receive tests do, to store these files, and
making sure they get deleted when the test finishes. On average the
sum of the size of those files is between 5.5Mb to 6Mb, but changing
the number of operations for fsstress makes it even bigger.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test fsync after fallocate on a very small file
Filipe Manana [Mon, 15 Oct 2018 08:51:17 +0000 (09:51 +0100)]
generic: test fsync after fallocate on a very small file

Test that if we have a very small file, with a size smaller than the
block size, then fallocate a very small range within the block size
but past the file's current size, fsync the file and then power
fail, after mounting the filesystem all the file data is there and
the file size is correct.

This test is motivated by a failure in btrfs where it triggered an
assertion when using the no-holes feature, that is, when running
with MKFS_OPTIONS="-O no-holes". The btrfs issue is fixed by a patch
for the linux kernel titled:

 "Btrfs: fix assertion on fsync of regular file when using no-holes
  feature"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/140: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:03 +0000 (11:53 +0530)]
xfs/140: work with 1k block size

Commit 7a7641063ac3a7ae051c9e1959f4d7b1a25bb91c (xfs/140: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by resetting AG size to 16MiB if (8192 *
block size) results in a value less than 16MiB. Later the test file size
and the test file block count are then appropriately calculated.

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/139: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:02 +0000 (11:53 +0530)]
xfs/139: work with 1k block size

Commit 0e2b99951fa11ea8a8adf4676aef130cfeeb5250 (xfs/139: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by setting AG size to be (16384 * block
size).

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/fiemap-tester: fix getting blocksize on overlayfs
Amir Goldstein [Thu, 11 Oct 2018 14:41:06 +0000 (17:41 +0300)]
src/fiemap-tester: fix getting blocksize on overlayfs

There was a regression in v4.19-rc1 that caused FIGETBSZ ioctl
to return 0 on an overlayfs file.

That regression went unnoticed because the xfstests that run
fiemap-tester program terminated in success status after not doing
much instead of failing.

Check for invalid value of block size returned by FIGETBSZ ioctl,
so these tests can detect the regression.

Fallback to statfs(2) for getting the filesystem blocksize if
FIGETBSZ ioctl fails (i.e. on overlayfs).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>