xfstests-dev.git
2 years agoxfs: test new v5 bulkstat commands
Darrick J. Wong [Thu, 1 Aug 2019 01:43:10 +0000 (18:43 -0700)]
xfs: test new v5 bulkstat commands

Check that the new v5 bulkstat commands do everything the old one do,
and then make sure the new functionality actually works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/xfs: refactor agcount calculation for mounted filesystems
Darrick J. Wong [Thu, 1 Aug 2019 01:43:04 +0000 (18:43 -0700)]
common/xfs: refactor agcount calculation for mounted filesystems

Create a helper function to return the number of AGs of a mounted
filesystem so that we can get rid of the open-coded versions in various
tests.  The new helper will be used in a subsequent patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/122: add the new v5 bulkstat/inumbers ioctl structures
Darrick J. Wong [Thu, 1 Aug 2019 01:42:57 +0000 (18:42 -0700)]
xfs/122: add the new v5 bulkstat/inumbers ioctl structures

The new v5 bulkstat and inumbers structures are correctly padded so that
no format changes are necessary across platforms, so add them to the
output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/122: mask wonky ioctls
Darrick J. Wong [Thu, 1 Aug 2019 01:42:47 +0000 (18:42 -0700)]
xfs/122: mask wonky ioctls

Don't check the structure size of the inogrp/bstat/fsop_bulkreq
structures because they're incorrectly padded.  When we remove the
old typdefs the old filter stops working.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/122: ignore inode geometry structure
Darrick J. Wong [Thu, 1 Aug 2019 01:42:41 +0000 (18:42 -0700)]
xfs/122: ignore inode geometry structure

Ignore new in-core structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/194: unmount forced v4 fs during cleanup
Darrick J. Wong [Thu, 25 Jul 2019 18:04:13 +0000 (11:04 -0700)]
xfs/194: unmount forced v4 fs during cleanup

Unmount the V4 filesystem we forcibly created to run this test during
test cleanup so that the post-test wrapup checks won't try to remount
the filesystem with different MOUNT_OPTIONS (specifically, the ones
that get screened out by _force_xfsv4_mount_options) and fail.

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/033: filter out root inode nlink repair
Darrick J. Wong [Wed, 24 Jul 2019 15:56:31 +0000 (08:56 -0700)]
xfs/033: filter out root inode nlink repair

A couple of releases ago, xfs_repair was patched to set the root inode
link count correctly when messing around with lost inodes.  However, the
old xfs_repair remains in the golden output, so remove it and filter the
line so that we don't cause 'new' regressions on old software.

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: disable quotas before running test
Darrick J. Wong [Wed, 24 Jul 2019 15:56:10 +0000 (08:56 -0700)]
fstests: disable quotas before running test

For all the tests which require that quotas be disabled, remove the
quota mount options before mounting the scratch filesystem.

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/506: mount scratch fs before testing for prjquota presence
Darrick J. Wong [Wed, 24 Jul 2019 15:55:43 +0000 (08:55 -0700)]
generic/506: mount scratch fs before testing for prjquota presence

On XFS, the _require_prjquota helper takes a path to a block device,
but (unintuitively) requires the block device to be mounted for the
detection to work properly.  Fix the detection code in generic/506.

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/561: kill duperemove after sleep_time
Darrick J. Wong [Wed, 24 Jul 2019 04:13:06 +0000 (21:13 -0700)]
generic/561: kill duperemove after sleep_time

generic/561 can take a very long time to run on XFS (45+ minutes)
because it kicks off fsstress and a lot of duperemove processes,
waits 50 seconds, and then waits for the duperemove processes to
finish.  duperemove, however, fights with fsstress for file locks
and can take a very long time to make even a single pass over the
filesystem and exit, which means the test just takes forever to run.

Once we've decided to tear down the duperemove processes let's just send
them SIGINT and then wait for them to exit.

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/504: fix bogus test description
Darrick J. Wong [Wed, 24 Jul 2019 04:13:00 +0000 (21:13 -0700)]
xfs/504: fix bogus test description

Fix the description of this test to reflect what it actually checks.

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 agooverlay/065: adjust test to expect EBUSY only with index=on
Amir Goldstein [Sun, 28 Jul 2019 10:21:24 +0000 (13:21 +0300)]
overlay/065: adjust test to expect EBUSY only with index=on

This is needed to support the kernel regression fix commit 0be0bfd2de9d
("ovl: fix regression caused by overlapping layers detection").

Overlayfs mount is not supposed to fail due to upper/work dir in-use
by other mount unless option index=on is enabled.

Add test variants for index=on and index=off.

Fix some wrong comments and clean noise lines in golden output.

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 agocommon/rc: ceph only supports default SEEK_HOLE behavior
Jeff Layton [Fri, 26 Jul 2019 13:45:52 +0000 (09:45 -0400)]
common/rc: ceph only supports default SEEK_HOLE behavior

CephFS currently has only a very primitive SEEK_HOLE implementation,
and always sets the offset to EOF when it's used. Remove it from the
whitelist.

Cc: Amir Goldstein <amir73il@gmail.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 agocommon/rc: check quota sysfile feature for f2fs
Chao Yu [Tue, 23 Jul 2019 09:25:29 +0000 (17:25 +0800)]
common/rc: check quota sysfile feature for f2fs

In _require_prjquota(), f2fs missed to check whether we have enabled
quota sysfile feature in the image, add it.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/quota: support f2fs in _require_quota() and _check_quota_usage()
Chao Yu [Tue, 23 Jul 2019 09:25:28 +0000 (17:25 +0800)]
common/quota: support f2fs in _require_quota() and _check_quota_usage()

This can let f2fs pass the check of quota testcases.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: cross-device copy_file_range test
Amir Goldstein [Mon, 15 Jul 2019 12:55:16 +0000 (15:55 +0300)]
generic: cross-device copy_file_range test

Old kernels do not support cross-device copy_file_range.

This is a regression test for kernel commit:

  5dae222a5ff0 vfs: allow copy_file_range to copy across devices

[Amir] Split out cross-device copy_range test to a new test and
_notrun if kernel/filesystem do not support cross-device copy_range.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
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: copy_file_range bounds test
Amir Goldstein [Mon, 15 Jul 2019 12:55:15 +0000 (15:55 +0300)]
generic: copy_file_range bounds test

Test that copy_file_range will return the correct errors for various
error conditions and boundary constraints.

This is a regression test for kernel commit:

  96e6e8f4a68d ("vfs: add missing checks to copy_file_range")

[Amir] Split out cross-device copy_range test and use only test dev.
Split out immutable/swapfile test cases to reduce the requirements to
run the bounds check to minimum and get coverage for more filesystems.
Remove the tests for read past EOF and write after chmod -r,
because we decided to stick with read(2)/write(2) semantics.
Add requirements needed for large size copy tests and fifo test.
Use existing char/block devices for char/block dev tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
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 agocommon/rc: check support for xfs_io copy_range -f N
Amir Goldstein [Mon, 15 Jul 2019 12:55:14 +0000 (15:55 +0300)]
common/rc: check support for xfs_io copy_range -f N

Implement "_require_xfs_io_command copy_range -f" to check for
the option added by following xfsprogs commit:

  10d4ca4aeff5 ("xfs_io: allow passing an open file to copy_range")

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 agoshared/011: move to generic/
Christoph Hellwig [Mon, 15 Jul 2019 08:25:23 +0000 (10:25 +0200)]
shared/011: move to generic/

Now that we run the test for all block device based file systems, there
is no reason to keep it out of generic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoshared/011: run for all block device based file systems
Christoph Hellwig [Mon, 15 Jul 2019 08:25:22 +0000 (10:25 +0200)]
shared/011: run for all block device based file systems

Cgroupv2 writeback support can't be easily detected.  But it is
kindof expected from block based file systems and can be easily
added, so just assume support and fail if it doesn't work.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/cgroup2: better error message if cgroup2 fs is not mounted
Christoph Hellwig [Mon, 15 Jul 2019 08:25:21 +0000 (10:25 +0200)]
common/cgroup2: better error message if cgroup2 fs is not mounted

Improve the _require_cgroup2 helper to print a more useful message
if the cgroup2 fs is not mounted.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: test incremental send after deduplication on both snapshots
Filipe Manana [Wed, 17 Jul 2019 12:24:39 +0000 (13:24 +0100)]
btrfs: test incremental send after deduplication on both snapshots

Test that an incremental send operation works after deduplicating into the
same file in both the parent and send snapshots.

This currently fails on btrfs and a kernel patch to fix it was submitted
with the subject:

  Btrfs: fix incremental send failure after deduplication

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 agocommon/rc: set max label length for f2fs
Chao Yu [Thu, 18 Jul 2019 09:11:54 +0000 (17:11 +0800)]
common/rc: set max label length for f2fs

f2fs can support FS_IOC_{GET,SET}FSLABEL now, set max label length
to enable generic/492 testcase for f2fs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/119: fix MKFS_OPTIONS exporting
Darrick J. Wong [Tue, 9 Jul 2019 17:49:53 +0000 (10:49 -0700)]
xfs/119: fix MKFS_OPTIONS exporting

This test originally exported its own MKFS_OPTIONS to force the tested
filesystem config to the mkfs defaults + test-specific log size options.
This overrides whatever the test runner might have set in MKFS_OPTIONS.

In commit 2fd273886b525 ("xfs: refactor minimum log size formatting
code") we fail to export our test-specific MKFS_OPTIONS before
calculating the minimum log size, which leads to the wrong min log size
being calculated once we fixed the helper to be smarter about mkfs options.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/016: calculate minimum log size and end locations
Darrick J. Wong [Tue, 9 Jul 2019 17:49:47 +0000 (10:49 -0700)]
xfs/016: calculate minimum log size and end locations

xfs/016 looks for corruption in the log when the log wraps.  However,
it hardcodes the minimum log size and the "95%" point where it wants to
start the "nudge and check for corruption" part of the test.  New
features require larger logs, which causes the test to fail when it
can't mkfs with the smaller log size and when that 95% point doesn't put
us within 20x "_log_traffic 2"s of the end of the log.

Fix the first problem by using the new min log size helper and replace
the 95% figure with an estimate of where we need to be to guarantee that
the 20x loop wraps the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: rework min log size helper
Darrick J. Wong [Tue, 9 Jul 2019 17:49:41 +0000 (10:49 -0700)]
xfs: rework min log size helper

The recent _scratch_find_xfs_min_logblocks helper has a major thinko in
it -- it relies on feeding a too-small size to _scratch_do_mkfs so that
mkfs will tell us the minimum log size.  Unfortunately, _scratch_do_mkfs
will see that first failure and retry the mkfs without MKFS_OPTIONS,
which means that we return the minimum log size for the default mkfs
settings without MKFS_OPTIONS.

This is a problem if someone's running fstests with a set of
MKFS_OPTIONS that affects the minimum log size.  To fix this, open-code
the _scratch_do_mkfs retry behavior so that we only do the "retry
without MKFS_OPTIONS" behavior if the mkfs failed for a reason other
than the minimum log size check.

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/189: make the test work on systems with a page size greater than 4Kb
Filipe Manana [Fri, 5 Jul 2019 11:26:21 +0000 (12:26 +0100)]
btrfs/189: make the test work on systems with a page size greater than 4Kb

The test currently uses offsets and lengths which are multiples of
4K, but not multiples of 64K (or any other page size between 4Kb and
64Kb). This makes the reflink calls fail with -EINVAL because
reflink only operates on ranges that are aligned to the the
filesystem's block size.

Fix this by ensuring all ranges passed to the reflink calls are
aligned to 64K, so that the test works on any system regardless of
its page size.  The test still fails without the corresponding
kernel fix applied [1] as it is supposed to.

[1] 3c850b45110950 ("Btrfs: incremental send, fix emission of invalid clone operations")

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 agogeneric/399: don't rely on xfs_io exit status
Eric Biggers [Mon, 8 Jul 2019 20:32:39 +0000 (13:32 -0700)]
generic/399: don't rely on xfs_io exit status

Unexpectedly, 'xfs_io -f $file -c "pwrite 0 1M"' exits with failure
status if the file can't be created, but exits with success status if an
error occurs actually writing data.  As discussed previously, xfs_io's
exit status has always been broken, and it will be difficult to fix:
https://marc.info/?l=linux-xfs&m=151269053129101&w=2

Because of this, generic/399 fails on ext4 if "-I 256" (256-byte inodes)
is specified in the mkfs options, e.g. with 'kvm-xfstests -c ext4/adv
generic/399'.  This is because the test tries to fill a filesystem
entirely with 1 MiB encrypted files, and it expects the xfs_io commands
to start failing when no more files should be able to fit.  But when the
filesystem supports in-inode xattrs, no blocks need to be allocated for
the encryption xattrs, so empty encrypted files can continue to be
created even after all the filesystem's blocks are in-use.

For better or worse, the convention for xfstests is to ignore the exit
status of xfs_io and instead rely on the printed error messages.  Thus,
other tests don't run into this problem.  So for now, let's fix the test
failure by making generic/399 do the same.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/449: test xfs_info on a mounted block device
Zorro Lang [Sat, 6 Jul 2019 14:52:17 +0000 (22:52 +0800)]
xfs/449: test xfs_info on a mounted block device

There was a bug, xfs_info fails on a mounted block device:

  # xfs_info /dev/mapper/testdev
  xfs_info: /dev/mapper/testdev contains a mounted filesystem

  fatal error -- couldn't initialize XFS library

  xfsprogs has fixed it by:

    bbb43745 xfs_info: use findmnt to handle mounted block devices

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 agocommon/rc: print out kernel version too
Mauricio Faria de Oliveira [Wed, 10 Jul 2019 17:58:09 +0000 (14:58 -0300)]
common/rc: print out kernel version too

The kernel version (uname -v) may also be needed in addition to
the kernel release (uname -r) in order to properly identify and
distinguish different kernel builds in some cases/distributions.

For example, in the Ubuntu kernel package the test/debug string
is usually a suffix to the version field, not the release field.

  $ uname -rv
  4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019

  $ uname -rv
  4.15.0-51-generic #55+test20190520b1 SMP Mon May 20 11:57:40 -03 2019

Looking at other OSes uname(1) man pages it looks like '-v' is
quite standard, and the Linux man page only cites '-p' and '-i'
as non-portable, so the change should be OK. The only caller is
the 'check' script for the header print out, so it's contained.

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/553[4]: correct kernel fix commit
Yang Xu [Wed, 10 Jul 2019 11:35:22 +0000 (19:35 +0800)]
generic/553[4]: correct kernel fix commit

commit 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
adds checks for immutablefile and swapfile instead of commit a31713517d
("vfs: introduce generic_file_rw_checks()").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: test cloning large exents to a file with many small extents
Filipe Manana [Fri, 28 Jun 2019 22:08:36 +0000 (23:08 +0100)]
generic: test cloning large exents to a file with many small extents

Test that if we clone a file with some large extents into a file
that has many small extents, when the fs is nearly full, the clone
operation does not fail and produces the correct result.

This is motivated by a bug found in btrfs wich is fixed by the
following patches for the linux kernel:

 [PATCH 1/2] Btrfs: factor out extent dropping code from hole punch handler
 [PATCH 2/2] Btrfs: fix ENOSPC errors, leading to transaction aborts, when
             cloning extents

The test currently passes on xfs.

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 agoshared,generic: move tests using duperemove to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:10 +0000 (18:59 -0400)]
shared,generic: move tests using duperemove to generic/

Add _require_scratch_duperemove which validates that the file system
supports duperemove.  This allows us to move three tests from shared/
to generic/.  This means these tests will automatically adapt when
duperemove supports other file systems.  Tests moved are:

shared/008 --> generic/559
shared/009 --> generic/560
shared/010 --> generic/561

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoshared,generic: move shared/006 to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:09 +0000 (18:59 -0400)]
shared,generic: move shared/006 to generic/

The shared/006 uses _scratch_mkfs_sized to create a limited size
file system, and then creates inodes until it gets ENOSPC, and then
checks to make sure the file system is consistent.  It then remounts
the file system, removes all of the files, and makes sure the file
system is consistent afterwards. This test was marked as only being
supported on ext[234] and xfs, and so it was in shared.

Now introduce a new _require_inode_limits() rule to run test on
filesystems that have a fixed inode number, then move the test to
generic.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoshared,ext4: move ext[234]-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:08 +0000 (18:59 -0400)]
shared,ext4: move ext[234]-specific tests out of shared/

Move the following tests:

shared/005 --> ext4/040
shared/007 --> ext4/041
shared/289 --> ext4/042

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocheck: add ext4 group list when testing ext2 and ext3
Theodore Ts'o [Fri, 28 Jun 2019 22:59:07 +0000 (18:59 -0400)]
check: add ext4 group list when testing ext2 and ext3

Modern kernels use the ext4 implementation to support ext2 and ext3
mounts, and a number of the ext4 tests are actually suitable for
ext2 and ext3.  We're trying to move tests out of shared anyway, so
instead of moving tests from ext4/NNN to shared, let's just include
the ext4 group list when FSTYP is ext2 or ext3.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoshared,ext4: move ext4-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:06 +0000 (18:59 -0400)]
shared,ext4: move ext4-specific tests out of shared/

The tests shared/{001,003,004,272} test behaviour around the ext4's
journal.  As such, they are pointless to run on ext2, and ext3 no
longer is in kernels newer than 4.3.  (And most enterprise
distributions have been using ext4 to support the ext3 file system;
that capability has been around since 2.6.33.)  So we can move these
tests out of shared and into the ext4 class of tests:

shared/001 --> ext4/036
shared/003 --> ext4/037
shared/004 --> ext4/038
shared/272 --> ext4/039

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/encrypt: check that contents encryption is usable
Eric Biggers [Mon, 1 Jul 2019 17:12:55 +0000 (10:12 -0700)]
common/encrypt: check that contents encryption is usable

In _require_encryption_policy_support(), when checking whether the
encryption policy is usable, try creating a nonempty file rather
than an empty one.  This ensures that both the contents and
filenames encryption modes are available, rather than just the
filenames mode.

On f2fs this makes generic/549 be correctly skipped, rather than
failed, when run on a kernel built from the latest fscrypt.git tree
with CONFIG_CRYPTO_SHA256=n.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: project quota ineritance flag test
Zorro Lang [Wed, 19 Jun 2019 10:10:47 +0000 (18:10 +0800)]
xfs: project quota ineritance flag test

This case is used to cover xfsprogs bug fixed by commit b136f48b19a5
("xfs_quota: fix false error reporting of project inheritance flag
is not set") at first. Then test more behavior when project
ineritance flag is set or removed.

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 agogeneric/486: filter out irrelevant attrs
Murphy Zhou [Thu, 27 Jun 2019 09:00:59 +0000 (17:00 +0800)]
generic/486: filter out irrelevant attrs

In some setup, there could be extra attrs printed, like selinux.
They are breaking golden output and irrelevant for this test.
So focus on the attr we are testing on to avoid false alarm.
Print the output to .full for debug.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: check for COW overflows in i_delayed_blks
Darrick J. Wong [Tue, 18 Jun 2019 21:07:37 +0000 (14:07 -0700)]
xfs: check for COW overflows in i_delayed_blks

With the new copy on write functionality it's possible to reserve so
much COW space for a file that we end up overflowing i_delayed_blks.
The only user-visible effect of this is to cause totally wrong i_blocks
output in stat, so check for that.

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 agooverlay/061: remove from auto and quick groups
Amir Goldstein [Tue, 18 Jun 2019 06:43:55 +0000 (09:43 +0300)]
overlay/061: remove from auto and quick groups

In late 2016, tests overlay/01[6-8] where merged to track the
state of several ilong standing posix compliance issues on overlayfs.

This practice was somewhat of an exception for xfstests project,
which more often merges tests for issues that are expected to be
resolved in the short term.

Over the years, some test cases have been fixed and more tests
where created to cover the remaining issues (e.g. overlay/04[34]).

Currently, the only failing test from this category is overlay/061
which covers item b) in the "Non-standard behavior" section of
Documentation/filesystems/overlayfs.txt.

Since there is no clear design, roadmap nor allocated resources
to resolve this remaining issue, the test is removed from the
"auto" and "quick" groups, following a suggestion that Darrick
has made for a similarly long failing generic test.

The test was added to the new "posix" group, to allow testing
for posix compliance.

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/059: also test that the file's mtime and ctime are updated
Filipe Manana [Wed, 19 Jun 2019 12:06:24 +0000 (13:06 +0100)]
generic/059: also test that the file's mtime and ctime are updated

Test as well that hole punch operations that affect a single file block
also update the file's mtime and ctime.

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

 "Btrfs: add missing inode version, ctime and mtime updates when
  punching hole"

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 agogeneric: test dir fsync after deleting dentry post eviction of its inode
Filipe Manana [Wed, 19 Jun 2019 12:06:08 +0000 (13:06 +0100)]
generic: test dir fsync after deleting dentry post eviction of its inode

Test that if we fsync a file, evict its inode, unlink it and then fsync
its parent directory, after a power failure the file does not exists.

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

 "Btrfs: fix fsync not persisting dentry deletions due to inode evictions"

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 agodump: _cleanup_dump should only check the scratch fs if the test required it
Darrick J. Wong [Tue, 18 Jun 2019 21:07:08 +0000 (14:07 -0700)]
dump: _cleanup_dump should only check the scratch fs if the test required it

_cleanup_dump always tries to check the scratch fs, even if the caller
didn't actually _require_scratch.  If a previous test wrote garbage to
the scratch device then the dump test will fail here when repair
stumbles over the garbage.

This was observed by running xfs/016 and xfs/036 in succession.  xfs/016
writes 0xc6 to the scratch device and tries to format a small log.  If
the log is too small the format fails and the test will _notrun.  The
subsequent xfs/036 will _notrun and then _cleanup_dump if no tape device
is set, at which point we try to check the scratch device and logprint
aborts due to the abnormal log size (0xc6c6c6c6).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/532: document the kernel commit
Murphy Zhou [Wed, 19 Jun 2019 02:28:55 +0000 (10:28 +0800)]
generic/532: document the kernel commit

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewedf-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: fix _scratch_remount with xfs_info 5.0.0
Amir Goldstein [Mon, 17 Jun 2019 13:58:43 +0000 (16:58 +0300)]
overlay: fix _scratch_remount with xfs_info 5.0.0

xfs_info version 5.0.0 started using findmnt to find the
filesystem to query. This change resulted in a regression
of _scratch_remount when testing overlay over xfs.
For example, test overlay/035, started to report:
[not run] overlay/035 -- upper fs needs to support d_type

Internally, '_overlay_scratch_mount -o remount' calls
'_supports_filetype $OVL_BASE_SCRATCH_MNT -o remount'
and with the following example mounts:

/dev/vdf /vdf xfs rw,relatime,attr2,inode64,noquota 0 0
/vdf /vdf/ovl-mnt overlay rw,lowerdir=/vdf/lower,upperdir=/vdf/upper...

'_supports_filetype /vdf' returns false and reports:
"/vdf/ovl-mnt: Not on a mounted XFS filesystem".

Regardless of the change in xfs_info, which I proposed a fix
for, there is no reason to test d_type support on remount.
Therefore, fix the regression by skipping unneeded overlayfs
mount logic on remount.

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: Add tests for filename casefolding feature
Lakshmipathi.G [Wed, 12 Jun 2019 18:40:33 +0000 (14:40 -0400)]
generic: Add tests for filename casefolding feature

This new test implements verification for the per-directory
case-insensitive feature, as supported by the reference
implementation in Ext4.

Signed-off-by: Lakshmipathi.G <lakshmipathi.ganapathi@collabora.co.uk>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
  [Rewrite to support feature design]
  [Refactor to simplify implementation]
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/casefold: Add infrastructure to test filename casefold feature
Gabriel Krisman Bertazi [Wed, 12 Jun 2019 18:40:32 +0000 (14:40 -0400)]
common/casefold: Add infrastructure to test filename casefold feature

Add a set of basic helper functions to simplify the testing of
casefolding capable filesystems.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: check CAP_LINUX_IMMUTABLE capability with FS_IOC_FSSETXATTR
Amir Goldstein [Tue, 11 Jun 2019 16:08:39 +0000 (19:08 +0300)]
generic: check CAP_LINUX_IMMUTABLE capability with FS_IOC_FSSETXATTR

This is a flavor of test generic/545 with FS_IOC_FSSETXATTR ioctl
instead of FS_IOC_SETFLAGS ioctl.

Overlayfs gained support for FS_IOC_FSSETXATTR ioctl in v5.2-rc4
with buggy capability check. This change fixed the problem:

  ovl: fix wrong flags check in FS_IOC_FS[SG]ETXATTR ioctls

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: check for filesystem FS_IOC_FSSETXATTR support
Amir Goldstein [Tue, 11 Jun 2019 16:08:38 +0000 (19:08 +0300)]
fstests: check for filesystem FS_IOC_FSSETXATTR support

With "_require_xfs_io_command chattr <letter>", check that
flag can be set/cleared using FS_IOC_FSSETXATTR ioctl, similar
to "_require_chattr <letter>" and FS_IOC_SETFLAGS ioctl.

Update the documentation and the tests that use
"_require_xfs_io_command chattr" to test filesystem support
and not only xfs_io support.

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 agocommon/rc: print out xfs_io parameter when command fails
Amir Goldstein [Tue, 11 Jun 2019 16:08:37 +0000 (19:08 +0300)]
common/rc: print out xfs_io parameter when command fails

In _require_xfs_io_command, when command fails for one of the
generic reasons, if command was tested with params, print out
the params of the failed command.

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/146: remove unnecessary scratch unmount to avoid test failure
Filipe Manana [Wed, 12 Jun 2019 10:05:44 +0000 (11:05 +0100)]
btrfs/146: remove unnecessary scratch unmount to avoid test failure

Right at the beginning of the test we are unmonting the scratch device,
however at this point the device was never mounted, so the unmount fails
with an error message like the following:

  umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted

Which is not expected by the golden output and therefore causes the test
to fail.

Since the device/mount point was not mounted yet in the test, and since
the test framework unmounts the scratch device after each test finishes,
just remove the call to _scratch_unmount.

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 agofstests: don't oom the box opening tmpfiles (take 2)
Amir Goldstein [Sun, 9 Jun 2019 17:12:29 +0000 (20:12 +0300)]
fstests: don't oom the box opening tmpfiles (take 2)

For the t_open_tmpfiles tests that run multiple jobs in parallel,
limit ourselves to half of file-max for all jobs combined,
so that we don't OOM the test machine.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoext4/035: skip this test if DAX is in use
Theodore Ts'o [Mon, 10 Jun 2019 02:42:54 +0000 (22:42 -0400)]
ext4/035: skip this test if DAX is in use

This test creates a file system with a 1k block size.  Since there
are no architectures with a 1k page size, the test file system can
never be mounted with DAX enabled, causing the test to fail.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/554: test only copy to active swap file
Amir Goldstein [Tue, 11 Jun 2019 15:39:16 +0000 (18:39 +0300)]
generic/554: test only copy to active swap file

Depending on filesystem, copying from active swapfile may be allowed,
just as read from swapfile may be allowed.

Note the kernel fix commit in test description.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/553: fix test description
Amir Goldstein [Tue, 11 Jun 2019 15:39:15 +0000 (18:39 +0300)]
generic/553: fix test description

The test only checks copy to immutable file.
Note the kernel fix commit.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoreport: gracefully handle XML report creation when no tests are run
Theodore Ts'o [Sun, 9 Jun 2019 21:04:31 +0000 (17:04 -0400)]
report: gracefully handle XML report creation when no tests are run

If no tests are run (because they have all been excluded) then make
sure we insert a valid timestamp into the XML file, and avoid printing
an error message when reading a non-existent test summary scratch
file.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: copy_file_range swapfile test
Amir Goldstein [Sun, 2 Jun 2019 12:41:11 +0000 (15:41 +0300)]
generic: copy_file_range swapfile test

Check that we cannot copy_file_range() to/from a swapfile.

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: copy_file_range immutable file test
Amir Goldstein [Sun, 2 Jun 2019 12:41:10 +0000 (15:41 +0300)]
generic: copy_file_range immutable file test

Check that we cannot copy_file_range() to/from an immutable file.

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: create copy_range group
Amir Goldstein [Sun, 2 Jun 2019 12:41:09 +0000 (15:41 +0300)]
generic: create copy_range group

Move some tests to the copy_range group so they are distinct
from the copy group which refers to xfs_copy tests.

[Amir] Revert copy past EOF behavior change

Signed-off-by: Dave Chinner <dchinner@redhat.com>
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 agocheck: try to insulate the test framework from oom killer
Darrick J. Wong [Tue, 4 Jun 2019 21:16:49 +0000 (14:16 -0700)]
check: try to insulate the test framework from oom killer

Some of the tests in xfstests (e.g. generic/224 with 512M of memory)
consume a lot of memory, and when this happens the OOM killer will
run around stomping on processes.  Sometimes it kills the ./check
process before it kills the actual test, which means that the test
run doesn't complete.

Therefore, make the ./check process OOM-proof while bumping up the
attractiveness of the test itself, in the hopes that even if the
test OOMs we'll still be able to continue on our way.

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: remove obsolete xfs ioctl typedef usage
Darrick J. Wong [Tue, 4 Jun 2019 21:17:01 +0000 (14:17 -0700)]
fstests: remove obsolete xfs ioctl typedef usage

Convert 'xfs_foo_t' typedef usage to 'struct xfs_foo' in preparation
for changes to some of the xfs ioctls.

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/122: add new ioctl structures
Darrick J. Wong [Tue, 4 Jun 2019 21:16:55 +0000 (14:16 -0700)]
xfs/122: add new ioctl structures

Add some new ioctls that are being introduced in 5.2.

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: test for data loss on fsync after evicting an inode and renaming it
Filipe Manana [Thu, 6 Jun 2019 11:07:47 +0000 (12:07 +0100)]
generic: test for data loss on fsync after evicting an inode and renaming it

Check that if we write some data to a file, its inode gets evicted
(while its parent directory's inode is not evicted due to being in
use), then we rename the file and fsync it, after a power failure
the file data is not lost.

This currently passes on xfs, ext4 and f2fs but fails on btrfs. The
following patch for btrfs fixes it:

  "Btrfs: fix data loss after inode eviction, renaming it, and fsync it"

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/048: add validation of compression options
Johannes Thumshirn [Fri, 7 Jun 2019 09:09:37 +0000 (11:09 +0200)]
btrfs/048: add validation of compression options

The current btrfs/048 test-case did not check the behavior of
properties with options like compression and with the compression
level supplied.

Add test cases for compression with compression level as well so we
can be sure we don't regress there.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/163: make readahead run on the seed device
Naohiro Aota [Fri, 7 Jun 2019 05:39:10 +0000 (14:39 +0900)]
btrfs/163: make readahead run on the seed device

There is a long lived bug that btrfs wait for readahead to finish
indefinitely when readahead zone is inserted into seed devices.

Current write size to the file "foobar" is too small to run readahead
before the replacing on seed device. So, increase the write size to
reproduce the issue.

Following patch fixes it:

"btrfs: start readahead also in seed devices"

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: Test mount error cases with overlapping layers
Amir Goldstein [Tue, 28 May 2019 08:27:14 +0000 (11:27 +0300)]
overlay: Test mount error cases with overlapping layers

Add tests for overlayfs mounts with:
- Same upperdir/lowerdir
- Overlapping upperdir/lowerdir
- Overlapping lowerdir layers
- Overlapping lowerdir with other mount upperdir/workdir

Add test for moving layer into another after mount.

Overlapping layers on mount or lookup results in ELOOP.
Overlapping lowerdir with other mount upperdir/workdir
result in EBUSY.

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: fix exit code for some fsck.overlay valid cases
zhangyi (F) [Tue, 28 May 2019 15:17:23 +0000 (18:17 +0300)]
overlay: fix exit code for some fsck.overlay valid cases

Some valid test cases about fsck.overlay may be not valid enough now,
they lose the impure xattr on the parent directory of the simluated
redirect directory, and lose the whiteout which use to cover the origin
lower object. Then fsck.overlay will fix these two inconsistency which
are not those test cases want to cover, thus it will lead to
fsck.overlay return FSCK_NONDESTRUCT instead of FSCK_OK. Fix these by
complement the missing overlay related features.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agooverlay: correct fsck.overlay exit code
zhangyi (F) [Tue, 28 May 2019 15:17:22 +0000 (18:17 +0300)]
overlay: correct fsck.overlay exit code

fsck.overlay should return correct exit code to show the file system
status after fsck, instead of return 0 means consistency and !0 means
inconsistency or something bad happened.

Fix the following three exit code after running fsck.overlay:

- Return FSCK_OK if the input file system is consistent,
- Return FSCK_NONDESTRUCT if the file system inconsistent errors
  corrected,
- Return FSCK_UNCORRECTED if the file system still have inconsistent
  errors.

This patch also add a helper function to run fsck.overlay and check
the return value is expected or not.

[amir] rename helper to _overlay_fsck_expect, split define of FSCK_*
to a seprate path.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
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: fix _repair_scratch_fs
Amir Goldstein [Tue, 28 May 2019 15:17:21 +0000 (18:17 +0300)]
overlay: fix _repair_scratch_fs

_repair_scratch_fs did not do the right thing for overlay.
Implement and call _repair_overlay_scratch_fs to repair
overlay filesystem and then fall through to repair base filesystem.

The only tests currentrly calling _repair_scratch_fs on a
./check -overlay run are generic/330 generic/332 in case the
base fs supports reflink. The rest of the tests calling
_repair_scratch_fs require that $SCRATCH_DEV is a block device.

Suggested-by: zhangyi (F) <yi.zhang@huawei.com>
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: define constants for fsck exit codes
Amir Goldstein [Tue, 28 May 2019 15:17:20 +0000 (18:17 +0300)]
fstests: define constants for fsck exit codes

Define the constants for hard coded values used in _repair_scratch_fs()
to check fsck exit code.

Suggested-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/rc: fix _repair_scratch_fs error reporting
Amir Goldstein [Tue, 28 May 2019 12:08:47 +0000 (15:08 +0300)]
common/rc: fix _repair_scratch_fs error reporting

_dump_err2() helper was introduced over two years ago and it broke
the error reporting from _repair_scratch_fs.

Every test that runs:
_repair_scratch_fs >> $seqres.full

and expect to fail if anything is written to stderr is not working
as intended.

Reported-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: zhangyi (F) <yi.zhang@huawei.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoext4: regression test for online resizing maximum blocks
Yang Xu [Fri, 31 May 2019 02:12:27 +0000 (10:12 +0800)]
ext4: regression test for online resizing maximum blocks

This adds a regression test for online resizing maximum blocks
which can trigger a BUG_ON with non-zero s_first_data_block
filesystem.

The bug was fixed by patch:
f96c3ac8dfc2 ("ext4: fix crash during online resizing")

The bug was introduced by patch:
1c6bd7173d66 ("ext4: convert file system to meta_bg if needed during
resizing")

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs/278: use _scratch_xfs_repair helper instead of xfs_repair
Anthony Iliopoulos [Tue, 28 May 2019 16:27:44 +0000 (18:27 +0200)]
xfs/278: use _scratch_xfs_repair helper instead of xfs_repair

Use _scratch_xfs_repair helper instead of calling xfs_repair
directly, as local.config may want to define $XFS_REPAIR_PROG
and override the default binary in the search path.

Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs/190: Fix a typo for seqres.full
Qu Wenruo [Thu, 30 May 2019 01:28:15 +0000 (09:28 +0800)]
btrfs/190: Fix a typo for seqres.full

$seqref.full -> $seqres.full

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: aio random write and verify stress test
Zorro Lang [Mon, 13 May 2019 01:49:04 +0000 (09:49 +0800)]
generic: aio random write and verify stress test

We found some AIO write related bugs recently, so I think a AIO
random write test is needed. By the new aio-aio-write-verify.c tool,
we can do this easily.

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 agogeneric: verify ciphertext of v1 encryption policies with Adiantum
Eric Biggers [Fri, 24 May 2019 22:04:25 +0000 (15:04 -0700)]
generic: verify ciphertext of v1 encryption policies with Adiantum

Verify ciphertext for v1 encryption policies that use Adiantum to
encrypt file contents and file names.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: verify ciphertext of v1 encryption policies with AES-128
Eric Biggers [Fri, 24 May 2019 22:04:24 +0000 (15:04 -0700)]
generic: verify ciphertext of v1 encryption policies with AES-128

Verify ciphertext for v1 encryption policies that use AES-128-CBC-ESSIV
to encrypt file contents and AES-128-CTS-CBC to encrypt file names.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: verify ciphertext of v1 encryption policies with AES-256
Eric Biggers [Fri, 24 May 2019 22:04:23 +0000 (15:04 -0700)]
generic: verify ciphertext of v1 encryption policies with AES-256

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

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/encrypt: add helper for ciphertext verification tests
Eric Biggers [Fri, 24 May 2019 22:04:22 +0000 (15:04 -0700)]
common/encrypt: add helper for ciphertext verification tests

Introduce a function _verify_ciphertext_for_encryption_policy() which
verifies the correctness of encryption with the specified settings.

Basically, it does the following:

1. If missing any prerequisites, skip the test.

2. Create files in encrypted directories on the scratch device.

3. Unmount the scratch device and compare the actual ciphertext stored
   on-disk to the ciphertext computed by the fscrypt-crypt-util program.

Both file contents and names are verified, and non-default encryption
modes are supported.  Previously, non-default encryption modes were
untested by xfstests.  Also, while there's an existing test generic/399
that checks that encrypted contents seem random, it doesn't actually
test for correctness, nor does it test filenames encryption.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agocommon/encrypt: support requiring other encryption settings
Eric Biggers [Fri, 24 May 2019 22:04:21 +0000 (15:04 -0700)]
common/encrypt: support requiring other encryption settings

Update _require_scratch_encryption() to support checking for kernel
support for contents and filenames encryption modes besides the default.
This will be used by some of the ciphertext verification tests.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofscrypt-crypt-util: add utility for reproducing fscrypt encrypted data
Eric Biggers [Fri, 24 May 2019 22:04:20 +0000 (15:04 -0700)]
fscrypt-crypt-util: add utility for reproducing fscrypt encrypted data

Add a utility program that can reproduce encrypted contents and
filenames.  It implements all encryption algorithms currently supported
by fscrypt (a.k.a. ext4, f2fs, and ubifs encryption), and it generates
IVs in the same way.  The program takes the algorithm and master key on
the command line, and encrypts stdin to stdout.

A file nonce may also be passed on the command line, and the program
will "tweak" the encryption using this nonce in the same way the kernel
does -- either by deriving a subkey, or by including the nonce in the
IVs.  The block size and padding amount may also be specified.

No dependencies are added, as all algorithms implemented from scratch.

Signed-off-by: Eric Biggers <ebiggers@google.com>
2 years agocommon/encrypt: introduce helpers for set_encpolicy and get_encpolicy
Eric Biggers [Fri, 24 May 2019 22:04:19 +0000 (15:04 -0700)]
common/encrypt: introduce helpers for set_encpolicy and get_encpolicy

For conciseness in tests, add helper functions that wrap the xfs_io
commands 'set_encpolicy' and 'get_encpolicy'.  Then update all
encryption tests to use them.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agoxfs: basic testing of new xfs_spaceman health command
Darrick J. Wong [Mon, 20 May 2019 22:31:41 +0000 (15:31 -0700)]
xfs: basic testing of new xfs_spaceman health command

Basic tests to make sure xfs_spaceman health command works properly.

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: validate unicode filesystem labels
Darrick J. Wong [Mon, 20 May 2019 22:31:21 +0000 (15:31 -0700)]
xfs: validate unicode filesystem labels

Make sure we can set and retrieve unicode labels, including emoji.

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/{436,445}: define _cleanup function earlier in the tests
Luis Henriques [Fri, 17 May 2019 15:56:35 +0000 (16:56 +0100)]
generic/{436,445}: define _cleanup function earlier in the tests

If the filesystem doesn't support a feature that is required for the tests
to run, they will fail to execute the _cleanup function because it isn't yet
defined:

  ./common/rc: line 1: _cleanup: command not found

This error became more visible with commit 87a53d2e7c82 ("generic/{436,445}:
check falloc support").

Cc: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agofstests: use _scratch_shutdown instead of calling src/godown
Darrick J. Wong [Mon, 20 May 2019 22:31:10 +0000 (15:31 -0700)]
fstests: use _scratch_shutdown instead of calling src/godown

Overlayfs introduces some complexity with regards to what path we have
to use to shut down the scratch filesystem: it's SCRATCH_MNT for regular
filesystems, but it's OVL_BASE_SCRATCH_MNT (i.e. the lower mount of the
overlay) if overlayfs is enabled.  The helper works through all that, so
we might as well use it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/530, xfs/501: pass fs shutdown handle to t_open_tmpfiles
Darrick J. Wong [Mon, 20 May 2019 22:31:04 +0000 (15:31 -0700)]
generic/530, xfs/501: pass fs shutdown handle to t_open_tmpfiles

So it turns out that overlayfs can't pass FS_IOC_SHUTDOWN to the lower
filesystems and so xfstests works around this by creating shutdown
helpers for the scratch fs to direct the shutdown ioctl to wherever it
needs to go to shut down the filesystem -- SCRATCH_MNT on normal
filesystems and OVL_BASE_SCRATCH_MNT when -overlay is enabled.  This
means that t_open_tmpfiles cannot simply use one of the open tempfiles
to shut down the filesystem.

Commit f8f57747222 tried to "fix" this by ripping the shutdown code out,
but this made the tests useless.  Fix this instead by creating a
xfstests helper to return a path that can be used to shut down the
filesystem and then pass that path to t_open_tmpfiles so that we can
shut down the filesystem when overlayfs is enabled.

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/530: revert commit f8f57747222
Darrick J. Wong [Mon, 20 May 2019 22:30:57 +0000 (15:30 -0700)]
generic/530: revert commit f8f57747222

Commit f8f57747222 ("generic/530: fix shutdown failure of generic/530 in
overlay") improperly clears an overlayfs test failure by shutting down
the filesystem after all the tempfiles are closed, which totally defeats
the purpose of both generic/530 and xfs/501.  Revert this commit so we
can fix it properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agobtrfs: resume balance on mount with qgroup
Qu Wenruo [Thu, 23 May 2019 01:11:01 +0000 (09:11 +0800)]
btrfs: resume balance on mount with qgroup

There are two regressions related to balance resume:
- Kernel NULL pointer dereference at mount time
  Introduced in v5.0
- Kernel BUG_ON() just after mount
  Introduced in v5.1

The kernel fixes are:
"btrfs: qgroup: Check if @bg is NULL to avoid NULL pointer
 dereference"
"btrfs: reloc: Also queue orphan reloc tree for cleanup to
 avoid BUG_ON()"

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 agobtrfs: send after cloning and truncating source file
Filipe Manana [Mon, 20 May 2019 08:59:15 +0000 (09:59 +0100)]
btrfs: send after cloning and truncating source file

Test that an incremental send receive does not issue clone operations
that attempt to clone the last block of a file, with a size not aligned to
the filesystem's sector size, into the middle of some other file. Such
clone request causes the receiver to fail (with EINVAL), for kernels that
include commit ac765f83f1397646 ("Btrfs: fix data corruption due to
cloning of eof block"), or cause silent data corruption for older kernels.

This test is motived by a recent regression introduced in kernel 5.2-rc1,
commit 040ee6120cb6706 ("Btrfs: send, improve clone range"), and the
following patch fixes it:

  "Btrfs: incremental send, fix emission of invalid clone perations"

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: send with no-holes enabled, fallocate and hole punching
Filipe Manana [Mon, 20 May 2019 08:55:47 +0000 (09:55 +0100)]
btrfs: send with no-holes enabled, fallocate and hole punching

Test that an incremental send with not corrupt data when the source
filesystem has the no-holes feature enabled, a file has prealloc
(unwritten) extents that start after its size and hole is punched (after
the first snapshot is made) that removes all extents from some offset up
to the file's size.

This currently fails on any kernel version starting from 3.16, and it's
by a patch titled:

 "Btrfs: incremental send, fix file corruption when no-holes feature is enabled"

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 agooverlay/023: use numeric user and group IDs in getfacl
Luis Henriques [Fri, 17 May 2019 11:24:22 +0000 (12:24 +0100)]
overlay/023: use numeric user and group IDs in getfacl

This prevents test failures if cases where, e.g., /etc/group doesn't
include the 'root' group ID.

Cc: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Murphy Zhou <xzhou@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/319: use numeric user and group IDs in getfacl
Luis Henriques [Fri, 17 May 2019 11:24:21 +0000 (12:24 +0100)]
generic/319: use numeric user and group IDs in getfacl

This prevents test failures if cases where, e.g., /etc/group doesn't
include the 'root' group ID.

Cc: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agosrc/attr_replace_test: limit size of extended attribute value
Luis Henriques [Tue, 21 May 2019 08:28:36 +0000 (09:28 +0100)]
src/attr_replace_test: limit size of extended attribute value

The maximum size for extended attribute values is 65536 (XATTR_SIZE_MAX).
Since there are filesystems that can set blksize to really big values
(CephFS for example has a default of 4M), it's easy to have this test
failing with fsetxattr returning -E2BIG.

Cc: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Luis Henriques <lhenriques@suse.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/54{0..3}: redirect FILEFRAG error output to .full too
Murphy Zhou [Mon, 20 May 2019 06:28:18 +0000 (14:28 +0800)]
generic/54{0..3}: redirect FILEFRAG error output to .full too

NFSv4.2 supports reflink but does not support FIBMAP nor FIEMAP.
These 4 tests about file content can pass on NFSv4.2, but filefrag
complaints :

+/mnt/testarea/scratch/test-542/file2: FIBMAP unsupported

which is breaking golden output.

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric: fsync fuzz tester with fsstress
Filipe Manana [Fri, 17 May 2019 15:34:31 +0000 (16:34 +0100)]
generic: fsync fuzz tester with fsstress

Run fsstress, fsync every file and directory, simulate a power failure and
then verify that all files and directories exist, with the same data and
metadata they had before the power failure.

This test has found already 2 bugs in btrfs, that caused mtime and ctime of
directories not being preserved after replaying the log/journal and loss
of a directory's attributes (such a UID and GID) after replaying the log.
The patches that fix the btrfs issues are titled:

  "Btrfs: fix wrong ctime and mtime of a directory after log replay"
  "Btrfs: fix fsync not persisting changed attributes of a directory"

Running this test 1000 times:

- on xfs, no issues were found

- on ext4 it has resulted in about a dozen journal checksum errors (on a
  5.0 kernel) that resulted in failure to mount the filesystem after the
  simulated power failure with dmflakey, which produces the following
  error in dmesg/syslog:

    [Mon May 13 12:51:37 2019] JBD2: journal checksum error
    [Mon May 13 12:51:37 2019] EXT4-fs (dm-0): error loading journal

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 agocommon/rc: improve _fstyp_has_non_default_seek_data_hole()
Jeffle Xu [Mon, 13 May 2019 09:14:41 +0000 (17:14 +0800)]
common/rc: improve _fstyp_has_non_default_seek_data_hole()

commit 34081087 adds more sanity to seek_sanity_test() to prevent
a lseek() implementation regression from being ignored, and a
hardcoded whitelist is maintained to distinguish whether a
filesystem type only supports non-default behavior of SEEK_HOLE
or not.

In commit 34081087, NFS is listed in this whitelist, that is, NFS
is thought supporting non-default behavior only. However as far as
I know, nfsv2 and nfsv3 only support default behavior of SEEK_HOLE
(that is, always returning EOF) in linux.

On the other hand, xfstests uses "mount -t nfs ..." to mount a
NFS mount point. Normally the mount point is mounted as nfsv4,
but it can be mounted mandatorily as nfsv3 if we specify
"Nfsvers=3" in /etc/nfsmount.conf. In this case, a series of
tests fail (including generic/285, generic/448, generic/490, etc.)
with error message "Default behavior is not allowed. Aborting."

So I just make some special handling for NFS in
_fstyp_has_non_default_seek_data_hole(), that is, default behavior
of SEEK_HOLE is acceptable for nfsv2 and nfsv3.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2 years agogeneric/530: fix shutdown failure of generic/530 in overlay
Jeffle Xu [Mon, 13 May 2019 06:11:05 +0000 (14:11 +0800)]
generic/530: fix shutdown failure of generic/530 in overlay

Testcases are recommended to use  _require_scratch_shutdown()
and _scratch_shutdown() pair helper function to test and execute
shutdown.

generic/530 formmerly used _require_scratch_shutdown() to test
whether the filesystem supports shutdown or not, while executed
the shutdown action in a raw binary (src/t_open_tmpfiles) rather
than the recommended _scratch_shutdown() helper. This will cause
a "shutdown: Inappropriate ioctl for device" error message when
testing overlay filesystem.

This patch simply move the shutdown action from the raw binary
into the packaged _scratch_shutdown() helper. That is, we remove
the "shutdown" interface of t_open_tmpfiles.c and call
_scratch_shutdown() in genric/530 and xfs/501.

Signed-off-by: Jeffle Xu <jefflexu@linux.alibaba.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>