xfstests-dev.git
6 years agobuild: update AC_PACKAGE_WANT_GDBM() and src/dbtest.c to build
Luis R. Rodriguez [Wed, 13 Dec 2017 00:45:14 +0000 (16:45 -0800)]
build: update AC_PACKAGE_WANT_GDBM() and src/dbtest.c to build

Modern gdbm-devel packages bundle together gdbm.h and ndbm.h.  The
old m4 macro had detection support for some old gdbm libraries but
not for new ones.

We fix compilation of src/dbtest.c by making the autoconf helper
check for this new arrangement:

If both gdbm.h and ndbm.h are found define set both gdbm_ndbm_=true,
and have_db=true, and define HAVE_GDBM_H. The src/dbtest.c already
had a HAVE_GDBM_H but there was never a respective autoconf settter
for it. We can just re-use this and fix it for new arrangement.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/group: add 304 to dedupe group
Luis R. Rodriguez [Wed, 13 Dec 2017 00:45:13 +0000 (16:45 -0800)]
generic/group: add 304 to dedupe group

Other generic tests that test dedupe all have 'dedupe' group except
generic/304. Add 304 to dedupe group too.

[eguan: add commit log]

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: initial fiemap range query test
Nikolay Borisov [Thu, 30 Nov 2017 16:05:27 +0000 (18:05 +0200)]
generic: initial fiemap range query test

Fiemap gained support for passing in optional offset len which
denote the range requested, so this patch adds testcases for this
functionality. Aditionally, a special "ranged" argument is added to
the require_xfs_io_command which checks for the presence of fiemap
range support.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: Partial direct write test
Goldwyn Rodrigues [Thu, 7 Dec 2017 16:00:44 +0000 (10:00 -0600)]
generic: Partial direct write test

Getting an error midway through a direct write would return an error
and the error-code is returned in the write() call. However, partial
data is over-written during the call.

This tests simulates the ENOSPC error to check for partial direct
write consistency.

[eguan: use $AWK_PROG instead of bare awk]

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: Test RWF_NOWAIT
Goldwyn Rodrigues [Thu, 7 Dec 2017 16:00:43 +0000 (10:00 -0600)]
generic: Test RWF_NOWAIT

Tests the RWF_NOWAIT flag so the I/O returns immediately with
-EAGAIN on a new file since it requires block allocation.

It creates a file, syncs it, and overwrites the file with
RWF_NOWAIT.  This should succeed.

Finally, read the contents to make sure the overwrite is successful.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/rc: Check pwrite parameters in _require_xfs_io_command
Goldwyn Rodrigues [Thu, 7 Dec 2017 16:00:42 +0000 (10:00 -0600)]
common/rc: Check pwrite parameters in _require_xfs_io_command

There are some parameters added with xfs_io. Check if the pwrite
parameters are available. For some cases, xfs_io now returns
"command -%c not supported", so added "not supported" to count as
error.

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/populate: fix S_IFDIR.FMT_BLOCK and ATTR.FMT_LOCAL for ext4 encryption
Theodore Ts'o [Tue, 12 Dec 2017 05:19:37 +0000 (00:19 -0500)]
common/populate: fix S_IFDIR.FMT_BLOCK and ATTR.FMT_LOCAL for ext4 encryption

When ext4 encryption is enabled, the directory entries are encrypted
so we need to create fewer directory entries to guarantee that they
will all fit in a single block.

Also, the encryption metadata takes up extended attribute room so we
can only add a single xattr to guarantee that the xattrs will fit in
the inode.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon: rework _require_ext4_mkfs_feature
Theodore Ts'o [Mon, 11 Dec 2017 22:49:19 +0000 (17:49 -0500)]
common: rework _require_ext4_mkfs_feature

In all of the places where we need check to see if mkfs.ext4 can
support a set of file system features, we also should be checking to
see if the kernel can support those file system features.  So rename
_require_ext4_mkfs_feature to _require_scratch_ext4_feature, and
actually format the file system in $SCRATCH_DEV.

Also allow ext4/306 to run on systems where mke2fs doesn't support
the "64bit" option.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobuild: fix Wlog_Error_String overflow issues
Ross Zwisler [Thu, 7 Dec 2017 21:35:03 +0000 (14:35 -0700)]
build: fix Wlog_Error_String overflow issues

The 'Wlog_Error_String' string is defined to be 256 bytes in length,
but in two places we write into it with a format that contains a
string (wfile->w_file) that has length 1024.  This can overflow
Wlog_Error_String, as we see in the new compiler warnings from gcc
7.2.1:

 write_log.c:124:37: warning: ā€˜%sā€™ directive writing up to 1023 bytes into
 a region of size 224 [-Wformat-overflow=]
 "Could not open write_log - open(%s, %#o, %#o) failed:  %s\n",
  ^~

Fix this by increasing the length of Wlog_Error_String to 1280
characters (1024 for wfile->w_file plus 256 for the rest of the
format string), and by using snprintf() instead of sprintf() so we
are sure we don't overflow.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobuild: fix TagName overflow issues
Ross Zwisler [Thu, 7 Dec 2017 21:35:02 +0000 (14:35 -0700)]
build: fix TagName overflow issues

The 'TagName' string is defined to be 40 characters in length, but
in three places we write into it with a format of "(%.39s)".  This
can result in a string of up to 42 characters, the 39 character user
string plus "()\0".  This overflows TagName, as we see in the new
complier warnings from gcc 7.2.1:

iogen.c:1277:6: note: 'sprintf' output between 3 and 42 bytes into a
destination of size 40
  sprintf( TagName, "(%.39s)", optarg );
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Fix this by limiting the user string to 37 characters.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobuild: fix _BSD_SOURCE complier warning
Ross Zwisler [Thu, 7 Dec 2017 21:35:01 +0000 (14:35 -0700)]
build: fix _BSD_SOURCE complier warning

When compiling xfstests with either gcc 6.4.1 or 7.2.1 I see the
following warning:

In file included from /usr/include/stdio.h:27:0,
                 from fssum.c:25:
/usr/include/features.h:148:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE
are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
 # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
   ^~~~~~~

The feature_test_macros(7) man page says this about _BSD_SOURCE:

 Since glibc 2.20, this macro is deprecated. It now has the same
 effect as defining _DEFAULT_SOURCE, but generates a compile-time
 warning (unless _DEFAULT_SOURCE is also defined). Use
 _DEFAULT_SOURCE instead.  To allow code that requires _BSD_SOURCE
 in glibc 2.19 and earlier and _DEFAULT_SOURCE in glibc 2.20 and
 later to compile without warnings, define both _BSD_SOURCE and
 _DEFAULT_SOURCE.

Keep backwards compatibility with older code by defining both
_BSD_SOURCE and _DEFAULT_SOURCE.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: add test for DAX MAP_SYNC support
Ross Zwisler [Thu, 7 Dec 2017 23:19:50 +0000 (16:19 -0700)]
generic: add test for DAX MAP_SYNC support

This test creates a file and writes to it via an mmap(), but never
syncs via fsync/msync. This process is tracked via dm-log-writes,
then replayed.

If MAP_SYNC is working the dm-log-writes replay will show the test
file with 1 MiB of on-media block allocations.  This is because each
allocating page fault included an implicit metadata sync.  If
MAP_SYNC isn't working (which you can test by removing the "-S" flag
to xfs_io mmap) the file will be smaller or missing entirely.

Note that dm-log-writes doesn't track the data that we write via the
mmap(), so we can't do any data integrity checking.  We can only
verify that the metadata writes for the page faults happened.

[eguan: add comments on _require_log_writes_dax and fix its cleanup]

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agodm-log-writes: only replay log to marks that exist
Ross Zwisler [Wed, 6 Dec 2017 00:37:43 +0000 (17:37 -0700)]
dm-log-writes: only replay log to marks that exist

The 'replay-log' executable will replay the dm-log-writes log until
the given mark, or until the end of the log if the mark isn't found.

This means that if the mark you're looking for was never inserted in
the log or if you give garbage to _log_writes_replay_log() the
entire log will be replayed.  This can cause unexpected test
results.

Fix this by making sure that the mark we're given actually exists in
the log before we allow the replay.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: reproduce a read failure on raid6 setup
Liu Bo [Mon, 4 Dec 2017 22:33:23 +0000 (15:33 -0700)]
btrfs: reproduce a read failure on raid6 setup

This test case is to reproduce a bug of raid6 reconstruction
process.

The kernel fix are
Btrfs: do not merge rbios if their fail stripe index are not identical
Btrfs: make raid6 rebuild retry more

[eguan: whitespace and indention fix, add 'raid' group]

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs/124: add balance --full-balance option
Anand Jain [Tue, 5 Dec 2017 11:36:32 +0000 (19:36 +0800)]
btrfs/124: add balance --full-balance option

btrfs balance needs --full-balance option since 4.6, so check the
version and then use it.

As this may be useful for other btrfs tests as well, so this patch
also adds _run_btrfs_balance_start() to the common/btrfs file.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/459: Fix check for ro-remount in extN
yang xu [Fri, 1 Dec 2017 10:05:36 +0000 (18:05 +0800)]
generic/459: Fix check for ro-remount in extN

Currently ,freeze failure caused by the lack of space can not
guarantee to remount extN filesystem in read-only mode, and test
failed due to "ro" mount option not found. We can add a touch to
trigger the action which aborts journal and ro-remounts the fs.

[eguan: update commit log and comments a bit]

Signed-off-by: yang xu <xuyang.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: make sure btrfs can handle full fs trim correctly
Qu Wenruo [Wed, 29 Nov 2017 06:14:19 +0000 (14:14 +0800)]
btrfs: make sure btrfs can handle full fs trim correctly

Ancient commit f4c697e6406d ("btrfs: return EINVAL if start >
total_bytes in fitrim ioctl") introduced a regression where btrfs
may fail to trim any free space in existing block groups.

It's caused by confusion with btrfs_super_block->total_bytes and
btrfs logical address space.

Unlike physical address, any aligned bytenr in range [0, U64_MAX) is
valid in btrfs logical address space, and it's chunk mapping
mechanism of btrfs to handle the logical<->physical mapping.

The test case will craft a btrfs with the following features:
0) Single data/meta profile
   Make trimmed bytes reporting and chunk allocation more predictable.

1) All chunks start beyond super_block->total_bytes (1G)
   By relocating these blocks several times.

2) Unallocated space is less than 50% of the whole fs

3) Fragmented data chunks
   Data chunks will be full of fragments, 50% of data chunks will be
   free space.

So in theory fstrim should be able to trim over 50% space of the fs.
(after fix, 64% of the fs can be trimmed)

While the regression makes btrfs only able to trim unallocated
space, which is less than 50% of the total space.
(without fix, it's only 31%)

Fixed by patch named "btrfs: Ensure btrfs_trim_fs can trim the whole
fs".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/042: remove wrong check for empty index
Amir Goldstein [Tue, 28 Nov 2017 16:42:02 +0000 (18:42 +0200)]
overlay/042: remove wrong check for empty index

The check for empty index in this test was wrongly copied from test
overlay/034. In test overlay/034 lower file starts as a hardlink, so
nlink accounting is done from the first copy up and index can be cleaned
on last upper hardlink unlink. In this test, lower starts as
non-hardlink, so first copy up does not perform nlink accounting and
therefore, union nlink count does not drop to 0 at the end of the test
and the index is not expected to be cleaned.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: regression test for orphan index cleanup on mount
Amir Goldstein [Tue, 28 Nov 2017 16:42:01 +0000 (18:42 +0200)]
overlay: regression test for orphan index cleanup on mount

Test nlink accounting of overlay hardlinks with offline modifications.

nlink of overlay inode should account for the union of lower and upper
hardlinks. Orphan index inodes with union nlink 0 should be cleaned on
mount.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: regression test for hardlink breakage after unlink and mount cycle
Amir Goldstein [Tue, 28 Nov 2017 16:42:00 +0000 (18:42 +0200)]
overlay: regression test for hardlink breakage after unlink and mount cycle

- file A and B are hardlinked in lower
- modify A to trigger copy up and index lower
- unlink A and mount cycle
- check that B still contains the modified data

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/388: use TIME_FACTOR to scale test duration
Darrick J. Wong [Wed, 29 Nov 2017 01:09:04 +0000 (17:09 -0800)]
generic/388: use TIME_FACTOR to scale test duration

Use TIME_FACTOR to increase the amount of time we spend testing log
shutdown recovery.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: test send for files with multiple hard links renamed
Filipe Manana [Fri, 17 Nov 2017 14:49:05 +0000 (14:49 +0000)]
btrfs: test send for files with multiple hard links renamed

Test that an incremental send operation works if a file that has
multiple hard links has some of its hard links renamed in the send
snapshot, with one of them getting the same path that some other
inode had in the send snapshot.

At the moment this test fails on btrfs and a fix is provived by a
linux kernel patch titled:

  "Btrfs: incremental send, fix wrong unlink path after renaming file"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/465: just check the actual read data under dio read/write
Xiao Yang [Mon, 27 Nov 2017 02:34:27 +0000 (10:34 +0800)]
generic/465: just check the actual read data under dio read/write

I got the following message when running generic/465 in ext4
data=journal mode
---------------------------------------------------------------
QA output created by 465
non-aio dio test
encounter an error: block 0 offset 4096, content 62
encounter an error: block 0 offset 122880, content 62
encounter an error: block 0 offset 274432, content 62
encounter an error: block 0 offset 86016, content 62
aio-dio test
encounter an error: block 0 offset 28672, content 62
encounter an error: block 0 offset 12288, content 62
encounter an error: block 2 offset 16384, content 62
encounter an error: block 1 offset 565248, content 62
---------------------------------------------------------------

In ext4 data=journal mode, direct read will fall back to buffer
read, and buffer read doesn't take inode lock, so it doesn't need to
wait for the writer to finish first and sees the intermediate inode
size and returns data less than 1M.

We can just check the actual read data instead of the whole read
buffer.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: filter readonly mount error messages
Eryu Guan [Tue, 14 Nov 2017 10:26:45 +0000 (18:26 +0800)]
fstests: filter readonly mount error messages

util-linux commit 6dede2f2f7c5 ("libmount: support MS_RDONLY on
write-protected devices") changed the error message on read-only
block device, and in the failure case printed one line message
instead of two (for details please see comments in common/filter),
and this change broke generic/050 and overlay/035.

Fix it by adding more filter rules to _filter_ro_mount and updating
associated .out files to unify the output from both old and new
util-linux versions.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/036: filter busy mount message
Eryu Guan [Tue, 14 Nov 2017 08:56:00 +0000 (16:56 +0800)]
overlay/036: filter busy mount message

util-linux v2.30 changed error message of a busy mount and caused
overlay/036 to fail. e.g.

 - mount: <device> is already mounted or <mountpoint> busy
 + mount: <mountpoint>: <device> already mounted or mount point busy.

Filter the mount output by a newly introduced _filter_busy_mount
into a unified format.

   mount: device already mounted or mount point busy

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: filter mount error message for EUCLEAN and ESTALE
Eryu Guan [Tue, 14 Nov 2017 07:49:36 +0000 (15:49 +0800)]
fstests: filter mount error message for EUCLEAN and ESTALE

util-linux commit ea848180dd34 ("libmount: add
mnt_context_get_excode()") since v2.30 changed the error message on
EUCLEAN and ESTALE again (and maybe other errno too):

 - mount: <device> on <mountpoint> failed: Structure needs cleaning
 + mount: <mountpoint>: mount(2) system call failed: Structure needs cleaning.

and it causes xfs/005, overlay/037 to fail (and probably xfs/333 too,
but it's always _notrun for now).

And what's more, the mentioned tests would also fail when testing
with util-linux prior to v2.21, no one complained just because the
tests are usually _notrun on such old distributions that ship
util-linux < v2.21.

So let's filter out the changing parts and keep the error message
simple.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/456: document the fix commit
Amir Goldstein [Thu, 23 Nov 2017 06:43:43 +0000 (08:43 +0200)]
generic/456: document the fix commit

Add a link to Ted's post with more details about the bug
and the fix.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/458: document the fix commit
Amir Goldstein [Thu, 23 Nov 2017 06:43:42 +0000 (08:43 +0200)]
generic/458: document the fix commit

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: test consistent values of st_ino/d_ino for subdirs
Chandan Rajendra [Mon, 20 Nov 2017 14:34:10 +0000 (20:04 +0530)]
overlay/038: test consistent values of st_ino/d_ino for subdirs

This commit implements similar changes made to overlay/038 test i.e. in
addition to checking consistent values of st_ino/d_ino for "."  and ".."
entries, check also the values for subdir inside each tested directory
setup.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: code cleanup
Chandan Rajendra [Mon, 20 Nov 2017 14:34:09 +0000 (20:04 +0530)]
overlay/038: code cleanup

This commit implements similar changes made to overlay/041 test i.e.
- Remove duplicate merged dir tests
- Remove duplicate pure upper dir inside merged dir tests
- Sort out comments and error messages

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/459: add check for dm-snapshot target
Xiao Yang [Tue, 21 Nov 2017 06:27:20 +0000 (14:27 +0800)]
generic/459: add check for dm-snapshot target

generic/459 should be skipped when dm-snapshot is not supported.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoperf: a random write buffered fio perf test
Josef Bacik [Thu, 16 Nov 2017 18:29:59 +0000 (13:29 -0500)]
perf: a random write buffered fio perf test

This uses the new fio results perf helpers to run a rand write
buffered workload on the scratch device.

[eguan: add Makefile]

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: add fio perf results support
Josef Bacik [Tue, 7 Nov 2017 21:53:32 +0000 (16:53 -0500)]
fstests: add fio perf results support

This patch does the nuts and bolts of grabbing fio results and
storing them in a database in order to check against for future
runs.  This works by storing the results in resuts/fio-results.db as
a sqlite database.  The src/perf directory has all the supporting
python code for parsing the fio json results, storing it in the
database, and loading previous results from the database to compare
with the current results.

This also adds a PERF_CONFIGNAME option that must be set for this to
work.  Since we all have various ways we run fstests it doesn't make
sense to compare different configurations with each other (unless
specifically desired).  The PERF_CONFIGNAME will allow us to
separate out results for different test run configurations to make
sure we're comparing results correctly.

Currently we only check against the last perf result.  In the future
I will flesh this out to compare against the average of N number of
runs to be a little more complete, and hopefully that will allow us
to also watch latencies as well.

[eguan: add required Makefile updates]

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/041: use user defined overlay mount option
Amir Goldstein [Sun, 19 Nov 2017 11:56:29 +0000 (13:56 +0200)]
overlay/041: use user defined overlay mount option

Mount non-samefs dirs with OVERLAY_MOUNT_OPTIONS, so user can opt-in
for constant inode numbers on non-samefs setup (i.e. -o xino) when
it is implemented.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/041: test consistent values of st_ino/d_ino for subdirs
Amir Goldstein [Sun, 19 Nov 2017 11:56:28 +0000 (13:56 +0200)]
overlay/041: test consistent values of st_ino/d_ino for subdirs

In addition to checking consistent values of st_ino/d_ino for "."
and ".." entries, check also the values for subdir inside each
tested directory setup.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/041: code cleanup
Amir Goldstein [Sun, 19 Nov 2017 11:56:27 +0000 (13:56 +0200)]
overlay/041: code cleanup

- Remove duplicate merged dir tests
- Remove duplicate pure upper dir inside merged dir tests
- Sort out comments and error messages

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: Test hardlink breakage on non-samefs setup
Chandan Rajendra [Sat, 18 Nov 2017 05:58:04 +0000 (11:28 +0530)]
overlay: Test hardlink breakage on non-samefs setup

This commit adds a test to check hardlink breakage when the
overlayfs instance is composed of two different underlying
filesystem instances.

For example,
$ mount -t xfs /dev/loop0 /mnt/test
$ mount -t xfs /dev/loop1 /mnt/scratch
$ mkdir /mnt/scratch/upper
$ mkdir /mnt/scratch/work
$ mount -t overlay overlay -o lowerdir=/mnt/test \
        -o upperdir=/mnt/scratch/upper \
        -o workdir=/mnt/scratch/work /mnt/merge

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: Test consistent st_ino numbers for non-samefs scenario
Chandan Rajendra [Sat, 18 Nov 2017 05:57:00 +0000 (11:27 +0530)]
overlay: Test consistent st_ino numbers for non-samefs scenario

This commit adds a test to verify consistent st_ino feature when
the overlayfs instance is composed of two different underlying
filesystem instances.

For example,
$ mount -t xfs /dev/loop0 /mnt/test
$ mount -t xfs /dev/loop1 /mnt/scratch
$ mkdir /mnt/scratch/upper
$ mkdir /mnt/scratch/work
$ mount -t overlay overlay -o lowerdir=/mnt/test \
        -o upperdir=/mnt/scratch/upper \
        -o workdir=/mnt/scratch/work /mnt/merge

The goal of this test is to verify that overlayfs returns consistent
st_ino for the following scenarios,
- Copy-up of lowerdir files
- Rename files and drop dentry/inode cache
- Remount the overlayfs instance

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/018: Add constant d_ino test
Chandan Rajendra [Sat, 18 Nov 2017 05:58:03 +0000 (11:28 +0530)]
overlay/018: Add constant d_ino test

Constant d_ino for hardlinks is possible only when "index" config
feature/mount option is enabled.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/017: Remove constant st_ino/d_ino test for hardlinks
Chandan Rajendra [Sat, 18 Nov 2017 05:58:02 +0000 (11:28 +0530)]
overlay/017: Remove constant st_ino/d_ino test for hardlinks

Constant st_ino/d_ino for hardlinks requires "index" config
feature/mount option to be enabled. overlay/018 already tests
constant st_ino feature for hardlinks. A future commit will add
constant d_ino test to overlay/018 test.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: test zero page cache beyond new EOF on truncate down
Eryu Guan [Thu, 9 Nov 2017 08:32:42 +0000 (16:32 +0800)]
generic: test zero page cache beyond new EOF on truncate down

From mmap(2) manpage, "a file is mapped in multiples of the page
size. For a file that is not a multiple of the page size, the
remaining memory is zeroed when mapped", this test is to test this
behavior on truncate down.

This is inspired by an XFS bug that truncate down fails to zero page
cache beyond new EOF and causes stale data written to disk
unexpectedly and a subsequent mmap sees non-zeros post EOF.

Patch "xfs: truncate pagecache before writeback in
xfs_setattr_size()" fixed the bug on XFS.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs/143: make test case more reliable
Liu Bo [Wed, 15 Nov 2017 23:47:59 +0000 (16:47 -0700)]
btrfs/143: make test case more reliable

This changes to use '_scratch_cycle_mount' to drop all caches btrfs
could have in order to avoid an issue that drop_caches somehow
doesn't work on Nikolay's box.

Also use bash -c to run 'read' only when %pid is odd so that we can
read the faulty disk.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Tested-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/122: don't check xfs_iext_cursor
Darrick J. Wong [Thu, 16 Nov 2017 01:22:50 +0000 (17:22 -0800)]
xfs/122: don't check xfs_iext_cursor

Don't size-check the incore extent map cursor; it's not a disk
structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/rc: check dmesg for UBSAN errors
Darrick J. Wong [Thu, 16 Nov 2017 01:22:44 +0000 (17:22 -0800)]
common/rc: check dmesg for UBSAN errors

If the UBSAN complains about bad behavior, we should capture the
dmesg so that developers can inspect it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoaio-dio-append-write-read-race: abort if we encounter syscall errors
Darrick J. Wong [Thu, 16 Nov 2017 01:22:37 +0000 (17:22 -0800)]
aio-dio-append-write-read-race: abort if we encounter syscall errors

If any of the library calls return error codes, just print out a message
and abort the test.  Whoever wrote the write test did not check for
write failures, which means that if we ENOSPC without writing anything
then the reader thread will loop forever trying to read.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/45[34]: add emoji to the unusual fs naming test
Darrick J. Wong [Thu, 16 Nov 2017 01:22:31 +0000 (17:22 -0800)]
generic/45[34]: add emoji to the unusual fs naming test

Since we have a test to make sure that we can use Unicode points in
filesystem names, enhance it to check emoji names too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value
Darrick J. Wong [Thu, 16 Nov 2017 01:22:25 +0000 (17:22 -0800)]
common/fuzzy: if the fuzz verb is random, keep fuzzing until we get a new value

If the fuzz verb is 'random', keep generating new random values
until we get one that is distinct from the previous value.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: add testcase to test fallocate & f{data,}sync
Chao Yu [Wed, 15 Nov 2017 08:58:33 +0000 (16:58 +0800)]
generic: add testcase to test fallocate & f{data,}sync

f2fs can skip isize updating in fsync(), since during mount, f2fs
tries to recovery isize according to valid block address or
preallocated flag in last fsynced dnode block.

However, fallocate() breaks our rule with setting
FALLOC_FL_KEEP_SIZE flag, since it can preallocated block cross EOF,
once the file is fsynced, in POR, we will recover isize incorrectly
based on these fallocated blocks.

This patch adds a new testcase to test fallocate, in order to verify
whether filesystem will do correct recovery on isize.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: test for device dynamic rescan
Anand Jain [Wed, 15 Nov 2017 03:05:15 +0000 (11:05 +0800)]
btrfs: test for device dynamic rescan

Make sure missing device is included in the alloc list when it is
scanned on a mounted FS.

This test case needs btrfs kernel patch which is in the ML
  [PATCH] btrfs: handle dynamically reappearing missing device

Without the kernel patch, the test will run, but reports as
failed, as the device scanned won't appear in the alloc_list.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agosrc/t_dir_type.c: Use strtoul() instead of atoll()
Chandan Rajendra [Mon, 13 Nov 2017 14:45:26 +0000 (20:15 +0530)]
src/t_dir_type.c: Use strtoul() instead of atoll()

An overlayfs filesystem instance with one lowerdir filesystem and
with "xino" mount option enabled can have the layer index encoded in
the 63rd bit of the inode number. A signed 64 bit integer won't
suffice to store this inode number. Hence this commit uses strtoul()
to convert the inode number in string form to unsigned integer form.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/204: use available blocks to determine the number of files to create
Darrick J. Wong [Tue, 7 Nov 2017 01:54:11 +0000 (17:54 -0800)]
generic/204: use available blocks to determine the number of files to create

Use the available block count to compute the number of files we think
we can create, rather than hardcoding a particular size.  This fixes
the ENOSPC failures for xfs filesystems with rmap/reflink support.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: test that we don't leak inodes and dquots during failed cow recovery
Darrick J. Wong [Fri, 10 Nov 2017 00:44:40 +0000 (16:44 -0800)]
xfs: test that we don't leak inodes and dquots during failed cow recovery

Add a couple of tests to check that we don't leak inodes or dquots
if CoW recovery fails and therefore the mount fails.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/fuzzy: ignore padding fields on xfs
Darrick J. Wong [Fri, 10 Nov 2017 00:44:34 +0000 (16:44 -0800)]
common/fuzzy: ignore padding fields on xfs

Padding fields are never checked and can have arbitrary values (if we
ever put them to use there'll be a feature flag) so there's no point
in fuzz-testing them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/31[2-7]: hide pwrite fsync errors that are supposed to fail
Darrick J. Wong [Fri, 10 Nov 2017 00:44:28 +0000 (16:44 -0800)]
xfs/31[2-7]: hide pwrite fsync errors that are supposed to fail

xfs_io 4.14 will gain the ability to print error messages when
pwrite+fsync fail.  Certain tests use the error injector to cause
failures, so the errors are expected.  Since we test for a shut down
filesystem after the error injection, we can push the error messages to
the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: do not call _scratch_mkfs_sized in a pipe
Eryu Guan [Sun, 5 Nov 2017 06:14:11 +0000 (14:14 +0800)]
fstests: do not call _scratch_mkfs_sized in a pipe

_scratch_mkfs_sized will create a filesystem of the given size, and
call _notrun and exit if current $FSTYP doesn't support sized mkfs.
But when it's called in a pipe, the exit in _notrun only exits from
the subshell created by the pipe not the test itself, and test
continues to run unnecessarily, though the test is still reported as
[notrun] due to existence of $seqres.notrun file.

Fix it by not calling _scratch_mkfs_sized in a pipe, but dumping the
output to a tmp file, which will be fed to _filter_mkfs later.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoltp/fsx: allow comments when reading operations from logs
Eryu Guan [Wed, 25 Oct 2017 04:06:06 +0000 (12:06 +0800)]
ltp/fsx: allow comments when reading operations from logs

We use '--replay-ops' option to replay operations in the specified
operation log file, but we're not allowed to add comments for the
operations in the log, which might be useful when writing regression
tests that replay a given sequence of operations.

Now treat lines starting with '#' as comments and skip them when
reading operations.

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/filter.btrfs: add 'zstd' to compress property filter
Misono, Tomohiro [Wed, 8 Nov 2017 04:27:00 +0000 (13:27 +0900)]
common/filter.btrfs: add 'zstd' to compress property filter

This fixes the false failure of btrfs/059 when running with the
mount option '-o compress=zstd'.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: add test with more open by file handle use cases
Amir Goldstein [Thu, 2 Nov 2017 10:15:39 +0000 (12:15 +0200)]
generic: add test with more open by file handle use cases

This test is a variant of test generic/426 that tests with less
files and more use cases:
- Create test dir with non empty files with known content and verify
  their content after opening file by handle.
- Check open by handle of directory.
- Check open by handle of files that have been unlinked, but still open.
- Check open by handle of files that have been renamed in same dir,
  moved to new dir and whose parent dir has been renamed.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/426: factor out helper functions
Amir Goldstein [Thu, 2 Nov 2017 10:15:38 +0000 (12:15 +0200)]
generic/426: factor out helper functions

Helper test_file_handles() outputs the sub-test command to output,
so if errors are detected in one of the sub-tests, it is easier
to know which sub-tests have failed.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoopen_by_handle: test file handles of open files
Amir Goldstein [Thu, 2 Nov 2017 10:15:37 +0000 (12:15 +0200)]
open_by_handle: test file handles of open files

usage: open_by_handle -dk <test_dir> [N]

Get file handles for existing test set, keep open file handles for all
test files, unlink all test files, drop caches and try to open all files
by handle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoopen_by_handle: test directory file handle
Amir Goldstein [Thu, 2 Nov 2017 10:15:36 +0000 (12:15 +0200)]
open_by_handle: test directory file handle

usage: open_by_handle -cp <test_dir> [N]
usage: open_by_handle  -p <test_dir> [N]
usage: open_by_handle -dp <test_dir> [N]

With -p flag, create/delete also the test_dir itself and try to open by
handle also test_dir itself after droping caches and use dir fd to test
faccessat() of a file inside dir.
mount_fd argument to open_by_handle_at() is open fd of test_dir's parent.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoopen_by_handle: test content of open file handle
Amir Goldstein [Thu, 2 Nov 2017 10:15:35 +0000 (12:15 +0200)]
open_by_handle: test content of open file handle

usage: open_by_handle -rwa <test_dir> [N]

Get file handles for existing test set, write data to files,
drop caches, open all files by handle, read data and verify old data,
write new data to files.

This is needed for testing that overlay decoded file handles are not
pointing the lower inodes after new data is already written to upper
inodes after copy up.

open_by_handle -a is needed for testing copy up of disconnected overlay
decoded file handles (to index dir).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoopen_by_handle: test file handles of renamed files
Amir Goldstein [Thu, 2 Nov 2017 10:15:34 +0000 (12:15 +0200)]
open_by_handle: test file handles of renamed files

usage: open_by_handle -m <test_dir> [N]

Get file handles for existing test set, rename all test files,
drop cache and try to open all files by handle.

This is needed for testing that overlayfs can find the upper
inode from lower file handle even when upper is not in the same
path as lower.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoopen_by_handle: add filename to error reports
Amir Goldstein [Thu, 2 Nov 2017 10:15:33 +0000 (12:15 +0200)]
open_by_handle: add filename to error reports

This makes it easier to understand which of the tests
failed when testing on overlay lower and upper files.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/020: check that we have enough space to write out a huge fs
Darrick J. Wong [Fri, 3 Nov 2017 04:28:02 +0000 (21:28 -0700)]
xfs/020: check that we have enough space to write out a huge fs

Make sure that we have enough free space on the test fs to create a
60t sparse filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: test IO at maximum file offset
Darrick J. Wong [Fri, 3 Nov 2017 04:27:17 +0000 (21:27 -0700)]
generic: test IO at maximum file offset

Make sure we can write to and read from the highest possible offset
that Linux will allow.  Format the filesystem with a variety of
possible blocksizes to stress the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/013: don't fail because cp ran out of space
Darrick J. Wong [Wed, 1 Nov 2017 21:47:48 +0000 (14:47 -0700)]
xfs/013: don't fail because cp ran out of space

Don't fail xfs/013 just because cp -Rl runs out of space to allocate
inodes and sprays the ENOSPC messages into the golden output.  We
want to stress the finobt by using cp to push us near ENOSPC
conditions, so it's fine to let cp run out of space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: filter and record the unknown block state messages
Darrick J. Wong [Wed, 1 Nov 2017 21:47:36 +0000 (14:47 -0700)]
xfs: filter and record the unknown block state messages

Record the unknown block state messages that xfs_repair produces
when we nuke the finobt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/122: add inode log formats
Darrick J. Wong [Wed, 1 Nov 2017 21:47:30 +0000 (14:47 -0700)]
xfs/122: add inode log formats

The inode log record formats have been standardized, so check them here.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/459: explicitly require thin_check
Darrick J. Wong [Wed, 1 Nov 2017 21:47:11 +0000 (14:47 -0700)]
generic/459: explicitly require thin_check

The lvm command can invoke the thin pool utilities as part of
managing a thin volume. It'll fail if the thin provisioning
utilities are not installed, so we need to check for its presence
before running a test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: test for qgroup reservation leaks with prealloc
Justin Maggard [Mon, 30 Oct 2017 22:33:48 +0000 (15:33 -0700)]
btrfs: test for qgroup reservation leaks with prealloc

This test case writes into pre-allocated space, then tries to
fallocate some more within the defined quota limit. Currently
(4.14-rc7) this fails with EDQUOT due to quota reservation leakage
when writing into pre- allocated space.

A possible fix has been sent to the ML as "btrfs: Fix quota
reservation leak on preallocated files"

Signed-off-by: Justin Maggard <jmaggard@netgear.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: test if receive with qgroups corrupts metadata
Justin Maggard [Mon, 30 Oct 2017 22:32:45 +0000 (15:32 -0700)]
btrfs: test if receive with qgroups corrupts metadata

This test case does some concurrent send/receives with qgroups
enabled.  Currently (4.14-rc7) this usually results in btrfs check
errors, and often also results in a WARN_ON in
record_root_in_trans().

Bisecting points to 6426c7ad697d (btrfs: qgroup: Fix qgroup
accounting when creating snapshot) as the culprit.

Signed-off-by: Justin Maggard <jmaggard@netgear.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: test creating lower hardlinks for copied up files
Amir Goldstein [Mon, 30 Oct 2017 12:06:56 +0000 (14:06 +0200)]
overlay: test creating lower hardlinks for copied up files

kernel v4.13 introduced the index=on feature for not breaking
hardlinks on copy-up.  With the index feature enabled a regression
was introduced - lower files that are hardlined while overlay is
offline can result in lookup error after overlay in mounted.

The regression was fixed by upstream commit
  6eaf011144af ovl: fix EIO from lookup of non-indexed upper
that was merged to v4.14-rc7.

This test verifies that behavior is sane after creating lower
hardlinks for copied up files while overlayfs is offline.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/rc: force mkfs for xfs in _mkfs_dev
Darrick J. Wong [Sat, 28 Oct 2017 17:08:56 +0000 (10:08 -0700)]
common/rc: force mkfs for xfs in _mkfs_dev

In generic/459, if the DISCARD of the thin device somehow fails with
this message:

device-mapper: thin: Data device (dm-1) discard unsupported: Disabling discard passdown.

Then we can end up with arbitrary gunk in the thin device.  This
causes mkfs to fail because it's afraid to format the device.  Don't
be afraid, just zap it.  FWIW mkfs.xfs thinks that the thinp device
has an xfs external log because sometimes the thinp device just
happen to be backed by the log of the previous test's scratch fs.

Fix this by making the _mkfs_dev helper always format the device,
per Eryu Guan's suggestion.

[eguan: fix subject to reflect the fix is in common/rc]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/333: fix errors with new inode pointer verifiers
Darrick J. Wong [Fri, 27 Oct 2017 20:24:07 +0000 (13:24 -0700)]
xfs/333: fix errors with new inode pointer verifiers

Fix test failures with new inode pointer verifiers... and also make
sure that the running xfs actually supports realtime rmap. (This
should stop the current crop of weird test failures since nobody has
rtrmap yet anyway...)

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/xfs: remove inode-paths cruft
Darrick J. Wong [Fri, 27 Oct 2017 20:25:50 +0000 (13:25 -0700)]
common/xfs: remove inode-paths cruft

Remove the inode-paths check from _check_xfs_test_fs because we don't
support inode paths, xfsprogs doesn't have a xfs_{check,repair}_ipaths
tool, and it's broken anyway because we ignore _check_xfs_filesystem
(which tells whether or not the filesystem is even still mounted).

[eguan: also fix the return value of _check_xfs_test_fs]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: add module reloading helpers
Darrick J. Wong [Fri, 27 Oct 2017 20:23:08 +0000 (13:23 -0700)]
fstests: add module reloading helpers

Add some helper functions to require that we can reload a given
module, and add a helper to actually do that.  Refactor the existing
users to use the generics.

We need to hoist completely the behaviors of the old btrfs module
helper because we need to confirm before starting the test that we
actually can remove the module.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/xfs: standardize the xfs_scrub output that gets recorded to $seqres.full
Darrick J. Wong [Thu, 26 Oct 2017 05:51:51 +0000 (22:51 -0700)]
common/xfs: standardize the xfs_scrub output that gets recorded to $seqres.full

Make the xfs_scrub output that gets recorded to $seqres.full follow
the format of xfs_repair checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/xfs: refactor xfs_scrub presence testing
Darrick J. Wong [Fri, 27 Oct 2017 20:21:46 +0000 (13:21 -0700)]
common/xfs: refactor xfs_scrub presence testing

Move all the requirements checking for xfs_scrub into a helper function.
Make sure the helper properly detects the presence of the scrub ioctl
and situations where we can't run scrub (e.g. norecovery).

Refactor the existing three xfs_scrub call sites to use the helper to
check if it's appropriate to run scrub.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/fuzzy: online re-scrub should not preen
Darrick J. Wong [Fri, 27 Oct 2017 00:43:12 +0000 (17:43 -0700)]
common/fuzzy: online re-scrub should not preen

When we're doing the second online scrub (to figure out if the
repair did any good) we shouldn't let that second scrub preen the
filesystem in any way. If scrub finds things it can't/won't preen
that turns into a nonzero return code which gets reported
(incorrectly) as a failure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/45[34]: force UTF-8 codeset to enable utf-8 namer checks in xfs_scrub
Darrick J. Wong [Thu, 26 Oct 2017 05:51:58 +0000 (22:51 -0700)]
generic/45[34]: force UTF-8 codeset to enable utf-8 namer checks in xfs_scrub

The upcoming xfs_scrub tool will have the ability to warn about
suspicious UTF-8 normalization collisions.  We want generic/45[34]
to be able to test this functionality, but to do that we have to
forcibly set the codeset to UTF-8 via LC_ALL since the rest of
xfstests only uses LC_ALL=C.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoquota: clear speculative delalloc when checking quota usage
Darrick J. Wong [Thu, 26 Oct 2017 05:51:39 +0000 (22:51 -0700)]
quota: clear speculative delalloc when checking quota usage

Occasionally speculative preallocation kicks in when writing files
to a filesystem under test.  These preallocations consume quota and
/usually/ aren't around after we drop_caches, but there's nothing to
guarantee that they actually have, so the quota reports will be
different before and after the fs remount, causing sporadic test
failures in generic/{23[123],270}.

We now have xfs_spaceman which can instruct XFS to forcibly remove
the speculative preallocations.  This fixes the sporadic failures,
at least for XFS.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs/010: fix offset in test Btrfs delalloc accounting overflow
Robbie Ko [Thu, 26 Oct 2017 06:02:15 +0000 (14:02 +0800)]
btrfs/010: fix offset in test Btrfs delalloc accounting overflow

Found it when test btrfs delalloc accounting overflow, Fix offset
error.  We will fill in the gaps between the created extents, then
outstanding extents will all be merged into 1.

Signed-off-by: Robbie Ko <robbieko@synology.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs/130: Remove from auto group
Qu Wenruo [Mon, 23 Oct 2017 01:48:54 +0000 (09:48 +0800)]
btrfs/130: Remove from auto group

No agreement on how to fix it in the foreseeable future. So remove
it from auto group to prevent newbie tester from spending days
waiting it to finish.

Reported-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: Remove usage of _overlay_scratch_unmount
Chandan Rajendra [Thu, 19 Oct 2017 13:49:07 +0000 (19:19 +0530)]
overlay/038: Remove usage of _overlay_scratch_unmount

_overlay_scratch_unmount is not supposed to be invoked directly by
tests. Also, since unmounting scratch fs is optional, this commit
removes invocation of _overlay_scratch_unmount.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agolog-writes: fix possible infinite loop in zero_range()
Hou Tao [Tue, 17 Oct 2017 03:20:45 +0000 (11:20 +0800)]
log-writes: fix possible infinite loop in zero_range()

Found it when trying to remove the limitation of log->max_zero_size.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: test if device delete ends up with losing raid profile
Liu Bo [Mon, 16 Oct 2017 16:51:20 +0000 (10:51 -0600)]
btrfs: test if device delete ends up with losing raid profile

Currently running 'btrfs device delete' can end up with losing data
raid profile (if any), this test is to reproduce the problem.

The fix is
     "Btrfs: avoid losing data raid profile when deleting a device"

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: test for NULL xattr buffer problem during unlink
Brian Foster [Thu, 12 Oct 2017 11:36:27 +0000 (07:36 -0400)]
xfs: test for NULL xattr buffer problem during unlink

XFS had a bug that resulted in an unexpected NULL buffer during
unlink of an inode with a multi-level attr fork tree. This occurred
due to a stale reference to content in a released/reclaimed buffer.

Use the XFS buffer LRU reference count error injection tag to
recreate the conditions for the bug. Create a file with a
multi-level attr fork tree and then unlink it with buffer caching
disabled.

Commit f35c5e10c6ed ("xfs: reinit btree pointer on attr tree
inactivation walk") fixed the bug.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: Test consistent d_ino feature for non-samefs setup
Chandan Rajendra [Thu, 12 Oct 2017 13:34:32 +0000 (19:04 +0530)]
overlay: Test consistent d_ino feature for non-samefs setup

This commit adds a test to verify consistent d_ino feature when
the overlayfs instance is composed of two different underlying
filesystem instances.

For example,
$ mount -t xfs /dev/loop0 /mnt/test
$ mount -t xfs /dev/loop1 /mnt/scratch
$ mkdir /mnt/scratch/upper
$ mkdir /mnt/scratch/work
$ mount -t overlay overlay -o lowerdir=/mnt/test \
        -o upperdir=/mnt/scratch/upper \
-o workdir=/mnt/scratch/work /mnt/merge

The goal of this test is to verify that the inode numbers returned by
readdir(3) (i.e. dirent->d_ino) are consistent with inode numbers
returned by stat(2) (i.e. stat->st_ino) in all the below listed cases,
- Parent's (i.e. "..") d_ino must always be calculated because a
  pure dir can be residing inside a merged dir.
- d_ino for "." must always be calculated because the present
  directory can have a copy-up origin.
- Verify d_ino of '.' and '..' before and after dir becomes impure.
  While at it also verify if trusted.overlay.impure xattr is
  set/reset appropriately and invalidation of readdir cache.
- Verify copied up file's (inside a impure dir) d_ino.
- Verify invalidation of readdir cache.
- Verify d_ino values corresponding to "." and ".." entries of a
  pure lower dir.
- Verify d_ino of ".." entry of a merged dir.
- Verify pure lower residing in dir which has another lower layer

Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/036,208: whitelist [iomap_]dio_complete() WARNs
Ilya Dryomov [Thu, 12 Oct 2017 14:54:04 +0000 (16:54 +0200)]
generic/036,208: whitelist [iomap_]dio_complete() WARNs

These tests appear to mix buffered and O_DIRECT I/O; easily triggered
on both xfs and ext4.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon: turn _filter_xfs_dmesg() into _filter_aiodio_dmesg()
Ilya Dryomov [Thu, 12 Oct 2017 14:54:03 +0000 (16:54 +0200)]
common: turn _filter_xfs_dmesg() into _filter_aiodio_dmesg()

With upstream commit 332391a9935d ("fs: Fix page cache inconsistency
when mixing buffered and AIO DIO"), ext4 (and probably other
non-iomap based filesystems) need a _check_dmesg() whitelist entry
for a new WARN in dio_complete() -- generic/095 and 247 trigger a
dio_complete() splat pretty reliably for me.

Add dio_complete() entry to _filter_xfs_dmesg(), rename it and use
it unconditionally in generic/095, 224, 247 and 446.

[eguan: source common/filter too in generic/446]

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon: move _filter_xfs_dmesg() to common/filter
Ilya Dryomov [Thu, 12 Oct 2017 14:54:02 +0000 (16:54 +0200)]
common: move _filter_xfs_dmesg() to common/filter

Move this XFS-specific _filter_xfs_dmesg() to common/filter so all
tests could use it. It will be renamed & made more generic and used
by more tests in later patches.

[eguan: add commit log]

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/036: expect EBUSY for dir inuse only when mounting with index=on
Amir Goldstein [Thu, 12 Oct 2017 06:33:29 +0000 (09:33 +0300)]
overlay/036: expect EBUSY for dir inuse only when mounting with index=on

This fixes test failure with kernel v4.14-rc4 and default index=off
configuration.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/166: speed up on slow disks
Dave Chinner [Wed, 11 Oct 2017 23:15:44 +0000 (10:15 +1100)]
generic/166: speed up on slow disks

generic/166 is takes way too long to run on iscsi disks - over an
*hour* on flash based iscsi targets. In comparison, it takes 18s to
run on a pmem device.

The issue is that it takes 3-4s per file write cycle on slow disks,
and it does a thousand write cycles. The problem is taht reflink is
so much faster than the write cycle that it's doing many more
snapshots on slow disks than fast disks, and this slows it down even
more.

e.g. the pmem system that takes 18s to run does just under 1000
snapshots - roughly one per file write. 20 minutes into the iscsi
based test, it's only done ~300 write cycles but there are almost
10,000 snapshots been taken. IOWs, we're doing 30 snapshots a file
write, not ~1.

Fix this by rate limiting snapshots to at most 1 per whole file
write. This reduces the number of snapshots taken on fast devices by
~50% (runtime on pmem device went from 18s -> 8s) but reduced it to
1000 on slow devices and reduced runtime from 3671s to just 311s.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/422: Do not hardcode space used by files
Andreas Gruenbacher [Tue, 10 Oct 2017 10:21:14 +0000 (12:21 +0200)]
generic/422: Do not hardcode space used by files

Test generic/422 hardcodes in the output file how much space files it
creates are supposed to take up on disk.  This doesn't work when
additional space is allocated for extended attributes for ACLs or
SELinux labels.

Instead, record the actual space used in generic/422.full, and only
check if the writeback changes the space used.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: test race when checking i_size on direct i/o read
Zheng Liu [Fri, 18 Aug 2017 20:35:02 +0000 (15:35 -0500)]
generic: test race when checking i_size on direct i/o read

In this commit a new test case is added to test that i_size races
don't occur under dio reads/writes.  We add a program in /src dir,
which has a writer to issue some append dio writes.  Meanwhile it
has a reader in this test to do some dio reads.  As we expect,
reader should read nothing or data with 'a'. But it might read some
data with '0'.

The bug can be reproduced by this test case [1].

1.  http://patchwork.ozlabs.org/patch/311761/

This ostensibly tests commit:
9fe55eea7 Fix race when checking i_size on direct i/o read

Update by Eric Sandeen:
- update to recent xfstests
- update commit log

Update by Eryu Guan:
- add aio-dio support to the test and add 'aio' group
- add ability to test different alignments
- move test from src/ to src/aio-dio-regress/
- add .gitignore entry
- rebase against latest xfstests with various minor fixes & cleanups
- update commit log

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: test race between block map change and writeback
Eryu Guan [Tue, 10 Oct 2017 07:42:07 +0000 (15:42 +0800)]
generic: test race between block map change and writeback

Run delalloc writes & append writes & non-data-integrity syncs
concurrently to test the race between block map change vs writeback.

This is to cover an XFS bug that data could be written to wrong
block and delay allocated blocks are leaked because the block map
was changed due to the removal of speculative allocated eofblocks
when writeback is in progress.

And this test partially mimics what lustre-racer[1] test does, using
which this bug was first found.

[1] https://git.hpdd.intel.com/?p=fs/lustre-release.git;a=tree;f=lustre/tests/racer;hb=HEAD

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs/246: add _require_scratch
Hans Holmberg [Tue, 10 Oct 2017 13:31:16 +0000 (15:31 +0200)]
xfs/246: add _require_scratch

The test uses a scratch device, so add _require_scratch so
the test will be skipped instead of failing when $SCRATCH_DEV
has not been specified.

Signed-off-by: Hans Holmberg <hans.holmberg@cnexlabs.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: deduplicate code in overlay mount helpers
Amir Goldstein [Thu, 28 Sep 2017 11:55:10 +0000 (14:55 +0300)]
overlay: deduplicate code in overlay mount helpers

factor out helpers _overlay_base_mount() and _overlay_base_umount()
to reduce code duplication.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: move _overlay helpers to common/overlay
Amir Goldstein [Wed, 27 Sep 2017 10:47:32 +0000 (13:47 +0300)]
overlay: move _overlay helpers to common/overlay

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