xfstests-dev.git
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>
6 years agooverlay: fix _overlay_config_override of MOUNT_OPTIONS
Amir Goldstein [Wed, 27 Sep 2017 07:04:12 +0000 (10:04 +0300)]
overlay: fix _overlay_config_override of MOUNT_OPTIONS

The config variable OVERLAY_MOUNT_OPTIONS is used to configure
the overlay mount options when running ./check -overlay.
The config variable MOUNT_OPTIONS is used to configure the
mount options for base fs.

If config sets value of OVERLAY_MOUNT_OPTIONS and
does not set MOUNT_OPTIONS, the value of MOUNT_OPTIONS
may be leftover from previous _overlay_config_override, so
don't use that value for base fs 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: create helper _overlay_scratch_mount_dirs()
Amir Goldstein [Wed, 27 Sep 2017 07:04:11 +0000 (10:04 +0300)]
overlay: create helper _overlay_scratch_mount_dirs()

A helper to mount with same options/mnt/dev of scratch mount, but
optionally with different lower/upper/work dirs.
use instead of _overlay_mount_dirs() in all tests where applicable.

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: use default overlay mount options _overlay_mount_dirs()
Amir Goldstein [Wed, 27 Sep 2017 07:04:10 +0000 (10:04 +0300)]
overlay: use default overlay mount options _overlay_mount_dirs()

Tests that use _overlay_mount_dirs() should also use the
default overlay mount options.
Move mount options from overlay_mount() into _overlay_mount_dirs()
and use helper common_dev_mount_opts() to get options.

OVERLAY_MOUNT_OPTIONS is assigned to MOUNT_OPTIONS, so
there is no need to use OVERLAY_MOUNT_OPTIONS directly.

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: remove stale implementation of _scratch_mount_options
Amir Goldstein [Wed, 27 Sep 2017 07:04:09 +0000 (10:04 +0300)]
overlay: remove stale implementation of _scratch_mount_options

_scratch_mount_options() was not implemented correctly for
overlayfs and wasn't used by any overlay tests.

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 agoext4: skip project quota tests if the kernel does not support them
Theodore Ts'o [Sun, 8 Oct 2017 19:27:46 +0000 (15:27 -0400)]
ext4: skip project quota tests if the kernel does not support them

In _scratch_enable_pquota, use _notrun if the file system with project
quotas enable can't be mounted, since that indicates the kernel
doesn't support that feature.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: Miscellaneous fixes
Chandan Rajendra [Sun, 8 Oct 2017 11:25:35 +0000 (16:55 +0530)]
overlay/038: Miscellaneous fixes

This commit removes the redundant chown operation which was supposed to
cause the test file to be copied up. Also, _overlay_scratch_unmount() is
used to unmount the overlay filesystem rather than invoking $UMOUNT_PROG.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/rc: Further improve gfs2 support
Andreas Gruenbacher [Wed, 4 Oct 2017 18:20:09 +0000 (20:20 +0200)]
common/rc: Further improve gfs2 support

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: add a new test for racing AIO COW writes
Christoph Hellwig [Wed, 4 Oct 2017 06:16:16 +0000 (08:16 +0200)]
generic: add a new test for racing AIO COW writes

This can be used to trigger an assert in the current XFS code
because it can't handle the case where there are COW extents on a
file, but none at or below the range converted by the AIO completion
handler.

Note that it doesn't trigger the assert 100% but fairly reliably.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobulkstat_unlink_test_modified: Remove extraneous if statement
Rostislav Skudnov [Fri, 6 Oct 2017 08:25:19 +0000 (08:25 +0000)]
bulkstat_unlink_test_modified: Remove extraneous if statement

Fixes the following compiler warning:

bulkstat_unlink_test_modified.c:171:26: warning: equality comparison
with extraneous parentheses [-Wparentheses-equality]
                    if ((ret[i].bs_ino == inodelist[j])) {
                         ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoholetest: Use pid_t type for fork(2) return value
Rostislav Skudnov [Fri, 6 Oct 2017 08:19:46 +0000 (08:19 +0000)]
holetest: Use pid_t type for fork(2) return value

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agowritev_on_pagefault: Use ssize_t type for write(2) return value
Rostislav Skudnov [Thu, 5 Oct 2017 12:49:58 +0000 (12:49 +0000)]
writev_on_pagefault: Use ssize_t type for write(2) return value

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofsstress: Fix wrong size argument to getcwd()
Rostislav Skudnov [Thu, 5 Oct 2017 12:49:57 +0000 (12:49 +0000)]
fsstress: Fix wrong size argument to getcwd()

Fixes the following ASAN failure:

==11670==WARNING: AddressSanitizer failed to allocate 0xffffffffffffffff bytes
==11670==AddressSanitizer's allocator is terminating the process instead of returning 0

...

    #5 0x4bb230 in __interceptor_malloc /home/vak-local/3.9.1/release/final/llvm.src/projects/compiler-rt/lib/asan/asan_malloc_linux.cc:65:10
    #6 0x7f97e6491405 in getcwd /build/glibc-6V9RKT/glibc-2.19/io/../sysdeps/unix/sysv/linux/getcwd.c:68
    #7 0x454691 in getcwd /home/vak-local/3.9.1/release/final/llvm.src/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:2822:15
    #8 0x4f765d in doproc /.../ltp/fsstress.c:933:12
    #9 0x4f5f54 in main /.../ltp/fsstress.c:581:5

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: Remove af_unix program requirement
Chandan Rajendra [Fri, 6 Oct 2017 09:29:33 +0000 (14:59 +0530)]
overlay/038: Remove af_unix program requirement

overlay/038 does not use src/af_unix program. This commit removes the
corresponding _require_test_program statement.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agofstests: update mkfs.xfs filters for new refactoring
Dave Chinner [Tue, 3 Oct 2017 08:21:34 +0000 (19:21 +1100)]
fstests: update mkfs.xfs filters for new refactoring

From: Dave Chinner <dchinner@redhat.com>

The new mkfs code adds some output to indicate where the defaults
were sourced from, so filter that out so it doesn't contaminate
tests unnecessarily.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoreport: fix summary statistics in xUnit header
Theodore Ts'o [Mon, 2 Oct 2017 03:39:32 +0000 (23:39 -0400)]
report: fix summary statistics in xUnit header

The xUnit XML DTD distinguishes between test failures and test errors,
where a test failure indicate that the test has explicitly indicated
that the code under test has behaved in an unexpected fashion, whereas
a test error indicates the test code itself has thrown an error or
there has been some other test implementation error.

Xfstest failures are correctly marked as xUnit failures, but in the
attributes of the testsuite XML element, the number of test failures
was incorrectly reported as the number of errors.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoreport: encode XML Character Entities in xUnit report
Theodore Ts'o [Sat, 30 Sep 2017 03:46:21 +0000 (23:46 -0400)]
report: encode XML Character Entities in xUnit report

Since the xUnit report is an XML document, special XML characters such
as '<', '>', '&', etc. have to be encoded as "&lt;", "&gt;", etc.
Otherwise programs parsing something like this:

<testcase classname="xfstests.global" name="generic/450" time="0">
<skipped message="Only test on sector size < half of block size" />
</testcase>

Will get choke the unescaped '<' character in the skipped message.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Dmitry Monakhov <dmonakhov@openvz.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agosrc/nsexec: fix stack pointer alignment exception
Zorro Lang [Fri, 29 Sep 2017 16:49:25 +0000 (00:49 +0800)]
src/nsexec: fix stack pointer alignment exception

When test g/317 or g/318 on ARM server, we got a kernel exception:

  kernel: nsexec[8203]: SP Alignment exception: pc=00000000004010a0 sp=00000000005200e8

nsexec gives an unaligned child stack address to clone() system
call sometimes. For making sure it's always aligned, use
"__attribute__((aligned))" extension of GCC (Thanks this suggestion
from Eric sandeen).

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: test increased overlong directory extent discard threshold
Darrick J. Wong [Fri, 29 Sep 2017 05:37:39 +0000 (22:37 -0700)]
xfs: test increased overlong directory extent discard threshold

As of 2007, metadump has an interesting "feature" where it discards
directory extents that are longer than 1000 (originally 20) blocks.
This ostensibly was to protect metadump from corrupt bmbt records, but
it also has the effect of omitting from the metadump valid long extents.
The end result is that we create incomplete metadumps, which is
exacerbated by the lack of warning unless -w is passed.

So now that we've fixed the default threshold to MAXEXTLEN, check that
the installed metadump no longer exhibits this behavior.

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: add iomap_dio_complete() to the dmesg filter
Eryu Guan [Fri, 29 Sep 2017 04:05:41 +0000 (12:05 +0800)]
common/xfs: add iomap_dio_complete() to the dmesg filter

Kernel commit 332391a9935d ("fs: Fix page cache inconsistency when mixing
buffered and AIO DIO") moved the WARN_ON_ONCE() into iomap_dio_complete(),
along with the page cache invalidation. Let's add iomap_dio_complete() to the
filter whitelist too, so this expected warning when mixing direct I/O with
buffered I/O won't fail tests.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric/447: not a quick test
Amir Goldstein [Thu, 28 Sep 2017 16:40:41 +0000 (19:40 +0300)]
generic/447: not a quick test

It hogged my cpu for a good 300s.
Test was inheritted from generic/176, which is not quick.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-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 agogeneric: mmap write readonly DAX file
Xiong Zhou [Thu, 28 Sep 2017 07:41:39 +0000 (15:41 +0800)]
generic: mmap write readonly DAX file

Regression case that one can write to read-only
file in a DAX mountpoint.

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogitignore: sort src/ binaries name
Xiong Zhou [Thu, 28 Sep 2017 07:41:38 +0000 (15:41 +0800)]
gitignore: sort src/ binaries name

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agotests: add new group dax
Xiong Zhou [Thu, 28 Sep 2017 07:41:37 +0000 (15:41 +0800)]
tests: add new group dax

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agobtrfs: regression test for reading compressed data
Liu Bo [Wed, 27 Sep 2017 16:35:51 +0000 (10:35 -0600)]
btrfs: regression test for reading compressed data

We had a bug in btrfs compression code which could end up with a
kernel panic.

This is adding a regression test for the bug and I've also sent a
kernel patch to fix the bug.

The patch is "Btrfs: fix kernel oops while reading compressed data".

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 agogeneric/45[34]: fix the xfs_scrub probe test
Darrick J. Wong [Wed, 27 Sep 2017 01:04:19 +0000 (18:04 -0700)]
generic/45[34]: fix the xfs_scrub probe test

We changed the name of the xfs_scrub verb from 'test' to 'probe', so
fix xfstests to follow.

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 nocheck shutdown stress test
Khazhismel Kumykov [Fri, 22 Sep 2017 20:10:47 +0000 (13:10 -0700)]
generic: Add nocheck shutdown stress test

Most shutdown tests only run on filesystems with metadata
journaling, so we lose coverage. Add a shutdown stress test that
doesn't check for consistency, so does not require journaling. This
is a modified version of generic/051, with some extras trimmed and
fs checking removed.

Signed-off-by: Khazhismel Kumykov <khazhy@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: Add test for CVE-2017-14340
Richard Wareing [Fri, 22 Sep 2017 02:34:46 +0000 (19:34 -0700)]
xfs: Add test for CVE-2017-14340

Verify kernel doesn't panic when user attempts to set realtime flags
on non-realtime FS, using kernel compiled with CONFIG_XFS_RT.
Unpatched kernels will panic during this test.  Kernels not compiled
with CONFIG_XFS_RT should pass test.

This bug was fixed via commit b31ff3cdf540 ("xfs:
XFS_IS_REALTIME_INODE() should be false if no rt device present") on
the main kernel tree.

[eguan: don't assume fixed position when grepping 't' and add some
comments about why we do this, also remove testfile after test]

Signed-off-by: Richard Wareing <rwareing@fb.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/031: fix test with inodes index enabled
Amir Goldstein [Tue, 19 Sep 2017 11:39:44 +0000 (14:39 +0300)]
overlay/031: fix test with inodes index enabled

When overlayfs is configured with CONFIG_OVERLAY_FS_INDEX=y,
workdir from previous overlay mount cannot be reused in a new
overlay mount that uses a different upper dir.

Fix the test to use a different workdir when mounting with a
different upper dir.

This change has no effect on older kernels and overlay
configured without CONFIG_OVERLAY_FS_INDEX.

Cc: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/014: correct comment relating to workdir reuse
Amir Goldstein [Tue, 19 Sep 2017 11:39:43 +0000 (14:39 +0300)]
overlay/014: correct comment relating to workdir reuse

Clarification: EBUSY is what you get when trying to use the same
upperdir/workdir with two different *concurent* overlayfs mounts.
The EBUSY case is independent of the inodes index feature.

This is not the case in this test, but rather the case of trying to
reuse the same workdir with different upper dirs on *subsequent*
overlayfs mounts.

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: Improve gfs2 support
Andreas Gruenbacher [Sat, 16 Sep 2017 13:20:54 +0000 (15:20 +0200)]
common/rc: Improve gfs2 support

Support gfs2 in _scratch_mkfs_sized _scratch_mkfs_blocksized.

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 agoxfs/310: relax extent count check
Christoph Hellwig [Sun, 3 Sep 2017 15:51:01 +0000 (17:51 +0200)]
xfs/310: relax extent count check

If we got over the bmbt length we'll always allocate two extents,
its just that so far getbmap merged them.

Also fix/update some comments.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay/038: fix impure xattr test
Amir Goldstein [Fri, 15 Sep 2017 10:47:28 +0000 (13:47 +0300)]
overlay/038: fix impure xattr test

On kvm-xfstest, getfattr (2.4.43) does not return failure exit code
when the requested xattr is not found.

Change the test to check the returned xattr value instead of exit
code.

Cc: Chandan Rajendra <chandan@linux.vnet.ibm.com>
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 agoxfs/115: add missing 115 into group file
xiao yang [Mon, 18 Sep 2017 01:29:00 +0000 (09:29 +0800)]
xfs/115: add missing 115 into group file

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 agooverlay: test chattr lower file in overlay
zhangyi (F) [Thu, 14 Sep 2017 13:27:07 +0000 (21:27 +0800)]
overlay: test chattr lower file in overlay

chattr with [iap..] attributes open file for read-only and invoke
ioctl(). If we chattr a lower file in overlay, it will get the lower
file but not trigger copy-up, so ioctl() lead to modification of
that lower file incorrectly. Add this test for this case.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agooverlay: test relatime for directories
zhangyi (F) [Thu, 14 Sep 2017 12:04:02 +0000 (20:04 +0800)]
overlay: test relatime for directories

Add test access time update issue for directories in upper layer.

Upstream commit cd91304e7190 ("ovl: fix relatime for directories")
fixed this issue.

[eguan: add atime group]

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agosrc/fsync-err: write to different offset on each fd
Jeff Layton [Wed, 13 Sep 2017 13:06:24 +0000 (09:06 -0400)]
src/fsync-err: write to different offset on each fd

NFS currently has slightly different semantics from other fs' and
fails this test due to the fact that the same range is overwritten
via each fd.

Change it so that each fd overwrites a different region, which is
more representative of a real workload anyway.

Reported-by: Neil Brown <neilb@suse.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: reserve correct indirect blocks for delalloc write path
Eryu Guan [Mon, 4 Sep 2017 09:38:19 +0000 (17:38 +0800)]
generic: reserve correct indirect blocks for delalloc write path

Test that XFS reserves reasonable indirect blocks for delalloc and
speculative allocation, and doesn't cause any fdblocks corruption.

This was inspired by an XFS but that too large 'indlen' was returned by
xfs_bmap_worst_indlen() which can't fit in a 17 bits value
(STARTBLOCKVALBITS is defined as 17), then leaked 1 << 17 blocks in
sb_fdblocks.

This was only seen on XFS with rmapbt feature enabled, but nothing
prevents the test from being a generic test.

Reviewed-by: "Darrick J. Wong" <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agoxfs: Test infinite loop while searching for a free inode slot
Carlos Maiolino [Fri, 18 Aug 2017 08:51:56 +0000 (10:51 +0200)]
xfs: Test infinite loop while searching for a free inode slot

Tests the search algorithm for a free inode slot in a specific AG,
done in xfs_dialloc_ag_inobt().

When finobt is not used, and agi->freecount is not 0, XFS will scan
the AG inode tree looking for a free inode slot, but if
agi->freecount is corrupted, and there is no free slot at all, it
will end up in an infinite loop.

This test checks for the infinite loop fix.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agocommon/xfs: Add helpers for checking CONFIG_XFS_DEBUG availability
Carlos Maiolino [Fri, 18 Aug 2017 08:51:55 +0000 (10:51 +0200)]
common/xfs: Add helpers for checking CONFIG_XFS_DEBUG availability

Add the following helpers to common/xfs:

_require_xfs_debug()
_require_no_xfs_debug()

Tests that require or not a kernel built with XFS_DEBUG can now use
these two helpers to explicitly check for it.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: Test filesystem lockup on full overprovisioned dm-thin
Carlos Maiolino [Thu, 13 Jul 2017 13:12:08 +0000 (15:12 +0200)]
generic: Test filesystem lockup on full overprovisioned dm-thin

With thin devices, it's possible to have a virtual device larger
than the physical device itself, and such situation can cause
problems to filesystems, once the filesystem 'believe' to have more
space than it actually has.

This can lead the filesystem to several weird behaviors. The one
tested here is filesystem lockup.

In case of XFS, it locks up when trying to writeback AIL metadata
back to the filesystem, but, once there is no physical space
available, XFS locks up and do not gracefuly handle this case.

Other filesystems usually are remounted as read-only, so they
already have this situation covered.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogitignore: ignore cscope files
Ross Zwisler [Tue, 12 Sep 2017 04:45:19 +0000 (22:45 -0600)]
gitignore: ignore cscope files

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: renumber tests after merge
Eryu Guan [Fri, 8 Sep 2017 04:34:42 +0000 (12:34 +0800)]
generic: renumber tests after merge

Tests were merged with high seq numbers to avoid conflicts with
other tests. Now renumber them to contiguous numbers, as all other
tests have been merged correctly. This is easier to do than
assigning the final seq numbers at commit time.

Signed-off-by: Eryu Guan <eguan@redhat.com>
6 years agogeneric: regression test for xfs leftover CoW extent error
Amir Goldstein [Thu, 7 Sep 2017 10:03:13 +0000 (13:03 +0300)]
generic: regression test for xfs leftover CoW extent error

The following error are reported after running this test:

*** xfs_check output ***
leftover CoW extent (0/2147483736) len 1
block 0/2147483736 out of range
blocks 0/2147483736..2147483736 claimed by block 0/6
leftover CoW extent (0/2147483738) len 2
blocks 0/2147483738..2147483739 out of range
blocks 0/2147483738..2147483739 claimed by block 0/6
leftover CoW extent (0/2147483741) len 3
blocks 0/2147483741..2147483743 out of range
blocks 0/2147483741..2147483743 claimed by block 0/6
block 0/88 type unknown not expected
block 0/90 type unknown not expected
block 0/91 type unknown not expected
block 0/93 type unknown not expected
block 0/94 type unknown not expected
block 0/95 type unknown not expected

*** xfs_repair -n output ***
Phase 1 - find and verify superblock...
Phase 2 - using internal log
        - zero log...
        - scan filesystem freespace and inode maps...
leftover CoW extent (0/88) len 1
leftover CoW extent (0/90) len 2
leftover CoW extent (0/93) len 3
        - found root inode chunk

This should be fixed by patch titled:
xfs: evict CoW fork extents when performing finsert/fcollapse

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: crash consistency fsx test for cloned files
Amir Goldstein [Thu, 7 Sep 2017 10:03:12 +0000 (13:03 +0300)]
generic: crash consistency fsx test for cloned files

[eguan: fixed minor code style issues, remove extra newline at eof]

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: regression test for ext4 crash consistency bug
Amir Goldstein [Thu, 7 Sep 2017 10:03:11 +0000 (13:03 +0300)]
generic: regression test for ext4 crash consistency bug

This test is motivated by this inconsistency found in ext4 during random
crash consistency tests:

 *** fsck.ext4 output ***
 fsck from util-linux 2.27.1
 e2fsck 1.42.13 (17-May-2015)
 Pass 1: Checking inodes, blocks, and sizes
 Inode 12, end of extent exceeds allowed value
         (logical block 33, physical block 33817, len 7)
 Clear? no

 Inode 12, i_blocks is 240, should be 184.  Fix? no

This test uses device mapper flakey target to demonstrate the bug
found using device mapper log-writes target.

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: crash consistency fsx test using dm-log-writes
Amir Goldstein [Thu, 7 Sep 2017 10:03:10 +0000 (13:03 +0300)]
generic: crash consistency fsx test using dm-log-writes

Cherry-picked the test from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

  The test just runs some ops and exits, then finds all of the good buffers
  in the directory we provided and:
  - replays up to the mark given
  - mounts the file system and compares the md5sum
  - unmounts and fsck's to check for metadata integrity

  dm-log-writes will pretend to do discard and the replay-log tool will
  replay it properly depending on the underlying device, either by writing
  0's or actually calling the discard ioctl, so I've enabled discard in the
  test for maximum fun.

[Amir:]
- Removed unneeded _test_falloc_support dynamic FSX_OPTS
- Fold repetitions into for loops
- Added place holders for using constant random seeds
- Add pre umount checkpint
- Add test to new 'replay' group
- Address review comments by Eryu Guan

[eguan: fixed minor code style issues, remove extra newline at eof]

Cc: Josef Bacik <jbacik@fb.com>
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 agofstests: add support for working with dm-log-writes target
Amir Goldstein [Thu, 7 Sep 2017 10:03:09 +0000 (13:03 +0300)]
fstests: add support for working with dm-log-writes target

Cherry-picked the relevant common bits from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

  This patch adds the supporting code for using the dm-log-writes
  target.  The dmlogwrites code is similar to the dmflakey code, it just
  gives us functions to build and tear down a dm-log-writes target.  We
  add a new LOGWRITES_DEV variable to take in the device we will use as
  the log and add checks for that.

[Amir:]
- Removed unneeded _test_falloc_support
- Moved _require_log_writes to dmlogwrites
- Document _require_log_writes
- Address review comments by Eryu Guan

Cc: Josef Bacik <jbacik@fb.com>
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 agoreplay-log: add support for replaying ops in target device sector range
Amir Goldstein [Thu, 7 Sep 2017 10:03:08 +0000 (13:03 +0300)]
replay-log: add support for replaying ops in target device sector range

Using command line options --start-sector and --end-sector, only
operations acting on the specified target device range will be
replayed.

Single vebbose mode (-v) prints out only replayed operations.
Double verbose mode (-vv) prints out also skipped operations.

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 agoreplay-log: add validations for corrupt log entries
Amir Goldstein [Thu, 7 Sep 2017 10:03:07 +0000 (13:03 +0300)]
replay-log: add validations for corrupt log entries

Check for all zeros entry and for non zero padded entry
and report log offset of corrupted log entry.

Also report log offsets with -v and -vv debug prints.

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 agolog-writes: add replay-log program to replay dm-log-writes target
Amir Goldstein [Thu, 7 Sep 2017 10:03:06 +0000 (13:03 +0300)]
log-writes: add replay-log program to replay dm-log-writes target

Imported Josef Bacik's code from:
https://github.com/josefbacik/log-writes.git

Specialized program for replaying a write log that was recorded by
device mapper log-writes target.  The tools is used to perform
crash consistency tests, allowing to run an arbitrary check tool
(fsck) at specified checkpoints in the write log.

[Amir:]
- Add project Makefile and SOURCE files
- Document the replay-log auxiliary program
- Address review comments by Eryu Guan

Cc: Josef Bacik <jbacik@fb.com>
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 agofsx: add support for keeping existing file
Amir Goldstein [Thu, 7 Sep 2017 07:26:38 +0000 (10:26 +0300)]
fsx: add support for keeping existing file

With fsx -k, do not truncate existing file and use its size as upper
bound on file size.

This is needed to prevent fsx from truncating the file on start of
test when testing fsx on cloned 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 agofsx: add support for writing constant instead of random data
Amir Goldstein [Thu, 7 Sep 2017 07:26:37 +0000 (10:26 +0300)]
fsx: add support for writing constant instead of random data

-g X: write character X instead of random generated data

This is useful to compare holes between good and bad files
because hexdump of good and bad files compacts the contigious
ranges of X and zeroes.

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 agofsx: add support for recording operations to a file
Amir Goldstein [Thu, 7 Sep 2017 07:26:36 +0000 (10:26 +0300)]
fsx: add support for recording operations to a file

Usually, fsx dumps an .fsxops file on failure with same basename
as work file and possibly under dirctory specified by -P dirpath.

The --record-ops[=opsfile] flag can be use to dump ops file also
on success and to optionally specify the ops file name.

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 agofsx: add optional logid prefix to log messages
Amir Goldstein [Thu, 7 Sep 2017 07:26:35 +0000 (10:26 +0300)]
fsx: add optional logid prefix to log messages

When redirecting the intermixed output of several fsx processes
to a single output file, it is usefull to prefix debug log messages
with a log id. Use fsx -j <logid> to define the log messages prefix.

Fix implementation of prt() function to avoid using a temp buffer
and convert some more printf() calls to use ptr() instead.

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 agofsx: add support for integrity check with dm-log-writes target
Amir Goldstein [Thu, 7 Sep 2017 07:26:34 +0000 (10:26 +0300)]
fsx: add support for integrity check with dm-log-writes target

Cherry-picked the relevant fsx bits from commit 70d41e17164b
in Josef Bacik's fstests tree (https://github.com/josefbacik/fstests).
Quoting from Josef's commit message:

  I've rigged up fsx to have an integrity check mode.  Basically it works
  like it normally works, but when it fsync()'s it marks the log with a
  unique mark and dumps it's buffer to a file with the mark in the filename.
  I did this with a system() call simply because it was the fastest.  I can
  link the device-mapper libraries and do it programatically if that would
  be preferred, but this works pretty well.

Signed-off-by: Josef Bacik <jbacik@fb.com>
[Amir:]
- Fix some exit codes
- Require -P dirpath for -i logdev

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