xfstests-dev.git
3 years agobtrfs/057: Fix false alerts due to orphan files
Qu Wenruo [Tue, 30 Oct 2018 10:18:19 +0000 (18:18 +0800)]
btrfs/057: Fix false alerts due to orphan files

For any recent kernel, there is a chance that btrfs/057 reports false
errors.

The false error would look like:
  btrfs/057 4s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/057.out.bad)
      --- tests/btrfs/057.out 2017-08-21 09:25:33.166666666 +0800
      +++ /home/adam/xfstests-dev/results//btrfs/057.out.bad 2018-10-29 14:07:28.443651293 +0800
      @@ -1,3 +1,3 @@
       QA output created by 057
       4096 4096
      -4096 4096
      +28672 28672

This is related to the fact that "btrfs subvolume sync" (or
vanilla sync) will not ensure orphan (unlinked but still exist) files to
be removed.

In fact, for that false error case, if inspecting the fs after umount,
its qgroup number is correct and btrfs check won't report qgroup error.

To fix the false alerts, just skip any manual qgroup number comparison,
and let fsck done after the test case to detect problem.

This also elimiate the necessary of using specified mount and mkfs
option, allowing us to improve coverage.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: update group file to indicate generic/456 uses {collapse,zero}_range
Theodore Ts'o [Fri, 26 Oct 2018 11:53:49 +0000 (07:53 -0400)]
generic: update group file to indicate generic/456 uses {collapse,zero}_range

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: add some tests to the 'log' group that use dmflakey
Filipe Manana [Sat, 27 Oct 2018 08:48:58 +0000 (09:48 +0100)]
fstests: add some tests to the 'log' group that use dmflakey

Some tests that use dmflakey to test filesystem consistency after a power
failure are in the 'log' group while others are not. So fix the
incosistency and put them all under the 'log' group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: fix classification of a couple btrfs tests
Filipe Manana [Sat, 27 Oct 2018 08:48:38 +0000 (09:48 +0100)]
btrfs: fix classification of a couple btrfs tests

Test btrfs/108 does not test collapse, in fact btrfs does not even support
the fallocate collapse operation, so remove it.
Test btrfs/159 does not test collapse either, it tests hole punching, so
replace the collapse group with the punch group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/508: fix to check inode creation time feature on scratch mountpoint
Chao Yu [Sat, 27 Oct 2018 01:55:20 +0000 (09:55 +0800)]
generic/508: fix to check inode creation time feature on scratch mountpoint

_require_btime() just check inode creation time feature on TEST_DIR
mountpoint, but generic/508 needs to do that check on SCRATCH_MNT
mountpoint. Let's add _require_scratch_btime() for that, meanwhile
handling scratch_{mkfs,mount,umount} inside the function to decouple
with caller.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test reflink side effects
Darrick J. Wong [Tue, 16 Oct 2018 03:29:13 +0000 (20:29 -0700)]
generic: test reflink side effects

Test that ctime gets updated and suid is cleared when we reflink.
Ensure we can't reflink about RLIMIT_FSIZE.  Ensure that we can't
expose stale preallocation block data when reflinking above EOF.
Make sure dedupe actually catches a single different byte.

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>
3 years agobtrfs: fix test btrfs/007 to not leave temporary files in /tmp
Filipe Manana [Mon, 15 Oct 2018 09:22:46 +0000 (10:22 +0100)]
btrfs: fix test btrfs/007 to not leave temporary files in /tmp

This test was using the "mktemp -d" command to create a temporary
directory for storing send streams and computations from fssum,
without ever deleting them when it finishes. Therefore after running
it for many times it filled up all space from /tmp.

Fix this by using a temporary directory in TEST_DEV instead, as all
the more recent send/receive tests do, to store these files, and
making sure they get deleted when the test finishes. On average the
sum of the size of those files is between 5.5Mb to 6Mb, but changing
the number of operations for fsstress makes it even bigger.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test fsync after fallocate on a very small file
Filipe Manana [Mon, 15 Oct 2018 08:51:17 +0000 (09:51 +0100)]
generic: test fsync after fallocate on a very small file

Test that if we have a very small file, with a size smaller than the
block size, then fallocate a very small range within the block size
but past the file's current size, fsync the file and then power
fail, after mounting the filesystem all the file data is there and
the file size is correct.

This test is motivated by a failure in btrfs where it triggered an
assertion when using the no-holes feature, that is, when running
with MKFS_OPTIONS="-O no-holes". The btrfs issue is fixed by a patch
for the linux kernel titled:

 "Btrfs: fix assertion on fsync of regular file when using no-holes
  feature"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/140: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:03 +0000 (11:53 +0530)]
xfs/140: work with 1k block size

Commit 7a7641063ac3a7ae051c9e1959f4d7b1a25bb91c (xfs/140: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by resetting AG size to 16MiB if (8192 *
block size) results in a value less than 16MiB. Later the test file size
and the test file block count are then appropriately calculated.

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/139: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:02 +0000 (11:53 +0530)]
xfs/139: work with 1k block size

Commit 0e2b99951fa11ea8a8adf4676aef130cfeeb5250 (xfs/139: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by setting AG size to be (16384 * block
size).

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/fiemap-tester: fix getting blocksize on overlayfs
Amir Goldstein [Thu, 11 Oct 2018 14:41:06 +0000 (17:41 +0300)]
src/fiemap-tester: fix getting blocksize on overlayfs

There was a regression in v4.19-rc1 that caused FIGETBSZ ioctl
to return 0 on an overlayfs file.

That regression went unnoticed because the xfstests that run
fiemap-tester program terminated in success status after not doing
much instead of failing.

Check for invalid value of block size returned by FIGETBSZ ioctl,
so these tests can detect the regression.

Fallback to statfs(2) for getting the filesystem blocksize if
FIGETBSZ ioctl fails (i.e. on overlayfs).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/288: shut up verifier error
Darrick J. Wong [Fri, 5 Oct 2018 00:19:39 +0000 (17:19 -0700)]
xfs/288: shut up verifier error

Ignore the verifier errors when we fuzz hdr.count to zero.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/270: use _scratch_xfs_set_metadata_field to fuzz rocompat bits
Darrick J. Wong [Fri, 5 Oct 2018 00:19:33 +0000 (17:19 -0700)]
xfs/270: use _scratch_xfs_set_metadata_field to fuzz rocompat bits

Use the helper to set the metadata field so that we can bypass write
verifier checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/189: skip 'barrier' mount option test on newer kernels
Darrick J. Wong [Fri, 5 Oct 2018 00:19:26 +0000 (17:19 -0700)]
xfs/189: skip 'barrier' mount option test on newer kernels

Starting in Linux 4.19 the 'barrier' and 'nobarrier' mount options were
removed.  If mount complains about a bad option when we remount with
'barrier', just skip the 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>
3 years agoxfs: test mount time summary counter check and fix
Darrick J. Wong [Fri, 5 Oct 2018 00:19:20 +0000 (17:19 -0700)]
xfs: test mount time summary counter check and fix

Tests to ensure that the xfs mount code can detect obviously bad fs
summary counters at mount time and fix them.

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>
3 years agogeneric: another mread-after-eof test
Darrick J. Wong [Fri, 5 Oct 2018 00:19:14 +0000 (17:19 -0700)]
generic: another mread-after-eof test

Add Brian Foster's alternate reproducer code for the mread-after-eof
problem so that we increase the chances that either this or generic/499
will catch the problem.

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>
3 years agogeneirc/077: fix min size for btrfs
Anand Jain [Thu, 11 Oct 2018 07:55:28 +0000 (15:55 +0800)]
geneirc/077: fix min size for btrfs

If btrfs need to be tested at its default blockgroup which is non-mixed,
then it needs at least 256mb.

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 agogeneric: test for file fsync after moving it to a new parent directory
Filipe Manana [Tue, 9 Oct 2018 14:05:35 +0000 (15:05 +0100)]
generic: test for file fsync after moving it to a new parent directory

Test that if we move a file from a directory B to a directory A, replace
directory B with directory A, fsync the file and then power fail, after
mounting the filesystem the file has a single parent, named B and there
is no longer any directory with the name A.

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

  "Btrfs: fix wrong dentries after fsync of file that got its parent
   replaced"

This test passes on ext4, xfs and patched btrfs but it hangs on f2fs (the
fsck.f2fs process seems stuck).

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test mounting filesystem after fsync of a tmpfile
Filipe Manana [Mon, 8 Oct 2018 10:13:13 +0000 (11:13 +0100)]
generic: test mounting filesystem after fsync of a tmpfile

Test that if we fsync a tmpfile, without adding a hard link to it, and
then power fail, we will be able to mount the filesystem without
triggering any crashes, warnings or corruptions.

This test is motivated by an issue in btrfs where this scenario triggered
a warning (without any side effects). The following linux kernel patch
fixes the issue in btrfs:

  "Btrfs: fix warning when replaying log after fsync of a tmpfile"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: fix check for yp
Johannes Thumshirn [Fri, 12 Oct 2018 11:50:55 +0000 (13:50 +0200)]
common/rc: fix check for yp

Only testing if a domainname is set and ypcat is installed is not a
sufficient criteria to check if NIS is actually active.

Check for a running ypbind in rpcinfo as well.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/reflink: fix error messages in _require_scratch_dedupe()
Anthony Iliopoulos [Wed, 10 Oct 2018 23:55:50 +0000 (01:55 +0200)]
common/reflink: fix error messages in _require_scratch_dedupe()

In case dedupe returns an error in _require_scratch_dedupe(),
report the error for the scratch rather than for the test
filesystem.

Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/018: fix mismatch wildcard with debugfs
Yufen Yu [Thu, 11 Oct 2018 13:14:10 +0000 (21:14 +0800)]
ext4/018: fix mismatch wildcard with debugfs

For the new version of debugfs(v1.44.0+), it changes "File ACL:" format
from "%sFile ACL: %llu    Directory ACL: %d\n" to "%sFile ACL: %llu\n".

Thus, update this case accordingly.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test creation time recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:48 +0000 (20:25 +0800)]
generic: test creation time recovery after power failure

After fsync, filesystem should guarantee inode metadata including
creation time being persisted, so even after sudden power-cut, during
mount, we should recover i_crtime_{,nsec} fields correctly, in order
to not loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Note that, it needs inode creation time support on specified filesystem.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test i_flags recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:47 +0000 (20:25 +0800)]
generic: test i_flags recovery after power failure

After fsync, filesystem should guarantee inode metadata including
i_flags being persisted, so even after sudden power-cut, during
mount, we should recover i_flags fields correctly, in order to not
loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

We only check below attribute modification which most filesystem
supports:
- no atime updates (A)
- secure deletion (s)
- synchronous updates (S)
- undeletable (u)

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test project id recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:46 +0000 (20:25 +0800)]
generic: test project id recovery after power failure

After fsync, filesystem should guarantee inode metadata including
project id being persisted, so even after sudden power-cut, during
mount, we should recover project_id fields correctly, in order to
not loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/387: fix _scratch_mkfs_sized option for btrfs
Anand Jain [Tue, 25 Sep 2018 04:24:22 +0000 (12:24 +0800)]
generic/387: fix _scratch_mkfs_sized option for btrfs

btrfs needs 256mb to create a fs with default block group which is
non mixed, so pass 256mb to _scratch_mkfs_sized().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/449: fix fs size for _scratch_mkfs_sized for btrfs
Anand Jain [Tue, 25 Sep 2018 04:24:21 +0000 (12:24 +0800)]
generic/449: fix fs size for _scratch_mkfs_sized for btrfs

btrfs needs 256m to create btrfs with default options like non mixed
block groups.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/083: fix btrfs fs size for default mode
Anand Jain [Tue, 25 Sep 2018 04:24:17 +0000 (12:24 +0800)]
generic/083: fix btrfs fs size for default mode

btrfs needs at least 256mb to create a FS with the defaults options.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/015: fix to test the default non-mixed mode
Anand Jain [Tue, 25 Sep 2018 04:24:15 +0000 (12:24 +0800)]
generic/015: fix to test the default non-mixed mode

commit 97575acd7495 (generic/015: Change the test filesystem size to
101mb), created 101mb FS instead of 100mb FS to make sure we create
a FS which is non mixed mode.

btrfs-progs commit 18e2663db3e1 (btrfs-progs: Add minimum device
size check) added a more accurate minimum required space to create
the btrfs FS in non mixed mode depending on the group profile, and
considering any group profiles we would need at least 256MB (with
upward round off).

So this patch changes the FS size to be created by
_scratch_sized_mkfs() to 256MB so that we create the FS in non mixed
mode for any group profile.

Mixed blockgroup can be tested using the MKFS_OPTIONS explicitly.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: _scratch_mkfs_sized fix min size without mixed option
Anand Jain [Tue, 25 Sep 2018 04:24:14 +0000 (12:24 +0800)]
btrfs: _scratch_mkfs_sized fix min size without mixed option

As of now _scratch_mkfs_sized() checks if the requested size is
below 1G and forces the --mixed option for the mkfs.btrfs. Well the
correct size considering all possible group profiles at which we
need to force the mixed option is roughly 256Mbytes. So fix that.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test unaligned punch hole at ENOSPC
Anand Jain [Sun, 30 Sep 2018 01:39:52 +0000 (09:39 +0800)]
btrfs: test unaligned punch hole at ENOSPC

Try to punch hole with unaligned size and offset when the FS is
full. Mainly holes are punched at locations which are unaligned
with the file extent boundaries when the FS is full by data.
As the punching holes at unaligned location will involve
truncating blocks instead of just dropping the extents, it shall
involve reserving data and metadata space for delalloc and so data
alloc fails as the FS is full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents, without truncating data extent blocks.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: add struct xfs_unmount_log_format
Eric Sandeen [Thu, 4 Oct 2018 17:27:32 +0000 (12:27 -0500)]
xfs/122: add struct xfs_unmount_log_format

struct xfs_unmount_log_format used to be anonymous and gained a name
in 4.19, so add that to the list of expected structures in xfs/122.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/quota: adapt _require_prjquota() for f2fs
Chao Yu [Sun, 30 Sep 2018 09:26:53 +0000 (17:26 +0800)]
common/quota: adapt _require_prjquota() for f2fs

In _require_prjquota(), let's check project quota support as below
for f2fs:

- For image support, check 'project_quota' on enabled feature list
  of specified device.
- For kernel support, check /sys/fs/f2fs/features/project_quota
  sysfs entry status.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/108: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:42 +0000 (20:49 +0530)]
generic/108: work with 64k block size

This commit increases the size of the scsi debug device to 300MiB to
accommodate a 275MiB sized XFS filesystem with 64k block size. mkfs.xfs
fails to create a 64k block sized filesystem on devices with capacity
less than 275MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/018: to work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:41 +0000 (20:49 +0530)]
generic/018: to work with 64k block size

This commit replaces the hard coded bsize variable with the block size
obtained from the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/459: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:40 +0000 (20:49 +0530)]
generic/459: work with 64k block size

With 64k block size, 200MiB disk space is not sufficient to create an
XFS filesystem. Hence this commit increases the size of the
overprovisioned dm-thin device to 300MiB. The commit also increases the
other associated disk sizes (original physical size and new physical
size) appropriately.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/235: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:39 +0000 (20:49 +0530)]
generic/235: work with 64k block size

With 64k blocksized filesystem, this test fails since a single 8k write
will actually end up consuming 64k. Hence this commit writes 64k data
into the test file.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/230: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:38 +0000 (20:49 +0530)]
generic/230: work with 64k block size

This commit changes the test to work on file offsets that are aligned
with the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/177: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:37 +0000 (20:49 +0530)]
generic/177: work with 64k block size

This commit changes the test to work on file offsets that are aligned
with the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/punch: Filter fiemap output by FS block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:36 +0000 (20:49 +0530)]
common/punch: Filter fiemap output by FS block size

When testing FS instances of block size other than 4k, the output of
fiemap command will not match those in *.out files. This commit adds
an optional "block size" argument to _filter_fiemap() which prints
fiemap output in units of block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/172: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:35 +0000 (20:49 +0530)]
generic/172: work with 64k block size

For 64k block size, With 256MiB as the XFS filesystem size and 168 MiB
as the size of the clone source file, we end up hitting ENOSPC when
cloning the source file. This happens due to lack of space for housing
the corresponding metadata. This scenario also occurs when using a
512MiB XFS filesystem and 300MiB clone source file.

Hence this commit increases the size of the test filesystem to 1 GiB and
the size of the clone source file to 768MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/102: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:34 +0000 (20:49 +0530)]
generic/102: work with 64k block size

With 64k block size, mkfs.xfs fails with the following message when the
filesystem size is 512MiB in size,

"log size 2037 blocks too small, minimum size is 2473 blocks"

Hence this commit increases the test filesystem size to 1GiB. Also, the
size of the test file is increased to 800MiB which is ~80% of the test
filesystem size. This is in proportion to the 400MiB test file used with
the original 512MiB test filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/325: Inject free_extent error after CoW operation
Chandan Rajendra [Mon, 24 Sep 2018 15:19:33 +0000 (20:49 +0530)]
xfs/325: Inject free_extent error after CoW operation

On a 64k blocksized filesystem, when the test CoWs the file2's offset
range [10 * 64k, 19 * 64k], the call to xfs_bmapi_reserve_delalloc()
allocates 32 64k blocks. This is because XFS_DEFAULT_COWEXTSZ_HINT has
the value of 32 and xfs_get_cowextsz_hint() uses this to compute the
extent alignment. This leads to xfs_bmapi_reserve_delalloc() to reserve
space corresponding to the file range [0, 32 * 64k] in the inode's
cow fork area. On completion of write I/O corresponding to file2's range
[10 * 64k, 19 * 64k], xfs_end_io() moves 10 out of the originally
allocated 32 64k blocks to the data fork area. The remaining 22 64k
blocks linger on in cow fork area of the inode.

Later, when servicing the exit() syscall for the xfs_io process,
xfs_free_eofblocks() ends up invoking xfs_reflink_cancel_cow_blocks()
since i_delayed_blks has the value 22. xfs_reflink_cancel_cow_blocks()
indirectly invokes __xfs_free_extent() which returns EIO since
XFS_ERRTAG_FREE_EXTENT has been set. This leads to the filesystem to be
shutdown. The "rm" command invoked later ends up returning an
error and hence the test fails. The test actually requires that the
filesystem gets shutdown when executing the "rm" command.

To fix the problem, this commit injects the free_extent error after we
CoW file2's [10 * 64k, 19 * 64k] range.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/299: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:32 +0000 (20:49 +0530)]
xfs/299: work with 64k block size

This commit changes the test to calculate quota limits based on the
block size of the underlying filesystem. Also, the sizes of the test
files are now made to be a multiple of the filesystem block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/299: Fix "Push past soft inode limit" case
Chandan Rajendra [Mon, 24 Sep 2018 15:19:31 +0000 (20:49 +0530)]
xfs/299: Fix "Push past soft inode limit" case

The test sets an inode soft limit of four but only three files are
created. This commit creates two more files in order to really push past
the soft inode limit.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/190: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:30 +0000 (20:49 +0530)]
xfs/190: work with 64k block size

This commit describes "file hole" ranges in multiples of block sizes
rather than using constants.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/140: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:29 +0000 (20:49 +0530)]
xfs/140: work with 64k block size

For 64k block size, the agsize provided in the test causes mkfs.xfs to
fail due to insufficient log space. Hence this commit computes agsize
based on block size of the filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/139: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:28 +0000 (20:49 +0530)]
xfs/139: work with 64k block size

For 64k block size, the agsize provided in the test causes mkfs.xfs to
fail due to insufficient log space. Hence this commit computes agsize
based on block size of the filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/127: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:27 +0000 (20:49 +0530)]
xfs/127: work with 64k block size

With reflink feature enabled, we require atleast 500MiB of
disk space to create a filesystem with 64k block size. Hence this commit
sets the size of the scratch filesystem to 512MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/074: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:26 +0000 (20:49 +0530)]
xfs/074: work with 64k block size

This commit makes file and extent size calculations to be a function of
the filesystem's block size. It also adds a brief description of the
bug that is being tested.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/050: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:25 +0000 (20:49 +0530)]
xfs/050: work with 64k block size

This commit changes the test to calculate quota limits based on the
block size of the underlying filesystem. Also, the sizes of the test
files are now made to be a multiple of the filesystem block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/050: Fix "Push past soft inode limit" case
Chandan Rajendra [Mon, 24 Sep 2018 15:19:24 +0000 (20:49 +0530)]
xfs/050: Fix "Push past soft inode limit" case

The test sets an inode soft limit of four but only three files are
created. This commit creates two more files in order to really push past
the soft inode limit.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/009: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:23 +0000 (20:49 +0530)]
xfs/009: work with 64k block size

xfs_alloc_file_space() rounds up allocation requests by the filesystem
block size. Hence this commit changes the test to work with block size
units rather than with a multiple of 4096 bytes.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test uid/gid recovery after power failure
Chao Yu [Tue, 25 Sep 2018 08:45:58 +0000 (16:45 +0800)]
generic: test uid/gid recovery after power failure

After fsync, filesystem should guarantee inode metadata including
uid/gid being persisted, so even after sudden power-cut, durign
mount, we should recover uid/gid fields correctly, in order to not
loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/270: allow corrupted xfs_db write
Eric Sandeen [Tue, 25 Sep 2018 18:16:16 +0000 (13:16 -0500)]
xfs/270: allow corrupted xfs_db write

Upcoming verifiers treat the unknown ro_compat flag written via xfs_db
as corruption, so use the -d flag to allow it, and filter our the
resulting informational message.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: fix _test_generic_punch() to fit 64k extent
Anand Jain [Wed, 12 Sep 2018 07:48:44 +0000 (15:48 +0800)]
fstests: fix _test_generic_punch() to fit 64k extent

14 test cases use _test_generic_punch(), and they work well as long
as the ext4/xfs blocksize or btrfs sectorsize is below 4K.

In the system with 64K pagesize, as the blocksize can be upto 64K or the
sectorsize can be 64K so 13/14 test cases fail, because the
test-file-size (20k) and thus the extent boundary offsets aren't
big enough to fit the larger than 4k extent size.

Commit 2f194e4e820e6acfcfdadf9f488a162b22db9d86 (generic/009: don't run
for btrfs if PAGE_SIZE > 4096) tried to address this by calling the
not_run in generic/009.

And in the function _test_generic_punch() we use multiple=4 to address
the similar problem but its limited to the subcommand fcollapse.

Now to run these test cases successfully on systems with pagesize 64k,
this patch propose to increase the default multiple=1 to multiple=16.
With this we increase the test file size from 20k to 320k and thus it
encapsulates maximum extent size of 64k here. And we can drop the
multiple=4 which is just being done similar for the cases of fcollapse
subcommand only. And it appears to me there is no harm in increasing
the file size and offsets in general for all commands instead of just
fcollapse command.

This change is tested on ext4, xfs and btrfs on system with pagesize
4K and 64K.

With this patch, these 14 test cases runs fine on system with 64K
pagesize as well as pagesize 4K. However we may hit the same
limitation at some point when we want to validate the FSs with
pagesizes -gt 64K. And this patch does not address that part as of
now.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
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>