xfstests-dev.git
3 years agocommon/rc: fix check for disabled kmemleak
Amir Goldstein [Sat, 22 Sep 2018 15:23:39 +0000 (18:23 +0300)]
common/rc: fix check for disabled kmemleak

With kernel commit b353756b2b71 ("kmemleak: always register debugfs
file") that was merged to v4.19-rc3, the kmemleak debugfs knob
exists even if kmemleak is disabled, but returns EBUSY on write.

Suppress EBUSY errors in tests by disabling _check_kmemleak() calls
if the write to kmemleak knob failed on _init_kmemleak().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs/149: make it sectorsize independent
Anand Jain [Sun, 16 Sep 2018 10:52:08 +0000 (18:52 +0800)]
btrfs/149: make it sectorsize independent

Originally this test case was designed to work with 4K sectorsize.
Now enhance it to work with any sector sizes and makes the following
changes:
.out file not to contain any traces of sector size.
Use max_inline=0 mount option so that it meets the requisite of non inline
regular extent.
Don't log the md5sum results to the output file as the data size vary by
the sectorsize.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoshared/010: avoid dedupe testing blocked on large fs
Zorro Lang [Wed, 12 Sep 2018 10:15:47 +0000 (18:15 +0800)]
shared/010: avoid dedupe testing blocked on large fs

When test on large fs (--large-fs), xfstests preallocates a large
file in SCRATCH_MNT/ at first. Duperemove will take too long time
to deal with that large file (many days on 500T XFS). So move
working directory to a sub-dir underlying $SCRATCH_MNT/.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/498: don't call _cleanup_flakey repeatedly
Lu Fengqi [Tue, 4 Sep 2018 06:26:50 +0000 (14:26 +0800)]
generic/498: don't call _cleanup_flakey repeatedly

Since exit always traps into _cleanup function which contains
_cleanup_flakey, don't need _cleanup_flakey twice.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agotmpfs: don't require {TEST|SCRATCH}_DEV
Miklos Szeredi [Mon, 3 Sep 2018 12:27:28 +0000 (14:27 +0200)]
tmpfs: don't require {TEST|SCRATCH}_DEV

tmpfs doesn't require a device and the source argument of the mount
is ignored.  If {TEST|SCRATCH}_DEV is not given then set them to
proper strings.

[Eryu: don't require SCRATCH_DEV too]

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/504: Check inode number accurately
Xiao Yang [Mon, 3 Sep 2018 09:36:20 +0000 (17:36 +0800)]
generic/504: Check inode number accurately

If inode number is equal to the line number of locks which is
first column in /proc/locks, generic/504 will match wrong number
and get PASS. For example:
-----------------------------------------------------------
inode 12
...
12: FLOCK  ADVISORY  WRITE 1615 00:2e:37889 0 EOF
-----------------------------------------------------------

We should match correct inode number by six column in /proc/locks.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/009: fix test failure with overlay over ext4
Amir Goldstein [Mon, 27 Aug 2018 18:29:26 +0000 (21:29 +0300)]
generic/009: fix test failure with overlay over ext4

When running test with overlayfs and ext4 as base fs, we need to
disable extent zeroout on the underlying base fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: do not set OVL_BASE_FSTYP value to "overlay"
Amir Goldstein [Mon, 27 Aug 2018 18:29:25 +0000 (21:29 +0300)]
overlay: do not set OVL_BASE_FSTYP value to "overlay"

The purpose of OVL_BASE_FSTYP is to store the value of FSTYP that is
found in a host config file section.

When there is no host config file or if user sets FSTYP=overlay in config
file, it makes no sense to store the value "overlay" in OVL_BASE_FSTYP
and it is better to leave it empty or leave its current value in tact.

This allows user to set OVL_BASE_FSTYP in config file or before running
the test to support queries about base fs, such as
_require_metadata_journaling, even when running an overlay test.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/seek_sanity_test: skip test20 if file's too big
Luis Henriques [Mon, 27 Aug 2018 13:12:11 +0000 (14:12 +0100)]
src/seek_sanity_test: skip test20 if file's too big

Since the allocation size can be quite big for some filesystems
(4194304 for cephfs), the pwrite operation in test20 may fail with
EFBIG.  Skip this test if that's the case.

Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay/016: split into two tests
Amir Goldstein [Fri, 24 Aug 2018 04:40:44 +0000 (07:40 +0300)]
overlay/016: split into two tests

overlay/016 tests two cases of ro/rw fd data inconsistecies -
one using pread and one using mmap read (i.e. mread).

The first case now passes with stacked overlay file operations
patch set merged. The second case will still fail.

By splitting the two test cases we get one regression test for
the common case of ro/rw fd data inconsistecy with pread and
one test to track the remaining non-standard behavior of
overlayfs w.r.t mmap.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoopen_by_handle: fix name of directory in error messages
Amir Goldstein [Fri, 24 Aug 2018 04:27:55 +0000 (07:27 +0300)]
open_by_handle: fix name of directory in error messages

dirname() modifies the string in dname, but we use that string
in error messages later on to print the test dir name.
Make another copy of test_dir for passing to dirname().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: filter redundant output by getfattr
Zorro Lang [Thu, 23 Aug 2018 02:41:24 +0000 (10:41 +0800)]
fstests: filter redundant output by getfattr

When getfattr dumps values of all extended attributes (-d option),
it doesn't print empty extended attributes. e.g: user.name. But from
attr-2.4.48 this behavior is changed,  new getfattr prints
user.name="".

The {=""} will break the golden image, so filter the redundant =""
at the end if it has.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: Fix buffer alignment of aiocp
Xiao Yang [Wed, 15 Aug 2018 05:41:45 +0000 (13:41 +0800)]
fstests: Fix buffer alignment of aiocp

In generic/252, aiocp with DIRECT will fail and return EINVAL on
4096 sector size block device, because the default 512 alignment
defined in aiocp is not aligned with 4096.

Please see the following error:
----------------------------------------------------------
read missing bytes expect 8388608 got -22
----------------------------------------------------------

We use '-a' option to specify a proper alignment size in all tests
that call aiocp with DIRECT.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: Add test for corrupted childless qgroup numbers
Qu Wenruo [Mon, 13 Aug 2018 05:22:05 +0000 (13:22 +0800)]
btrfs: Add test for corrupted childless qgroup numbers

This bug is exposed by populating a high level qgroup, and then make
it childless with old qgroup numbers, and finally do rescan.

Normally rescan should zero out all qgroups' accounting number, but
due to a kernel bug which won't mark childless qgroups dirty, their
on-disk data is never updated, thus old numbers remain and cause
qgroup corruption.

Fixed by the following kernel patch:
"btrfs: qgroup: Dirty all qgroups before rescan"

[Eryu: removed useless _filter_xfs_io]

Reported-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: show locks info owned by dead process
Xiong Murphy Zhou [Thu, 9 Aug 2018 07:53:53 +0000 (15:53 +0800)]
generic: show locks info owned by dead process

Regression test case for kernel patchset:
    fs/lock: show locks info owned by dead/invisible processes

Open new fd by exec shell built-in, then require exclusive lock
by flock(1) command. Checking /proc/locks for the lock info.

This patchset post by Konstantin Khorenko <khorenko@virtuozzo.com>
has not been merged v4.18-rc8.

[Eryu: require $FLOCK_PROG and add more comments]

Signed-off-by: Xiong Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/288: notrun if xfs_db write command fails
Zorro Lang [Fri, 10 Aug 2018 03:26:32 +0000 (11:26 +0800)]
xfs/288: notrun if xfs_db write command fails

Old xfsprogs can't change attr hdr.count to 0 on v5 filesystems, two
reasons maybe cause this issue:

1) This commit has been merged: 89baf918(xfs_db: write values into
   dir/attr blocks and recalculate CRCs).
2) xfs_db write command doesn't support -d option.

That's not a real bug, so skip this test if xfs_db can't set attr
hdr.count to 0.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/228: fix restoration of kernel.core_pattern sysctl
Omar Sandoval [Thu, 9 Aug 2018 21:40:12 +0000 (14:40 -0700)]
generic/228: fix restoration of kernel.core_pattern sysctl

generic/228 changes kernel.core_pattern, so it saves it beforehand in
order to restore it. However, it adds an extra space in the process:

$ echo \"$(sysctl kernel.core_pattern | awk -F = '{print $NF}')\"
" |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h %e"

Instead of using awk, just use sysctl -n to only print the value.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/stat_test: fix undefined reference to `xfstests_statx'
Lu Fengqi [Tue, 7 Aug 2018 12:35:51 +0000 (20:35 +0800)]
src/stat_test: fix undefined reference to `xfstests_statx'

Since glibc 2.28 has added the statx function after commit
fd70af45528d ("Add the statx function"), stat_test.c will include
/usr/include/bits/statx.h eventually by "include <sys/stat.h>". That
causes the STATX_TYPE has already been defined before include
"status.h", then xfstests_statx will not be defined.

So make fails with the following error message:

/usr/bin/ld: /tmp/cc2Isfch.o: in function `main':
/home/luke/workspace/xfstests-dev/src/stat_test.c:690: undefined reference to `xfstests_statx'
/usr/bin/ld: /tmp/cc2Isfch.o: in function `get_reference':
/home/luke/workspace/xfstests-dev/src/stat_test.c:301: undefined reference to `xfstests_statx'
/usr/bin/ld: /tmp/cc2Isfch.o: in function `main':
/home/luke/workspace/xfstests-dev/src/stat_test.c:642: undefined reference to `xfstests_statx'

Just move out the definition of xfstests_statx between "#ifndef
STATX_TYPE" and "#endif /* STATX_TYPE */".

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test writing into unwritten extent right before snapshotting
Filipe Manana [Mon, 6 Aug 2018 08:08:39 +0000 (09:08 +0100)]
btrfs: test writing into unwritten extent right before snapshotting

Test that if we write into an unwritten extent of a file when there
is no more space left to allocate in the filesystem and then
snapshot the file's subvolume, after a clean shutdown the data was
not lost.

This test is motivated by a bug found by Robbie Ko for which there
is a fix whose patch title is:

  "Btrfs: fix unexpected failure of nocow buffered writes after
   snapshotting when low on space"

Reported-by: Robbie Ko <robbieko@synology.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test inode allocation state missmatch corruption
Zorro Lang [Mon, 30 Jul 2018 07:15:51 +0000 (15:15 +0800)]
xfs: test inode allocation state missmatch corruption

There's a situation where the directory structure and the inobt
thinks the inode is free, but the inode on disk thinks it is still
in use. XFS should detect it and prevent the kernel from oopsing on
lookup.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/057: Update test case to keep subvolume in any kernel version
Misono Tomohiro [Fri, 3 Aug 2018 06:44:37 +0000 (15:44 +0900)]
btrfs/057: Update test case to keep subvolume in any kernel version

Since commit a79a464d5675 ("btrfs: Allow rmdir(2) to delete an empty
subvolume"), rm -r can delete a subvolume too.

This test assumes that rm -r does not delete a subvolume.
Currently the commit does not affect the test since qgroup items
still exist after subvolume deletion, but we plan to change the
behavior and remove them along with subvolume deletion.

So update the test and keep subvolume (and qgroup item) in any kernel
version.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test send with prealloc extent beyond EOF and hole punching
Filipe Manana [Mon, 30 Jul 2018 11:40:17 +0000 (12:40 +0100)]
btrfs: test send with prealloc extent beyond EOF and hole punching

Test that an incremental send operation produces correct results if
a file that has a prealloc (unwritten) extent beyond its EOF gets a
hole punched in a section of that prealloc extent.

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

 "Btrfs: send, fix incorrect file layout after hole punching beyond eof"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/288: use -d option of xfs_db write command for v5 XFS
Zorro Lang [Sun, 29 Jul 2018 14:20:53 +0000 (22:20 +0800)]
xfs/288: use -d option of xfs_db write command for v5 XFS

The commit b3cf8b72334fd35ef961869506e5a72ab398bc82 update xfs/288
to support v5 filesystem testing. That commit thought xfs_db write
command can work well with -d option on V5 XFS. But the truth is the
case doesn't use that option.

So turn to use _scratch_xfs_set_metadata_field, it will help to use
proper options for xfs_db write command.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test DAX DMA vs truncate/hole-punch
Ross Zwisler [Fri, 27 Jul 2018 21:12:52 +0000 (15:12 -0600)]
generic: test DAX DMA vs truncate/hole-punch

This adds a regression test for the following series:

[PATCH v4 0/2] ext4: fix DAX dma vs truncate/hole-punch
https://lists.01.org/pipermail/linux-nvdimm/2018-July/016842.html

which adds synchronization between DAX DMA in ext4 and truncate/hole-punch.
The intention of the test is to test those specific changes, but it runs
fine both with XFS and without DAX so I've put it in the generic tests
instead of ext4 and not restricted it to only DAX configurations.

When run with v4.18-rc6 + DAX + ext4, this test will hit the following
WARN_ON_ONCE() in dax_disassociate_entry():

WARN_ON_ONCE(trunc && page_ref_count(page) > 1);

If you change this to a WARN_ON() instead, you can see that each of the
four paths being exercised in this test hits that condition many times in
the one second that the subtest is being run.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test send with snapshots that have files deleted while open
Filipe Manana [Mon, 23 Jul 2018 08:11:03 +0000 (09:11 +0100)]
btrfs: test send with snapshots that have files deleted while open

Test that we are able to do send operations when one of the source
snapshots (or subvolume) has a file that is deleted while there is
still a open file descriptor for that file.

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

  "Btrfs: fix send failure when root has deleted files still open"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: add test for fsync after renaming hard links of same file
Filipe Manana [Thu, 19 Jul 2018 18:02:20 +0000 (19:02 +0100)]
generic: add test for fsync after renaming hard links of same file

Test that if we have a file with 2 (or more) hard links in the same
parent directory, rename of the hard links, rename one of the other
hard links to the old name of the hard link we renamed before,
create a new file in the same parent directory with the old name of
second hard link we renamed, fsync fsync this new file and power
fail, we will be able to mount again the filesystem and the new file
and all hard links exist.

This test is motivated by a bug found in btrfs, where mounting the
filesystem after the power failure resulted in failure with an errno
value of EEXIST, which is fixed by a patch for the linux kernel
titled:

  "Btrfs: fix mount failure after fsync due to hard link recreation"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobuild: replace lowercase letters regex with POSIX character class in Makefile
Zorro Lang [Thu, 19 Jul 2018 10:03:49 +0000 (18:03 +0800)]
build: replace lowercase letters regex with POSIX character class in Makefile

Latest glibc changed some rules of sorting and regexes, the usage
likes "[a-z]" maybe not only stand for lowcase letters a..z in
different locale. Similar issues include [A-Z], [0-9] and so on.

For example, in en_US.UTF-8 locale, [a-z] means aAbBcCdD...zZ, it
stands for both of uppercase and lowercase. Currently this issue
cause `make install` fails on system with new glibc.

So use POSIX character class to instead of [...] group, something
likes [:lower:], [:upper:], [:alpha:], [:alnum:], etc... are common.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/: add license and copyright info to files
Ross Zwisler [Tue, 10 Jul 2018 22:09:41 +0000 (16:09 -0600)]
src/: add license and copyright info to files

Add copyright and license info to files that I've authored in src/.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
4 years agogeneric: add test for fsync after cloning file range
Filipe Manana [Thu, 12 Jul 2018 00:38:11 +0000 (01:38 +0100)]
generic: add test for fsync after cloning file range

Test that if we do a buffered write to a file, fsync it, clone a
range from another file into our file that overlaps the previously
written range, fsync the file again and then power fail, after we
mount again the filesystem, no file data was lost or corrupted.

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

  "Btrfs: fix file data corruption after cloning a range and fsync"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon: filter out quota regeneration messages
Darrick J. Wong [Wed, 4 Jul 2018 04:51:31 +0000 (21:51 -0700)]
common: filter out quota regeneration messages

Filter out quota regeneration messages from xfs_repair when we check
the filesystem, because the xfs tests that encode xfs_repair output
in the golden output will fail when quotas are enabled and the
xfs_repair quota messages appear.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/338: don't check fs after crashing it
Darrick J. Wong [Wed, 4 Jul 2018 04:51:25 +0000 (21:51 -0700)]
generic/338: don't check fs after crashing it

This test tries to make the filesystem go down by setting up
dm-error and committing metadata updates.  Since the test doesn't
remount the fs after it goes down to recover the log, this can
result in a dirty log being presented to the post-test filesystem
check if the filesystem is xfs and quotas are enabled.

Since this is a regression test for a NULL pointer dereference in
the kernel after the fs goes down, simply skip the post-test fsck.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/288: update for v5 filesystem support in xfs_db
Darrick J. Wong [Wed, 4 Jul 2018 04:51:18 +0000 (21:51 -0700)]
xfs/288: update for v5 filesystem support in xfs_db

The xfs_db 'write -d' command has supported v5 filesystems for a few
releases now, and there's nothing about this test that require v4,
so let the test run with v5 if the user so specifies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/001: update to handle v5 filesystems
Darrick J. Wong [Wed, 4 Jul 2018 04:51:06 +0000 (21:51 -0700)]
xfs/001: update to handle v5 filesystems

xfs/001 fuzzes various extent fields using xfs_db.  There's nothing
in it that's specific to v4 filesystems, so upgrade the test to be
able to handle v5 filesystems.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/{279, 28[1-3]}: hide SIGBUS reporting from golden output
Darrick J. Wong [Wed, 4 Jul 2018 04:50:53 +0000 (21:50 -0700)]
generic/{279, 28[1-3]}: hide SIGBUS reporting from golden output

These four tests check that mmap'd cow writes fail when the
filesystem goes down.  For regular filesystems the msync reports
EIO, but if quotas are enabled on xfs the write itself terminates
xfs_io with a SIGBUS.  We don't care how the write fails, so don't
let the SIGBUS report escape to the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test dm-thin running out of data space vs concurrent discard
Zorro Lang [Thu, 12 Jul 2018 05:08:50 +0000 (13:08 +0800)]
generic: test dm-thin running out of data space vs concurrent discard

If a user constructs a test that loops repeatedly over below steps
on dm-thin, block allocation can fail due to discards not having
completed yet (Fixed by a685557 dm thin: handle running out of data
space vs concurrent discard):

1) fill thin device via filesystem file
2) remove file
3) fstrim

And this maybe cause a deadlock (fast device likes ramdisk can help
a lot) when racing a fstrim with a filesystem (XFS) shutdown. (Fixed
by 8c81dd46ef3c Force log to disk before reading the AGF during a
fstrim)

This case can reproduce both two bugs if they're not fixed. If only
the dm-thin bug is fixed, then the test will pass. If only the fs
bug is fixed, then the test will fail. If both of bugs aren't fixed,
the test will hang.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/xfs: remove bad xfs_repair -t option
Zorro Lang [Tue, 10 Jul 2018 09:41:29 +0000 (17:41 +0800)]
common/xfs: remove bad xfs_repair -t option

The xfs_repair "-t" option shouldn't be used alone. An interval must
follow the -t option, or xfs_repair will report errors. And only
modify reporting interval is useless, if we don't enable ag_stride.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/499: filter fsx stderr output
Zorro Lang [Tue, 10 Jul 2018 12:52:43 +0000 (20:52 +0800)]
generic/499: filter fsx stderr output

On some old kernel which supports COLLAPSE_RANGE and ZERO_RANGE, but
doesn't support INSERT_RANGE, this case alway fails as:

   QA output created by 499
  +main: filesystem does not support fallocate mode FALLOC_FL_INSERT_RANGE, disabling!
   Silence is golden

fsx print one more line to break the golden image.

To fix this issue, redirect both fsx stdout and stderr to a file,
then check the return value.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: fuzz every field of every structure and test kernel crashes
Darrick J. Wong [Fri, 6 Jul 2018 14:41:46 +0000 (07:41 -0700)]
xfs: fuzz every field of every structure and test kernel crashes

Fuzz every field of every structure and then try to write the
filesystem, to see how many of these writes can crash the kernel.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agonfs/001: ignore the header in nfs4_getfacl output
Scott Mayhew [Fri, 6 Jul 2018 15:37:38 +0000 (11:37 -0400)]
nfs/001: ignore the header in nfs4_getfacl output

nfs4-acl-tools commit 6630629bb661 ("nfs4_getfacl: Add support to
accept more paths") added a header to the nfs4_getfacl output.  Make
sure the test is only counting the number of ACEs.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: skip copy fs test on large device
Zorro Lang [Fri, 6 Jul 2018 06:07:28 +0000 (14:07 +0800)]
xfs: skip copy fs test on large device

When test on large SCRATCH_DEV, copy a huge size XFS to TEST_DIR
will fill the TEST_DIR soon, and xfs_copy process will be blocked
there. Due to copy LARGE_SCRATCH_DEV won't add any more test
coverage, so skip this kind of tests if LARGE_SCRATCH_DEV is yes.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: mread past eof shows nonzero contents
Darrick J. Wong [Wed, 4 Jul 2018 04:50:30 +0000 (21:50 -0700)]
generic: mread past eof shows nonzero contents

Certain sequences of generic/127 invocations complain about being
able to mread nonzero contents past eof.  Replicate that here as a
regression test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/262: remove -y parameter
Liu Yiding [Thu, 5 Jul 2018 01:37:03 +0000 (09:37 +0800)]
xfs/262: remove -y parameter

Since commit 66f7b4c2ce14 ("xfs_scrub: remove -y parameter") has
removed parameter -y, -y is an invalid option.

Signed-off-by: Liu Yiding <liuyd.fnst@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobuild: fix undefined macro: AC_PACKAGE_NEED_GETXATTR_LIBATTR
Lu Fengqi [Mon, 2 Jul 2018 07:00:01 +0000 (15:00 +0800)]
build: fix undefined macro: AC_PACKAGE_NEED_GETXATTR_LIBATTR

Because the macro AC_PACKAGE_NEED_GETXATTR_LIBATTR was removed by
the following commit specified by fixes tag, we also need remove
AC_PACKAGE_NEED_GETXATTR_LIBATTR from configure.ac.

In addition, the libattr will not be set after the macro being
removed. This cause gcc fail to link the libattr for fsstress
correctly. The macro AC_PACKAGE_NEED_ATTRGET_LIBATTR has been
obsoleted, so change it to AC_PACKAGE_NEED_ATTRSET_LIBATTR and add
it to configure.ac. It can help check libattr and set libattr
variable.

Fixes: 42b851446ff1 ("build: remove <attr/xattr.h> check")
Reported-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Tested-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobuild: remove <attr/xattr.h> check
Lu Fengqi [Wed, 27 Jun 2018 10:18:54 +0000 (18:18 +0800)]
build: remove <attr/xattr.h> check

Since fsstress and src/t_immutable don't need attr/xattr.h, just
remove <attr/xattr.h> and getxattr(2) check.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/t_immutable: use sys/xattr.h instead of attr/xattr.h
Lu Fengqi [Wed, 27 Jun 2018 10:18:53 +0000 (18:18 +0800)]
src/t_immutable: use sys/xattr.h instead of attr/xattr.h

Since attr v2.4.48 has removed <attr/xattr.h>, use <sys/xattr.h>
provided by glibc.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: remove include <attr/xattr.h>
Lu Fengqi [Wed, 27 Jun 2018 10:18:52 +0000 (18:18 +0800)]
fsstress: remove include <attr/xattr.h>

Since commit de6d86177ff8 ("QA test updates - fixes for pquota,
extsize, fsstress, and ensure mount options passed through to
test_dev. Merge of master-melb:xfs-cmds:24763a by kenmcd.") remove
llistxattr from fsstress, xattr.h is useless.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test if btrfs will corrupt nodatasum compressed extent when replacing device
Qu Wenruo [Thu, 14 Jun 2018 06:30:53 +0000 (14:30 +0800)]
btrfs: test if btrfs will corrupt nodatasum compressed extent when replacing device

This is a long existing bug (from 2012) but exposed by a reporter
recently, that when compressed extent without data csum get written
to device-replace target device, the written data is in fact
uncompressed data other than the original compressed data.

And since btrfs still consider the data is compressed and will try
to read it as compressed, it can cause read error.

This is fixed by kernel commit ac0b4145d662 ("btrfs: scrub: Don't
use inode pages for device replace")

Reported-by: James Harvey <jamespharvey20@gmail.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobuild: fix install target using sudo
Luis R. Rodriguez [Wed, 27 Jun 2018 16:03:55 +0000 (09:03 -0700)]
build: fix install target using sudo

If you install with:

sudo make install

Depending on the system, you may see that /var/lib/xfstests/
installed properly but /var/lib/xfstests/tests/ is empty and so your
install really is broken and not functional. Finding out what went
wrong is not obvious.

The issue is caused due to the fact that $(PWD) is used nad if sudo
is used this can be empty on some systems.

PWD is only used on one target on the xfstests build system, the
tests/*/ dir install target.

We can fix this by using $(CURDIR) instead.

This issue is observed on both Fedora and OpenSUSE, but not on
Debian.

Signed-off-by: Luis R. Rodriguez <mcgrof@kernel.org>
Suggested-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test bad character in xfs_db field list selector string
Zorro Lang [Wed, 27 Jun 2018 16:59:57 +0000 (00:59 +0800)]
xfs: test bad character in xfs_db field list selector string

Bad characters likes tailing asterisk, slash or quote in xfs_db
field string can trigger a xfs_db crash. This bug has been fixed by
xfsprogs commit 945e47e2fcc5 ("xfs_db: fix crash when field list
selector string has trailing slash").

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test power failure while qgroups rescan is in progress
Filipe Manana [Tue, 26 Jun 2018 23:43:27 +0000 (00:43 +0100)]
btrfs: test power failure while qgroups rescan is in progress

Test that if a power failure happens on a filesystem with quotas
(qgroups) enabled while the quota rescan kernel thread is running,
we will be able to mount the filesystem after the power failure.

This test is motivated by a recent regression introduced in the
linux kernel's 4.18 merge window and is fixed by a patch with the
title:

  "Btrfs: fix mount failure when qgroup rescan is in progress"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon: Add _dmsetup_create and _dmsetup_remove helpers
Xiao Yang [Thu, 28 Jun 2018 01:45:34 +0000 (09:45 +0800)]
common: Add _dmsetup_create and _dmsetup_remove helpers

Make sure both "$UDEV_SETTLE_PROG" and "mknodes" can always
be run after a dm create or remove operation.

Suggested-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared: dedupe with random io race test
Zorro Lang [Sat, 23 Jun 2018 18:00:29 +0000 (02:00 +0800)]
shared: dedupe with random io race test

Run several duperemove processes with fsstress on same directory at
same time. Make sure the race won't break the fs or kernel.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared: iterate dedupe integrity test
Zorro Lang [Sat, 23 Jun 2018 18:00:28 +0000 (02:00 +0800)]
shared: iterate dedupe integrity test

This case does dedupe on a dir, then copy the dir to next dir.
Dedupe the next dir again, then copy this dir to next again, and
dedupe again ... At the end, verify the data in the last dir is
still same with the first one.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared: dedupe a single big file and verify integrity
Zorro Lang [Sat, 23 Jun 2018 18:00:27 +0000 (02:00 +0800)]
shared: dedupe a single big file and verify integrity

Duperemove is a tool for finding duplicated extents and submitting
them for deduplication, and it supports XFS. This case trys to
verify the integrity of XFS after running duperemove.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: Test root inode parent pointer repairing
Marco Benatto [Fri, 22 Jun 2018 18:03:57 +0000 (15:03 -0300)]
xfs: Test root inode parent pointer repairing

Recently we found out xfs_repair were not repairing root inode
parent pointer when root inode is on short-form and parent points to
an invalid inode number (refer to: "xfs_repair: Fix root inode's
parent when it's bogus for sf directory" on xfs-devel list).

This test checks if xfs_repair successfully repair the filesystem in
the scenario mentioned before.

Signed-off-by: Marco Benatto <mbenatto@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: regression test for rmapbt fdblocks accounting problems
Darrick J. Wong [Fri, 22 Jun 2018 06:40:42 +0000 (23:40 -0700)]
xfs: regression test for rmapbt fdblocks accounting problems

In "xfs: fix fdblocks accounting w/ RMAPBT per-AG reservation", we fixed
the per-ag reservation code so that we always decrease fdblocks by the
reserved size because rmapbt blocks are counted as free space.

The primary symptom of this bug is that if the rmapbt has expanded since
mount time, the disk block counters reported via statfs will change
across a remount. Therefore, we exercise this as a regression test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: add SPDX license comments for src/log-writes/*
Josef Bacik [Tue, 26 Jun 2018 17:07:58 +0000 (13:07 -0400)]
fstests: add SPDX license comments for src/log-writes/*

I apparently never bothered to put copyright or license info with this
code, just tag it as GPL 2 and I'll fix the upstream stuff as well.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
4 years agoxfs/365: fuzz inobt in ag 1
Darrick J. Wong [Thu, 21 Jun 2018 18:32:35 +0000 (11:32 -0700)]
xfs/365: fuzz inobt in ag 1

In kernel patch "xfs: verify root inode more thoroughly", we strengthen
the root inode mount checks to make sure that the inobt agrees that the
root inode exists and is in use.  Unfortunately, that makes this whole
test useless because we can't even mount the filesystem to run scrub.
So, redirect it to AG1's inobt.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoltp/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:17 +0000 (12:04 +1000)]
ltp/: spdx license conversion

Mostly scripted like all the others, manually added tags to
Makefile. aio-stress.c was manually touched up before scripted
conversions.

Notes for future reference:
- fsx.c license is ambiguous. Not tagged in any way.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agosrc/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:16 +0000 (12:04 +1000)]
src/: spdx license conversion

Mostly scripted like all the others, manually added tags to
Makefile, nsexec.c and t_mmap_writev.c. Manually touched up
open_by_handle.c and t_encrypted_d_revalidate.c post script.

Notes for future reference:
- src/log-writes/ code has no explicit copyright or license tags,
  nor does the upstream repository, hence license is unknown.
  Need Josef to clarify the license and send a patch adding SPDX
  tags to those files.

- src/perf code has no explicit copyright or license tags, but it
  was code submitted explictly for fstests so it is assumed to be
  GPLv2.0 and tagged as such. If this is incorrect, Josef will need
  to clarify copyright and the license and send patches to correct
  it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agosrc/aio-dio-regress/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:15 +0000 (12:04 +1000)]
src/aio-dio-regress/: spdx license conversion

The license headers all had to be manually editted into a consistent
format, then converted to spdx tags via scripting.  Manually added
tag to Makefile.

Notes for future reference and research:
- quoted source repositories for aio-dio suite no longer exist
- src/aio-dio-regress/aiodio_sparse2.c has no explicit license
  statement, so need to find original source to determine actual
  license before tagging.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agolib/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:14 +0000 (12:04 +1000)]
lib/: spdx license conversion

Scripted like all the others, manually added tags to
Makefile, touchups required for random.c

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agoinclude/: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:13 +0000 (12:04 +1000)]
include/: spdx license conversion

Mostly scripted like all the others, manually added tags to
Makefile and build/config input files.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agodmapi: spdx license conversion
Dave Chinner [Wed, 20 Jun 2018 02:04:12 +0000 (12:04 +1000)]
dmapi: spdx license conversion

Scripted like all the others.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agosrc: fix up mmap() error checking
Ross Zwisler [Wed, 20 Jun 2018 22:51:46 +0000 (16:51 -0600)]
src: fix up mmap() error checking

I noticed that in some of my C tests in src/ I was incorrectly
checking for mmap() failure by looking for NULL instead of
MAP_FAILED.  Fix those and clean up some places where we were
testing against -1 (the actual value of MAP_FAILED) which was
manually being cast to a pointer.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/xfs: Add _scratch_get_sfdir_prefix function
Marco Benatto [Mon, 18 Jun 2018 17:44:32 +0000 (14:44 -0300)]
common/xfs: Add _scratch_get_sfdir_prefix function

Move get_sfdir_prefix function from xfs/278 to commom/xfs
and rename it to _scratch_get_sfdir_prefix so it can be
used in other xfs tests.

This commit also changes xfs/278 to make use of
_scratch_get_sfdir_prefix instead previous one.

Signed-off-by: Marco Benatto <mbenatto@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: replace btrfs-debug-tree with btrfs inspect-internal dump-tree
Lu Fengqi [Thu, 21 Jun 2018 07:04:22 +0000 (15:04 +0800)]
btrfs: replace btrfs-debug-tree with btrfs inspect-internal dump-tree

Since btrfs-dump-tree has been removed from btrfs-progs, use btrfs
inspect-internal dump-tree instead of btrfs-dump-tree.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/t_stripealign.c: Fix complier error
Xiao Yang [Wed, 20 Jun 2018 03:12:00 +0000 (11:12 +0800)]
src/t_stripealign.c: Fix complier error

The FIEMAP_EXTENT_SHARED flag was added into kernel since commit
8c0414cd524e, so undefined FIEMAP_EXTENT_SHARED resulted in complier
error on old distros(e.g. RHEL6), as below:
----------------------------------------------------------------------
t_stripealign.c:99: error: 'FIEMAP_EXTENT_SHARED' undeclared (first use in this function)
----------------------------------------------------------------------

We fix it by defining the flag manually.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/170: increase agsize for bigger internal log size
Zorro Lang [Mon, 11 Jun 2018 09:10:40 +0000 (17:10 +0800)]
xfs/170: increase agsize for bigger internal log size

xfs/170 always fails on xfs with "-m rmapbt=1,reflink=1", because
XFS need bigger internal log size if rmapbt and reflink are both
enabled.

One line of xfs/170 as below:

  _test_streams 8 16 4 8 3 0 0

Refer to common/filestreams, we can see xfs/170 trys to create a
128M XFS (agcount=8, agsize=16M), then each stream writes
24M (8 * 3M files), and there're 4 streams.

So the case expects each stream takes 2 AGs, 4 streams takes
different 8 AGs just enough. But internal log will break this
balance. For example:

"mkfs.xfs -f -b size=4k -m rmapbt=1,reflink=1 $dev" will take 3075
4k blocks (12M) by default:
  meta-data=/dev/mapper/xxxx-xfscratch isize=512    agcount=8, agsize=4096 blks
  ...
  log      =internal               bsize=4096   blocks=3075, version=2
           =                       sectsz=512   sunit=0 blks, lazy-count=1
  ...

And the internal log is in the 4th AG:
  # xfs_logprint: /dev/mapper/xxxx-xfscratch
  xfs_logprint:
      data device: 0xfd03
      log device: 0xfd03 daddr: 131120 length: 24600
  # xfs_db -c "convert daddr 131120 agno" /dev/mapper/xxxx-xfscratch
  0x4 (4)

Then if one stream write data into AG-1 at first, then turn to AG-4
after fill 16M agsize. But AG-4 has 12M space for log section, so
only 4M free space for data. Then this stream have to turn to the
next AG after fill the 4M space. All these as below:

  # xfs_bmap -vp stream2-dir/*
  stream2-dir/frame-1:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       32960..39103      1 (192..6335)       6144 000000
  ...
  ...
  stream2-dir/frame-5:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       57536..63679      1 (24768..30911)    6144 000000
  stream2-dir/frame-6:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       155776..161919    4 (24704..30847)    6144 000000
  stream2-dir/frame-7:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       170088..176231    5 (6248..12391)     6144 000000
  stream2-dir/frame-8:
   EXT: FILE-OFFSET      BLOCK-RANGE      AG AG-OFFSET        TOTAL FLAGS
     0: [0..6143]:       176232..182375    5 (12392..18535)    6144 000000

Later _test_streams maybe takes AG-5 again, and cause two streams use
AG-5. To avoid this failure, increase the agsize from 16M to 22M,
others stay the same, each stream still writes 2 AGs. Even internal
log takes some space from someone AG, left space should be enough to
write (24 - 22)=2M data.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/223: port t_stripealign to FIEMAP
Darrick J. Wong [Wed, 13 Jun 2018 22:50:57 +0000 (15:50 -0700)]
generic/223: port t_stripealign to FIEMAP

Since XFS has deprecated FIBMAP on FSDAX filesystems, we can't use
FIBMAP to verify stripe alignment anymore.  FIEMAP has existed for
quite some time now, so port it to use that instead, and only fall
back to FIBMAP if FIEMAP doesn't exist.

Tested-by: ross.zwisler@linux.intel.com
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: Add test that checks rmdir(2) can delete a subvolume
Misono Tomohiro [Wed, 13 Jun 2018 06:06:45 +0000 (15:06 +0900)]
btrfs: Add test that checks rmdir(2) can delete a subvolume

Add btrfs test that checks "rmdir" or "rm -r" command can delete a
subvolume like an ordinary directory.

This behavior has been restricted long time but becomes allowed by
kernel commit a79a464d5675 ("btrfs: Allow rmdir(2) to delete an
empty subvolume")

The test will be skipped if kernel does not support the feature,
which can be checked whether /sys/fs/btrfs/features/rmdir_subvol
exists or not.

Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoltp/fsx: output the seed value after logid is initialized
Hou Tao [Tue, 12 Jun 2018 12:43:30 +0000 (20:43 +0800)]
ltp/fsx: output the seed value after logid is initialized

When running multiple fsx processes simultaneously (e.g.
generic/455), it is difficult to tell the seed value for one fsx
process if the seed value is needed to reproduce a log-replay
failure.

Fix it by outputting the seed value after logid is initialized.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: add test for fsync of directory after creating hard link
Filipe Manana [Mon, 11 Jun 2018 18:24:35 +0000 (19:24 +0100)]
generic: add test for fsync of directory after creating hard link

Test that if we create a new hard link for a file which was
previously fsync'ed, fsync a parent directory of the new hard link
and power fail, the parent directory exists after mounting the
filesystem again. The parent directory must be a new directory, not
yet persisted.

This test is motivated by a bug found in btrfs, where the fsync'ed
parent directory was lost after a power failure. The bug in btrfs is
fixed by a patch for the linux kernel titled:

 "Btrfs: sync log after logging new name"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/391: add _require_odirect
Jakob Unterwurzacher [Tue, 12 Jun 2018 19:39:40 +0000 (21:39 +0200)]
generic/391: add _require_odirect

On filesystems that do not support O_DIRECT, the test should skip
itself with

 generic/391  [not run] O_DIRECT is not supported

instead of failing with

 generic/391  - output mismatch ...
     ...
     +open: Invalid argument
      Silence is golden
     ...

This patch make it do that by adding a call to _require_odirect.
Fixes https://github.com/rfjakob/gocryptfs/issues/244 .

Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon: improve regex in _check_dmesg
Zorro Lang [Tue, 12 Jun 2018 06:09:06 +0000 (14:09 +0800)]
common: improve regex in _check_dmesg

A dmesg output as below cause all cases fail:

[  508.002072] EDAC DEBUG: ie31200_check: MC0

Due to it matches `egrep -e "BUG:"` in _check_dmesg. But it's not a
real BUG output, so use "\bBUG:" to avoid this mistake.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofstests: make lsqa.pl work with SPDX tags
Dave Chinner [Sat, 9 Jun 2018 01:45:38 +0000 (11:45 +1000)]
fstests: make lsqa.pl work with SPDX tags

The regex matches used to dump the test headers are no longer valid,
so update them to work with the new test header format.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agofstests: convert top level files and tools to SPDX
Dave Chinner [Sat, 9 Jun 2018 01:36:01 +0000 (11:36 +1000)]
fstests: convert top level files and tools to SPDX

Scripted conversion, see script in initial SPDX license commit
message. Many files required touch-ups after the script had run
because of the old and widely different formats. most touchups were
to remove excess empty comment lines the script left behind.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agofstests: convert remaining tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:53 +0000 (11:35 +1000)]
fstests: convert remaining tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agobtrfs: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:50 +0000 (11:35 +1000)]
btrfs: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agoxfs: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:45 +0000 (11:35 +1000)]
xfs: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

tests/xfs/044 was hand massaged to remove duplicate copyright and
divider lines before running the script.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agogeneric: convert tests to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:35:42 +0000 (11:35 +1000)]
generic: convert tests to SPDX license tags

Fully scripted conversion, see script in initial SPDX license commit
message.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agofstests: convert new test template to SPDX tags
Dave Chinner [Sat, 9 Jun 2018 01:35:32 +0000 (11:35 +1000)]
fstests: convert new test template to SPDX tags

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agocommon: convert to SPDX license tags
Dave Chinner [Sat, 9 Jun 2018 01:34:49 +0000 (11:34 +1000)]
common: convert to SPDX license tags

These have been scripted conversions then cleaned up by hand as
there was no consistency to the formatting of the license headers in
the common/ directory. Author information was also removed (it's in
the git history) and so now the header format is consistently:

##/bin/bash
# SPDX-License-Identifier: GPL-2.0(+)
# Copyright (c) <date> <owner>. All Rights Reserved.
#
# <file description>

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agofstests: Add LICENSES directory
Dave Chinner [Sat, 9 Jun 2018 01:29:45 +0000 (11:29 +1000)]
fstests: Add LICENSES directory

In preparation for changing tests over to use SPDX tags, add the
initial licenses needed for the common/ and tests/ changeover to
the LICENSES/ directory. For this initial patch set, only the GPLv2
license text is required.

The tests and other common scripts will be converted to tags via a
script and, if necessary touched up to fix any warts the script
can't handle. The script is run on a target via:

for f in `git grep -l "GNU General" <target>` ; do
echo $f
cat $f | awk -f hdr.awk > $f.new
mv -f $f.new $f
done

This, unfortunately, changes the permissions of the files, so each
patch was post processed to remove the mode change fields from
the patches before they were committed. This preserves the file
modes, even though the files were replaced.

The awk script that dos all the substitution work is as follows:

$ cat hdr.awk
BEGIN {
        hdr = 1
        tag = "GPL-2.0"
ignore = 0
        str = ""
cstr = ""
}

/^#[\!#][ ]*\/bin\/bash/ {
print $0
next
}

/^#[\!#][ ]*.*\/perl/ {
print $0
next
}

/any later version./ {
        tag = "GPL-2.0+"
        next
}

/^#[\-]{65}/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
} else if (ignore == 1) {
# use this to ignore empty comment line after license
ignore = 2
}
next
}

/This program is free software/ {
if (hdr == 1 && ignore == 0) {
ignore = 1
hdr = 0
}
next
}

/02110-1301[, ] *USA/ {
# use this to ignore empty comment line after license
if (ignore = 1) {
ignore = 2
}
next
}

/^#[ ]*Copyright/ {
if (cstr != "")
cstr = cstr "\n"
cstr = cstr $0
next
}

// {
if (ignore == 2) {
print "# SPDX-License-Identifier: " tag
print cstr "\n#"
print str
str=""
ignore = 3

}
if (ignore == 1) {
next
} else if (ignore == 3) {
# ignore trailing empty comment lines
if ($0 == "#")
next
ignore = 0
}

if (str != "")
str = str "\n"
str = str $0
}

END {
print str
}
$

Signed-off-by: Dave Chinner <dchinner@redhat.com>
4 years agogeneric: test swapfile creation, activation, and deactivation
Darrick J. Wong [Thu, 7 Jun 2018 15:17:10 +0000 (08:17 -0700)]
generic: test swapfile creation, activation, and deactivation

Test swapfile activation and deactivation.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: make sure pretty printed geometry output matches
Darrick J. Wong [Tue, 5 Jun 2018 16:43:33 +0000 (09:43 -0700)]
xfs: make sure pretty printed geometry output matches

Make sure that all of our commands that can print geometry
information all print the /same/ information.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: abstract xfs_info into $XFS_INFO_PROG
Darrick J. Wong [Tue, 5 Jun 2018 16:43:27 +0000 (09:43 -0700)]
xfs: abstract xfs_info into $XFS_INFO_PROG

Abstract calls to xfs_info into $XFS_INFO_PROG like we do for all
other xfs utilities.

[Eryu: require xfs_info to be present if FSTYP is xfs]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/310: fix _require_scratch_nocheck ordering
Darrick J. Wong [Tue, 5 Jun 2018 16:43:14 +0000 (09:43 -0700)]
xfs/310: fix _require_scratch_nocheck ordering

In xfs/310 we have to _require_scratch_nocheck last because anything
else that calls _require_scratch (e.g. _require_xfs_scratch_rmapbt)
will create the "check scratch after test exit" file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/122: fix sb_fname[XFSLABEL_MAX] in test
Darrick J. Wong [Tue, 5 Jun 2018 16:43:02 +0000 (09:43 -0700)]
xfs/122: fix sb_fname[XFSLABEL_MAX] in test

We recently redefined sb_fname's array length to use a symbolic
constant instead of a magic number, so update this test accordingly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/439: don't check filesystem afterwards
Darrick J. Wong [Tue, 5 Jun 2018 16:42:56 +0000 (09:42 -0700)]
xfs/439: don't check filesystem afterwards

We deliberately corrupted the scratch fs, so don't check it afterwards.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/401: fix test in case of no filetype support
Amir Goldstein [Tue, 5 Jun 2018 08:08:50 +0000 (11:08 +0300)]
generic/401: fix test in case of no filetype support

Xu Huan reported that this test fails on nfs in some setup.
Apparently, the assumptions made about xfs/ext* do not hold
for nfs.

Relax the verification of filetype not supported case to
allow either DT_UNKNOWN or actual file type on all files and
not only on special dir entires "." and "..".

Convert the unknown d_type replacement code from awk to bash
so it is a bit more readable and flexible.

Reported-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Tested-by: Xu Huan <xuhuan.fnst@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agooverlay: nicer report when features are not supported
Amir Goldstein [Fri, 1 Jun 2018 10:44:16 +0000 (13:44 +0300)]
overlay: nicer report when features are not supported

Commit ea7ad43 ("fstests: implement require of multiple overlayfs
features") changed the message when tests are not run due to missing
overlayfs feature.

Restore the check for existing module param before trying to mount
which restores the old message format, e.g.:

[not run] feature 'metacopy' not supported by overlay

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: skip atime related tests on CIFS
xiaoli feng [Thu, 31 May 2018 04:10:14 +0000 (12:10 +0800)]
common/rc: skip atime related tests on CIFS

From the feedback of cifs developer, the behaviour of atime/noatime
for cifs is basically noatime always. So the atime related mount
options have no effect on cifs mounts. And Skip these tests on CIFS.

Signed-off-by: xiaoli feng <xifeng@redhat.com>
Acked-by: Steve French <smfrench@gmail.com>
Acked-by: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: Regression test for vulnerable directory integrity check
Xiao Yang [Wed, 30 May 2018 08:53:43 +0000 (16:53 +0800)]
xfs: Regression test for vulnerable directory integrity check

If a malicious XFS contains a block+ format directory wherein the
directory inode's core.mode is corrupted, and there are
subdirectories of the corrupted directory, an attempt to traverse up
the directory tree by running xfs_scrub will crash the kernel in
__xfs_dir3_data_check.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: Fix _require_xfs_io_command for scrub probe
Xiao Yang [Mon, 4 Jun 2018 04:50:12 +0000 (12:50 +0800)]
common/rc: Fix _require_xfs_io_command for scrub probe

Currently, xfs_io scrub command doesn't allow the probe function
to have any parameter, so we remove the invalid parameter.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: fail tests if check/dmesg are not clean
Dave Chinner [Mon, 28 May 2018 23:07:37 +0000 (09:07 +1000)]
check: fail tests if check/dmesg are not clean

Currently a test appears to pass even if it leaves a corrupt
filesystem behind, or a splat in the system logs that should not be
there. While the test is internally tracked as failed (and the
summary reports it as failed) the per-test output exits with a
success and so emits a completion time before the post-test checks
are run by the test harness.  Rework the check code to report
post-test check failures as specific test failures rather than as
separate failure line items in the overall harness output.

Reworking where we emit the errors this also allows us to include
the post-test filesystem checking in the test runtime. This is
currently not accounted to the test and can be substantial. Hence
the real elapsed time of each test is not accurately reflected in
the time stats being reported and so regressions in filesystem
checking performance go unnoticed.

Changing the output reporting requires a complete reworking of the
main test check loop. It's a bunch of spaghetti at the moment
because it has post test reporting code at the end of the loop which
must run regardless of the test result.  By moving the post test
reporting to the start of the next loop iteration, we can clean up
the code substantially by using continue directives where
appropriate.

Also, for cases where we haven't run the test or it's already been
marked as failed, don't bother running the filesystem/dmesg checks
for failure as we're already going to report the test as failed.

This touches almost all of the loop, so get rid of the remaining
4 space indents inside the loop while moving all this code around.

[Eryu: fixed wrong test seq name issue in xUnit report when test hit
"continue" in the check loop, e.g. notrun, with Dave ACKing the fix]

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agooverlay: Add tests for overlay metadata only copy up feature
Vivek Goyal [Fri, 1 Jun 2018 12:59:58 +0000 (08:59 -0400)]
overlay: Add tests for overlay metadata only copy up feature

Add tests for metadata only copy up feature.

Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: introduce btrfs/volume group
Anand Jain [Tue, 29 May 2018 05:56:12 +0000 (13:56 +0800)]
btrfs: introduce btrfs/volume group

The btrfs/volume group represent a set of btrfs test-cases, which
shall intend to verify the relevant btrfs volume operations.

Under this new group all the existing btrfs/replace group would come
under, and also the device operations test cases which does not have
any group as of now. This group is helpful to verify the btrfs
volume related changes.

Run as
  ./check -g btrfs/volume

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: seed device delete test
Anand Jain [Fri, 1 Jun 2018 15:57:26 +0000 (23:57 +0800)]
btrfs: seed device delete test

Test case to verify that a seed device can be deleted

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: seed device replace test
Anand Jain [Fri, 1 Jun 2018 15:57:25 +0000 (23:57 +0800)]
btrfs: seed device replace test

Test case to verify that a seed device can be replaced

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>