xfstests-dev.git
2 years agoxfs/260: Move and update xfs/260
Xiao Yang [Thu, 6 Aug 2020 02:13:39 +0000 (10:13 +0800)]
xfs/260: Move and update xfs/260

1) Both ext4 and xfs have supported FS_XFLAG_DAX so move it to generic.
2) Modifying FS_XFLAG_DAX on flies does not take effect immediately so
   make files inherit the DAX state of parent directory.
3) Setting/clearing FS_XFLAG_DAX have no chance to change S_DAX flag if
   mount with dax option so remove the related subtest.
4) Setting/clearing FS_XFLAG_DAX doesn't change S_DAX flag on older xfs
   due to commit 742d84290739 ("xfs: disable per-inode DAX flag") so
   only do test when fs supports new dax=inode option.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/413, xfs/260: Improve format operation for PMD fault testing
Xiao Yang [Thu, 6 Aug 2020 02:13:38 +0000 (10:13 +0800)]
generic/413, xfs/260: Improve format operation for PMD fault testing

1) Simple code and fix the wrong value of stripe_width by _scratch_mkfs_geom().
2) Get hugepage size by _get_hugepagesize() and replace fixed 2M with
   hugepage size because hugepage size/PMD_SIZE is not 2M on some
   arches(e.g. hugepage size/PMD_SIZE is 512M on arm64).
3) For debugging, redirect the output of mkfs to $seqres.full.

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>
2 years agogeneric/223: Don't clear MKFS_OPTION before calling _scratch_mkfs_geom()
Xiao Yang [Thu, 6 Aug 2020 02:13:37 +0000 (10:13 +0800)]
generic/223: Don't clear MKFS_OPTION before calling _scratch_mkfs_geom()

Current _scratch_mkfs_geom() adds geometry parameters to the end of the
MKFS_OPTIONS blindly.  ext4 can accept the last one if geometry parameters
and original MKFS_OPTION have the same mkfs options but xfs cannot accept
them and reports "xxx option is respecified" error.  Make _scratch_mkfs_geom()
override the same mkfs options in original MKFS_OPTION by geometry parameters.

With this change, generic/223 doesn't need to clear original MKFS_OPTION
before calling _scratch_mkfs_geom() and can use other mkfs options in original
MKFS_OPTION.

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>
2 years agofstests: Use _require_scratch_dax_mountopt() and _require_dax_iflag()
Xiao Yang [Thu, 6 Aug 2020 02:13:36 +0000 (10:13 +0800)]
fstests: Use _require_scratch_dax_mountopt() and _require_dax_iflag()

1) Make related tests use _require_scratch_dax_mountopt() and _require_dax_iflag().
2) Remove unused _require_scratch_dax().

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: Introduce helpers for new dax mount options and FS_XFLAG_DAX
Xiao Yang [Thu, 6 Aug 2020 02:13:35 +0000 (10:13 +0800)]
common/rc: Introduce helpers for new dax mount options and FS_XFLAG_DAX

1) _check_scratch_dax_mountopt() checks old/new dax mount option and
   returns a value.
2) _require_scratch_dax_mountopt() throws notrun if _check_scratch_dax_mountopt()
   returns a non-zero value.
3) _require_dax_iflag() checks FS_XFLAG_DAX.

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>
2 years agogeneric/452: Fix the wrong commit id
Xiao Yang [Wed, 29 Jul 2020 05:17:01 +0000 (13:17 +0800)]
generic/452: Fix the wrong commit id

The mentioned commit 42d4a99b09cb doesn't exist so use the correct one.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoext4: Test read-only external journal device
Lukas Czerner [Mon, 27 Jul 2020 10:26:18 +0000 (12:26 +0200)]
ext4: Test read-only external journal device

We should never be able to mount ext4 file system read-write with
read-only external journal device. Test it.

This problem has been addressed with proposed kernel patch
https://lore.kernel.org/linux-ext4/20200717090605.2612-1-lczerner@redhat.com/

The test was based on generic/050.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/062: use more restrictive filter when querying for attributes
Jeff Layton [Wed, 5 Aug 2020 13:53:08 +0000 (09:53 -0400)]
generic/062: use more restrictive filter when querying for attributes

Sometimes we can end up with unexpected xattrs showing up on an inode.
For instance, on an SELinux-enabled host security.selinux may be set and
show up in a listing even though we've never set it.

generic/062 lists out all of the xattrs on an inode in some cases, but
it can't easily account for these "automatic" xattrs being set. Change
it to use a more restrictive regex when filtering attributes, so that we
just get the namespaces we're interested in.

Cc: Zorro Lang <zlang@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/377: filter out xattrs that don't start with 'user.'
Jeff Layton [Wed, 5 Aug 2020 13:53:07 +0000 (09:53 -0400)]
generic/377: filter out xattrs that don't start with 'user.'

Most hosts that I've been testing on seem to display security.selinux in
listxattr. 377.out doesn't account for that so it routinely fails for me
in testing.

When testing the output of listxattr in generic/377, filter out any xattr
names that don't start with 'user.'. That should help ensure consistent
output on SELinux-enabled hosts.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/263: filters to accommodate new xfs_quota state command and prevent regression
Bill O'Donnell [Mon, 3 Aug 2020 13:46:00 +0000 (08:46 -0500)]
xfs/263: filters to accommodate new xfs_quota state command and prevent regression

New xfs_quota kernel and xfsprogs add grace timers for group and project,
in addition to user quota. Adjust xfs/263 to accommodate those
changes, and avoid regression.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/{050,299}: clear quota warnings in between checks
Darrick J. Wong [Thu, 30 Jul 2020 18:34:38 +0000 (11:34 -0700)]
xfs/{050,299}: clear quota warnings in between checks

Both of these quota tests contain the output of the xfs_quota repquota
command in the golden output.  Unfortunately, the output was recorded
before quota soft warnings were implemented, which means they'll regress
the output when we make quota warning work.  Fix this by resetting the
warning count to zero before generating output.

While we're at it, use $XFS_QUOTA_PROG instead of xfs_quota.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/{263,106}: erase max warnings printout
Darrick J. Wong [Thu, 30 Jul 2020 18:35:33 +0000 (11:35 -0700)]
xfs/{263,106}: erase max warnings printout

Both of these tests encode the xfs_quota output in the golden output.
Now that we've changed xfs_quota to emit max warnings, we have to fix
the test to avoid regressions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/518: modify timer/state commands to remove new g,p timer output
Bill O'Donnell [Fri, 31 Jul 2020 17:37:39 +0000 (12:37 -0500)]
xfs/518: modify timer/state commands to remove new g,p timer output

New xfs_quota kernel and xfsprogs add grace timers for group and project,
in addition to existing user quota. Adjust xfs/518 to accommodate those
changes, and avoid regression.

Signed-off-by: Bill O'Donnell <billodo@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: Add test to check if shrink works well with fstrim
Qu Wenruo [Thu, 30 Jul 2020 12:17:35 +0000 (20:17 +0800)]
btrfs: Add test to check if shrink works well with fstrim

There is a bug in trim code which leads to fstrim accessing beyond
device boundary.

The test case will check if fstrim, then shrink, then fstrim, all of
them works without problem.

The fix is titled "btrfs: trim: fix underflow in trim length to prevent
access beyond device boundary".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/030: repair should actually find the zeroed block pointer in the agfl
Darrick J. Wong [Wed, 29 Jul 2020 16:14:43 +0000 (09:14 -0700)]
xfs/030: repair should actually find the zeroed block pointer in the agfl

In xfs/030, we zero the entire AGFL which makes it corrupt because the
AG superblock block is /never/ free.  In commit dcd6c2e1 ("xfs_repair:
convert to libxfs_verify_agbno") we enhanced repair to complain about
zeroed entries in the AGFL, so add that to the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/603: don't run on XFS v4 filesystems
Darrick J. Wong [Wed, 29 Jul 2020 02:51:41 +0000 (19:51 -0700)]
generic/603: don't run on XFS v4 filesystems

XFS filesystems require V5 format to support all three quota types at
the same time, so skip the test if we're testing XFS older than that.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/162: Stop using device mount option
Nikolay Borisov [Fri, 24 Jul 2020 13:12:50 +0000 (16:12 +0300)]
btrfs/162: Stop using device mount option

btrfs is clever enough to figure out which devices constitute the
sprout fs even without specifying them explicitly with -o device.
Additionally, explicitly settings the devices via -o device reduces
coverage of the test since it didn't detect breakage a local change
introduced. Without -o device instead this breakage was detected.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/501: make the test work on machines with a non 4K page size
Filipe Manana [Wed, 22 Jul 2020 14:12:54 +0000 (15:12 +0100)]
generic/501: make the test work on machines with a non 4K page size

Currently generic/501 fails on machines with a page size different from 4K
(like ppc64le), because the clone operation fails with -EINVAL due to the
fact we pass it an offset that is 4K aligned but not aligned to the page
size of the machine.

The test doesn't actually need offsets and lengths to be 4K aligned, so
just update the test to use offsets and lenghts that work for page size.
Also add a comment mentioning that a file size of at least 16Mb was a
necessary condition to trigger the btrfs bug.

The test is a regression test for a btrfs issue fixed by kernel commit
bd3599a0e142cd ("Btrfs: fix file data corruption after cloning a range
and fsync"), which landed in kernel 4.18.

Since I couldn't compile a 4.17 kernel on debian testing, I tried this
with a 4.18 kernel with that commit reverted, and it fails as expected
on a x86_64 box:

$ ./check generic/501
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 debian9 4.18.0-btrfs-next-64 #1 SMP (...)
MKFS_OPTIONS  -- /dev/sdc
MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

generic/501 1s ... - output mismatch (see .../xfstests/results//generic/501.out.bad)
    --- tests/generic/501.out 2020-07-22 14:50:12.585674202 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//generic/501.out.bad ...
    @@ -2,4 +2,4 @@
     File bar digest before power failure:
     69319d0343ab8f5ea564167da445addc  SCRATCH_MNT/bar
     File bar digest after power failure:
    -69319d0343ab8f5ea564167da445addc  SCRATCH_MNT/bar
    +21de7d7325fe4dae1f3311d5a76f819f  SCRATCH_MNT/bar
    ...
    (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/generic/501.out ...
Ran: generic/501
Failures: generic/501
Failed 1 of 1 tests

Without the commit reverted it passes as expected.

Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/210: Ignore output from "quota rescan" after "quota enable"
Marcos Paulo de Souza [Tue, 21 Jul 2020 12:46:30 +0000 (09:46 -0300)]
btrfs/210: Ignore output from "quota rescan" after "quota enable"

Command "quota enable" triggers a quota rescan, but it can finish
quick in some machines leading to the next command "quota rescan" to
be able to start scanning again, and then printing "quota rescan
started" making the test fail.

In some machines this don't happen because the first rescan
initiated by "quota enable" is still running when "quota rescan" is
executed, returning -EINPROGRESS from ioctl
BTRFS_IOC_QUOTA_RESCAN_STATUS and not printing the message.

Ignoring any output from "quota rescan" solves the issue in both
cases, and this is already being done by others tests as well.

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: add missing runtime checks for mknod/mkfifo
Vladimir Zapolskiy [Tue, 21 Jul 2020 09:38:30 +0000 (12:38 +0300)]
generic: add missing runtime checks for mknod/mkfifo

Some generic tests explicitly run 'mknod' or 'mkfifo' command, however
the correspondent runtime check is missing, this results in a test
failure instead of selecting not to execute the test.

The change adds _require_mknod check to the next generic tests:

  * generic/157
  * generic/158
  * generic/294
  * generic/423

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: associate a few tests with punch and zero test groups
Vladimir Zapolskiy [Tue, 21 Jul 2020 09:38:09 +0000 (12:38 +0300)]
generic: associate a few tests with punch and zero test groups

In runtime the modified tests requires and utilizes fpunch command
of xfs_io, thus a tested filesystem shall support the feature and
running a filesystem check by "punch" group selection should include
these tests:

  * generic/176
  * generic/415
  * generic/447
  * generic/469
  * generic/562

In addition and due to the same reasons add generic/469 to zero test
group, the test already contains _require_xfs_io_command "fzero" check.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: add a test for umount racing mount
Boris Burkov [Mon, 20 Jul 2020 19:05:56 +0000 (12:05 -0700)]
generic: add a test for umount racing mount

Test if dirtying many inodes (which can delay umount) then
unmounting and quickly mounting again causes the mount to fail.

A race, which breaks the test in btrfs, is fixed by kernel commit
48cfa61b58a1 ("btrfs: fix mount failure caused by race with umount")

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: test if show_devname returns sprout device
Anand Jain [Mon, 20 Jul 2020 03:55:54 +0000 (11:55 +0800)]
btrfs: test if show_devname returns sprout device

Test if the show_devname() returns sprout device instead of seed device.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: add unionmount tests with nested overlay
Amir Goldstein [Sun, 31 May 2020 11:01:56 +0000 (14:01 +0300)]
overlay: add unionmount tests with nested overlay

These tests use an overlay mount as lower layer for a nested overlay.
That provides test coverage for a lower layer with null uuid and
lower layer with real inode numbers that use the high xino bits.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: add unionmount tests with multi lower layers
Amir Goldstein [Sun, 31 May 2020 11:01:55 +0000 (14:01 +0300)]
overlay: add unionmount tests with multi lower layers

The tests with multi lower layers rotate the upper layer into a lower
layer on specific operations such as mkdir, rename and link.
That provides test coverage for redirect_dir and index features.

The following variations are covered:
1. All layers all on scratch fs (--ov=10 --samefs)
2. All layers on scratch fs expect for lowermost on test fs (--ov=10)
3. Lowermost layer on test fs, one layer on tmpfs and the rest
   on sratch fs (--ov=10 --maxfs=1)
4. Lowermost layer on test fs, one layer on scratch fs and the rest
   are unique tmpfs instances (--ov=10 --maxfs=10)

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: run unionmount testsuite test cases
Amir Goldstein [Sun, 31 May 2020 11:01:54 +0000 (14:01 +0300)]
overlay: run unionmount testsuite test cases

Add support for running unionmount-testsuite from xfstests.
This requires that unionmount-testsuite is installed under src dir or
that UNIONMOUNT_TESTSUITE variable points to the location of the
testsuite.  It also requires a recent version of unionmount-testsuite
that supports setting basedir path via UNIONMOUNT_* environment variables.

Add tests for three basic configurations:
1. overlay with upper/lower on same fs
2. overlay with upper/lower not on same fs without xino
3. overlay with upper/lower not on same fs with xino

The samefs test uses scratch partition for lower/upper layers.
The non samefs tests use the scratch partition for upper layer and the
test partition for lower layer.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/587: associate the test with quota test group
Vladimir Zapolskiy [Fri, 17 Jul 2020 11:09:36 +0000 (14:09 +0300)]
generic/587: associate the test with quota test group

The test checks regressions on quota accounting and therefore it relies
on quota support by a tested filesystem, this makes it reasonable to
include the test into 'quota' test group for better managing of test
groups.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: fix insert test group associations
Vladimir Zapolskiy [Fri, 17 Jul 2020 08:22:07 +0000 (11:22 +0300)]
generic: fix insert test group associations

The change makes one-in-one correspondence between generic tests in
'insert' test group and tests with $(_require_xfs_io_command "finsert")
runtime check:

* generic/348 -- insert group association is removed,
* generic/458 -- insert group association is added.

The intention of the change is to get better summarized association
between tests and test groups to be able to operate with test groups
in a better way.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocheck: clear WARN_ONCE state before each test
Lukas Czerner [Wed, 15 Jul 2020 11:42:19 +0000 (13:42 +0200)]
check: clear WARN_ONCE state before each test

clear WARN_ONCE state before each test to allow a potential problem
to be reported for each test

[Eryu: replace "/sys/kernel/debug" with $DEBUGFS_MNT ]

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/038: assign the test to trim group of tests
Vladimir Zapolskiy [Wed, 15 Jul 2020 13:08:38 +0000 (16:08 +0300)]
generic/038: assign the test to trim group of tests

The test runs fstrim utility to stress a filesystem, however it implies
that the filesystem supports ioctl(FITRIM), this is checked in runtime by
_require_batched_discard() in the test itself, however the assignment of
the test to trim group is missing.

The intention of the change is to get better association between tests
and test groups.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/079: remove assignment of the test to acl and attr groups
Vladimir Zapolskiy [Mon, 13 Jul 2020 12:26:48 +0000 (15:26 +0300)]
generic/079: remove assignment of the test to acl and attr groups

The test does not belong to acl group of tests, and expectedly the test
is supposed to pass on a filesystem which supports file attributes but
not ACLs.

In addition the test should be removed from attr group of tests, because
the attr group specifies tests which operate over extended file attributes,
this test does not fall into this category.

The change is intended to improve the assignment of tests to groups
to get better testing coverage, if a list of run tests is selected by
test group attributes.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: assign a number of tests to attr group
Vladimir Zapolskiy [Mon, 13 Jul 2020 12:26:28 +0000 (15:26 +0300)]
generic: assign a number of tests to attr group

A few generic tests have a _require_attrs runtime check for support
of extended file attributes by a tested filesystem, review shows that
the tests listed below are definitely using extended file attributes,
thus this implies that the tested filesystem should provide support of
the feature in general.

Adding the tests explicitly to attr group of tests allows to get a better
granularity of selecting or deselecting tests by groups in accordance to
extended file attributes feature given by a filesystem, the change affects
the next list of tests:

  * generic/037
  * generic/066
  * generic/103
  * generic/337
  * generic/449

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: reorder output to stderr and stdout from _scratch_mkfs
Vladimir Zapolskiy [Sat, 11 Jul 2020 09:23:19 +0000 (12:23 +0300)]
generic: reorder output to stderr and stdout from _scratch_mkfs

The change fixes false positives from generic/554 and generic/565 tests,
when supplementary output of an mkfs utility to stderr apprears to be mixed
into the test output, which results into non-empty diff with the expected
output found in *.out files.

The change unifies _scratch_mkfs redirections among all generic tests, these
two modified tests are the only ones with the swapped order of output
redirections.

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: fix false positives due to leaked mkfs output to stderr
Vladimir Zapolskiy [Fri, 10 Jul 2020 14:13:50 +0000 (17:13 +0300)]
common/rc: fix false positives due to leaked mkfs output to stderr

The change fixes false positives reported by a few generic tests under
circumstances, when an mkfs utility prints its output to stderr and then it
appears in produced *.out files. The change is intended to fix such issues
in the tests, which utilize _require_scratch_swapfile().

Signed-off-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/530: Require metadata journaling
Jan Kara [Thu, 9 Jul 2020 09:57:53 +0000 (11:57 +0200)]
generic/530: Require metadata journaling

Test generic/530 doesn't make sence without metadata journalling as in
that case, there's no way to recover shutdown fs besides fsck. ext4
can be configured without a journal and it supports shutdown ioctl even
in that mode which makes this test fail for that configuration. Add
requirement for metadata journalling to this test so that it's properly
skipped.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/518: require scratch device
Darrick J. Wong [Thu, 9 Jul 2020 15:36:55 +0000 (08:36 -0700)]
xfs/518: require scratch device

This test requires the scratch device, so we need to test for it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocheck: add CLI option to repeat tests
Dave Chinner [Wed, 8 Jul 2020 05:35:13 +0000 (15:35 +1000)]
check: add CLI option to repeat tests

Frequently when trying to reproduce a problem I want to run a set of
specific tests in a loop, over and over again. I run fstests from a
set of run scripts that have non-trivial overhead (e.g. patterning
block devices before the runs start), so if all I want to do is run
the same test 100x, using a shell loop over the entire run
scripts reduces the iteration rate substantially.

Hence add an option to check to allow fstests to loop a number of
times over the configured test set without stopping.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: add test for CVE-2020-12655
Gao Xiang [Wed, 24 Jun 2020 01:06:30 +0000 (09:06 +0800)]
xfs: add test for CVE-2020-12655

Add a regression test to see if kernel hangs in order to
look after CVE-2020-12655 and check if the corresponding
fix is applied as well.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: test that corruption counter is incremented correctly
Nikolay Borisov [Thu, 2 Jul 2020 14:38:23 +0000 (17:38 +0300)]
btrfs: test that corruption counter is incremented correctly

This patch ensures device corrupted counter is being modified when we try to
read broken data.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: test per-type quota softlimit enforcement timeout
Zorro Lang [Sun, 5 Jul 2020 12:28:42 +0000 (20:28 +0800)]
generic: test per-type quota softlimit enforcement timeout

Set different block & inode grace timers for user, group and project
quotas, then test softlimit enforcement timeout, make sure different
grace timers as expected.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/516: Use scratch_xfs_get/set_sb_field api
Yang Xu [Tue, 30 Jun 2020 06:23:07 +0000 (14:23 +0800)]
xfs/516: Use scratch_xfs_get/set_sb_field api

When using old xfsprogs, this case fails as below:
    +write: invalid option -- 'd'

xfs_db write command support -d options since xfsprogs commit
86769b32d01 ("xfs_db: allow recalculating CRCs on invalid metadata").
For avoid invalid error, use scratch_xfs_set_sb_field api instead.

Also add missing "rm -f $seqres.full" at the beginning of the test.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/361: disable xfs metadata io error retries
Darrick J. Wong [Wed, 24 Jun 2020 03:52:54 +0000 (20:52 -0700)]
generic/361: disable xfs metadata io error retries

This test examines the behavior of xfs when the underlying filesystem is
a sparse image on the scratch filesystem when the scratch fs is about to
run out of space.  Unfortunately, the test assumes that the scratch fs
will ENOSPC on the large data write.  It's possible that metadata
writeback will hit ENOSPC instead, and if we do, the test will hang
forever while xfs retries the write.  Make sure we're set up to fail
fast so that we don't hang the test appliance.

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>
2 years agogeneric/270: wait for fsstress processes to be killed
Lukas Czerner [Mon, 15 Jun 2020 10:52:36 +0000 (12:52 +0200)]
generic/270: wait for fsstress processes to be killed

Currently wait will do nothing, because $pid is empty due to the fact
that the command was ran on the background in a separate shell so we
never got the $! set.

This is causing unexpected test failures especially under low memory
due to the fact that the fsstress is still running when we are
checking and comparing quota usage.

Fix it by using -w argument for killall that will wait for all processes
to actually die before it exits.

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: regression test for two file handle bugs
Amir Goldstein [Sun, 14 Jun 2020 07:01:09 +0000 (10:01 +0300)]
overlay: regression test for two file handle bugs

Test two overlayfs file handle bugs:

 1. Failure to query file handle size
    Fixed by kernel commit 144da23beab8:
        ovl: return required buffer size for file handles

 2. Kernel OOPS on open by hand crafted malformed file handle
    Fixed by kernel commit 9aafc1b01873:
        ovl: potential crash in ovl_fid_to_fh()

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoopen_by_handle: add option -z to query file handle size
Amir Goldstein [Sun, 14 Jun 2020 07:01:08 +0000 (10:01 +0300)]
open_by_handle: add option -z to query file handle size

Instead of using MAX_HANDLE_SZ, query the filesystem buffer size
and use that buffer size to get the file handle.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/471: adapt test when running on btrfs to avoid failure on RWF_NOWAIT write
Filipe Manana [Fri, 12 Jun 2020 14:06:03 +0000 (15:06 +0100)]
generic/471: adapt test when running on btrfs to avoid failure on RWF_NOWAIT write

This test currently always fails on btrfs:

generic/471 2s ... - output mismatch (see ...results//generic/471.out.bad)
    --- tests/generic/471.out   2020-06-10 19:29:03.850519863 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//generic/471.out.bad   ...
    @@ -2,12 +2,10 @@
     pwrite: Resource temporarily unavailable
     wrote 8388608/8388608 bytes at offset 0
     XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
    -RWF_NOWAIT time is within limits.
    +pwrite: Resource temporarily unavailable
    +(standard_in) 1: syntax error
    +RWF_NOWAIT took  seconds

This is because btrfs is a COW filesystem and an attempt to write into a
previously written file range allocating a new extent (or multiple).
The only exceptions are when attempting to write to a file range with a
preallocated/unwritten extent or when writing to a NOCOW file that has
extents allocated in the target range already.

The test currently expects that writing into a previously written file
range succeeds, but that is not true on btrfs since we are not dealing
with a NOCOW file. So to make the test pass on btrfs, set the NOCOW bit
on the file when the filesystem is btrfs.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/dmthin: modify DMTHIN_POOL_NAME
Jeffle Xu [Fri, 12 Jun 2020 05:18:20 +0000 (13:18 +0800)]
common/dmthin: modify DMTHIN_POOL_NAME

_dmthin_set_queue() gets $cluster_size by 'dmsetup table | grep
$DMTHIN_POOL_NAME'. The original name 'thin-pool' is accidently
the same as the fourth field of the output of 'dmsetup table'.

For example,
vg-pool-tpool: 0 64864256 thin-pool 252:0 252:1 128 0 0

Thus if there is other thin-pool in the test environment, except
for the thin-pool created by _dmthin_init(), the parsed $cluster_size
may be a multi-line string, which is unexpected.

This issue caused a failure of generic/347 and generic/500, while the
dmesg reports 'Invalid argument count'.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
Gao Xiang [Fri, 12 Jun 2020 01:40:18 +0000 (09:40 +0800)]
common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify

When stressing xfs/083, I found it sometimes fails as the following:

+++ touch 50000 files
setfattr: /home/fsgqa/scratchmnt/INOBT/20627: Operation not permitted
./common/fuzzy: line 18: /home/fsgqa/scratchmnt/INOBT/20627: Operation not permitted
mv: cannot move '/home/fsgqa/scratchmnt/INOBT/20627' to '/home/fsgqa/scratchmnt/INOBT/20627.longer': Operation not permitted
...
xfs_repair did not fix everything

It's simply that INOBT/20627 was an immutable file generated from
fuzzing. Therefore, this patch tries to clear append, immutable flag
first before modification. Note that it clears dax flag as well
since it prevents immutable flag from clearing.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoREADME: add note about 123456-fsgqa user creation step
Aurelien Aptel [Thu, 11 Jun 2020 12:41:33 +0000 (14:41 +0200)]
README: add note about 123456-fsgqa user creation step

Signed-off-by: Aurelien Aptel <aaptel@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/096: filter out the "Discarding..." output
Zorro Lang [Tue, 9 Jun 2020 08:24:42 +0000 (16:24 +0800)]
xfs/096: filter out the "Discarding..." output

Latest xfsprogs mkfs.xfs prints "Discarding blocks...Done" if the
disk supports the trim. That breaks the golden image, cause
unexpected failure, so filter out it.

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>
2 years agoext4: add empty lines to mkfs_filter
Harshad Shirwadkar [Fri, 5 Jun 2020 23:31:03 +0000 (16:31 -0700)]
ext4: add empty lines to mkfs_filter

Mkfs program can dump empty lines if encounters warnings and results
in test to fail. One of the case when this happens is when we are
trying to create a big file system (> 4T) and if "big" is not present
in /etc/mke2fs.conf. Ignore those empty lines too.

Before the fix, test generic/472 failed with following diff

diff /root/xfstests/tests/generic/472.out /root/xfstests/results//generic/472.out.bad
@@ -1,6 +1,6 @@
 QA output created by 472
 +
 +
  regular swap
  too long swap
  tiny swap
After the fix, test generic/472 passed
Ran generic/472
Passed all 1 tests

Signed-off-by: Harshad Shirwadkar <harshadshirwadkar@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: modify user name beginning with non-digit
Yong Sun [Fri, 5 Jun 2020 03:12:38 +0000 (11:12 +0800)]
fstests: modify user name beginning with non-digit

openSUSE and SLE don't support username begin with digit, so it will
skip test generic/597 and generic/598 by lack of 123456-fsgqa user.
generic/597 and 598 are not test username begin with digit on purpose
(different with generic/381). It's will be helpful to use an username
begin with non-digit in this case.

Signed-off-by: Sun Yong <yosun@suse.com>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: verify ciphertext of IV_INO_LBLK_32 encryption policies
Eric Biggers [Thu, 4 Jun 2020 02:25:01 +0000 (19:25 -0700)]
generic: verify ciphertext of IV_INO_LBLK_32 encryption policies

Verify the ciphertext for v2 encryption policies that use the
IV_INO_LBLK_32 flag and that use AES-256-XTS to encrypt file contents
and AES-256-CTS-CBC to encrypt file names.

The IV_INO_LBLK_32 encryption policy flag modifies the IV generation and
key derivation to be optimized for use with inline encryption hardware
that only accepts 32-bit IVs.  It is similar to IV_INO_LBLK_64 (which is
tested by generic/592), but it uses a trick to get the IV down to 32
bits.  For more information, see kernel commit e3b1078bedd3 ("fscrypt:
add support for IV_INO_LBLK_32 policies").

This test required adding SipHash support to fscrypt-crypt-util.

Running this test requires a kernel containing the above commit, e.g.
the latest mainline (which will become v5.8 and later).  For ext4, it
also needs an e2fsprogs version that supports the stable_inodes feature,
e.g. the latest git master branch (which will become v1.46 and later).

Signed-off-by: Eric Biggers <ebiggers@google.com>
2 years agobtrfs: test if the capability is kept on incremental send
Marcos Paulo de Souza [Mon, 1 Jun 2020 19:48:45 +0000 (16:48 -0300)]
btrfs: test if the capability is kept on incremental send

This test exercises full send and incremental send operations for cases
where files have capabilities, ensuring the capabilities aren't lost in
the process.

There was a problem with kernel <=5.7 that was making capabilities
to be lost after a combination of full + incremental send. This
behavior was fixed by commit 89efda52e6b6 ("btrfs: send: emit file
capabilities after chown").

Signed-off-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: individual user grace period extension via xfs_quota
Eric Sandeen [Mon, 18 May 2020 20:01:08 +0000 (15:01 -0500)]
fstests: individual user grace period extension via xfs_quota

Test that we can extend an individual user's grace time once they
reach their soft limit.

[Eryu: add "Slilence is golden" output]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: individual user grace period extension via setquota
Eric Sandeen [Mon, 18 May 2020 20:00:36 +0000 (15:00 -0500)]
fstests: individual user grace period extension via setquota

Test that we can extend an individual user's grace time once they
reach their soft limit.

[Eryu: add "Silence is golden" output]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: test data integrity for rdonly remount
Chengguang Xu [Tue, 19 May 2020 08:09:29 +0000 (16:09 +0800)]
fstests: test data integrity for rdonly remount

This test checks data integrity when remounting from rw to ro mode.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/484: add _require_xfs_io_command "syncfs"
Yang Xu [Thu, 28 May 2020 07:32:59 +0000 (15:32 +0800)]
generic/484: add _require_xfs_io_command "syncfs"

When using old xfsprogs version, xfs_io doesn't support syncfs command.
It was not fixed until xfsprogs commit eb24bcffc0("xfs_io: fix missing syncfs command").
Add a require for this so that we can skip this case if xfs_io doesn't
support syncfs command.

Reported-by: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay/031: fix failure with whiteout inode sharing
Amir Goldstein [Wed, 20 May 2020 08:53:44 +0000 (11:53 +0300)]
overlay/031: fix failure with whiteout inode sharing

Kernel commit c21c839b8448 "ovl: whiteout inode sharing" results in
a temp whiteout file resident inside work dir.

Test overlay/031 is a regression test for two user visible bugs:
1. Exposed whiteouts in overlay
2. Failure to remove directory

It also has a sanity tests for a harmless by-product of the bug -
a residue file in work dir.

The new temp whiteout file looks like a residue and causes the test
to fail.

Drop this sanity test, because it is not vital to the regression test.
We could also check if the residue is a single whiteout, but that is
not really needed, so best not poke into overlay internal work dir.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: Add a test for dead looping balance after balance cancel
Qu Wenruo [Thu, 21 May 2020 00:52:15 +0000 (08:52 +0800)]
btrfs: Add a test for dead looping balance after balance cancel

Test if canceling a running balance can cause later balance to dead
loop.

The fix is titled "btrfs: relocation: Clear the DEAD_RELOC_TREE bit for
 orphan roots to prevent runaway balance".

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: Add a test for leaking root crash at unmount time
Qu Wenruo [Wed, 20 May 2020 11:44:42 +0000 (19:44 +0800)]
btrfs: Add a test for leaking root crash at unmount time

Test if canceled balance could lead to root leakage.
If the kernel has CONFIG_BTRFS_DEBUG compiled, unmount time root leakge
check would detect it, and cause NULL pointer dereference as the pages
of the leaked root are already freed.

The fix is titled "btrfs: relocation: Fix reloc root leakage and the NULL
 pointer reference caused by the leakage".

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: renumber tests after merge
Eryu Guan [Sun, 24 May 2020 16:07:45 +0000 (00:07 +0800)]
fstests: renumber tests after merge

Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: test sunit/swidth updates
Darrick J. Wong [Thu, 23 Apr 2020 23:32:15 +0000 (16:32 -0700)]
xfs: test sunit/swidth updates

Add one test to make sure that we can update sunit without blowing up
the filesystem.  This is a regression test for 13eaec4b2adf ("xfs: don't
commit sunit/swidth updates to disk if that would cause repair
failures").

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>
2 years agoxfs: make sure our default quota warning limits and grace periods survive quotacheck
Darrick J. Wong [Thu, 23 Apr 2020 23:32:08 +0000 (16:32 -0700)]
xfs: make sure our default quota warning limits and grace periods survive quotacheck

Make sure that the default quota grace period and maximum warning limits
set by the administrator survive quotacheck.  This is a regression test
for 5885539f0af371 ("xfs: preserve default grace interval during
quotacheck").

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>
2 years agoxfs: race freeze and fsmap for a while to see if we livelock
Darrick J. Wong [Thu, 23 Apr 2020 23:32:02 +0000 (16:32 -0700)]
xfs: race freeze and fsmap for a while to see if we livelock

Run fsfreeze and fsmap against each other in a loop to see if we observe
any livelocks, crashes, or odd slowness from either operation.  This is
a regression test for 27fb5a72f50aa77 ("xfs: prohibit fs freezing when
using empty transactions").

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>
2 years agoxfs: test that reflink forces the log if mounted with wsync
Darrick J. Wong [Thu, 23 Apr 2020 23:31:53 +0000 (16:31 -0700)]
xfs: test that reflink forces the log if mounted with wsync

A code inspection revealed that reflink does not force the log to disk
even if the filesystem is mounted with wsync.  Add a regression test for
commit 5833112df7e9a ("xfs: reflink should force the log out if mounted
with wsync").

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>
2 years agofstests: check for unknown flag result in _require_xfs_io_command
Eric Sandeen [Mon, 18 May 2020 16:18:08 +0000 (11:18 -0500)]
fstests: check for unknown flag result in _require_xfs_io_command

If we are testing for "xfs_io -c chattr $FOO" be sure to catch any
unknown flag output and _notrun

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: add _require_mknod
Eric Sandeen [Mon, 18 May 2020 16:16:47 +0000 (11:16 -0500)]
fstests: add _require_mknod

Add a _require_mknod test so that filesystems with no ->mknod
operation will _notrun instead of fail, and add the helper to
all necessary tests.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: test restricted file access sysctls
Eric Sandeen [Mon, 18 May 2020 16:15:34 +0000 (11:15 -0500)]
fstests: test restricted file access sysctls

This tests the fs.protected_regular and fs.protected_fifos
sysctls which restrict access behavior in sticky world-writable
directories as documented in the kernel at
Documentation/admin-guide/sysctl/fs.rst

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: test restricted symlinks & hardlinks sysctls
Eric Sandeen [Mon, 18 May 2020 16:14:43 +0000 (11:14 -0500)]
fstests: test restricted symlinks & hardlinks sysctls

This tests the fs.protected_symlinks and fs.protected_hardlinks
sysctls which restrict links behavior in sticky world-writable
directories as documented in the kernel at
Documentation/admin-guide/sysctl/fs.rst

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: add _require_sysctl_variable helper
Eric Sandeen [Mon, 18 May 2020 16:11:31 +0000 (11:11 -0500)]
fstests: add _require_sysctl_variable helper

New _require_sysctl_variable test to ensure that the sysctl we wish to
test is available on the system.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/14{2,3}: use dm-dust instead of fail_make_request
Omar Sandoval [Wed, 15 Apr 2020 20:54:31 +0000 (13:54 -0700)]
btrfs/14{2,3}: use dm-dust instead of fail_make_request

These two tests test direct I/O and buffered read repair, respectively,
with fail_make_request. However, by using "fail_make_request/times",
they rely on repair having a specific I/O pattern. My pending Btrfs
direct I/O refactoring patch series changes this I/O pattern and thus
breaks this test.

The dm-dust target (added in v5.2) emulates a device with bad blocks
that are fixed when written to (like a device that remaps bad blocks).
This is exactly what we want for testing repair. Add some common dm-dust
helpers and update the tests to use dm-dust.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: test for whiteout inode sharing
Chengguang Xu [Wed, 13 May 2020 19:23:38 +0000 (22:23 +0300)]
overlay: test for whiteout inode sharing

This is a test for whiteout inode sharing feature.

[Amir] added check for whiteout sharing support
       and whiteout of lower dir.

Signed-off-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: update sparse file & negative timestamp tests for exfat
Eric Sandeen [Wed, 6 May 2020 22:16:50 +0000 (17:16 -0500)]
fstests: update sparse file & negative timestamp tests for exfat

exfat cannot do sparse files or negative timestamps, so exclude
tests which require these.

Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/506: fix _require test, use xfs_io vs chattr
Eric Sandeen [Fri, 8 May 2020 03:25:51 +0000 (22:25 -0500)]
generic/506: fix _require test, use xfs_io vs chattr

_require_prjquota doesn't work on xfs unless the scratch device has
been mounted with project quota, so do that prior to the test.

older chattr/lsattr don't understand project quotas, so use xfs_io
instead for compatibility on older systems.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: test reporting of wb errors via syncfs
Jeff Layton [Thu, 30 Apr 2020 11:59:02 +0000 (07:59 -0400)]
generic: test reporting of wb errors via syncfs

Add a test for new syncfs error reporting behavior. When an inode fails
to be written back, ensure that a subsequent call to syncfs() will also
report an error.

Kernel with the following patches should pass the test:

  vfs: track per-sb writeback errors and report them to syncfs
  buffer: record blockdev write errors in super_block that it backs

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/fssum: Fix duplicate CLI arguments
Arvind Raghavan [Thu, 30 Apr 2020 00:13:54 +0000 (20:13 -0400)]
src/fssum: Fix duplicate CLI arguments

fssum currently has a duplicate '-x' flag, which is used for both
excluding paths and including xattrs. As the former is the only one
currently used in xfstests, this patch renames the latter to use '-t'.

Signed-off-by: Arvind Raghavan <raghavan.arvind@gmail.com>
Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
Signed-off-by: Vijay Chidambaram <vijay@cs.utexas.edu>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoext4/308: Fix misspelling in comment
mafeng 00292095 [Tue, 28 Apr 2020 14:18:50 +0000 (22:18 +0800)]
ext4/308: Fix misspelling in comment

Just fix three word misspellings in one commet.

Signed-off-by: Ma Feng <mafeng.ma@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/122: fix for linux 5.7 stuff
Darrick J. Wong [Thu, 23 Apr 2020 23:31:42 +0000 (16:31 -0700)]
xfs/122: fix for linux 5.7 stuff

Fix some regressions on xfsprogs 5.7.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/30[78]: fix regressions due to strengthened AGF checks
Darrick J. Wong [Thu, 23 Apr 2020 23:31:36 +0000 (16:31 -0700)]
xfs/30[78]: fix regressions due to strengthened AGF checks

Reorder the order in which we tweak AGF fields to avoid falling afoul of
the new AGF sanity checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/570: don't run this test on systems supporting userspace hibernate
Darrick J. Wong [Thu, 23 Apr 2020 23:31:30 +0000 (16:31 -0700)]
generic/570: don't run this test on systems supporting userspace hibernate

It turns out that userspace actually does need the ability to write to
an active swapfile if userspace hibernation (uswsusp) is enabled.
Therefore, this test doesn't apply under those conditions.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/590: fix the xfs feature detection logic
Darrick J. Wong [Thu, 23 Apr 2020 23:31:18 +0000 (16:31 -0700)]
generic/590: fix the xfs feature detection logic

The setup code in this regression test case tries to figure out if
certain features known to be incompatible with realtime are known to
mkfs, and if so, to forcibly disable them.

Unfortunately, the reflink feature detection logic here is broken,
because we have no way of distinguishing between the helper function
_scratch_mkfs_xfs_supported returning nonzero because reflink isn't
compatible with mkfs's defaults (e.g. your mkfs has rmapbt=1 by default)
vs. reflink isn't recognized at all vs. something else broke.

However, we can grep the mkfs output to look for reflink support, and if
we find it then we disable it.  That's fine for this test, since on XFS
it's trying to set up the exact conditions to test a known bug.

Second, rmapbt isn't currently compatible with realtime either, so we
need to detect and mask that off too.

Third, the test only needs to perform this feature detection if the test
runner didn't set SCRATCH_RTDEV, because we require that if the runner
configured SCRATCH_RTDEV, they also set MKFS_OPTIONS appropriately.

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>
2 years agobtrfs: add a test for fsync of file with prealloc extents crossing eof
Filipe Manana [Tue, 21 Apr 2020 10:25:39 +0000 (11:25 +0100)]
btrfs: add a test for fsync of file with prealloc extents crossing eof

Test that if we fsync a file with prealloc extents that start before and
after the file's size, we don't end up with missing parts of the extents
and implicit file holes after a power failure. Test both without and with
the NO_HOLES feature.

It is fixed commit f135cea30de5 ("btrfs: fix partial loss of
prealloc extent past i_size after fsync")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/126: make blocktrash work reliably on attrleaf blocks
Anthony Iliopoulos [Tue, 21 Apr 2020 11:36:43 +0000 (13:36 +0200)]
xfs/126: make blocktrash work reliably on attrleaf blocks

Running xfs/126 sometimes fails due to output mismatch. Due to the
randomized nature of the test, periodically the selected bits are not
relevant to the test, or the selected bits are not flipped. Supply an
offset that is close to the start of the metadata block, so that the
test will reliably corrupt the header.

Suggested-by: Darrick J. Wong <darrick.wong@oracle.com>
Link: https://lore.kernel.org/linux-xfs/20200116160323.GC2149943@magnolia
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofsx: move range generation logic into a common helper
Filipe Manana [Mon, 20 Apr 2020 17:09:31 +0000 (18:09 +0100)]
fsx: move range generation logic into a common helper

We have very similar code that generates the destination range for clone,
dedupe and copy_file_range operations, so avoid duplicating the code three
times and move it into a helper function.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofsx: fix infinite/too long loops when generating ranges for copy_file_range
Filipe Manana [Mon, 20 Apr 2020 17:09:17 +0000 (18:09 +0100)]
fsx: fix infinite/too long loops when generating ranges for copy_file_range

While running generic/521 I've had fsx taking a lot of CPU time and not
making any progress for several hours. Attaching gdb to the fsx process
revealed that fsx was in the loop that generates the ranges for a
copy_file_range operation, in particular the loop seemed to never end
because the range defined by 'offset2' kept overlapping with the range
defined by 'offset'.
So far this happened one time only in one of my test VMs with generic/521.

Fix this by breaking out of the loop after trying 30 times, like we
currently do for dedupe operations, which results in logging the operation
as skipped.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofsx: fix infinite/too long loops when generating ranges for clone operations
Filipe Manana [Mon, 20 Apr 2020 17:09:05 +0000 (18:09 +0100)]
fsx: fix infinite/too long loops when generating ranges for clone operations

While running generic/457 I've had fsx taking a lot of CPU time and not
making any progress for over an hour. Attaching gdb to the fsx process
revealed that fsx was in the loop that generates the ranges for a clone
operation, in particular the loop seemed to never end because the range
defined by 'offset2' kept overlapping with the range defined by 'offset'.
So far this happened two times in one of my test VMs with generic/457.

Fix this by breaking out of the loop after trying 30 times, like we
currently do for dedupe operations, which results in logging the operation
as skipped.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofsx: allow zero range operations to cross eof
Filipe Manana [Mon, 20 Apr 2020 17:07:38 +0000 (18:07 +0100)]
fsx: allow zero range operations to cross eof

Currently we are limiting the range for zero range operations to stay
within the i_size boundary. This is not optimal because like this we lose
coverage of the filesystem's zero range implementation, since zero range
operations are allowed to cross the i_size. Fix this by limiting the range
to 'maxfilelen' and not 'file_size', and update the 'file_size' after each
zero range operation if needed.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/456: document the other kernel commit
Yang Xu [Mon, 20 Apr 2020 08:18:17 +0000 (16:18 +0800)]
generic/456: document the other kernel commit

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: another test for dropping nlink below zero
Amir Goldstein [Mon, 20 Apr 2020 10:34:53 +0000 (13:34 +0300)]
overlay: another test for dropping nlink below zero

This is a variant on test overlay/034.

This variant is mangling upper hardlinks instead of lower hardlinks
and does not require the inodes index feature.

This is a regression test for kernel commit 83552eacdfc0
("ovl: fix WARN_ON nlink drop to zero")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay/029: fix test failure with nfs_export feature enabled
Amir Goldstein [Mon, 20 Apr 2020 10:27:31 +0000 (13:27 +0300)]
overlay/029: fix test failure with nfs_export feature enabled

When overlayfs nfs_export feature is enabled by default in either kernel
config or module parameters, this test fails:

    mount: /tmp/8751/mnt: mount(2) system call failed: Stale file handle.
    cat: /tmp/8751/mnt/bar: No such file or directory

The reason is that nfs_export depends on index feature and with index
feature enabled, an upper/work dirs cannot be reused for mounting with
a different lower layer.

To reproduce the failure do:
  echo Y > /sys/module/overlay/parameters/index
  echo Y > /sys/module/overlay/parameters/nfs_export
before running the test.

Fix the failure by explicitly re-creating upper/work dirs.

Reported-by: Chengguang Xu <cgxu519@mykernel.net>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/594: require setquota tool supports project quota
Zorro Lang [Sun, 19 Apr 2020 10:49:36 +0000 (18:49 +0800)]
generic/594: require setquota tool supports project quota

The old setquota tool doesn't support project quota, it doesn't has
"-P, --project" option. So _notrun the test to avoid a failure.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: snapshot creation with qgroup inherit would mark qgroup inconsistent
Qu Wenruo [Wed, 15 Apr 2020 06:49:16 +0000 (14:49 +0800)]
btrfs: snapshot creation with qgroup inherit would mark qgroup inconsistent

Test that a new snapshot created with qgroup inherit passed should
mark qgroup numbers inconsistent.

Such inconsistent flag is required to show that we need a qgroup
rescan to make qgroup numbers correct again.

This is unavoidable since snapshot creation with qgroup inherit acts
as snapshot creation + qgroup relationship assign.

See btrfs(5) for why such operation needs qgroup rescan.

This test failed on current kernel, the fix is submitted to the btrfs
mail list titled:

  "btrfs: qgroup: Mark qgroup inconsistent if we're inherting snapshot to a new qgroup"

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: exclude exfat from tests which require metadata journaling
Eric Sandeen [Wed, 15 Apr 2020 20:22:49 +0000 (15:22 -0500)]
fstests: exclude exfat from tests which require metadata journaling

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: test for fallocate capability in more tests
Eric Sandeen [Wed, 15 Apr 2020 20:21:55 +0000 (15:21 -0500)]
fstests: test for fallocate capability in more tests

These 3 tests explicitly call xfs_io's fallocate command, test whether
it works before running the test.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: add _require_hardlinks for all necessary tests
Eric Sandeen [Wed, 15 Apr 2020 20:20:33 +0000 (15:20 -0500)]
fstests: add _require_hardlinks for all necessary tests

Add a new _require function for hardlinks, to test hardlink support
in all tests which need it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: use _require_symlinks on all necessary tests
Eric Sandeen [Wed, 15 Apr 2020 20:18:27 +0000 (15:18 -0500)]
fstests: use _require_symlinks on all necessary tests

Consistently use _require_symlinks on all generic tests which
create a symlink when they run.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: rename _require_test_symlinks
Eric Sandeen [Wed, 15 Apr 2020 20:17:46 +0000 (15:17 -0500)]
fstests: rename _require_test_symlinks

Generally these tests are not restricted to one device or the other;
testing the test device will suffice to determine the capability
but it doesn't need to be named that way.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()
Filipe Manana [Tue, 14 Apr 2020 16:22:42 +0000 (17:22 +0100)]
btrfs: make all btrfs tests that exercise balance use _run_btrfs_balance_start()

In btrfs-progs v4.10 we had a behaviour change where starting a balance
operation without any filters results in a delay of 10 seconds and a
warning is printed to stdout that warns that a full balance is about to
be made and that it can be a slow operation. The new flag '--full-balance'
was added in that release to avoid the 10 seconds delay and the warning
message.

Our existing helper _run_btrfs_balance_start() uses that new balance flag
if we are running a btrfs-progs version that has it, to avoid that 10
seconds wait.

Make all existing btrfs tests that trigger balance operations use the
_run_btrfs_balance_start() helper, so that we avoid wasting time and
speed up some of the tests. In particular test btrfs/014 is now about 10x
faster and tests btrfs/060 to btrfs/064 3 to 5 times faster (depending
on the fsstress random load).

Besides speeding up many tests that do balance operations it also fixes
functional problems:

1) Since btrfs-progs v4.10 the test case btrfs/014 got broken, because
   its purpose is to run balance and snapshot creation in parallel,
   and that wasn't happening anymore because all snapshots were being
   created during the 10 seconds delay of the first balance operation,
   so balance and snapshot creation was being serialized instead of
   running in parallel.

   Fixing this test to avoid the 10 seconds delay immediately
   exposes a regression that went into kernel 5.7-rc1 which is fixed
   by the following commit

   aec7db3b13a0 ("btrfs: fix setting last_trans for reloc roots")

2) Test cases btrfs/060 to btrfs/064 now spend much more time running
   fsstress, balance and other operations in parallel, there's no
   longer intervals of 10 seconds where balance is not running
   concurrently with those other operations, making the tests a lot
   more useful again.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: stop using run_check in _run_btrfs_balance_start
Filipe Manana [Tue, 14 Apr 2020 16:22:32 +0000 (17:22 +0100)]
btrfs: stop using run_check in _run_btrfs_balance_start

The use of run_check() immediately stops a test because it calls the
_fail() function when execution of its argument fails. This is
generally not encouraged in fstests as it prevents a test from
detecting further problems after that failure.

Since the next patch in this series updates other tests to use
_run_btrfs_balance_start() for which a failure to run balance can be
expected (btrfs/187 for example), remove the use of run_check() from
_run_btrfs_balance_start(). Existing tests that use
_run_btrfs_balance_start() now redirect standard output to the
test's .full file for debugging purposes. In case balance fails the
tests will fail due to unexpected output from the standard error.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>