xfstests-dev.git
3 years agoxfs: Check for extent overflow when swapping extents
Chandan Babu R [Tue, 9 Mar 2021 05:01:23 +0000 (10:31 +0530)]
xfs: Check for extent overflow when swapping extents

This test verifies that XFS does not cause inode fork's extent count to
overflow when swapping forks across two files.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when remapping an extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:22 +0000 (10:31 +0530)]
xfs: Check for extent overflow when remapping an extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when remapping extents from one file's inode fork to another.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when moving extent from cow to data fork
Chandan Babu R [Tue, 9 Mar 2021 05:01:21 +0000 (10:31 +0530)]
xfs: Check for extent overflow when moving extent from cow to data fork

This test verifies that XFS does not cause inode fork's extent count to
overflow when writing to/funshare-ing a shared extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when writing to unwritten extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:20 +0000 (10:31 +0530)]
xfs: Check for extent overflow when writing to unwritten extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when writing to an unwritten extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when adding/removing dir entries
Chandan Babu R [Tue, 9 Mar 2021 05:01:19 +0000 (10:31 +0530)]
xfs: Check for extent overflow when adding/removing dir entries

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding/removing directory entries.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when adding/removing xattrs
Chandan Babu R [Tue, 9 Mar 2021 05:01:18 +0000 (10:31 +0530)]
xfs: Check for extent overflow when adding/removing xattrs

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding/removing xattrs.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when punching a hole
Chandan Babu R [Tue, 9 Mar 2021 05:01:17 +0000 (10:31 +0530)]
xfs: Check for extent overflow when punching a hole

This test verifies that XFS does not cause inode fork's extent count to
overflow when punching out an extent.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when growing realtime bitmap/summary inodes
Chandan Babu R [Tue, 9 Mar 2021 05:01:16 +0000 (10:31 +0530)]
xfs: Check for extent overflow when growing realtime bitmap/summary inodes

Verify that XFS does not cause realtime bitmap/summary inode fork's
extent count to overflow when growing the realtime volume associated
with a filesystem.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agoxfs: Check for extent overflow when trivally adding a new extent
Chandan Babu R [Tue, 9 Mar 2021 05:01:15 +0000 (10:31 +0530)]
xfs: Check for extent overflow when trivally adding a new extent

This test verifies that XFS does not cause inode fork's extent count to
overflow when adding a single extent while there's no possibility of splitting
an existing mapping.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agocommon/xfs: Add helper to obtain fsxattr field value
Chandan Babu R [Thu, 11 Mar 2021 08:52:05 +0000 (14:22 +0530)]
common/xfs: Add helper to obtain fsxattr field value

This commit adds a helper function to obtain the value of a particular field
of an inode's fsxattr fields.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agocommon/xfs: Add a helper to get an inode fork's extent count
Chandan Babu R [Tue, 9 Mar 2021 05:01:13 +0000 (10:31 +0530)]
common/xfs: Add a helper to get an inode fork's extent count

This commit adds the helper _scratch_get_iext_count() which returns an
inode fork's extent count.

Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years ago_check_xfs_filesystem: sync fs before running scrub
Chandan Babu R [Tue, 9 Mar 2021 05:01:12 +0000 (10:31 +0530)]
_check_xfs_filesystem: sync fs before running scrub

Tests can create a scenario in which a call to syncfs() issued at the end of
the execution of the test script would return an error code. xfs_scrub
internally calls syncfs() before starting the actual online consistency check
operation. Since this call to syncfs() fails, xfs_scrub ends up returning
without performing consistency checks on the test filesystem. This can mask a
possible on-disk data structure corruption.

To fix the above stated problem, this commit invokes syncfs() prior to
executing xfs_scrub.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
3 years agocommon: capture qcow2 dumps of corrupt ext* filesystems
Darrick J. Wong [Tue, 9 Mar 2021 04:39:27 +0000 (20:39 -0800)]
common: capture qcow2 dumps of corrupt ext* filesystems

Create a new helper to use e2image to capture a qcow2 image of an ext*
filesystem and make _check_generic_filesystem use it to dump corrupt ext
images.  Refactor the single user of e2image to use the helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
3 years agopopulate: support compressing metadumps
Darrick J. Wong [Tue, 9 Mar 2021 04:39:22 +0000 (20:39 -0800)]
populate: support compressing metadumps

If the test runner passed in a DUMP_COMPRESSOR program, make it so that
the metadumps we generate are also compressed.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
3 years agocommon: move _scratch_metadump to common/xfs
Darrick J. Wong [Tue, 9 Mar 2021 04:39:17 +0000 (20:39 -0800)]
common: move _scratch_metadump to common/xfs

_scratch_metadump is really an xfs-specific dump helper, so move it to
common/xfs, add 'xfs' to the name, and convert all users.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
3 years agocommon: capture metadump output if xfs filesystem check fails
Darrick J. Wong [Tue, 9 Mar 2021 04:39:11 +0000 (20:39 -0800)]
common: capture metadump output if xfs filesystem check fails

Capture metadump output when various userspace repair and checker tools
fail or indicate corruption, to aid in debugging.  We don't bother to
annotate xfs_check because it's bitrotting.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
3 years agobtrfs/232: fix umount failure due to fsstress still running
Filipe Manana [Thu, 18 Mar 2021 11:48:15 +0000 (11:48 +0000)]
btrfs/232: fix umount failure due to fsstress still running

We start a process that runs fsstress, then kill the process, wait for it
to die and then end the test, where we attempt to unmount the fs which
often fails because the fsstress subcommand started by the process is
still running and using the mount point. This results in a test failure:

  btrfs/232 1s ... umount: /home/fdmanana/btrfs-tests/scratch_1: target is busy.
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  (see /home/fdmanana/git/hub/xfstests/results//btrfs/232.full for details)

Fix that by adding a trap to the writer() function.

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 agosrc/chprojid_fail.c: Fix undefined compile error on old kernel
Yang Xu [Wed, 17 Mar 2021 10:11:13 +0000 (18:11 +0800)]
src/chprojid_fail.c: Fix undefined compile error on old kernel

On old kernel, linux/fs.h doesn't include FS_IOC_FSGETXATTR and FS_IOC_FSGETXATTR
ioctl flag. It also doesn't include fsxattr struct. To fix this error, just
use global.h like fsstress.c.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: add test for cases when a dio write has to fallback to a buffered write
Filipe Manana [Tue, 16 Mar 2021 12:22:15 +0000 (12:22 +0000)]
btrfs: add test for cases when a dio write has to fallback to a buffered write

Test cases where a direct IO write, with O_DSYNC, can not be done and has
to fallback to a buffered write.

This is motivated by the fact we don't have existing tests for these cases
and in fact we had a regression for one case in the 5.10 kernel. This was
the case when doing a direct IO write, with O_DSYNC, against a file offset
that is not aligned to the filesystem's block size, which resulted in
triggering an assertion failure when btrfs is built with assertions enabled
(CONFIG_BTRFS_ASSERT=y). One openSUSE Tumbleweed user hit this frequently
when using Docker and DB2.

The kernel commit in 5.10 that introduced the regression was commit
0eb79294dbe328 ("btrfs: dio iomap DSYNC workaround")). In kernel 5.11 the
regression fixed, by pure chance, by commit ecfdc08b8cc65d ("btrfs: remove
dio iomap DSYNC workaround"). Since the commit that fixed the bug in 5.11
was dependent on a large patchset, a special and simple fix was added to
the stable kernel 5.10.18 by commit a6703c71153438 ("btrfs: fix crash after
non-aligned direct IO write with O_DSYNC").

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: test delayed subvolume deletion on mount and remount
Filipe Manana [Tue, 16 Mar 2021 16:54:28 +0000 (16:54 +0000)]
btrfs: test delayed subvolume deletion on mount and remount

Test that subvolume deletion is resumed on RW mounts, that it is not
performed on RO mounts and that after remounting a filesystem from RO
to RW mode, it is also performed.

This triggers a regression introduced in kernel 5.11 which is fixed
by a patch that has the following subject:

   "btrfs: fix subvolume/snapshot deletion not triggered on mount"

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: virtiofs does not support atime options
Max Reitz [Tue, 16 Mar 2021 13:01:31 +0000 (14:01 +0100)]
common/rc: virtiofs does not support atime options

As documented in Documentation/filesystems/virtiofs.rst (in the Linux
tree), virtiofs ignores atime-related mount options.

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Vladimir Zapolskiy <vladimir@tuxera.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test delalloc quota leak when chprojid fails
Darrick J. Wong [Tue, 9 Mar 2021 04:40:58 +0000 (20:40 -0800)]
xfs: test delalloc quota leak when chprojid fails

This is a regression test for a bug in the XFS implementation of
FSSETXATTR.  When we try to change a file's project id, the quota
reservation code will update the incore quota reservations for delayed
allocation blocks.  Unfortunately, it does this before we finish
validating all the FSSETXATTR parameters, which means that if we decide
to bail out, we also fail to undo the incore changes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test file writers racing with FIDEDUPERANGE
Darrick J. Wong [Tue, 9 Mar 2021 04:40:47 +0000 (20:40 -0800)]
generic: test file writers racing with FIDEDUPERANGE

Create a test to make sure that dedupe actually locks the file ranges
correctly before starting the content comparison and keeps them locked
until the operation completes.

[Eryu: added .gitignore entry, required "deduperace" binary in test]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/122: fix test for xfs_attr_shortform_t conversion
Darrick J. Wong [Tue, 9 Mar 2021 04:40:42 +0000 (20:40 -0800)]
xfs/122: fix test for xfs_attr_shortform_t conversion

The typedef xfs_attr_shortform_t was converted to a struct in 5.10.
Update this test to pass.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test quota softlimit warning functionality
Darrick J. Wong [Tue, 9 Mar 2021 04:40:36 +0000 (20:40 -0800)]
xfs: test quota softlimit warning functionality

Make sure that quota softlimits work, which is to say that one can
exceed the softlimit up to warnlimit times before it starts enforcing
that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/filter: refactor quota report filtering
Darrick J. Wong [Tue, 9 Mar 2021 04:40:31 +0000 (20:40 -0800)]
common/filter: refactor quota report filtering

xfs/299 and xfs/050 share the same function to filter quota reporting
into a format suitable for the golden output.  Refactor this so that we
can use it in a new test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test mkfs min log size calculation w/ rt volumes
Darrick J. Wong [Tue, 9 Mar 2021 04:40:25 +0000 (20:40 -0800)]
xfs: test mkfs min log size calculation w/ rt volumes

In "mkfs: set required parts of the realtime geometry before computing
log geometry" we made sure that mkfs set up enough of the fs geometry to
compute the minimum xfs log size correctly when formatting the
filesystem.  This is the regression test for that issue.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test reflink and copy_file_range behavior with O_SYNC and FS_XFLAG_SYNC...
Darrick J. Wong [Tue, 9 Mar 2021 04:40:14 +0000 (20:40 -0800)]
generic: test reflink and copy_file_range behavior with O_SYNC and FS_XFLAG_SYNC files

Add two regression tests to make sure that FICLONERANGE and the splice
based copy_file_range actually flush all data and metadata to disk
before the call ends.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test regression in xfs_bmap_validate_extent
Darrick J. Wong [Tue, 9 Mar 2021 04:40:09 +0000 (20:40 -0800)]
xfs: test regression in xfs_bmap_validate_extent

This is a regression test to make sure that we can have realtime files
with xattr blocks and not trip the verifiers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: remove DMAPI support from build system
Darrick J. Wong [Tue, 9 Mar 2021 04:39:55 +0000 (20:39 -0800)]
fstests: remove DMAPI support from build system

Since we've axed all the DMAPI tests, get rid of the build system
support too.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: remove DMAPI tests
Darrick J. Wong [Thu, 11 Feb 2021 21:33:38 +0000 (13:33 -0800)]
fstests: remove DMAPI tests

Upstream XFS has never supported DMAPI, so remove the tests for this
feature.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test fallocate ops when rt extent size is and isn't a power of 2
Darrick J. Wong [Tue, 9 Mar 2021 04:40:02 +0000 (20:40 -0800)]
xfs: test fallocate ops when rt extent size is and isn't a power of 2

Make sure that fallocate works when the rt extent size is and isn't a
power of 2.

[Eryu: require filefrag command, add _require_loop, use xfs_io to do
truncate]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: remove libattr dependencies
Darrick J. Wong [Tue, 9 Mar 2021 04:39:40 +0000 (20:39 -0800)]
fstests: remove libattr dependencies

Now that we don't have any libattr dependencies anymore, get rid of all
the build system hooks.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofsstress: get rid of attr_list
Darrick J. Wong [Tue, 9 Mar 2021 04:39:34 +0000 (20:39 -0800)]
fsstress: get rid of attr_list

attr_list is deprecated, so just call llistxattr directly.  This is a
bit involved, since attr_remove_f was highly dependent on libattr
structures.  Note that attr_list uses llistxattr internally and
llistxattr is limited to XATTR_LIST_MAX, so this doesn't result in any
loss of functionality.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: clean up tests using fio
Theodore Ts'o [Mon, 8 Mar 2021 01:54:34 +0000 (20:54 -0500)]
generic: clean up tests using fio

During the code review for a test to exercises AIO/DIO into unwritten
space, a number of changes were requested that were also applicable to
generic/299 and generic/300 (from which the aforementioned test was
patterned).  For example, the use of run_check, which is deprecated,
was dropped.  In addition, we now rely on the test runner to unmount
the scratch file system.

Also fix a nit I found in generic/095, which resulted in debugging
information in the $seqres.full to get lost when "fio ...
--output=$seqres.full" is run.

[Eryu: add _require_aio to generic/095, fix more indention issues]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test which tries to exercise AIO/DIO into unwritten space
Theodore Ts'o [Mon, 8 Mar 2021 01:22:47 +0000 (20:22 -0500)]
generic: test which tries to exercise AIO/DIO into unwritten space

This test verifies that the an unwritten extent is properly marked as
written after writing into it.

There was a hard-to-hit bug which would occasionally trigger with ext4
for which this test was a reproducer.  This has been fixed after
moving ext4 to use iomap for Direct I/O's, although as of this
writing, there are still some occasional failures on ext4 when block
size < page size.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: rename RENAME_WHITEOUT test on fs no enough space
Zorro Lang [Mon, 8 Mar 2021 13:43:27 +0000 (21:43 +0800)]
fstests: rename RENAME_WHITEOUT test on fs no enough space

This's a regression test for linux 6b4b8e6b4ad8 ("ext4: fix bug for
rename with RENAME_WHITEOUT"). Rename a file with RENAME_WHITEOUT
flag might cause corruption when there's not enough space to
complete this renaming operation.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: Add simple stress test when qgroup limits are reached
Nikolay Borisov [Tue, 23 Feb 2021 15:50:42 +0000 (17:50 +0200)]
btrfs: Add simple stress test when qgroup limits are reached

This test uncovered 2 deadlocks with qgroups when their limit was
reached.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test retrieving verity signature
Eric Biggers [Wed, 24 Feb 2021 22:35:37 +0000 (14:35 -0800)]
generic: test retrieving verity signature

Add a test which tests dumping the built-in signature of a verity file
using the new FS_IOC_READ_VERITY_METADATA ioctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
3 years agogeneric: test retrieving verity Merkle tree and descriptor
Eric Biggers [Wed, 24 Feb 2021 22:35:36 +0000 (14:35 -0800)]
generic: test retrieving verity Merkle tree and descriptor

Add a test which tests retrieving the Merkle tree and fs-verity
descriptor of a verity file using the new FS_IOC_READ_VERITY_METADATA
ioctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
3 years agogeneric: add helpers for dumping fs-verity metadata
Eric Biggers [Wed, 24 Feb 2021 22:35:35 +0000 (14:35 -0800)]
generic: add helpers for dumping fs-verity metadata

In common/verity, add helper functions for dumping a file's fs-verity
metadata using the new FS_IOC_READ_VERITY_METADATA ioctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
3 years agogeneric: factor out helpers for fs-verity built-in signatures
Eric Biggers [Wed, 24 Feb 2021 22:35:34 +0000 (14:35 -0800)]
generic: factor out helpers for fs-verity built-in signatures

The test for retrieving a verity file's built-in signature using
FS_IOC_READ_VERITY_METADATA will need to set up a file with a built-in
signature, which requires the same commands that generic/577 does.
Factor this out into helper functions in common/verity.

Signed-off-by: Eric Biggers <ebiggers@google.com>
3 years agogeneric/60[78]: ensure the initial DAX file flag state before test
Darrick J. Wong [Tue, 2 Mar 2021 23:22:56 +0000 (15:22 -0800)]
generic/60[78]: ensure the initial DAX file flag state before test

Since this test checks the behaviors of both the in-core S_DAX flag and
the ondisk FS_XFLAG_DAX inode flags, it must be careful about the
initial state of the filesystem w.r.t. the inode flag.

Make sure that the root directory does /not/ have the inode flag set
before we begin testing, so that the initial state doesn't throw off
inheritance testing.

[Eryu: change chattr command to xfs_io -c 'chattr']

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: fix detection of device-mapper/persistent memory incompatibility
Darrick J. Wong [Tue, 2 Mar 2021 23:22:50 +0000 (15:22 -0800)]
common/rc: fix detection of device-mapper/persistent memory incompatibility

In commit fc7b3903, we tried to make _require_dm_target smart enough to
_notrun tests that require a device mapper target that isn't compatible
with "DAX".  However, as of this writing, the incompatibility stems from
device mapper's unwillingness to switch access modes when running atop
DAX (persistent memory) devices, and has nothing to do with the
filesystem mount options.

Since filesystems supporting DAX don't universally require "dax" in the
mount options to enable that functionality, switch the test to query
sysfs to see if the scratch device supports DAX.

Fixes: fc7b3903 ("dax/dm: disable testing on devices that don't support dax")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/271: fix test failure on non-reflink filesystems
Darrick J. Wong [Tue, 2 Mar 2021 23:22:45 +0000 (15:22 -0800)]
xfs/271: fix test failure on non-reflink filesystems

This test creates an empty filesystem with rmap btrees enabled, and then
checks that GETFSMAP corresponds (roughly) with what we expect mkfs to
have written to the filesystem.

Unfortunately, the test's calculation for the number of "per-AG
metadata" extents is not quite correct.  For a filesystem with a
refcount btree, the rmapbt and agfl blocks will be reported separately,
but for non-reflink filesystems, GETFSMAP merges the records.

Since this test counts the number of records, fix the calculation.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/623: don't fail on core dumps
Darrick J. Wong [Tue, 2 Mar 2021 23:22:39 +0000 (15:22 -0800)]
generic/623: don't fail on core dumps

This test is designed to fail an mmap write and see what happens.
Typically this is a segmentation fault.  If the user's computer is
configured to capture core dumps, this will cause the test to fail, even
though we got the reaction we wanted.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agofstests: remove _require_no_rtinherit completely
Zorro Lang [Mon, 1 Mar 2021 01:46:03 +0000 (09:46 +0800)]
fstests: remove _require_no_rtinherit completely

The _require_no_rtinherit has been removed by:
  0ac0d8fb ("common: remove _require_no_rtinherit")

But some cases still remain the _require_no_rtinherit, so remove
them all.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: add CLI option to repeat and stop tests in case of failure
Ritesh Harjani [Thu, 11 Feb 2021 03:31:44 +0000 (09:01 +0530)]
check: add CLI option to repeat and stop tests in case of failure

Currently with -i <n> option the test can run for many iterations,
but in case if we want to stop the iteration in case of a failure,
it is much easier to have such an option which could check the
failed status and stop the test from further proceeding.

This patch adds such an option (-I <n>) thereby extending the -i <n>
option functionality.

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: make sure we rescan all devices after unregistering
Qu Wenruo [Thu, 25 Feb 2021 05:57:17 +0000 (13:57 +0800)]
btrfs: make sure we rescan all devices after unregistering

There are some btrfs test cases utilizing
_btrfs_forget_or_module_reload() to unregister all btrfs devices.

However _btrfs_forget_or_module_reload() will unregister all devices,
meaning if TEST_DEV is part of a multi-device btrfs, after those test
cases TEST_DEV will no longer be mountable.

This patch will introduce a new function, btrfs_rescan_devices() to undo
the unregister, so that all later test cases can mount TEST_DEV without
any problem.

Since we are here, also add a missing
_require_btrfs_forget_or_module_loadable for btrfs/225.

Reported-by: Eric Sandeen <sandeen@sandeen.net>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: clone a hole post eof when using NO_HOLES feature
Filipe Manana [Tue, 16 Feb 2021 11:10:15 +0000 (11:10 +0000)]
btrfs: clone a hole post eof when using NO_HOLES feature

Test that when using the NO_HOLES feature, if we truncate down a
file, clone a file range covering only a hole into an offset beyond
the current file size, and then fsync the file, after a power
failure we get the expected file content and we do not get stale
data corresponding to file extents that existed before truncating
the file.

This currently fails on btrfs and is fixed by commit 3660d0bcdb82
("btrfs: fix stale data exposure after cloning a hole with NO_HOLES
enabled")

[Eryu: add the commit id of the patch fixing the bug]

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 agofuzzy: capture core dumps from repair utilities
Darrick J. Wong [Wed, 10 Feb 2021 02:56:53 +0000 (18:56 -0800)]
fuzzy: capture core dumps from repair utilities

Always capture the core dumps when we run repair tools against a fuzzed
filesystem.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: run tests in exactly the order specified
Darrick J. Wong [Wed, 10 Feb 2021 02:56:47 +0000 (18:56 -0800)]
check: run tests in exactly the order specified

Introduce a new --exact-order switch to disable all sorting, filtering
of repeated lines, and shuffling of test order.  The goal of this is to
be able to run tests in a specific order, namely to try to reproduce
test failures that could be the result of a -r(andomize) run getting
lucky.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: don't abort on non-existent excluded groups
Darrick J. Wong [Wed, 10 Feb 2021 02:56:42 +0000 (18:56 -0800)]
check: don't abort on non-existent excluded groups

Don't abort the whole test run if we asked to exclude groups that aren't
included in the candidate group list, since we actually /are/ satisfying
the user's request.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: allow '-e testid' to exclude a single test
Darrick J. Wong [Wed, 10 Feb 2021 02:56:36 +0000 (18:56 -0800)]
check: allow '-e testid' to exclude a single test

This enables us to mask off specific tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoconfig: wrap xfs_metadump as $XFS_METADUMP_PROG like the other tools
Darrick J. Wong [Wed, 10 Feb 2021 02:56:25 +0000 (18:56 -0800)]
config: wrap xfs_metadump as $XFS_METADUMP_PROG like the other tools

When we set up a fstests run, preserve the path xfs_metadump binary with
an $XFS_METADUMP_PROG wrapper, like we do for the other xfsprogs tools.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test mapped write after shutdown and failed writeback
Brian Foster [Wed, 10 Feb 2021 17:06:28 +0000 (12:06 -0500)]
generic: test mapped write after shutdown and failed writeback

XFS has a regression where it failed to check shutdown status in the
write fault path. This produced an iomap warning if the page
happened to recently fail a writeback attempt because writeback
failure can clear Uptodate status on the page.

Add a test for this scenario to help ensure mapped write failures
are handled as expected in the event of filesystem shutdown.
Upstream commit e4826691cc7e ("xfs: restore shutdown check in mapped
write fault path") fixed this bug.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agooverlay: Regression test for deadlock on directory ioctl
Amir Goldstein [Wed, 10 Feb 2021 19:03:34 +0000 (21:03 +0200)]
overlay: Regression test for deadlock on directory ioctl

Overlayfs added the ability to set inode flags (e.g. chattr +i) in
kernel 5.10 by commit 61536bed2149 ("ovl: support [S|G]ETFLAGS and
FS[S|G]ETXATTR ioctls for directories").
Icenowy Zheng reported [1] a regression in that commit that causes
a deadlock when setting inode flags on lower dir.

The regression was fixed by commit b854cc659dcb ("ovl: avoid deadlock
on directory ioctl") and applied to kernel 5.10.15.

[1] https://lore.kernel.org/linux-unionfs/20210101201230.768653-1-icenowy@aosc.io/

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: Test lost immutable/append-only flags on copy-up
Amir Goldstein [Wed, 10 Feb 2021 19:03:33 +0000 (21:03 +0200)]
overlay: Test lost immutable/append-only flags on copy-up

Chengguang Xu reported [1] that append-only flag is lost on copy-up.
I had noticed that for directories, immutable flag can also be lost
on copy up (when parent is copied up). That's an old overlayfs bug.

Fixing this requires some VFS API changes that Miklos has proposed[2]

[1] https://lore.kernel.org/linux-unionfs/20201226104618.239739-1-cgxu519@mykernel.net/
[2] https: //lore.kernel.org/linux-fsdevel/20210203124112.1182614-1-mszeredi@redhat.com/

[Eryu: referencing the thread of the pending fix]

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/t_immutable: Allow setting flags on existing files
Amir Goldstein [Wed, 10 Feb 2021 19:03:32 +0000 (21:03 +0200)]
src/t_immutable: Allow setting flags on existing files

For overlayfs tests we need to be able to setflags on existing
(lower) files.

t_immutable -C test_dir

Creates the test area and sets flags, but it also allows setting flags
on an existing test area.

t_immutable -R test_dir

Removes the flags from existing test area, but does not remove the files
in the test area.

To setup a test area with file without flags, need to run the -C and -R
commands.

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/t_immutable: factor out some helpers
Amir Goldstein [Wed, 10 Feb 2021 19:03:31 +0000 (21:03 +0200)]
src/t_immutable: factor out some helpers

Reduce boilerplate code.
define _GNU_SOURCE needed for asprintf.

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/030: Update comment w.r.t upstream kernel
Amir Goldstein [Wed, 10 Feb 2021 19:03:30 +0000 (21:03 +0200)]
overlay/030: Update comment w.r.t upstream kernel

commit 61536bed2149 ("ovl: support [S|G]ETFLAGS and FS[S|G]ETXATTR
ioctls for directories") makes the comment in test header inaccurate.
Fix the comment to include this information.

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 agocommon: remove _require_no_rtinherit
Darrick J. Wong [Wed, 10 Feb 2021 02:57:06 +0000 (18:57 -0800)]
common: remove _require_no_rtinherit

All the remaining tests that use _require_no_rtinherit can be adapted to
ignore SCRATCH_RTDEV or to force files to be created on the data device.
This makes the helper unnecessary and increases test coverage, so remove
this helper.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: fix filestreams tests when rtinherit=1
Darrick J. Wong [Wed, 10 Feb 2021 02:57:00 +0000 (18:57 -0800)]
xfs: fix filestreams tests when rtinherit=1

The filestreams allocator can only be selected for files that reside on
the data volume.  In commit ee3e0010, we sprinkled calls to
_require_no_rtinherit in the filestreams tests so that there wouldn't be
regressions reported if the filesystem is formatted with -d rtinherit=1.

This unnecessarily limits test coverage because userspace can control
the device selection parameters quite easily with xfs_io chattr.  Make
the filestreams tests unset SCRATCH_RTDEV so that the allocator isn't
thrown off by the rtbitmap consuming space on the data device.

Fixes: ee3e0010 ("xfs/realtime: add _require_no_rtinherit function")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/splice-test.c: use memalign instead of aligned_alloc
David Sterba [Tue, 9 Feb 2021 15:57:15 +0000 (16:57 +0100)]
src/splice-test.c: use memalign instead of aligned_alloc

The build fails on SLE11 as the function aligned_alloc is not
available there. Replace it by memalign that has the same semantics
and is commonly used in fstests code base. aligned_alloc has
additional requirements on the alignment and buffer size but that is
ok as the buffer is defined in multiples of the alignment.

Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years ago_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size
Chandan Babu R [Tue, 9 Feb 2021 16:12:52 +0000 (21:42 +0530)]
_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size

If the original value of $MKFS_OPTIONS contained a block size value
having 'k' as a suffix (e.g. -b size=4k), then the newly constructed
value of $MKFS_OPTIONS will have 'k' suffixed to the value of
$blocksize.  $blocksize itself is specified in units of bytes. Hence
having 'k' suffixed to this value will result in an incorrect block
size.

This commit fixes the bug by conditionally filtering out the 'k'
suffix from block size option present in the original value of
$MKFS_OPTIONS.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test a regression in dquot type checking
Darrick J. Wong [Tue, 2 Feb 2021 19:41:58 +0000 (11:41 -0800)]
xfs: test a regression in dquot type checking

This is a regression test for incorrect ondisk dquot type checking that
was introduced in Linux 5.9.  The bug is that we can no longer switch a
V4 filesystem from having group quotas to having project quotas (or vice
versa) without logging corruption errors.  That is a valid use case, so
add a regression test to ensure this can be done.

[Eryu: add _require_check_dmesg and print the 'corruption' dmesg]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/swapon.c: initiate p to NULL
Sun Ke [Mon, 1 Feb 2021 07:57:05 +0000 (15:57 +0800)]
src/swapon.c: initiate p to NULL

when run make, show:
swapon.c:135:3: warning: 'p' may be used uninitialized in this function
[-Wmaybe-uninitialized]
   memcpy(p, buf, BUF_SIZE);
      ^~~~~~~~~~~~~~~~~~~~~~~~

This's a fake uninitialized warning.
gcc think the 'p' can be used uninitialized at here when verb is
TEST_MWRITE_BEFORE_AND_MWRITE_AFTER:
    case TEST_MWRITE_BEFORE_AND_MWRITE_AFTER:
memcpy(p, buf, BUF_SIZE);
break;

But, if verb is TEST_MWRITE_BEFORE_AND_MWRITE_AFTER, the 'p' will be
initialized by:
    switch (verb) {
    case TEST_MWRITE_BEFORE_AND_MWRITE_AFTER:
    case TEST_MWRITE_BEFORE:
p = mmap(NULL, BUF_SIZE, PROT_WRITE | PROT_READ, MAP_SHARED,

Silent the warning by initializing p to NULL anyway.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/095: don't silence fio error output
Zorro Lang [Tue, 2 Feb 2021 06:22:53 +0000 (14:22 +0800)]
generic/095: don't silence fio error output

This case print both fio stdout and stderr to .full file, that cause
we miss some unexpected failures when there's a bug. For example:

  file:io_u.c:1803, func=io_u error, error=Block device required

This's an regression issue we find on a downstream kernel, not in
upstream. So release unexpected fio error output to find more issues.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoltp/fsstress: don't fail on io_uring ENOSYS
Eric Sandeen [Thu, 28 Jan 2021 21:31:40 +0000 (15:31 -0600)]
ltp/fsstress: don't fail on io_uring ENOSYS

We might have URING #defined at build time, but be running on a kernel
which does not support it.

For that reason, we should not exit with an error if
io_uring_queue_init() fails with ENOSYS. We can just note the lack of
support and skip all future io_uring operations.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test for lazytime timestamp updates
Eric Biggers [Fri, 22 Jan 2021 01:44:34 +0000 (17:44 -0800)]
generic: test for lazytime timestamp updates

Test that when the lazytime mount option is enabled, updates to atime,
mtime, and ctime get persisted in the cases when they should be.

This test currently runs on ext4, f2fs, and xfs, since it's limited to
filesystems that support the shutdown ioctl.

This test currently passes on ext4 and f2fs.  On xfs, kernel
commit 1e249cb5b7fc ("fs: fix lazytime expiration handling in
__writeback_single_inode()") is needed for the test to pass, since xfs
had a bug where it didn't persist timestamps when it should have.

[Eryu: add shutdown metadata atime group]

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoext4/046: skip test when ext4 doesn't support bs < ps with dioread_nolock
Yang Xu [Tue, 19 Jan 2021 06:13:39 +0000 (14:13 +0800)]
ext4/046: skip test when ext4 doesn't support bs < ps with dioread_nolock

When testing arm machine, this case fails because ps > bs and kernel
doesn't introduced commit c8cc88163f40 ("ext4: Add support for
blocksize < pagesize in dioread_nolock").  Only skip this case when
kernel complains about bs!=ps error, so we can find dioread_nolock
mount regression in the future.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs: test mkfs.xfs config files
Darrick J. Wong [Tue, 27 Oct 2020 20:54:50 +0000 (07:54 +1100)]
xfs: test mkfs.xfs config files

Simple tests of the upcoming mkfs.xfs config file feature.  First we
have some simple tests of properly formatted config files, then
improperly formatted config files, and finally we try to spot
conflicts between config file options and the cli.

[dchinner: updated for new libinih-based implementation.]

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: check qgroup doesn't crash when beyond limit
Qu Wenruo [Tue, 12 Jan 2021 07:40:24 +0000 (15:40 +0800)]
btrfs: check qgroup doesn't crash when beyond limit

There is a bug that, when btrfs is beyond qgroup limit, touching a file
could crash btrfs.

Such beyond limit situation needs to be intentionally created, e.g.
writing 1GiB file, then limit the subvolume to 512 MiB.
As current qgroup works pretty well at preventing us from reaching the
limit.

This makes existing qgroup test cases unable to detect it.

The regression is introduced by commit c53e9653605d ("btrfs: qgroup:
try to flush qgroup space when we get -EDQUOT"), and the fix is
commit 6f23277a49e6 ("btrfs: qgroup: don't commit transaction when
we already hold the handle")

Link: https://bugzilla.suse.com/show_bug.cgi?id=1178634
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/filter: add _filter_stat
Murphy Zhou [Tue, 12 Jan 2021 05:31:16 +0000 (13:31 +0800)]
common/filter: add _filter_stat

Since coreutils upstream v8.32~47

  commit a99ab266110795ed94a9cb4d2765ddad9c4310da
  Author: Jeff Layton <jlayton@kernel.org>
  Date:   Thu Sep 19 11:59:45 2019 -0400

      ls: use statx instead of stat when available

stat(1) starts to use statx(2) call.

In some testcase, if file does not exist, this breaks golden
output like this:

-stat: cannot stat 'SCRATCH_MNT/xxx': No such file or directory
+stat: cannot statx 'SCRATCH_MNT/xxx': No such file or directory

Add this filter to fix it, and add this filter to testcases that
need it.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test incremental send after cloning extents from the same file
Filipe Manana [Mon, 11 Jan 2021 11:41:54 +0000 (11:41 +0000)]
btrfs: test incremental send after cloning extents from the same file

Test that an incremental send operation correctly issues clone operations
for a file that had different parts of one of its extents cloned into
itself, at different offsets, and a large part of that extent was
overwritten, so all the reflinks only point to subranges of the extent.

This currently fails on btrfs but is fixed by a patch for the kernel that
has the following subject:

 "btrfs: send, fix invalid clone operations when cloning from the same file and root"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test correct operation of free objectid related functionality
Nikolay Borisov [Mon, 11 Jan 2021 09:17:42 +0000 (11:17 +0200)]
btrfs: test correct operation of free objectid related functionality

This test verifies btrfs' free objectid management. I.e it ensures that
the first objectid is always 256 in an fs tree.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/496: ext4 and xfs supports swapon on fallocated file
Ritesh Harjani [Tue, 5 Jan 2021 14:31:43 +0000 (20:01 +0530)]
generic/496: ext4 and xfs supports swapon on fallocated file

ext4, xfs should not fail swapon on fallocated file. Currently if this
fails the fstst was not returning a failure. Fix those for given
filesystems (for now added ext4/xfs).
There were some regressions which went unnoticed due to this in ext4
tree, which later got fixed as part of this patch [1]

[1]: https://patchwork.ozlabs.org/patch/1357275

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocommon/rc: swapon should not fail for given FS in _require_scratch_swapfile()
Ritesh Harjani [Tue, 5 Jan 2021 14:31:42 +0000 (20:01 +0530)]
common/rc: swapon should not fail for given FS in _require_scratch_swapfile()

Filesystems e.g. ext* and XFS supports swapon by default and an error
returned with swapon should be treated as a failure.

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/388: randomly recover via read-only mounts
Brian Foster [Tue, 5 Jan 2021 11:58:44 +0000 (06:58 -0500)]
generic/388: randomly recover via read-only mounts

XFS has an issue where superblock counters may not be properly
synced when recovery occurs via a read-only mount. This causes the
filesystem to become inconsistent after unmount. To cover this test
case, update generic/388 to switch between read-only and read-write
mounts to perform log recovery.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/dmiperf: Remove obsolete dmiperf
Xiao Yang [Wed, 9 Dec 2020 05:08:15 +0000 (13:08 +0800)]
src/dmiperf: Remove obsolete dmiperf

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>
3 years agooverlay: run unionmount tests with custom overlay mount options
Amir Goldstein [Sat, 19 Dec 2020 10:47:27 +0000 (12:47 +0200)]
overlay: run unionmount tests with custom overlay mount options

Assign $OVERLAY_MOUNT_OPTIONS to UNIONMOUNT_MNTOPTIONS and require
that unionmount supports UNIONMOUNT_MNTOPTIONS if OVERLAY_MOUNT_OPTIONS
was provided.

For example, when the mount option metacopy=on is set in
$OVERLAY_MOUNT_OPTIONS, it enables the --meta test option and affects
the test verifications after copy up.

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 agoshared/032: add options for jffs2
Su Yue [Sat, 19 Dec 2020 09:10:58 +0000 (17:10 +0800)]
shared/032: add options for jffs2

Recently I found that my disk space was eaten by results/shared/032.full
after one round of xfstests running. The file was filled with binary
bytes by the command:
`mkfs -t jffs2 /dev/mapper/test-2 >> results/shared/032.full 2>&1`

Manual of mkfs.jffs2:
========================================================================
The program mkfs.jffs2 creates a JFFS2 (Second Journalling Flash
File System) file system image and writes the resulting image to the
file specified by the -o option or by default to the standard output,
unless the standard output is a terminal device in which case mkfs.jffs2
will abort. The file system image is created using the files and
directories contained in the directory specified by the option -r or
the present directory, if the -r option is not specified.
========================================================================

So the command equals to
`mkfs -t jffs2 -r xfstests-dev /dev/mapper/test-2 \
    -o xfstests-dev/results/shared/032.full \
    >>xfstests-dev/results/shared/032.full 2>&1`

The output image 032.full is under the directory xfstests-dev.
mkfs.jffs2 keeps reading from 032.full in page size and append bytes
to 032.full until the disk where xfstests-devel located is full.

Fix it by setting @preargs to '-r /proc/fs -o' for jffs2, now the output
is $SCRATCH_DEV. Since mkfs.jffs2 doesn't check overwrite case, just
skip overwrite attempt.

Signed-off-by: Su Yue <l@damenly.su>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test incremental send after removing a directory and all its files
Filipe Manana [Thu, 10 Dec 2020 12:09:17 +0000 (12:09 +0000)]
btrfs: test incremental send after removing a directory and all its files

Test that an incremental send operation succeeds, and produces the
correct results, after removing a directory and all its files, unmounting
the filesystem, mounting the filesystem again and creating a new file (or
directory).

This currently fails on btrfs, but is fixed by a patch that has the
following subject:

  btrfs: send, fix wrong file path when there is an inode with a pending rmdir

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: test if rename handles dir item collision correctly
ethanwu [Tue, 15 Dec 2020 03:59:06 +0000 (11:59 +0800)]
btrfs: test if rename handles dir item collision correctly

This is a regression test for the issue fixed by the kernel commit titled
"btrfs: correctly calculate item size used when item key collision happens"

In this case, we'll simply rename many forged filename that cause collision
under a directory to see if rename failed and filesystem is forced readonly.

Signed-off-by: ethanwu <ethanwu@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agosrc/t_enospc.c: Fix an error for the loop initialization declaration
Feiyu Zhu [Thu, 10 Dec 2020 02:59:54 +0000 (21:59 -0500)]
src/t_enospc.c: Fix an error for the loop initialization declaration

When I compiled xfstests using the gcc(version 4.8.5), the following error occurred:
t_enospc.c: In function 'enospc_test':
t_enospc.c:88:2: error: 'for' loop initial declarations are only allowed in C99 mode
  for (int i = 0; i < size; i++) {
  ^

Signed-off-by: Feiyu Zhu <zhufy.jy@cn.fujitsu.com>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric/563: use a loop device to avoid partition incompatibility
Brian Foster [Mon, 14 Dec 2020 17:18:54 +0000 (12:18 -0500)]
generic/563: use a loop device to avoid partition incompatibility

cgroup writeback accounting does not track partition level
statistics. Instead, I/O is accounted against the parent device. As
a result, the test fails if the scratch device happens to be a
device partition. Since parent level stats are potentially polluted
by factors external to the test, wrap the scratch device in a
loopback device to guarantee the test always runs on a top-level
block device.

Reported-by: Boyang Xue <bxue@redhat.com>
Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test for creating duplicate filenames in encrypted dir
Eric Biggers [Mon, 14 Dec 2020 23:47:20 +0000 (15:47 -0800)]
generic: test for creating duplicate filenames in encrypted dir

Test for a race condition where a duplicate filename could be created in
an encrypted directory while the directory's encryption key was being
added concurrently.

generic/595 was already failing on ubifs due to this bug, but only by
accident.  This new test detects the bug on both ext4 and ubifs.  I
wasn't able to get it to detect the bug on f2fs.

Signed-off-by: Eric Biggers <ebiggers@google.com>
3 years agosrc/multi_open_unlink: Stop using attr_set
Xiao Yang [Wed, 9 Dec 2020 05:08:16 +0000 (13:08 +0800)]
src/multi_open_unlink: Stop using attr_set

Avoid the following warning by replacing deprecated
attr_set with setxattr:
---------------------------------------------------
warning: 'attr_set' is deprecated: Use setxattr or lsetxattr instead [-Wdeprecated-declarations]
---------------------------------------------------

Also remove unneeded flags, <attr/attributes.h> and $(LIBATTR).

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: Add test to check for mounting a huge sparse dm device
Ritesh Harjani [Wed, 9 Dec 2020 04:03:41 +0000 (09:33 +0530)]
generic: Add test to check for mounting a huge sparse dm device

Add this test to check for regression which was reported when ext4 bmap
aops was moved to use iomap APIs. jbd2 calls bmap() kernel function
from fs/inode.c which was failing since iomap_bmap() implementation earlier
returned 0 for block addr > INT_MAX.
This regression was fixed with following kernel commit [1]
commit b75dfde1212991b24b220c3995101c60a7b8ae74
("fibmap: Warn and return an error in case of block > INT_MAX")
[1]: https://patchwork.ozlabs.org/patch/1279914

w/o the kernel fix we get below errors and mount fails

[ 1461.988701] run fstests generic/613 at 2020-10-27 19:57:34
[ 1530.406645] ------------[ cut here ]------------
[ 1530.407332] would truncate bmap result
[ 1530.408956] WARNING: CPU: 0 PID: 6401 at fs/iomap/fiemap.c:116 iomap_bmap_actor+0x43/0x50
[ 1530.410607] Modules linked in:
[ 1530.411024] CPU: 0 PID: 6401 Comm: mount Tainted: G        W
<...>
[ 1530.511978] jbd2_journal_init_inode: Cannot locate journal superblock
[ 1530.513310] EXT4-fs (dm-1): Could not load journal inode

Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
3 years agobtrfs: Update btrfs/215
Nikolay Borisov [Mon, 7 Dec 2020 09:23:18 +0000 (11:23 +0200)]
btrfs: Update btrfs/215

This patch updates btrfs/215 to work with latest upstream kernel. That's
required since commit 324bcf54c449 ("mm: use limited read-ahead to satisfy read")
changed readahead logic to always issue a read even if the RA pages are
set to 0. This results in 1 extra io being issued so the counts in the
test should be incremented by 1. Also use the opportunity to update the
commit reference since it's been merged in the upstream kernel.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/513: fix the regression caused by mount option uqnoenforce
Kaixu Xia [Mon, 7 Dec 2020 11:41:05 +0000 (19:41 +0800)]
xfs/513: fix the regression caused by mount option uqnoenforce

The mount options uqnoenforce and qnoenforce no longer cause 'usrquota'
to be emitted in /proc/mounts, so there is a regression in xfs/513. Fix
it by using proper output option uqnoenforce.

You'll need kernel commit 237d7887ae72 ("xfs: show the proper user
quota options") to pass the test.

[Eryu: add kernel commit info in commit log]

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agocheck: source common/rc again if TEST_DEV was recreated
Eryu Guan [Fri, 4 Dec 2020 10:43:53 +0000 (16:13 +0530)]
check: source common/rc again if TEST_DEV was recreated

If TEST_DEV is recreated by check, FSTYP derived from TEST_DEV
previously could be changed too and might not reflect the reality.
So source common/rc again with correct FSTYP to get fs-specific
configs, e.g. common/xfs.

For example, using this config-section config file, and run section
ext4 first then xfs, you can see:

our local _scratch_mkfs routine ...
./common/rc: line 825: _scratch_mkfs_xfs: command not found
check: failed to mkfs $SCRATCH_DEV using specified options

local.config:
[default]
RECREATE_TEST_DEV=true
TEST_DEV=/dev/sda5
SCRATCH_DEV=/dev/sda6
TEST_DIR=/mnt/test
SCRATCH_MNT=/mnt/scratch

[ext4]
MKFS_OPTIONS="-b 4096"
FSTYP=ext4

[xfs]
FSTYP=xfs
MKFS_OPTIONS="-f -b size=4k"

Tested-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
3 years agocommon/rc: Fix _check_s_dax()
Ira Weiny [Fri, 4 Dec 2020 01:45:50 +0000 (17:45 -0800)]
common/rc: Fix _check_s_dax()

There is a conflict with the user visible statx bits 'mount root' and
'dax'.  The kernel is changing the dax bit to correct this conflict.[1]

Adjust _check_s_dax() to use the new bit.  Because DAX tests do not run
on root mounts, STATX_ATTR_MOUNT_ROOT should always be 0.  Therefore,
check for the old flag and fail the test if that occurs.

[1] https://lore.kernel.org/lkml/3e28d2c7-fbe5-298a-13ba-dcd8fd504666@redhat.com/

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: ENOSPC regression test in a multi-threaded scenario
Pratik Rajesh Sampat [Tue, 1 Dec 2020 13:03:28 +0000 (18:33 +0530)]
generic: ENOSPC regression test in a multi-threaded scenario

Test allocation strategies of the file system and validate space
anomalies as reported by the system versus the allocated by the
program.

The test is motivated by a bug in ext4 systems where-in ENOSPC is
reported by the file system even though enough space for allocations is
available[1].

[1]: https://patchwork.ozlabs.org/patch/1294003

Linux kernel patch series that fixes the above regression:
53f86b170dfa ("ext4: mballoc: add blocks to PA list under same spinlock
              after allocating blocks")
cf5e2ca6c990 ("ext4: mballoc: refactor ext4_mb_discard_preallocations()")
07b5b8e1ac40 ("ext4: mballoc: introduce pcpu seqcnt for freeing PA to
              improve ENOSPC handling")
8ef123fe02ca ("ext4: mballoc: refactor ext4_mb_good_group()")
993778306e79 ("ext4: mballoc: use lock for checking free blocks while
              retrying")

Suggested-by: Ritesh Harjani <riteshh@linux.ibm.com>
Co-authored-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Pratik Rajesh Sampat <psampat@linux.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoceph: add a new test for cross quota realms renames
Luis Henriques [Fri, 27 Nov 2020 12:37:42 +0000 (12:37 +0000)]
ceph: add a new test for cross quota realms renames

For the moment cross quota realms renames has been disabled in CephFS
after a bug has been found while renaming files created and truncated.
This allowed clients to easily circumvent quotas.

Link: https://tracker.ceph.com/issues/48203
Signed-off-by: Luis Henriques <lhenriques@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agogeneric: test XFS forkoff miscalcution on 32-bit platform
Gao Xiang [Tue, 24 Nov 2020 10:11:45 +0000 (18:11 +0800)]
generic: test XFS forkoff miscalcution on 32-bit platform

There is a regression that recent XFS_LITINO(mp) update causes
xfs_attr_shortform_bytesfit() returns maxforkoff rather than 0.

Therefore, one result is
  "ASSERT(new_size <= XFS_IFORK_SIZE(ip, whichfork));"

Add a regression test in fstests generic to look after that since
the testcase itself isn't xfs-specific.

Signed-off-by: Gao Xiang <hsiangkao@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 years agoxfs/033: use _scratch_xfs_db wrapper
Darrick J. Wong [Wed, 11 Nov 2020 00:43:45 +0000 (16:43 -0800)]
xfs/033: use _scratch_xfs_db wrapper

Use the wrapper instead of open-coding the call.

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 agomisc: fix _get_file_block_size usage
Darrick J. Wong [Wed, 11 Nov 2020 00:43:39 +0000 (16:43 -0800)]
misc: fix _get_file_block_size usage

Fix these tests that rely on the allocation unit size of a file, which
might not necessarily be the fs block size.

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 agomisc: fix $MKFS_PROG.$FSTYP usage treewide
Darrick J. Wong [Wed, 11 Nov 2020 00:43:33 +0000 (16:43 -0800)]
misc: fix $MKFS_PROG.$FSTYP usage treewide

Replace all the $MKFS_PROG.$FSTYP invocations with $MKFS_PROG -t $FSTYP.
The mkfs wrapper binary knows how to search the user's $PATH to find the
appropriate mkfs delegate, which the author uses to switch between
development and distro versions of various tools.

Unfortunately, using "$MKFS_PROG.$FSTYP" means that the shell only looks
in the same directory as the mkfs wrapper, which means that we can end
up mixing different tool versions when this is the case.

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 agocommon/populate: make sure _scratch_xfs_populate puts its files on the data device
Darrick J. Wong [Wed, 11 Nov 2020 00:43:26 +0000 (16:43 -0800)]
common/populate: make sure _scratch_xfs_populate puts its files on the data device

Make sure that _scratch_xfs_populate always installs its files on the
data device even if the test config selects rt by default.

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>