xfstests-dev.git
4 years agooverlay: renumber tests after merge
Eryu Guan [Thu, 8 Feb 2018 12:18:31 +0000 (20:18 +0800)]
overlay: 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>
4 years agooverlay: add fsck.overlay impure xattr test
zhangyi (F) [Thu, 8 Feb 2018 03:19:13 +0000 (11:19 +0800)]
overlay: add fsck.overlay impure xattr test

Add fsck.overlay test case to test it how to deal with impure xattr
in underlying directories of overlayfs.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: add fsck.overlay redirect directory test
zhangyi (F) [Thu, 8 Feb 2018 03:19:12 +0000 (11:19 +0800)]
overlay: add fsck.overlay redirect directory test

Add fsck.overlay test case to test it how to deal with invalid/valid/
duplicate redirect xattr in underlying directories of overlayfs.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: add fsck.overlay whiteout test
zhangyi (F) [Thu, 8 Feb 2018 03:19:11 +0000 (11:19 +0800)]
overlay: add fsck.overlay whiteout test

Add fsck.overlay test case to test it how to deal with orphan/valid
whiteouts in underlying directories of overlayfs.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: define common overlay xattr keys
zhangyi (F) [Thu, 8 Feb 2018 03:19:10 +0000 (11:19 +0800)]
overlay: define common overlay xattr keys

Define common overlay xattr keys from Linux kernel for ovl tests use.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: add filesystem check helper
zhangyi (F) [Thu, 8 Feb 2018 03:19:09 +0000 (11:19 +0800)]
overlay: add filesystem check helper

Add filesystem check helper for the upcoming fsck.overlay utility.
This helper invoke fsck.overlay to check and optionally repair
underlying directories of overlay filesystem.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/270: Check for scratch mount success
Andreas Gruenbacher [Sat, 3 Feb 2018 18:57:37 +0000 (19:57 +0100)]
generic/270: Check for scratch mount success

We don't want to fill up the scratch mount point if the scratch
mount fails.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: Fix exit status
Andreas Gruenbacher [Sat, 3 Feb 2018 18:57:35 +0000 (19:57 +0100)]
check: Fix exit status

Exit with status 1 if there were any failures: using the number of
failed tests as the exit status makes no sense and can easily
overwrap.

In addition, clean up a few minor things.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test overlay file handle of dir with ancestor under lower redirect
Amir Goldstein [Wed, 31 Jan 2018 11:44:55 +0000 (13:44 +0200)]
overlay: test overlay file handle of dir with ancestor under lower redirect

Overlayfs with nfs_export enabled, indexes all directories on copy
up.  Directory index is requires for decoding lower directory file
handles in case ancestors have been renamed.

When enabling nfs_export on an overlay that has merge dirs with
lower layer redirects, the possibility of ancestor rename requires
special handling when encoding lower directory file handles from
layer > 1.

- Check decode of lower dir with parent under lower redirect
- Check decode of lower dir with grandparent under lower redirect
- Check decode of lower dir after rename of lower redirected parent
- Check decode of lower dir after rename of lower redirected grandparent

This test requires and enables overlayfs NFS export support and
merge dir rename support (redirect_dir).
NFS export support depends on and requires overlayfs index feature.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test overlay file handles of lower dir with non-indexed ancestor
Amir Goldstein [Wed, 31 Jan 2018 11:44:54 +0000 (13:44 +0200)]
overlay: test overlay file handles of lower dir with non-indexed ancestor

Overlayfs with nfs_export enabled, indexes all directories on copy
up.  Directory index is requires for decoding lower directory file
handles in case ancestors have been renamed.

When enabling nfs_export on an overlay that already has non-indexed
merge dirs, the possibility of non-indexed ancestor rename requires
special handling when encoding lower directory file handles.

- Check encode/decode/read file handles of non-indexed merge dir
- Check encode/decode/read file handles of dir with non-indexed parent
- Check encode/decode/read file handles of dir with non-indexed grandparent
- Check decode/read of file handles after rename of non-indexed merge dir
- Check decode/read of file handles after rename of non-indexed parent
- Check decode/read of file handles after rename of non-indexed grandparent

This test requires and enables overlayfs NFS export support and
merge dir rename support (redirect_dir).
NFS export support depends on and requires overlayfs index feature.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/{274,315}: Require falloc -k support
Rostislav Skudnov [Tue, 30 Jan 2018 13:54:59 +0000 (13:54 +0000)]
generic/{274,315}: Require falloc -k support

These test cases require filesystem support for FALLOC_FL_KEEP_SIZE
flag in fallocate().

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/307: Require ACL support
Rostislav Skudnov [Tue, 30 Jan 2018 13:54:58 +0000 (13:54 +0000)]
generic/307: Require ACL support

Test checks ctime change on setfacl, which requires ACL support from
the underlying filesystem.

[eguan: add commit log and source common/attr]

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test encode/decode of non-samefs overlay file handles with renames
Amir Goldstein [Tue, 30 Jan 2018 06:12:22 +0000 (08:12 +0200)]
overlay: test encode/decode of non-samefs overlay file handles with renames

This is a variant of overlay file handles with renames test for an
overlayfs that is composed of multiple lower layers not on the same
underlying fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test encode/decode overlay file handles with renames
Amir Goldstein [Tue, 30 Jan 2018 06:12:21 +0000 (08:12 +0200)]
overlay: test encode/decode overlay file handles with renames

- Check decode/read of file handles after rename of parent
- Check decode/read of file handles after rename of grandparent
- Check decode/read of file handles after move to new parent
- Check encode/decode/read of file handles in non-upper overlay

This test requires and enables overlayfs NFS export support and merge
dir rename support (redirect_dir).
NFS export support depends on and requires overlayfs index feature.

This test covers only encode/decode of file handles for overlayfs
configuration of all layers on the same base fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test encode/decode of non-samefs overlay file handles
Amir Goldstein [Tue, 30 Jan 2018 06:12:20 +0000 (08:12 +0200)]
overlay: test encode/decode of non-samefs overlay file handles

This is a variant of overlay file handles test for an overlayfs that
is composed of multiple lower layers not on the same underlying fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test encode/decode overlay file handles
Amir Goldstein [Tue, 30 Jan 2018 06:12:19 +0000 (08:12 +0200)]
overlay: test encode/decode overlay file handles

- Check encode/write/decode/read content of lower/upper file handles
- Check encode/decode/write/read content of lower/upper file handles
- Check decode/read of unlinked lower/upper files and directories
- Check decode/read of lower file handles after copy up, link and unlink

This test requires and enables overlayfs NFS export support. NFS
export support depends on and requires overlayfs index feature.

This test covers only encode/decode of file handles for overlayfs
configuration of all layers on the same base fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: implement require of multiple overlayfs features
Amir Goldstein [Tue, 30 Jan 2018 06:12:18 +0000 (08:12 +0200)]
fstests: implement require of multiple overlayfs features

Some overlayfs features must be checked together, because they cannot
be enabled without a dependent feature (e.g. nfs_export and index).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: add a test for multiple redirects to the same lower dir
Amir Goldstein [Sun, 28 Jan 2018 09:07:30 +0000 (11:07 +0200)]
overlay: add a test for multiple redirects to the same lower dir

Multiple redirects to the same lower dir will falsely return the
same st_ino/st_dev for two different upper dirs and will cause
'diff' to falsely report that content of directories is the same
when it is not.

This test checks that overalyfs detects and fails lookup of a
multiply redirected dir.

The check for multiply redirected dir was implemented by kernel
commit titled "ovl: hash directory inodes for fsnotify".

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/017: require and enable redirect_dir
Amir Goldstein [Fri, 26 Jan 2018 07:59:08 +0000 (09:59 +0200)]
overlay/017: require and enable redirect_dir

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

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: consider index dir with whiteouts clean
Amir Goldstein [Fri, 26 Jan 2018 07:59:07 +0000 (09:59 +0200)]
overlay: consider index dir with whiteouts clean

Several tests check that index dir is empty after upper entries have
been unlinked. With nfs_export=on, index will contain a whiteout
index entry in that case so, allow chardevs when checking for clean
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>
4 years agooverlay/036: fix upper/lower dir mismatch
Amir Goldstein [Fri, 26 Jan 2018 07:59:06 +0000 (09:59 +0200)]
overlay/036: fix upper/lower dir mismatch

Mount option index=on checks on mount that upper dir is not being
reused with a different lower dir than the first lower dir it was
mounted with. This behavior is verified by test overlay/037.

In this test however, it is not desired to fail mount on mismatch of
upper/lower, so use the matching upper/lower dirs in this test.

The mismatch went unnoticed because the index=off mounts do not
verify lower dir and the index=on mounts fails on EBUSY (dir in use
by another live mount) before failing on ESTALE (upper/lower dir
mismatch).

Never the less, fix the mismatch, so a change in the kernel between
the two sanity checks (EBUSY vs. ESTALE) won't break the test.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoovelray: drop explicit use of OVERLAY_MOUNT_OPTIONS
Amir Goldstein [Fri, 26 Jan 2018 07:59:05 +0000 (09:59 +0200)]
ovelray: drop explicit use of OVERLAY_MOUNT_OPTIONS

Tests don't need to specify $OVERLAY_MOUNT_OPTIONS for overlay mount
helpers. These options have already been assigned to MOUNT_OPTIONS
by _overlay_config_override or by _mount_opts and will be added to
mount command by _common_dev_mount_options in _overlay_mount_dirs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/metaperf: Include linux/param.h explicitly for HZ macro
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:15 +0000 (15:57 +0000)]
src/metaperf: Include linux/param.h explicitly for HZ macro

Glibc includes linux/param.h when we include sys/param.h, whereas
musl libc does not do that. HZ is a Linux-specific macro, therefore
include the header file that defines it explicitly.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/dmiperf: Include sys/types.h for u_int32_t
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:16 +0000 (15:57 +0000)]
src/dmiperf: Include sys/types.h for u_int32_t

u_int32_t type is defined in sys/types.h, which is often included by
glibc implicitly when some other headers are used, but other C
libraries such as musl may not necessarily do so, therefore an
explicit include is needed.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/24[356]: checking cow fork bmap requires CONFIG_XFS_DEBUG=y
Darrick J. Wong [Wed, 24 Jan 2018 23:53:41 +0000 (15:53 -0800)]
xfs/24[356]: checking cow fork bmap requires CONFIG_XFS_DEBUG=y

These tests requires XFS debugging functionality, so test for that.

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>
4 years agogeneric/403: don't spew '$GETFATTR_PROG: Killed' messages
Darrick J. Wong [Wed, 24 Jan 2018 23:53:35 +0000 (15:53 -0800)]
generic/403: don't spew '$GETFATTR_PROG: Killed' messages

Use a runfile presence check to control the background getfattr loop
instead of using kill -9.  This helps us to avoid the problem that
the controlling bash will print a process killed message, which
wrecks the golden output.

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>
4 years agoxfs/122: fix xfs header ordering problems
Darrick J. Wong [Wed, 24 Jan 2018 23:53:29 +0000 (15:53 -0800)]
xfs/122: fix xfs header ordering problems

XFS headers are supposed to be included in a certain order so that
inline functions actually compile correctly.  For the most part the
shell feeds us the files in an order that works, but with the
addition of the xfs_dir2_dirblock_bytes function this doesn't always
work now.  Therefore, explicitly #include the headers in the
required order.

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>
4 years agocommon/rc: report kmemleak errors
Darrick J. Wong [Wed, 24 Jan 2018 23:53:23 +0000 (15:53 -0800)]
common/rc: report kmemleak errors

If kmemleak is enabled, scan and report memory leaks after every
test.

Note that the kmemleak check support is EXPERIMENTAL! Due to the way
kmemleak works, the leak might be from an earlier test, or something
totally unrelated.

[eguan: add EXPERIMENTAL disclaimer in commit log 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>
4 years agoext4: Ext4 online resize with bigalloc tests.
harshads [Wed, 24 Jan 2018 22:58:12 +0000 (14:58 -0800)]
ext4: Ext4 online resize with bigalloc tests.

Add tests to verify Ext4 online resizing feature with bigalloc
feature enabled. We test various resizing scenarios with different
cluster sizes.

Signed-off-by: Harshad Shirwadkar <harshads@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test decoding file handles after cycle mount
Amir Goldstein [Tue, 23 Jan 2018 20:59:08 +0000 (22:59 +0200)]
generic: test decoding file handles after cycle mount

open_by_handle can now store and load file handles from a file:

usage:
 open_by_handle -p -o <handles_file> <test_dir> [N]
 open_by_handle -p -i <handles_file> <test_dir> [N]

Add a new generic/exportfs test to use these new options to test
decoding file handles after cycle mount and after directory renames.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/exportfs: golden output is not silent
Amir Goldstein [Tue, 23 Jan 2018 20:59:07 +0000 (22:59 +0200)]
generic/exportfs: golden output is not silent

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/open_by_handle: verify dir content only with -r flag
Amir Goldstein [Tue, 23 Jan 2018 20:59:06 +0000 (22:59 +0200)]
src/open_by_handle: verify dir content only with -r flag

Without -r flag file handles are opened, but file content is not
read.  Treat dir file hanldes, similarly. without -r flag, open dir
file handle, but don't verify its content.

This is going to be used by tests for which dir content is changed
between encode and decode of dir file handle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/pwrite_mmap_blocked: Include signal.h instead of sys/signal.h
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:19 +0000 (15:57 +0000)]
src/pwrite_mmap_blocked: Include signal.h instead of sys/signal.h

sys/signal.h is wrong and should not be used. Musl C library warns
about it.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/t_mtab: Replace sys_siglist[] with strsignal()
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:18 +0000 (15:57 +0000)]
src/t_mtab: Replace sys_siglist[] with strsignal()

strsignal(3) says that strsignal() should be used instead of
sys_siglist[].

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/fssum: Use htobe64() instead of a custom macro
Rostislav Skudnov [Tue, 23 Jan 2018 08:08:18 +0000 (08:08 +0000)]
src/fssum: Use htobe64() instead of a custom macro

Remove unnecessary htonll() macro definition.

Macros and functions starting with two underscores are usually
internal and shouldn't be used by applications when a version
without "__" is available.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agodoio, growfiles: Use standard signal name SIGCHLD instead of SIGCLD
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:14 +0000 (15:57 +0000)]
doio, growfiles: Use standard signal name SIGCHLD instead of SIGCLD

SIGCLD is synonymous with SIGCHLD, but the former is non-standard
and not supported by some C libraries such as musl.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: Replace all __[u]intNN_t types with standard [u]intNN_t
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:13 +0000 (15:57 +0000)]
fstests: Replace all __[u]intNN_t types with standard [u]intNN_t

Integer types such as __uint32_t are non-standard and not supported
by some C libraries such as musl. This commit replaces them with
standard types such as uint32_t and includes stdint.h header where
necessary.

The following command was used to do the changing of types:
sed -r -i 's/__(u?int[0-9]{2}_t)/\1/g' src/*.c ltp/*.c

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofsstress: Include stddef.h for ptrdiff_t
Rostislav Skudnov [Mon, 22 Jan 2018 15:57:12 +0000 (15:57 +0000)]
fsstress: Include stddef.h for ptrdiff_t

In musl C library headers ptrdiff_t is only defined in stddef.h.

Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: expunge tests when doing a dry run
Luis R. Rodriguez [Sun, 21 Jan 2018 07:24:01 +0000 (23:24 -0800)]
check: expunge tests when doing a dry run

Running ./check with -n will not execute tests, however
when exclude files are used we still show them as if
they are run. Test the exclude file prior to assuming
we can run a test on a dry run.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: move expunge test into a helper
Luis R. Rodriguez [Sun, 21 Jan 2018 07:24:00 +0000 (23:24 -0800)]
check: move expunge test into a helper

Move the expunge test into a helper.

[eguan: make TEST_ID local and use grep -q not io redirection]

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: Regression test for invalid sb_logsunit
xiao yang [Fri, 19 Jan 2018 05:38:06 +0000 (13:38 +0800)]
xfs: Regression test for invalid sb_logsunit

If log stripe unit isn't a multiple of the fs blocksize and
mounting, the invalid sb_logsunit leads to crash as soon as we try
to write to the log.

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>
4 years agocommon: Add _require_no_xfs_bug_on_assert and factor out filter_xfs_dmesg
xiao yang [Fri, 19 Jan 2018 05:38:05 +0000 (13:38 +0800)]
common: Add _require_no_xfs_bug_on_assert and factor out filter_xfs_dmesg

1) Introduce _require_no_xfs_bug_on_assert helper to check if XFS is
   built with CONFIG_XFS_ASSERT_FATAL, and call _require_no_xfs_debug
   if bug_on_assert is not available.

2) Apply _require_no_xfs_bug_on_assert in xfs/098 and xfs/115.

3) Move filter_xfs_dmesg from xfs/098 to common/filter, and rename
   it as _filter_assert_dmesg.

[eguan: update comment and _notrun message a bit]

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>
4 years agoxfs/realtime: Fix direct invocations of xfs_repair
Richard Wareing [Fri, 12 Jan 2018 04:16:19 +0000 (20:16 -0800)]
xfs/realtime: Fix direct invocations of xfs_repair

Fixes direct invocations of xfs_repair to add in -r option if required.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Richard Wareing <rwareing@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/realtime: add _require_no_rtinherit function
Richard Wareing [Fri, 12 Jan 2018 04:16:18 +0000 (20:16 -0800)]
xfs/realtime: add _require_no_rtinherit function

To better exercise the data path code of realtime subvolumes, we
will set rtinherit=1 during mkfs calls.  For tests which this is not
desired we introduce a _require_no_rtinherit function to opt out of
this behavior.

Signed-off-by: Richard Wareing <rwareing@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/realtime: Add require_no_realtime function
Richard Wareing [Fri, 12 Jan 2018 04:16:17 +0000 (20:16 -0800)]
xfs/realtime: Add require_no_realtime function

Some tests do not play well with realtime devices, in an effort to
produce a stable set of test which exercise the realtime code paths
we introduce a _require_no_realtime function to allow tests to opt
out of realtime subvolume test runs.

And to make tests generic/409-411 work well with rt device, teach
_get_mount now honors $SCRATCH_OPTIONS.

Signed-off-by: Richard Wareing <rwareing@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/dmthin: dm-thin lacks DAX support
Ross Zwisler [Thu, 18 Jan 2018 16:07:37 +0000 (09:07 -0700)]
common/dmthin: dm-thin lacks DAX support

generic/347 currently fails when run in conjunction with the DAX
mount option:

generic/347 72s ... - output mismatch (see
/root/project/xfstests/results//generic/347.out.bad)
    --- tests/generic/347.out 2016-05-12 11:56:32.086618744 -0600
    +++ /root/project/xfstests/results//generic/347.out.bad 2018-01-17
    16:04:33.459348448 -0700
    @@ -1,2 +1,3 @@
     QA output created by 347
    +mount: /mnt/xfstests_scratch: can't read superblock on
    /dev/mapper/thin-vol.
     === completed
    ...
    (Run 'diff -u tests/generic/347.out
    /root/project/xfstests/results//generic/347.out.bad'  to see the entire
    diff)

This is expected because the dm-thin target currently lacks DAX
support.

Just skip this test if we are using DAX.

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>
4 years agocommon/xfs: Check if write supports [-c|-d] option in xfs_db
xiao yang [Tue, 16 Jan 2018 07:26:55 +0000 (15:26 +0800)]
common/xfs: Check if write supports [-c|-d] option in xfs_db

Make sure _scratch_xfs_set_metadata_field() can be used on an
old xfsprogs-dev(e.g. v3.1.1).

The "-d" option was introduced since xfsprogs-dev v4.7.0 by commit
86769b3 ("xfs_db: allow recalculating CRCs on invalid metadata").

The special argument "--" is only used to end option-scanning
in getopt().  getopt() was introduced since xfsprogs-dev v3.2.3 by
commit c9f5e3d ("xfs_db: Allow writes of corrupted data")'.

Signed-off-by: xiao yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoshared/272: don't use data journaling with DAX
Ross Zwisler [Wed, 17 Jan 2018 23:23:50 +0000 (16:23 -0700)]
shared/272: don't use data journaling with DAX

shared/272 fails with kernels v4.15-rc1 and beyond when you are
mounted with DAX:

shared/272  [failed, exit status 1] - output mismatch (see
/root/project/xfstests/results//shared/272.out.bad)
    --- tests/shared/272.out 2015-12-05 13:12:17.038257578 -0700
    +++ /root/project/xfstests/results//shared/272.out.bad 2018-01-17
    15:37:18.581631116 -0700
    @@ -1,3 +1,3 @@
     QA output created by 272
     Switch data journalling mode. Silence is golden.
    -Check filesystem
    +/usr/bin/chattr: Device or resource busy while setting flags on
    /mnt/xfstests_scratch/file.1
    ...
    (Run 'diff -u tests/shared/272.out
    /root/project/xfstests/results//shared/272.out.bad'  to see the entire
    diff)

This is expected.  The following kernel commit:

commit e9072d859df3 ("ext4: prevent data corruption with journaling + DAX")

makes "chattr +j", which is attempting to turn on data journaling,
return -EBUSY if the ext4 DAX mount option is in use.  This was done
to prevent the data corruption shown in xfstest ext4/030, added by
this xfstests commit:

commit 750a24e99e48 ("ext4: test for DAX + journaling corruption")

So, just skip shared/272 if the DAX mount option is in use.

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>
4 years agobtrfs/027: unmount scratch device if test fails
Liu Bo [Tue, 16 Jan 2018 20:10:18 +0000 (13:10 -0700)]
btrfs/027: unmount scratch device if test fails

This test, btrfs/027, runs tests against different raid profiles in
a loop, if one of them aborts, it also fails the following ones with
errors like,

Test -m raid10 -d raid10
ERROR: /dev/xxx is mounted
Test -m raid5 -d raid5
ERROR: /dev/xxx is mounted
Test -m raid6 -d raid6
ERROR: /dev/xxx is mounted

_scratch_unmount is added to avoid the above.

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>
4 years agobtrfs/011: umount device in _cleanup
Liu Bo [Tue, 16 Jan 2018 20:10:17 +0000 (13:10 -0700)]
btrfs/011: umount device in _cleanup

btrfs/011 replaces the first device in SCRATCH_DEV_POOL in test,
which is SCRATCH_DEV, and it fails to umount SCRATCH_MNT when it
aborts, because _cleanup doesn't do any umount. This may leave
SCRATCH_DEV not used but other devices from SCRATCH_DEV_POOL still
mounted on SCRATCH_MNT. Then this results in SCRATCH_DEV unusable
for subsequent tests because _require_scratch couldn't umount detect
& umount SCRATCH_DEV correctly.

Fix it by umounting SCRATCH_MNT in _cleanup, so the test always
umounts the devices on exit.

[eguan: add comments and rewrite summary and commit log]

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Tested-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: Add 9p network filesystem support
Tuomas Tynkkynen [Thu, 11 Jan 2018 14:05:43 +0000 (16:05 +0200)]
fstests: Add 9p network filesystem support

This commit adds support for the 9p network file system, which is mainly
used by QEMU for sharing a file system from the host to the guest VM.

To run xfstests on it, launch QEMU with e.g.:

-virtfs local,path=$TMPDIR/p9-test,security_model=mapped-xattr,mount_tag=p9-test
-virtfs local,path=$TMPDIR/p9-scratch,security_model=mapped-xattr,mount_tag=p9-scratch

and inside the VM run xfstests with:

export TEST_DEV=p9-test
export SCRATCH_DEV=p9-scratch
export PLAN9_MOUNT_OPTIONS="-o trans=virtio,version=9p2000.L,cache=loose,posixacl"

Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/015: Change the test filesystem size to 101mb
Nikolay Borisov [Thu, 11 Jan 2018 09:17:47 +0000 (11:17 +0200)]
generic/015: Change the test filesystem size to 101mb

This test has been failing for btrfs for quite some time, at least
since 4.7. There are 2 implementation details of btrfs that it
exposes:

1. Currently btrfs filesystem under 100mb are created in Mixed block
group mode. Freespace accounting for it is not 100% accurate - I've
observed consistent 1mb discrepancy between a newly created
filesystem, then writing a file and deleting it and checking the
free space.

2. BTRFS won't flush it's delayed allocation on file deletion if
less than 32mb are deleted. On such files we need to perform sync
(missing in the test) or wait until time elapses for transaction
commit.

In order to avoid both of the aforementioned idiosyncrasies of the
fs make the test filesystem 101mb. With this we achieve 2 things:

1. Since the filesystem is larger we can create a file larger than
32mb, so it's going to be flushed upon deletion and numbers acquired
from df will be accurate
2. We don't create the filesystem in mixed mode and also since the
1mb is less than %1 of 101mb we will fall within the tolerance of 1%

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofilter: Introduce filter to filter out offset for xfs_io
Qu Wenruo [Thu, 11 Jan 2018 08:01:11 +0000 (16:01 +0800)]
filter: Introduce filter to filter out offset for xfs_io

Some test cases (AFAIK, btrfs RAID recovery test cases) read out
certain location to verify its data.

Such read is mostly OK, but the golden output contains the on-disk
offset, which can differ due to underlying chunk change.  (This time
is mkfs chunk layout change for btrfs)

So introduce macro _filter_xfs_io_offset to filter out the offset part
wrote 65536/65536 bytes at offset 136708096
                       ^^^^^^^^^^^^^^^^^^^^
And offset from "pread -v"
08260000:  aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa  ................
^^^^^^^^^

Only btrfs/14[0-3] are affected.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: test for umount hang caused by the pending dquota log item in AIL
Hou Tao [Thu, 11 Jan 2018 06:49:32 +0000 (14:49 +0800)]
xfs: test for umount hang caused by the pending dquota log item in AIL

When the first writeback and the retried writeback of dquota buffer
get the same IO error, XFS will let xfsaild to restart the writeback
and xfs_qm_dqflush_done() will not be invoked. xfsaild will try to
re-push the quota log item in AIL, the push will return early
everytime after checking xfs_dqflock_nowait(), and xfsaild will try
to push it again.

IOWs, AIL will never be empty, and the umount process will wait for
the drain of AIL, so the umount process hangs.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: factor out _scratch_xfs_[get|set]_sb_field
Hou Tao [Thu, 11 Jan 2018 06:49:33 +0000 (14:49 +0800)]
common/rc: factor out _scratch_xfs_[get|set]_sb_field

It's common to get and set the values of fields in XFS super block,
so factor them out as scratch_xfs_[get|set]_sb_field, reimplement
them based on _scratch_xfs_[get|set]_metadata_field, and update the
related test cases accordingly.

Also move _scratch_xfs_[get|set]_metadata_field from common/fuzzy to
common/xfs.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Hou Tao <houtao1@huawei.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agodmflakey: support error_writes feature for dm-flakey
Hou Tao [Thu, 11 Jan 2018 06:49:31 +0000 (14:49 +0800)]
dmflakey: support error_writes feature for dm-flakey

Add _require_flakey_with_error_writes() to check the availability of
dm-flakey target and its error_writes feature, and support for
enabling FLAKEY_TABLE_ERROR table by passing FLAKEY_ERROR_WRITES to
_load_flakey_table().

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agodmflakey: support multiple dm targets for a dm-flakey device
Hou Tao [Thu, 11 Jan 2018 06:49:30 +0000 (14:49 +0800)]
dmflakey: support multiple dm targets for a dm-flakey device

dm-flakey can be used to emulate IO write error, however, when we
also need to prevent the IO error for a specific range of the block
device (eg., the log region of a XFS), we need to specify multiple
dm targets for the dm device.

Option --table can not accommodate the multiple dm targets case, so
let dmsetup get the possible-multiple-targets table from standard
input.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: ext4 doesn't support O_DIRECT with data journaling
Eric Whitney [Wed, 10 Jan 2018 21:19:05 +0000 (16:19 -0500)]
common/rc: ext4 doesn't support O_DIRECT with data journaling

Modify _require_odirect() to skip O_DIRECT tests if the ext4 mount
option data=journal has been applied.  Because ext4 disables its
O_DIRECT support when in data journaling mode, no significant value
is obtained by running these tests and they consume a significant
amount of run time.  Additionally, this change eliminates the need
to triage false negative O_DIRECT test results caused by test
problems, as has occurred from time to time.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: perform _require_metadata_journaling check on overlay base fs
Chengguang Xu [Sat, 6 Jan 2018 08:23:58 +0000 (16:23 +0800)]
common/rc: perform _require_metadata_journaling check on overlay base fs

Currently generic shutdown tests are enabled on overlayfs by
extending _require_scratch_shutdown() to check shutdown support for
overlayfs, some of those tests also call
_require_metadata_journaling() to inspect whether test filesystem
support metadata journaling or not, so need to extend
_require_metadata_journaling() as well to check metadata journaling
support for overlayfs in case shutdown tests run on uncommon
overlayfs setup and fail. For example, base filesystem of overlayfs
is ext2 or ext4 with noload mode.

Metadata journaling check is based on base filesystem configurations
and  because -overlay option saves those configurations to
OVL_BASE_*, adding restore/override the configurations before/after
the check.

Tested ext2, xfs, ext4(load/no-load mode) as base filesystem of
overlayfs in single and multi section configurations.

[eguan: update _notrun message]

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: find libxfs api violations
Darrick J. Wong [Wed, 3 Jan 2018 19:22:00 +0000 (11:22 -0800)]
xfs: find libxfs api violations

New test to run tools/find-api-violations.sh in xfsprogs.

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>
4 years agoext4: test for inline data + DAX corruption
Ross Zwisler [Thu, 4 Jan 2018 08:11:21 +0000 (01:11 -0700)]
ext4: test for inline data + DAX corruption

Add a regression test for the following kernel commit:

  ext4: prevent data corruption with inline data + DAX

The test passes either if we don't encounter corruption, or if
mounting with DAX + inline data fails.  The latter is the way that
we prevent this issue in the kernel.

[eguan: add 'dax' group]

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>
4 years agoext4: test for DAX + journaling corruption
Ross Zwisler [Thu, 4 Jan 2018 08:11:20 +0000 (01:11 -0700)]
ext4: test for DAX + journaling corruption

Add a regression test for the following kernel commit:

  ext4: prevent data corruption with journaling + DAX

The test passes if either we successfully compare the data between
the mmap with journaling turned on and the one with journaling
turned off, or if we fail the chattr command to turn on or off
journaling.  The latter is how we prevent this issue in the kernel.

[eguan: add 'dax' group]

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>
4 years agoxfs/068: fix clonerange problems in file/dir count output
Darrick J. Wong [Wed, 13 Dec 2017 23:28:05 +0000 (15:28 -0800)]
xfs/068: fix clonerange problems in file/dir count output

In this test we use a fixed sequence of operations in fsstress to
create some number of files and dirs and then exercise
xfsdump/xfsrestore on them.  Since clonerange/deduperange are not
supported on all xfs configurations, detect if they're in fsstress
and disable them so that we always execute exactly the same sequence
of operations no matter how the filesystem is configured.

[eguan: move it from xfs/068 to common/dump as Dave suggested]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Suggested-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: make sure scrub fixes raid6 corruption
Liu Bo [Tue, 2 Jan 2018 20:35:00 +0000 (13:35 -0700)]
btrfs: make sure scrub fixes raid6 corruption

This is to reproduce a bug of scrub, with which scrub is unable to
repair raid6 corruption as expected.

The kernel side fixes are
  Btrfs: make raid6 rebuild retry more
  Btrfs: fix scrub to repair raid6 corruption

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>
4 years agogeneric: run a long-soak write-only fsstress test
Darrick J. Wong [Wed, 13 Dec 2017 06:04:04 +0000 (22:04 -0800)]
generic: run a long-soak write-only fsstress test

Let a lot of writes soak in with multithreaded fsstress to look for
bugs and other problems.

[eguan: remove '-v' option of fsstress and remove 'clone' group]

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>
4 years agogeneric/050: fix _require_local_device $SCRATCH_DEV check order
Luis Henriques [Tue, 2 Jan 2018 17:17:05 +0000 (17:17 +0000)]
generic/050: fix _require_local_device $SCRATCH_DEV check order

Commit 2b4eae7fd825 ("common/rc: add scratch shutdown support for
overlayfs") added a _require_local_device check to generic tests 042
and 050.  However, for test 050, this check was added _before_
actually verifying that a SCRATCH_DEV actually exists.  This patch
simply re-orders the _require_local_device to the right place.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofsstress: implement the clonerange/deduperange ioctls
Darrick J. Wong [Fri, 15 Dec 2017 02:07:31 +0000 (18:07 -0800)]
fsstress: implement the clonerange/deduperange ioctls

Mix it up a bit by reflinking and deduping data blocks when
possible.

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>
4 years agogeneric: test error shutdown while stressing filesystem
Darrick J. Wong [Wed, 13 Dec 2017 06:03:48 +0000 (22:03 -0800)]
generic: test error shutdown while stressing filesystem

Test log recovery with repeated (simulated) disk failures.  We kick
off fsstress on the scratch fs, then switch out the underlying
device with dm-error to see what happens when the disk goes down.
Having taken down the fs in this manner, remount it and repeat.
This test is a Good Enough (tm) simulation of our internal multipath
failure testing efforts.

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>
4 years agoext4: use a slightly bigger file system in ext4/021
Theodore Ts'o [Fri, 22 Dec 2017 18:26:07 +0000 (13:26 -0500)]
ext4: use a slightly bigger file system in ext4/021

An 8 MB file system may not be big enough for certain file system
configurations --- in particular, if the inode size is 2048 bytes.
Make the test file system 10MB instead.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/encrypt: Create an encrypted equivalent of _scratch_mkfs_sized
Ari Sundholm [Thu, 21 Dec 2017 22:10:05 +0000 (00:10 +0200)]
common/encrypt: Create an encrypted equivalent of _scratch_mkfs_sized

Test case generic/399 hardcodes "-O encrypt" in MKFS_OPTIONS when
calling _scratch_mkfs_sized, which only works with the mkfs of
certain filesystems. Create a new helper,
_scratch_mkfs_sized_encrypted, for handling the differences between
the mkfs tools of different filesystems. It also allows those
filesystems whose mkfs doesn't accept "-O encrypt" to skip the test
gracefully until proper support is added for them in the helper.

ubifs is not supported in the new helper despite supporting
encryption, as _scratch_mkfs_sized has no ubifs support and adding
that should be done in a separate patch.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: Add new 'limit' test group for btrfs
Qu Wenruo [Tue, 26 Dec 2017 05:57:44 +0000 (13:57 +0800)]
btrfs: Add new 'limit' test group for btrfs

Btrfs qgroup also supports to limit the usage of specified qgroups.

It's possible to enable qgroup but doesn't enable limit.
(Most user won't use qgroup limit for various problems)

So add a new test group 'limit' for btrfs, as a subset of existing
'qgroup' group.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/040: document purpose
Luis R. Rodriguez [Fri, 15 Dec 2017 20:41:18 +0000 (12:41 -0800)]
xfs/040: document purpose

Getting xfs/040 to "pass" takes a bit of effort, however the effort
to require updating xfsprogs is purely an xfsprogs maintainer task
only. There no functional gain by users of xfs or a QA team to get
this test to pass. This is not trivial from the current description
so document this.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: add syncfs test
Chengguang Xu [Fri, 15 Dec 2017 07:47:35 +0000 (15:47 +0800)]
generic: add syncfs test

Inspired by syncfs bug of overlayfs which does not sync dirtyinodes
in underlying filesystem.

Run syncfs and shutdown filesystem(or underlying filesystem of
overlayfs) to check syncfs result.

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: check syncfs support
Chengguang Xu [Fri, 15 Dec 2017 07:47:34 +0000 (15:47 +0800)]
common/rc: check syncfs support

Add a check case in _require_xfs_io_command() to support syncfs

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: add scratch shutdown support for overlayfs
Chengguang Xu [Fri, 15 Dec 2017 07:47:33 +0000 (15:47 +0800)]
common/rc: add scratch shutdown support for overlayfs

Enable shutdown tests on overlayfs. This requires configuring
overlayfs with TEST|SCRATCH_DEV pointing to block device, which act
as base fs of overlay. The legacy config (pointing TEST|SCRATCH_DEV
to existing directories) won't support shutdown.

Extend _require_scratch_shutdown() to deal with overlay by checking
shutdown support on $OVL_BASE_SCRATCH_MNT instead of $SCRATCH_MNT,
so we check shutdown support status against the underlying upper fs
of overlay.

Introduce new _scratch_shutdown() helper to do the actual shutdown
work and shutdown upper fs in the case of overlay. Also converting
existing bare 'src/godown' calls to use this helper to avoid false
failures when testing overlayfs.

generic/042 and generic/050 assume $SCRATCH_DEV to be a local
device, so add _require_local_device $SCRATCH_DEV rule.

[eguan: rewrite commit log]

Signed-off-by: Chengguang Xu <cgxu519@icloud.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofsstress: getcwd() return value fixes
Ari Sundholm [Wed, 20 Dec 2017 17:00:11 +0000 (19:00 +0200)]
fsstress: getcwd() return value fixes

Add a check for the return value of getcwd(). Fix another check
which mistakenly checks if the return value is less than zero
instead of checking whether the return value is NULL.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofsstress: Eliminate valgrind noise
Ari Sundholm [Wed, 20 Dec 2017 17:00:10 +0000 (19:00 +0200)]
fsstress: Eliminate valgrind noise

This patch plugs what we think are the remaining sources of valgrind
noise we found when running fsstress under valgrind.  The noise is
caused by memory being left unfreed before process termination.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoREADME: document group fsgqa is required
Luis R. Rodriguez [Wed, 13 Dec 2017 00:45:12 +0000 (16:45 -0800)]
README: document group fsgqa is required

The group fsgqa is also required.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: fix tests to handle removal of no-alloc create nonfeature
Darrick J. Wong [Wed, 13 Dec 2017 22:45:01 +0000 (14:45 -0800)]
xfs: fix tests to handle removal of no-alloc create nonfeature

We're removing from XFS the ability to perform no-allocation file
creation.  This was added years ago because some customer of SGI
demanded that we still be able to create (empty?) files with zero
free blocks remaining so long as there were free inodes and space in
existing directory blocks.  This came at an unacceptable risk of
ENOSPC'ing midway through a transaction and shutting down the fs, so
we're removing it for the create case having changed our minds 20
years later.

However, some tests fail as a result, so fix them to be more
flexible about not failing when a dir/file creation fails due to
ENOSPC.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/45[34]: test line draw characters in file/attr names
Darrick J. Wong [Wed, 13 Dec 2017 06:03:34 +0000 (22:03 -0800)]
generic/45[34]: test line draw characters in file/attr names

Try to draw a multiline rectangular outline in a file name and xattr
name, just to see if we can.

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>
4 years agocommon/xfs: fix scrub support probing again
Darrick J. Wong [Wed, 13 Dec 2017 06:03:26 +0000 (22:03 -0800)]
common/xfs: fix scrub support probing again

In the final version of the xfs_io scrub command we don't allow the
probe function to have any parameters, so fix the helper to abide
that.

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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>