xfstests-dev.git
5 years agofstests: update the punch, collapse, insert, and zero groups
Theodore Ts'o [Tue, 29 May 2018 19:01:28 +0000 (15:01 -0400)]
fstests: update the punch, collapse, insert, and zero groups

Update the group files to annotate those tests which have a
_require_xfs_io_command for punch, collapse, insert, and zero.  This
makes it easier to exclude tests that use one of these fallocate
commands.  Or if you want to specifically test for those fallocate
commands you can do this.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/206: filter/fix for minor geometry reporting changes
Eric Sandeen [Fri, 25 May 2018 14:00:59 +0000 (09:00 -0500)]
xfs/206: filter/fix for minor geometry reporting changes

The pending common geometry printing function has removed the fiddly
little differences between the various utilities, so now we'll need
to accommodate that in xfs/206, which looks at mkfs & growfs output.

all now print "internal log" vs. just "internal"
ascii-ci now always has a "," after it

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/484: Need another process to check record locks
Xiao Yang [Mon, 21 May 2018 05:42:00 +0000 (13:42 +0800)]
generic/484: Need another process to check record locks

According to fcntl(2) manpage, A single process always gets F_UNLCK
in the l_type field when using fcntl(F_GETLK) to acquire the
existing lock set by itself because it could convert the existing
lock to a new lock unconditionally.  So we need another process to
check if the lock exists.

Also remove redundant exit(0).

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/447: fix typo
Darrick J. Wong [Wed, 23 May 2018 15:49:07 +0000 (08:49 -0700)]
xfs/447: fix typo

Fix a trivial typo that keeps barfing up:
./tests/xfs/447: line 60: /dev_null: Read-only file system

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: Make the test harness unmount fs when finishing a test
Xiao Yang [Tue, 22 May 2018 09:49:59 +0000 (17:49 +0800)]
check: Make the test harness unmount fs when finishing a test

Finishing xfs/132 left a shutdown scratch fs and the test harness
didn't unmount the fs(because we told it not to check the fs) so the
test harness called by subsequent xfs/133 tried to "test -d
$SCRATCH_MNT" and received the IO error from the dead fs.

i.e. Running xfs/132 and xfs/133 together got the following error:
------------------------------------------------------------
...
xfs/132 1s ... 1s
xfs/133 1s ... [failed, exit status 1] - output mismatch (see /var/lib/xfstests/results//xfs/133.out.bad)
...
QA output created by 133
-Format and mount
-Corrupt filesystem
-Remount, try to append
-Write did not succeed (ok).
+SCRATCH_DEV=/dev/sda11 is mounted but not on SCRATCH_MNT=common/config: - aborting
+Already mounted result:
+/dev/sda11 /mnt/xfstests/scratch
...
------------------------------------------------------------

Even if we don't check fs, the test harness is supposed to unmount
fs and return an initial state before running the next test.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test invalid swap file activation
Omar Sandoval [Wed, 16 May 2018 20:38:49 +0000 (13:38 -0700)]
generic: test invalid swap file activation

Swap files cannot have holes, and they must at least two pages.
swapon(8) and mkswap(8) have stricter restrictions, so add versions
of those commands without any restrictions.

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: add test for truncate/fpunch of an active swapfile
Omar Sandoval [Wed, 16 May 2018 20:38:48 +0000 (13:38 -0700)]
generic: add test for truncate/fpunch of an active swapfile

These should not be allowed.

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: add test for dedupe on an active swapfile
Omar Sandoval [Wed, 16 May 2018 20:38:47 +0000 (13:38 -0700)]
generic: add test for dedupe on an active swapfile

Similar to generic/356 that makes sure we can't dedupe an active
swapfile.

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: enable swapfile tests on Btrfs
Omar Sandoval [Tue, 22 May 2018 23:33:57 +0000 (16:33 -0700)]
generic: enable swapfile tests on Btrfs

Commit 8c96cfbfe530 ("generic/35[67]: disable swapfile tests on
Btrfs") disabled the swapfile tests on Btrfs because it did not
support swapfiles at the time. Now that we're adding support, we
want these tests to run, but they don't. _require_scratch_swapfile
always fails for Btrfs because swapfiles on Btrfs must be set to
nocow. After fixing that, generic/356 and generic/357 fail for the
same reason. After fixing _that_, both tests still fail because we
don't allow reflinking a non-checksummed extent (which nocow
implies) to a checksummed extent.

Add a helper for formatting a swap file which does the chattr, and
chattr the second file, which gets these tests running on kernels
supporting Btrfs swapfiles.

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 agofstests: create swap group
Omar Sandoval [Wed, 16 May 2018 20:38:45 +0000 (13:38 -0700)]
fstests: create swap group

I'm going to add a bunch of tests for swap files, so create a group
for them and add the existing tests.

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/475: fix confusing comment
Darrick J. Wong [Mon, 21 May 2018 16:07:34 +0000 (09:07 -0700)]
generic/475: fix confusing comment

The comment about the dmerror switcheroo is hard to understand and
wrong.  Fix both problems by rewriting it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/490: fix cleanup function
Theodore Ts'o [Sun, 20 May 2018 18:45:17 +0000 (14:45 -0400)]
generic/490: fix cleanup function

generic/490 fails because cleanup tries to delete . and .. since $tmp
is left unset, and so "rm -f $tmp.*" does nothing useful. Instead
define $tmp and delete temp files created by seek_sanity_test.

[Eryu: define $tmp and remove $tmp.* too on cleanup]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/quota: sort lines of repquota output
Zorro Lang [Sun, 20 May 2018 16:22:02 +0000 (00:22 +0800)]
common/quota: sort lines of repquota output

The golden image of some cases (e.g: generic/305 generic/326
generic/327 generic/328 xfs/214 xfs/330 and xfs/440) depend on the
output of repquota() function.

When it reports multi-users, we can't control the order of lines,
then always hit failures likes:

  ...
   Create the original files
  -root 3072 0 0
   nobody 0 0 0
   fsgqa 0 0 0
  +root 3072 0 0
  ...

So sort the lines to make sure it won't break the golden image.

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: drop test 472
Theodore Ts'o [Sun, 20 May 2018 19:46:08 +0000 (15:46 -0400)]
generic: drop test 472

From Goldwyn Rodrigues <rgoldwyn@suse.de>:

   "From earlier discussions, In between errors of a direct I/O cannot
   be handled correctly and may need a lot of tracking that it is not
   worth performing.

   It would be better to drop this test case and add in the documentation
   that a direct I/O error could mean that the write() may or may not have
   occurred and underlying data may be inconsistent."

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: add tests 405 and 459 to the group 'thin'
Theodore Ts'o [Sat, 19 May 2018 21:47:19 +0000 (17:47 -0400)]
generic: add tests 405 and 459 to the group 'thin'

Currently the only test in group 'thin' is 347.  On some recent
kernels tests that use dm-thin causing kernel crashes, so it's useful
to be able to be exclude all tests that use dm-thin.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoreport: make sure control charcters are encoded in xUnit report
Theodore Ts'o [Sat, 19 May 2018 17:43:10 +0000 (13:43 -0400)]
report: make sure control charcters are encoded in xUnit report

Control characters (such as backspace, used in progress reports by
mkfs.ext4, for example) can make Python's XML parsers choke, claiming
that it is an invalid XML document.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: Handle missing [gs]etcap tools
Jan Kara [Fri, 18 May 2018 08:02:39 +0000 (10:02 +0200)]
generic: Handle missing [gs]etcap tools

Add proper requires for getcap and setcap tools to tests that need
them.  Also define standard variables GETCAP_PROG and SETCAP_PROG.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test online label ioctl
Eric Sandeen [Thu, 17 May 2018 15:28:26 +0000 (10:28 -0500)]
generic: test online label ioctl

This tests the online label ioctl that btrfs has, which has been
recently proposed for XFS.

To run, it requires an updated xfs_io with the label command and a
filesystem that supports it

A slight change here to _require_xfs_io_command as well, so that
tests which simply fail with "Inappropriate ioctl" can be caught in
the common case.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/459: use xfs_freeze instead of fsfreeze
Amir Goldstein [Mon, 14 May 2018 05:49:49 +0000 (08:49 +0300)]
generic/459: use xfs_freeze instead of fsfreeze

This is what all other tests use as well as _require_freeze

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/486: Get rid of the redundant error=%d printing
Xiao Yang [Thu, 17 May 2018 03:32:27 +0000 (11:32 +0800)]
generic/486: Get rid of the redundant error=%d printing

1) Without the fix, perror() can indicate the actual error(ENODATA).
2) After calling perror() and redirecting the output of perror()
   to a file, errno seems to be set to EINVAL unexpectedly.
   See the following mail for detailed info:
   https://www.spinics.net/lists/fstests/msg09675.html

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 agocommon/quota: Fix _qmount_options for ext4 journalled quotas
Jan Kara [Mon, 14 May 2018 17:03:51 +0000 (19:03 +0200)]
common/quota: Fix _qmount_options for ext4 journalled quotas

_qmount_options didn't properly replace ext[34] journalled quotas
mount options. As such the mount option string got garbled and the
test (e.g. generic/379) failed.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/quota: Make project quota handling work for ext2 & ext3
Jan Kara [Mon, 14 May 2018 17:03:49 +0000 (19:03 +0200)]
common/quota: Make project quota handling work for ext2 & ext3

Project quota can work for ext2 & ext3 the same way as for ext4.
Handle them properly as currently the tests just fail because of
unknown prjquota mount option. After this patch, tests will be "not
run" because ext4 driver refuses to use project quota mount options
for "old" fs types.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test first read with freeze right after mount
Amir Goldstein [Mon, 14 May 2018 05:49:51 +0000 (08:49 +0300)]
generic: test first read with freeze right after mount

With ext4, this leads to freeze proection bypass WARN_ON in
ext4_journal_check_start.

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 agofstests: define and use TIMEOUT_PROG
Amir Goldstein [Mon, 14 May 2018 05:49:50 +0000 (08:49 +0300)]
fstests: define and use TIMEOUT_PROG

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: Add SEEK_DATA tests for offsets in the middle of holes
Jan Kara [Mon, 14 May 2018 09:47:07 +0000 (11:47 +0200)]
generic: Add SEEK_DATA tests for offsets in the middle of holes

ext4 had a bug for files with indirect extents where it wrongly
reported a size of a hole in some cases and thus SEEK_DATA
implementation could skip some data in a file. Test for that. The
problem is fixed by patch "ext4: Fix hole length detection in
ext4_ind_map_blocks()".

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test for fsync of file with xattrs
Filipe Manana [Fri, 11 May 2018 15:43:43 +0000 (16:43 +0100)]
generic: test for fsync of file with xattrs

Test that xattrs are not lost after calling fsync multiple times
with a filesystem commit in between the fsync calls.

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

  Btrfs: fix xattr loss after power failure

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: test mount vs superblock shrinker races
Dave Chinner [Fri, 11 May 2018 02:11:52 +0000 (12:11 +1000)]
xfs: test mount vs superblock shrinker races

Test case for superblock shrinkers running while the filesystem is
being set up and/or torn down and tripping over inconsistent state.

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 agobtrfs: test ENOSPC caused by many orphan items
Omar Sandoval [Thu, 10 May 2018 06:21:55 +0000 (23:21 -0700)]
btrfs: test ENOSPC caused by many orphan items

Btrfs has a bug where we can prematurely ENOSPC if we have lots of
orphaned files, i.e., deleted files which are still open. Add a test
which repeatedly creates and deletes a file while keeping all of the
file descriptors open. This should succeed but doesn't on Btrfs
without the fix.

[Eryu: use multi_open_unlink command to keep files open & unlinked
instead of shell scripts]

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 agoxfs: skip growfs test on large device
Zorro Lang [Mon, 14 May 2018 14:41:53 +0000 (22:41 +0800)]
xfs: skip growfs test on large device

When test on large SCRATCH_DEV, growing a small XFS to huge size is
a horrible thing (e.g grow 128M to 500T) and it doesn't add any more
test coverage. So skip this kind of tests if LARGE_SCRATCH_DEV is
yes.

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/484: add missing _require_test_program
Amir Goldstein [Sun, 13 May 2018 16:03:59 +0000 (19:03 +0300)]
generic/484: add missing _require_test_program

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 agobtrfs: add test for seeing unseen fsync errors on newly open files
Jeff Layton [Wed, 9 May 2018 14:10:58 +0000 (10:10 -0400)]
btrfs: add test for seeing unseen fsync errors on newly open files

This adds a regression test for the following kernel patch:

    b4678df184b3 ("errseq: Always report a writeback error once")

This is motivated by some rather odd behavior done by the PostgreSQL
project. The main database writers will offload the fsync calls to a
separate process, which can open files after a writeback error has
already occurred.

This used to work with older kernels that reported the error to only
one fd, but with the errseq_t changes we lost the ability to see
errors that occurred before the open. The above patch restores that
behavior.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test for seeing unseen fsync errors on newly open files
Jeff Layton [Tue, 8 May 2018 12:52:24 +0000 (08:52 -0400)]
generic: test for seeing unseen fsync errors on newly open files

This adds a regression test for the following kernel patch:

    b4678df184b3 ("errseq: Always report a writeback error once")

This is motivated by some rather odd behavior done by the PostgreSQL
project. The main database writers will offload the fsync calls to a
separate process, which can open files after a writeback error has
already occurred.

This used to work with older kernels that reported the error to only
one fd, but with the errseq_t changes we lost the ability to see
errors that occurred before the open. The above patch restores that
behavior.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: checkbashisms in all script files
Darrick J. Wong [Tue, 8 May 2018 16:53:59 +0000 (09:53 -0700)]
xfs: checkbashisms in all script files

Find all the /bin/sh scripts in xfsprogs and check for bashisms.

Cc: sandeen@sandeen.net
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/{159,160}: require chattr instead of lsattr
Amir Goldstein [Sun, 6 May 2018 06:36:08 +0000 (09:36 +0300)]
generic/{159,160}: require chattr instead of lsattr

The tests _require_test_lsattr, but don't actually use lsattr. They
use chattr +i/-i, so require the appropriate command.

_require_test_lsattr checks the FS_IOC_GETFLAGS ioctl on a directory
and that is not supported in overlayfs. _require_chattr checks the
ioctl on a file, which is supported in overlayfs, so this change
makes the tests run and pass 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>
5 years agocommon/rc: decouple xfs_io flink check from xfs_io -T check
Amir Goldstein [Sun, 6 May 2018 06:36:07 +0000 (09:36 +0300)]
common/rc: decouple xfs_io flink check from xfs_io -T check

The 3 tests that _require_xfs_io_command "flink", actually require
O_TMPFILE support and flink command, but the former is far unlikely
to be missing. The test btrfs/058 doesn't even use the flink
command.

When running these tests on a filesystem that does not support
O_TMPFILE (e.g. overlayfs) the result is not very infomative:

 generic/004 1s ... [not run] xfs_io flink failed (old kernel/wrong fs?)

Decouple the requirements for "flink" command and "-T" command line
flag and require the former explicitly in tests that use it.

As a result the report is now more informative:

 generic/004 1s ... [not run] O_TMPFILE is not supported

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 agoxfs: test inobt/on disk free state mismatches
Dave Chinner [Mon, 7 May 2018 23:05:51 +0000 (09:05 +1000)]
xfs: test inobt/on disk free state mismatches

Fuzzing has recently uncovered a couple of conditions where we don't
detect corruptions that reallocate already allocated inodes. This
test exercises those cases, and checks that we shut down the
filesystem appropriately when such a corruption occurs.

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: many dangerous+auto tests are not dangerous anymore
Dave Chinner [Sun, 6 May 2018 23:05:35 +0000 (09:05 +1000)]
fstests: many dangerous+auto tests are not dangerous anymore

There are a bunch of tests that are run by the auto group that are
marked dangerous. This was done because the test exercised a crash
or other fatal error that has since been fixed. Remove the dangerous
tag from the auto tests that pass on a 4.17-rc3 kernel as they are
not dangerous anymore.

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: remove old electric fence support
Dave Chinner [Sun, 6 May 2018 22:45:31 +0000 (08:45 +1000)]
fstests: remove old electric fence support

Just not used anymore.

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 agooverlay: test multiple origin references to the same lower file
Amir Goldstein [Fri, 4 May 2018 09:41:31 +0000 (12:41 +0300)]
overlay: test multiple origin references to the same lower file

Multiple origin references to the same lower file from upper files
that are not hardlinks will falsely return the same st_ino/st_dev
for two different overlay files and will cause 'diff' to falsely
report that content of files is the same when it is not.

This test checks that overlayfs detects and fails lookup of a
multiply referenced origin.

The check for multiply referenced origin was a by-product of kernel
commit 31747eda41ef ("ovl: hash directory inodes for fsnotify")

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 agooverlay/049: update fix commit id
Amir Goldstein [Fri, 4 May 2018 09:41:30 +0000 (12:41 +0300)]
overlay/049: update fix commit id

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 agoxfs/132: remove duplicate test
Amir Goldstein [Sat, 5 May 2018 10:31:22 +0000 (13:31 +0300)]
xfs/132: remove duplicate test

Test description says: "This is the same test as generic/156 except
that we also check the inode reflink flag.", only since commit
f1c3fee ("xfs: remove NOCOW_FL testing from test") it is almost
exactly the same test as generic/156.
almost - because since xfs/132 diverged from generic/156 the change
911efb0 ("reflink: change to relative margins") is only applied to
the original test.

Anyway, there doesn't seem to be a reason to keep this duplicated
test anymore, so remove it.

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>
5 years agoREADME: document the new default run mode
Dave Chinner [Sat, 5 May 2018 00:19:51 +0000 (10:19 +1000)]
README: document the new default run mode

Also document the new way to run all tests (i.e. check -g all) and
clean up all the stray whitespace in the readme file.

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 agocheck: run auto test group by default
Dave Chinner [Fri, 4 May 2018 00:05:09 +0000 (10:05 +1000)]
check: run auto test group by default

Everyone who starts using fstests runs "check" without parameters,
and then has problems with it running dangerous tests. most people
just want fstests to act as a regression test suite, not a fuzzer or
exercise known crash conditions. Hence make the default behaviour to
be "run the auto group" rather than "run every test".

To enable people to run all tests easily (if they really want to)
add a special group keyword named "all". This wildcard will trigger
selecting all the tests in fstests as per the original "check
without parameters" behaviour.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobuild: Use the original install-sh file from SGI
Theodore Ts'o [Thu, 3 May 2018 05:07:28 +0000 (01:07 -0400)]
build: Use the original install-sh file from SGI

The install-sh file is much more efficient than the libtool version
(50% faster wall clock time; much more than that when running in a
qemu emulation build environment).  There doesn't seem to be any
real need for the libtool version, so bring back the original
install-sh script.

[Eryu: move install-sh to include dir and copy it from there after
libtoolize in Makefile]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: fix blocktrash fuzzers
Darrick J. Wong [Tue, 1 May 2018 15:40:17 +0000 (08:40 -0700)]
xfs: fix blocktrash fuzzers

The blocktrash fuzz tests for xfs will try to mount and write to the
filesystem after corrupting it.  However, the mount may not necessarily
succeed, in which case we must not write junk to the root filesystem.
Use the new _try_scratch_mount to guard against 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>
5 years agoxfs/422: add fsstress to the freeze-and-rmap-repair race test
Darrick J. Wong [Tue, 1 May 2018 15:40:03 +0000 (08:40 -0700)]
xfs/422: add fsstress to the freeze-and-rmap-repair race test

Add fsstress to the pile of things that we race with rmap repair to
ensure that the rmap repair isolates the filesystem correctly while it
is doing its repairs.

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/453: test creation of malicious directory entries
Darrick J. Wong [Tue, 1 May 2018 15:39:57 +0000 (08:39 -0700)]
generic/453: test creation of malicious directory entries

Create malicious . and .. entries (you didn't see the zero-width
joiners at the end, did you?) in a directory to see if scrub will pick
them up.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/45[34]: test unicode confusables
Darrick J. Wong [Tue, 1 May 2018 15:39:51 +0000 (08:39 -0700)]
generic/45[34]: test unicode confusables

Test if a filesystem will allow us to create names with easily
confusable unicode sequences (character spoofing) and, if on XFS,
whether or not xfs_scrub will notice.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/45[34]: check unicode names only if xfs_scrub linked against libicu
Darrick J. Wong [Tue, 1 May 2018 15:39:45 +0000 (08:39 -0700)]
generic/45[34]: check unicode names only if xfs_scrub linked against libicu

Since we've rewriting the xfs_scrub Unicode name scanner to use libicu
to detect potential spoof names, change our check for unicode-enabled
name scanning xfs_scrub to look for libicu instead of libunistring,
adjust the golden output to reflect the new library's detection
capabilities and make sure we get all the scrub output by invoking with
-v.

Note that this requires xfsprogs 4.16 or newer; since xfs_scrub is (for
now) an experimental program, we don't care about breaking backwards
compatibility.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/45[34]: add unicode directional override checks
Darrick J. Wong [Tue, 1 May 2018 15:39:39 +0000 (08:39 -0700)]
generic/45[34]: add unicode directional override checks

Try injecting a Unicode directional override character in the middle of
a name to see if the fs can handle it / xfs_scrub will complain.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test XATTR_REPLACE doesn't take the fs down
Darrick J. Wong [Tue, 1 May 2018 15:39:26 +0000 (08:39 -0700)]
generic: test XATTR_REPLACE doesn't take the fs down

Kanda Motohiro reported that expanding a tiny xattr into a large
xattr fails on XFS because we remove the tiny xattr from a shortform
fork and then try to re-add it after converting the fork to extents
format having not removed the ATTR_REPLACE flag.  This fails because
the attr is no longer present, causing a fs shutdown.

[Eryu: introduce function "fail" and use it where appropriate]

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=199119
Reported-by: kanda.motohiro@gmail.com
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: test exceeding max file size via INSERT_RANGE
Eric Biggers [Mon, 30 Apr 2018 22:17:01 +0000 (15:17 -0700)]
generic: test exceeding max file size via INSERT_RANGE

Test how the "insert range" fallocate operation interacts with the
maximum file size (s_maxbytes).

- Shift extents past the max file size (exposes an ext4 bug).
- Increase i_size past the max file size (exposes an xfs bug).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/fsync-err: don't truncate files on second open
Jeff Layton [Fri, 27 Apr 2018 16:34:59 +0000 (12:34 -0400)]
src/fsync-err: don't truncate files on second open

...and no need for O_CREAT flag.

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test record locks across execve in multithread process
Xiong Zhou [Mon, 23 Apr 2018 02:42:48 +0000 (10:42 +0800)]
generic: test record locks across execve in multithread process

POSIX requires that record locks are preserved across an execve(2).
But currently the locks are released if process is multithreaded at
the time that execve is called.

As Jeff Layton wrote in his patch:
"
In that case, we'll end up unsharing the files_struct but the locks
will still have their fl_owner set to the address of the old one.
Eventually, when the other threads die and the last reference to the
old files_struct is put, any POSIX locks get torn down since it
looks like a close occurred on them.

The result is that all of your open files will be intact with none
of the locks you held before execve.
"

Add a new regression test for this particular case.

[Eryu: rewrite commit log and test description]

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/011: cleanup the functions
Anand Jain [Thu, 19 Apr 2018 16:03:37 +0000 (00:03 +0800)]
btrfs/011: cleanup the functions

Use common helper functions where needed. By doing this it improves
code readability and debugging of it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay/04{1,3,4}: enable xino feature
Amir Goldstein [Thu, 26 Apr 2018 05:53:27 +0000 (23:53 -0600)]
overlay/04{1,3,4}: enable xino feature

These tests check for constant inode number on copy up with
nonsamefs layer configuration. This problem is fixes only when
opting-in with the xino=on mount option, so let the tests enable the
mount option on new kernels and notrun on old kernels.

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 agooverlay/043: require and enable redirect_dir
Amir Goldstein [Thu, 26 Apr 2018 05:53:26 +0000 (23:53 -0600)]
overlay/043: require and enable redirect_dir

This test renames a merge directory so it needs to enable
redirect_dir feature, which is not enabled by default.

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 agooverlay/041: fix call to _overlay_check_scratch_dirs
Amir Goldstein [Thu, 26 Apr 2018 05:53:25 +0000 (23:53 -0600)]
overlay/041: fix call to _overlay_check_scratch_dirs

_overlay_check_scratch_dirs needs to base scratch fs to be mounted,
so only unmount overlay before check.

Remove redundant definition of upperdir/workdir path, which also
uses hardcoded path instead of the config vars OVL_UPPER/OVL_WORK.

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 agoxfs: filestream allocator inode use-after-free test
Brian Foster [Thu, 26 Apr 2018 12:04:44 +0000 (08:04 -0400)]
xfs: filestream allocator inode use-after-free test

The XFS filestreams allocator caches dir inode -> agno mappings in
an MRU mechanism that holds elements in memory for an amount of time
and then cleans up expired elements in the background. The elements
typically held inode pointers without holding a reference to the
associated inode. This means that if the inode is reclaimed before
an expired entry is cleaned up, the MRU reaper can access freed
memory and cause a panic.

Test for this problem by performing continuous filestreams
allocations under short-lived parent directory inodes. This will
produce KASAN use-after-free splats if enabled during the test.

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/130: make it workable on small systems
Anand Jain [Tue, 17 Apr 2018 14:56:40 +0000 (22:56 +0800)]
btrfs/130: make it workable on small systems

This test case takes a long time to complete at the default
LOAD_FACTOR=1, so reduce the nr_extents to 256, so for larger
systems it can still use higher LOAD_FACTOR.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/130: fix Invalid argument
Anand Jain [Tue, 17 Apr 2018 14:55:37 +0000 (22:55 +0800)]
btrfs/130: fix Invalid argument

btrfs-progs patch[1] replaced read(2) write(2) with splice(2) and
caused the append-redirect to stop working.

Before:
 btrfs send /btrfs/ro_send > /dev/null
 At subvol /btrfs/ro_snap

 btrfs send /btrfs/ro_send >> /dev/null
 At subvol /btrfs/ro_snap

After:
 btrfs send /btrfs/ro_send > /dev/null
 At subvol /btrfs/ro_snap

 btrfs send /btrfs/ro_send >> /dev/null
 At subvol /btrfs/ro_snap
 ERROR: failed to read stream from kernel: Invalid argument

Further in the test case the line..
btrfs/130
  ::
 _run_btrfs_util_prog send $SCRATCH_MNT/ro_snap > /dev/null 2>&1

which intended to redirect send output to /dev/null, but ended up
append redirect to the $seqres.full file. And so this test case
failed as 'Invalid argument' for sometime now.

Still as append of a btrfs send output doesn't make sense, so fix
the fstests.

Also adds logs going into $seqres.full.

[1]
ba23855cdc8961bbaef1fcad4854d494cdb3afd3
 btrfs-progs: send: use splice syscall instead of read/write to transfer buffer

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: move rm out from if block to always delete kmemleak temp file
Misono Tomohiro [Mon, 23 Apr 2018 05:23:14 +0000 (14:23 +0900)]
common/rc: move rm out from if block to always delete kmemleak temp file

Otherwise, *.kmemleak.tmp may remain in result folder if kmemleak is on.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: raise btrfs mixed mode threshold to 1GB
Omar Sandoval [Thu, 12 Apr 2018 05:07:29 +0000 (22:07 -0700)]
common/rc: raise btrfs mixed mode threshold to 1GB

generic/427 creates a 256 MB filesystem and then writes a 200 MB file,
which fails on Btrfs if mixed mode is not enabled. Raise the threshold
to 1GB, which is where we typically recommend mixed mode.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/aio-dio-eof-race: handle aio pwrite errors and short reads
Omar Sandoval [Thu, 12 Apr 2018 05:07:28 +0000 (22:07 -0700)]
src/aio-dio-eof-race: handle aio pwrite errors and short reads

generic/427 fails on Btrfs with a cryptic "pread: Success" message. This
is because an aio pwrite fails with ENOSPC, so the file isn't as long as
we expect it to be. Make sure we check the result of the aio writes and
also print a more explicit message for short reads (which are
technically valid but in practice shouldn't happen for this test case).
Now the test fails with a much more informative "pwrite: No space left
on device".

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 agocommon/xfs: Add require_xfs_db_write_array function
yang xu [Tue, 17 Apr 2018 06:11:40 +0000 (14:11 +0800)]
common/xfs: Add require_xfs_db_write_array function

xfsprogs commit 4222d00("db: write via array indexing doesn't
work") fixes a bug that xfs_db write can't support array indexing.
This function will check whether the bug is fixed on the current
xfsprogs.

xfs/444 applies the function, and skips if this bug exists.

Signed-off-by: yang xu <xuyang.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay/013: do not expect failure
Miklos Szeredi [Mon, 16 Apr 2018 10:41:41 +0000 (12:41 +0200)]
overlay/013: do not expect failure

Current test expects test_lower to fail with:

  truncate(test_lower) should have failed

While it is sort of okay to fail like that (the above expectation
basically acknowledges this weirdness in the overlayfs
implementation), it is by no means the only correct behavior: it is
also correct for the test to succeed (i.e. truncation fails with
ETXTBSY).

So add an option to t_truncate_self.c that allows both success and
failure, but obviously not SIGSEGV, which is what a we'd get in a
real failure mode.

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 agooverlay/040: clean up properly after setting immutable
Miklos Szeredi [Mon, 16 Apr 2018 10:41:40 +0000 (12:41 +0200)]
overlay/040: clean up properly after setting immutable

Test program expects only immutable on lower layer (test failure),
but does not expect the immutable file to be on the upper layer.
The later case is actually what *should* happen, except overlayfs
didn't properly implement this case yet (but is now in the works).

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric/304: only dedupe the last 64k of the single byte file
Darrick J. Wong [Tue, 17 Apr 2018 05:20:35 +0000 (22:20 -0700)]
generic/304: only dedupe the last 64k of the single byte file

Commit 1ddae54555b62 ("common/rc: add missing 'local' keywords") exposed
a long-hidden bug in generic/304 -- previously we'd set len to 8EiB, but
_pwrite_byte reset it to 1 because the helper clumsily polluted the
caller's variable namespace.  Now that's fixed, but we send an 8EiB
dedupe request to the kernel, which on XFS locks up the kernel while
doing this.  The point of this test is to demonstrate that one cannot
dedupe the last byte of a (2^63-1) byte file (that's the way the
interface has behaved historically), so start at 64k below that instead
of offset zero.

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>
6 years agobtrfs: fsync after hole punching with no-holes mode
Filipe Manana [Wed, 28 Mar 2018 11:55:30 +0000 (12:55 +0100)]
btrfs: fsync after hole punching with no-holes mode

Test that when we have the no-holes mode enabled and a specific
metadata layout, if we punch a hole and fsync the file, at replay
time the whole hole was preserved.

This issue is fixed by the following btrfs patch for the linux
kernel:

  "Btrfs: fix fsync after hole punching 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>
6 years agoxfs/187: fix ftype brokenness
Darrick J. Wong [Wed, 11 Apr 2018 16:08:09 +0000 (09:08 -0700)]
xfs/187: fix ftype brokenness

This test requires XFS_SB_VERSION_MOREBITSBIT to be zero.  ftype (which
is now enabled by default) causes this to be set, so detect it in mkfs
and disable 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>
6 years agogeneric: test for fsync after fallocate
Filipe Manana [Fri, 6 Apr 2018 13:59:15 +0000 (14:59 +0100)]
generic: test for fsync after fallocate

Test that fsync operations preserve extents allocated with
fallocate(2) that are placed beyond a file's size.

This test is motivated by a bug found in btrfs where unwritten
extents beyond the inode's i_size were not preserved after a fsync
and power failure. The btrfs bug is fixed by the following patch for
the linux kernel:

 "Btrfs: fix loss of prealloc extents past i_size after fsync log replay"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agocommon/config: support f2fs-tools v1.9 and later
Eric Biggers [Mon, 9 Apr 2018 18:55:39 +0000 (11:55 -0700)]
common/config: support f2fs-tools v1.9 and later

Pass the -f option to mkfs.f2fs when it appears to support it.  This is
required by f2fs-tools v1.9 and later in order to format the filesystem
even when an existing filesystem is detected.  But earlier versions did
not accept this option.

mkfs.f2fs doesn't yet have an option to print its version number.  So,
to detect a new enough version we grep for -f in the help output.  This
also works for mkfs.btrfs, so we switch that over to the same method
rather than grepping for "force overwrite" in the binary.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agocommon/rc: fix up variable naming
Eric Biggers [Sat, 7 Apr 2018 02:35:30 +0000 (19:35 -0700)]
common/rc: fix up variable naming

Remove the leading underscore from local variable names, and add a
leading underscore to $err_msg to reflect its status as a global
variable shared by 'check' and 'common/report'.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agocommon/rc: add missing 'local' keywords
Eric Biggers [Sat, 7 Apr 2018 02:35:29 +0000 (19:35 -0700)]
common/rc: add missing 'local' keywords

Many helper functions in xfstests are unnecessarily declaring variables
without the 'local' keyword, which pollutes the global namespace and can
collide with variables in tests.  Fix this for everything in common/rc
that I could find.

In _math(), just eliminate $result by removing the check for nonempty
$BC, which is redundant with _require_math() which the tests do.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric: Check the fs after each FUA writes
Qu Wenruo [Wed, 28 Mar 2018 04:40:23 +0000 (12:40 +0800)]
generic: Check the fs after each FUA writes

Basic test case which triggers fsstress with dm-log-writes, and then
check the fs after each FUA writes.
With needed infrastructure and special handlers for journal based fs.

[Eryu: cap $nr_cpu to 8 to avoid wasting time on hosts with many cpus]

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agolog-writes: Add support for METADATA flag
Qu Wenruo [Wed, 28 Mar 2018 04:40:22 +0000 (12:40 +0800)]
log-writes: Add support for METADATA flag

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agolog-writes: Add support to output human readable flags
Qu Wenruo [Wed, 28 Mar 2018 04:40:21 +0000 (12:40 +0800)]
log-writes: Add support to output human readable flags

Also change the flag numeric output to hex.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agocommon/rc: improve checks for YP/NIS
Benjamin Coddington [Thu, 29 Mar 2018 15:27:25 +0000 (11:27 -0400)]
common/rc: improve checks for YP/NIS

At the 2018 spring NFS BAT, we have a number of systems that return
a valid string from `domainaname`, but don't have the ypcat binary.
If we don't have the yp-tools package installed, we're not going to
be able to use ypcat, so check for it and bail out.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agooverlay: test decoding overlay file handles with warm/cold dentry cache
Amir Goldstein [Thu, 29 Mar 2018 12:06:50 +0000 (15:06 +0300)]
overlay: test decoding overlay file handles with warm/cold dentry cache

When opening a non-dir by file handle and the decoded inode/dentry
are not in cache, the resulting dentry is "disconnected" (i.e. unknown
path). This is a common case that is already covered by previous tests.
This test covers the case of decoding an overlay file handle, while a
disconnected dentry is still in cache.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agoopen_by_handle: add -s option to sleep and keep files open by handle
Amir Goldstein [Thu, 29 Mar 2018 12:06:49 +0000 (15:06 +0300)]
open_by_handle: add -s option to sleep and keep files open by handle

This feature is needed for tests that need to open file by handle and
then perform operations while that file is open. This will be used by
an overlay test to keep disconnected dentries in dcache.

Usage: open_by_handle -s <test_dir>

On success, the program will run until it gets a terminating signal.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agoopen_by_handle: add -n option to suppress drop caches
Amir Goldstein [Thu, 29 Mar 2018 12:06:48 +0000 (15:06 +0300)]
open_by_handle: add -n option to suppress drop caches

By default, open_by_handle drops inode and page caches before trying
to open by file handles. Add an option to suppress drop caches for
testing open by handle with warm caches.

Usage: open_by_handle -n <test_dir> [N]

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agoopen_by_handle: make -h (help) a valid option
Amir Goldstein [Thu, 29 Mar 2018 12:06:47 +0000 (15:06 +0300)]
open_by_handle: make -h (help) a valid option

All this does is suppress the "illegal value" message.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agoxfs/278: find sfdir inode field prefix
Darrick J. Wong [Fri, 23 Mar 2018 16:54:47 +0000 (09:54 -0700)]
xfs/278: find sfdir inode field prefix

Use the xfs set/get metadata field helpers to detect the correct sfdir
field name prefix on v4-v5 filesystems.  This enables us to test inode
link count corrections on a (deliberately) disconnected directory.

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>
6 years agoxfs: test agfl reset on bad list wrapping
Darrick J. Wong [Fri, 23 Mar 2018 16:54:41 +0000 (09:54 -0700)]
xfs: test agfl reset on bad list wrapping

From the kernel patch that this test examines ("xfs: detect agfl
count corruption and reset agfl"):

"The struct xfs_agfl v5 header was originally introduced with
unexpected padding that caused the AGFL to operate with one less
slot than intended. The header has since been packed, but the fix
left an incompatibility for users who upgrade from an old kernel
with the unpacked header to a newer kernel with the packed header
while the AGFL happens to wrap around the end. The newer kernel
recognizes one extra slot at the physical end of the AGFL that the
previous kernel did not. The new kernel will eventually attempt to
allocate a block from that slot, which contains invalid data, and
cause a crash.

"This condition can be detected by comparing the active range of the
AGFL to the count. While this detects a padding mismatch, it can
also trigger false positives for unrelated flcount corruption. Since
we cannot distinguish a size mismatch due to padding from unrelated
corruption, we can't trust the AGFL enough to simply repopulate the
empty slot.

"Instead, avoid unnecessarily complex detection logic and and use a
solution that can handle any form of flcount corruption that slips
through read verifiers: distrust the entire AGFL and reset it to an
empty state. Any valid blocks within the AGFL are intentionally
leaked. This requires xfs_repair to rectify (which was already
necessary based on the state the AGFL was found in). The reset
mitigates the side effect of the padding mismatch problem from a
filesystem crash to a free space accounting inconsistency."

This test exercises the reset code by mutating a fresh filesystem to
contain an agfl with various list configurations of correctly wrapped,
incorrectly wrapped, not wrapped, and actually corrupt free lists; then
checks the success of the reset operation by fragmenting the free space
btrees to exercise the agfl.  Kernels without this reset fix will shut
down the filesystem with corruption errors.

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>
6 years agooverlay/05[45]: Document the fix commit
Amir Goldstein [Sun, 25 Mar 2018 08:02:55 +0000 (11:02 +0300)]
overlay/05[45]: Document the fix commit

This fix was merged for v4.16-rc5.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric/478: fix potential test blocking
Xiong Zhou [Fri, 23 Mar 2018 02:49:37 +0000 (10:49 +0800)]
generic/478: fix potential test blocking

Reduce semtimedop timeout to 5s, 15s is too long if something get
tangled up. Add retry counting to getlk routine, infinite loop is
dangerous. If something goes wrong unexpextedly, test is blocked and
wasting time.

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agocommon/xfs: fix various problems with _supports_xfs_scrub
Darrick J. Wong [Thu, 22 Mar 2018 02:48:09 +0000 (19:48 -0700)]
common/xfs: fix various problems with _supports_xfs_scrub

The _supports_xfs_scrub helper is called with a mountpoint (a working
mountpoint is required for scrub) and a block device (used to detect
norecovery mounts).  If either of these conditions aren't satisfied we
should return failure status to the caller, not unilaterally decide to
bail out of the test.  In particular, the -b test doesn't work if the
fs has already shutdown on us.

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>
6 years agocommon/xfs: don't call xfs_scrub on a block device
Darrick J. Wong [Thu, 22 Mar 2018 02:46:56 +0000 (19:46 -0700)]
common/xfs: don't call xfs_scrub on a block device

xfs_scrub takes an xfs mountpoint as its argument, not a block
device. Therefore, fix _check_xfs_filesystem to call it correctly.

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>
6 years agobuild: fix <ndbm.h> detection in AC_PACKAGE_WANT_GDBM
Jeff Mahoney [Thu, 15 Mar 2018 21:54:55 +0000 (17:54 -0400)]
build: fix <ndbm.h> detection in AC_PACKAGE_WANT_GDBM

SUSE systems export the NDBM interface via /usr/include/ndbm.h

This means that dbtest wasn't built on SUSE systems until commit
2353022 (build: update AC_PACKAGE_WANT_GDBM() and src/dbtest.c to
build). That change was incompatible with older SLES releases due to
<ndbm.h> and <gdbm.h> both defining the datum type, resulting in
build failures.

Nothing has ever set HAVE_GDBM_H or checked for the <gdbm.h> header
prior to the above commit, and it's not required on SUSE systems
either, so just remove that entirely.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agobuild: clean up AC_PACKAGE_WANT_GDBM
Jeff Mahoney [Thu, 15 Mar 2018 21:54:54 +0000 (17:54 -0400)]
build: clean up AC_PACKAGE_WANT_GDBM

The AC_PACKAGE_WANT_GDBM macro is not easily read. It's not doing
anything particularly complex other than working through a set of
alternatives for headers and libraries.

This patch cleans it up to be more readable.  We also only attempt
to check in libgdbm_compat if the checks in libgdbm fail.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agobuild: AC_PACKAGE_WANT_GDBM, fall back to compat if libgdbm detection fails
Jeff Mahoney [Thu, 15 Mar 2018 21:54:53 +0000 (17:54 -0400)]
build: AC_PACKAGE_WANT_GDBM, fall back to compat if libgdbm detection fails

We currently check if libgdbm_compat contains the required symbols
even if libgdbm does. Let's fall back only when necessary (which is
pretty much always anyway).

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agobuild: remove dead AC_PACKAGE_WANT_NDBM macro
Jeff Mahoney [Thu, 15 Mar 2018 21:54:52 +0000 (17:54 -0400)]
build: remove dead AC_PACKAGE_WANT_NDBM macro

Commit fb05a918085 build: remove IRIX-specific build logic) removed
the tests used on IRIX but missed AC_PACKAGE_WANT_NDBM.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric/015: Issue sync after deleting the fillup file
Nikolay Borisov [Wed, 14 Mar 2018 14:48:37 +0000 (16:48 +0200)]
generic/015: Issue sync after deleting the fillup file

This test fails on btrfs due to the presence of delayed processing
of file deletes if the file is smaller than 32mb. Initially commit
97575acd7495b412435d06229a6d94ed9a814ada tried to fix a similar
failure by bumping the size of the filesystem. However that change
had a knock-on effect in that the scratch filesystem created is
larger than 100mb and thus not created in mixed mode. This in turn
causes the fs to have only 20mb for file data (rest is taken by DUP
metadata). Naturally, this leads to file freeing taking up to
"transaction commit interval" (default 30 s) time to properly account
the freed space.

Not standards define when unlink operations should be accounted so
btrfs is well within its right to be implemented in that way. So
to avoid this edge case just issue a sync before taking the 2nd
free space reading.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agooverlay: Absolute redirect should be followed even if ancestor is opaque
Vivek Goyal [Wed, 14 Mar 2018 13:16:18 +0000 (09:16 -0400)]
overlay: Absolute redirect should be followed even if ancestor is opaque

Typically, when following absolute redirect, if an opauqe dentry is
found, lookup in further lower directories is stopped. But if a child
dentry has another absolute redirect, then lookup in further lower
layers should continue.

Say, following is example setup.
upper:  /redirect (redirect=/a/b/c)
lower1: /a/[b]/c       ([b] is opaque) (c has absolute redirect=/a/b/d/)
lower0: /a/b/d/foo

"redirect" directory in upper should merge with lower1:/a/b/c/ and
lower0:/a/b/d/, despite lower1:/a/b/ being opaque.

This example and kernel fix has come from Amir Goldstein. I am just
putting a test for it to make sure its not broken down the line.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric: test on creating new file after log replay
Liu Bo [Sat, 10 Mar 2018 23:56:04 +0000 (16:56 -0700)]
generic: test on creating new file after log replay

The regression is introduced to btrfs in linux v4.4 and it refuses to
create new files after log replay by returning -EEXIST.

Although the problem is on btrfs only, there is no btrfs stuff in terms
of test, so this makes it generic.

The kernel fix is
  Btrfs: fix unexpected -EEXIST when creating new inode

[Eryu: add _require_metadata_journaling rule and 'log' 'metadata' group]

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agobtrfs/146: make sure hit all stripes in the case of compression
Lu Fengqi [Thu, 8 Mar 2018 08:30:53 +0000 (16:30 +0800)]
btrfs/146: make sure hit all stripes in the case of compression

In the case of compression, each 128K input data chunk will be
compressed to 4K (because of the characters written are duplicate).
Therefore we have to write (128K * 16) to make sure every stripe can be
hit.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agobtrfs/004: increase the buffer size of logical-resolve to the maximum value 64K
Lu Fengqi [Tue, 6 Mar 2018 07:02:31 +0000 (15:02 +0800)]
btrfs/004: increase the buffer size of logical-resolve to the maximum value 64K

Because of commit e76e13ce8c0b ("fsstress: implement the
clonerange/deduperange ioctls"), dedupe makes the number of references
to the same extent item increase so much that the default 4K buffer of
logical-resolve is no longer sufficient.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric: test fsync new file after removing hard link
Filipe Manana [Wed, 28 Feb 2018 15:58:00 +0000 (15:58 +0000)]
generic: test fsync new file after removing hard link

Test that if we have a file with two hard links in the same parent
directory, then remove of the links, create a new file in the same
parent directory and with the name of the link removed, fsync the new
file and have a power loss, mounting the filesystem succeeds.

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

  "Btrfs: fix log replay failure after unlink and link combination"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agogeneric: add test for fsync after renaming and linking special file
Filipe Manana [Wed, 28 Feb 2018 15:57:34 +0000 (15:57 +0000)]
generic: add test for fsync after renaming and linking special file

Test that when a fsync journal/log exists, if we rename a special file
(fifo, symbolic link or device), create a hard link for it with its old
name and then commit the journal/log, if a power loss happens the
filesystem will not fail to replay the journal/log when it is mounted
the next time.

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

  "Btrfs: fix log replay failure after linking special file and fsync"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 years agooverlay: correct scratch dirs check
zhangyi (F) [Thu, 1 Mar 2018 12:13:47 +0000 (20:13 +0800)]
overlay: correct scratch dirs check

Tests that use _overlay_scratch_mount_dirs instead of _scratch_mount
should use _require_scratch_nocheck instead of _require_scratch
because these tests are either mounting with multiple lower dirs or
mounting with non-default lower/upper/work dir, so
_check_overlay_scratch_fs won't handle these cases correctly. So we
introduce _overlay_check_scratch_dirs helper and should call this
helper with the correct dir arguments for these non-default cases.

This patch modify these tests to optionally call
_overlay_check_scratch_dirs at the end of the test or after
_scratch_umount to mount base filesystem only and run the checker.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>