xfstests-dev.git
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 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>
4 years agoxfs/294: calculate space to reserve for fragmentation test
Darrick J. Wong [Tue, 7 May 2019 16:57:09 +0000 (09:57 -0700)]
xfs/294: calculate space to reserve for fragmentation test

This test requires us to fragment free space, and in part accomplishes
this by fallocating 400M of a 512M filesystem, then fallocating another
70M, and then using dd to eat remaining space.  However, it's risky to
assume the 400M figure because new features such as reflink and rmap
have per-ag metadata reservations which add to overhead.  Therefore,
reserve the 70M fragment file first, then try to fallocate 95% of the
remaining free space.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/216: always disable rmap and reflink when creating log size test fs
Darrick J. Wong [Tue, 7 May 2019 16:57:03 +0000 (09:57 -0700)]
xfs/216: always disable rmap and reflink when creating log size test fs

This test seems to check that log sizes scale up properly with the size
of the filesystem, given a carefully controlled set of mkfs parameters.
Since turning on reflink or rmap will change the minimum log size,
change the test to detect their presence and ensure they're disabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: refactor minimum log size formatting code
Darrick J. Wong [Tue, 7 May 2019 16:56:56 +0000 (09:56 -0700)]
xfs: refactor minimum log size formatting code

Create a new helper function to discover the minimum log size that will
work with the mkfs options provided, then remove all the hardcoded block
sizes from various xfs tests.  This will be necessary when we turn on
reflink or rmap by default and the minimum log size increases.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Tested-by: Yang Xu<xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: do operations which doesn't take data space on full fs
Qu Wenruo [Wed, 8 May 2019 14:04:05 +0000 (22:04 +0800)]
generic: do operations which doesn't take data space on full fs

This test will test if we can still do the following operations when a
full is full:
- buffered write into unpopulated preallocated extent
- clone the untouched preallocated extent
- fsync
- no data loss if power loss happens after above fsync
Above operations should not fail, as they takes no extra data space.

Xfs passes the test, while btrfs fails at fsync and has data loss.
The fix for btrfs is:
"btrfs: Flush before reflinking any extent to prevent NOCOW write falling
 back to CoW without data reservation"

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: check CAP_LINUX_IMMUTABLE capability
Jiufei Xue [Wed, 8 May 2019 07:10:00 +0000 (15:10 +0800)]
generic: check CAP_LINUX_IMMUTABLE capability

It should return error while changing IMMUTABLE_FL and APPEND_FL if the
process has no capability CAP_LINUX_IMMUTABLE.

However, it's not true on overlayfs after kernel version v4.19 since
the process's subjective cred is overridden with ofs->creator_cred
before calling real vfs_ioctl.

The following patch for ovl fix the problem:
  "ovl: check the capability before cred overridden"

Add this testcase to cover this bug.

Signed-off-by: Jiufei Xue <jiufei.xue@linux.alibaba.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoext4/018: Match the value of File ACL accurately
Xiao Yang [Tue, 7 May 2019 09:19:51 +0000 (17:19 +0800)]
ext4/018: Match the value of File ACL accurately

Since e2fsprogs v1.44.0, debugfs with stat command shows the output:
---------------------------------------------------------------------
debugfs -R 'stat /attrfile' /dev/sda11 2> /dev/null | grep 'File ACL:'
File ACL: 9258
---------------------------------------------------------------------

Before e2fsprogs v1.44.0, debugfs with stat command shows the output:
----------------------------------------------------------------------
debugfs -R 'stat /attrfile' /dev/sda11 2> /dev/null | grep 'File ACL:'
File ACL: 9258    Directory ACL: 0
----------------------------------------------------------------------

"Directory ACL: XXXX" was removed by commit 578fcbf so running ext4/018
with older e2fsprogs(i.e. before v1.44.0) got the following error:
--------------------------------------------------------------------------
+./tests/ext4/018: line 59: 9258    Directory ACL: 0: syntax error in expression (error token is "Directory ACL: 0")
--------------------------------------------------------------------------

we match the value of File ACL accurately to fix it.

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>
4 years agogeneric/532: do not break golden silence if attributes_mask is 0
Murphy Zhou [Wed, 8 May 2019 03:11:44 +0000 (11:11 +0800)]
generic/532: do not break golden silence if attributes_mask is 0

If the filesystem does not support STATX_ATTR, like NFS, setting
both attributes and attributes_mask to 0 seems the right thing to
do. attributes_mask can be 0 only if attributes is also 0.
This situation is covered by the "&" check in the next line.

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/487: reorder logdev detection after filesystem detection
David Sterba [Thu, 25 Apr 2019 17:31:30 +0000 (19:31 +0200)]
generic/487: reorder logdev detection after filesystem detection

If SCRATCH_LOGDEV variable is unset, the _require_logdev check fails
earlier than the following check that decides that this test should not
be run on 'btrfs'.

Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agomisc: xfs_fsop_geom_t -> struct xfs_fsop_geom
Darrick J. Wong [Mon, 22 Apr 2019 15:48:20 +0000 (08:48 -0700)]
misc: xfs_fsop_geom_t -> struct xfs_fsop_geom

Remove the typedef usage for the xfs geometry structure, which will
be removed in future patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: fix filtering of scratch device in test case 048
Filipe Manana [Thu, 25 Apr 2019 00:37:09 +0000 (01:37 +0100)]
btrfs: fix filtering of scratch device in test case 048

The recent commit 4529b20e1aa8f9 ("btrfs/048: amend property validation
cases"), does not properly filter the scratch device because the error
messages are sent to stderr and not to stdout, and the pipe filter only
gets input from the stdout of the btrfs utility. We need to redirect the
stderr of the btrfs utility to its stdout.

Further, the golden output had the path "/mnt/scratch" hardcoded, instead
of using SCRATCH_MNT. Fix that as well.

The test was failing on any setup where the scratch device is not mounted
at "/mnt/scratch".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: stress send with deduplication and balance running in parallel
Filipe Manana [Mon, 22 Apr 2019 15:44:16 +0000 (16:44 +0100)]
btrfs: stress send with deduplication and balance running in parallel

Stress send running in parallel with balance and deduplication against
files that belong to the snapshots used by send. The goal is to verify
that these operations running in parallel do not lead to send crashing
(trigger assertion failures and BUG_ONs), or send finding an inconsistent
snapshot that leads to a failure (reported in dmesg/syslog). The test
needs big trees (snapshots) with large differences between the parent and
send snapshots in order to hit such issues with a good probability.

This currently fails on btrfs, hitting a BUG_ON() often, and with btrfs
error messages in dmesg/syslog. The problem has always existed and it is
not new, but probably unnoticed due to lack of test cases that exercise
these btrfs features running in parallel.

The following patches for btrfs fix the problems:

 "Btrfs: fix race between send and deduplication that lead to failures and
  crashes"

 "Btrfs: prevent send failures and crashes due to concurrent relocation"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: filter lockdep bugs when scanning dmesg
Darrick J. Wong [Wed, 17 Apr 2019 01:19:26 +0000 (18:19 -0700)]
check: filter lockdep bugs when scanning dmesg

Ignore lockdep complaining about its own bugginess when scanning dmesg
output, because we shouldn't be failing filesystem tests on account of
lockdep.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: wipe scratch devices between tests
Darrick J. Wong [Tue, 16 Apr 2019 22:36:28 +0000 (15:36 -0700)]
check: wipe scratch devices between tests

Wipe the scratch devices in between each test to ensure that tests are
formatting them and not making assumptions about previous contents.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: remove require_{test,scratch}* after a test fails
Darrick J. Wong [Tue, 16 Apr 2019 22:34:59 +0000 (15:34 -0700)]
check: remove require_{test,scratch}* after a test fails

Remove the require_{test,scratch]* sentinel files after a test fails.
This eliminates false fsck corruption reports such as the following:

1. Test A calls _require_scratch, which creates the sentinel file
$RESULT_DIR/require_scratch to facilitate fsck after the test completes.

2. Test A runs some test, which corrupts the scratch filesystem due to
kernel bug or something.

3. Test A calls _fail because of the errors in (2).  Note that the test
case returned 1, so ./check unmounts the test and scratch filesystems
without checking them or removing $RESULT_DIR/require_scratch

4. Test B starts up, but does not call _require_scratch.  The
$RESULT_DIR/require_scratch file is still there.

5. Test B completes successfully.

6. ./check calls _check_filesystems, which sees the
$RESULT_DIR/require_scratch file and runs fsck.

7. fsck reports the corrupt scratch device (which is associated with
test B) even though B did not ever touch the scratch device and it was
actually test A that corrupted the filesystem.

Note that with the "check: wipe scratch devices between tests" patch
applied, we can also reproduce this problem by running xfs/172 and
xfs/195 with a scratch device small enough that the files created in 172
span multiple AGs and therefore cause 172 to 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>
4 years agobtrfs: test send on subvolume with delalloc after setting it to RO mode
Filipe Manana [Mon, 15 Apr 2019 08:30:35 +0000 (09:30 +0100)]
btrfs: test send on subvolume with delalloc after setting it to RO mode

Test that if we have a subvolume/snapshot that is writable, has a file
with unflushed delalloc (buffered writes not yet flushed), turn the
subvolume to readonly mode and then use it for send a operation, the send
stream will contain the delalloc data - that is, no data loss happens.

This currently files on btrfs (data loss) but is fixed by a patch for
the linux kernel titled:

  "Btrfs: send, flush dellaloc in order to avoid data loss"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofssum: add support for checking xattrs
Filipe Manana [Thu, 4 Apr 2019 16:31:09 +0000 (17:31 +0100)]
fssum: add support for checking xattrs

Currently fssum, mostly used for btrfs test cases that test the btrfs send
feature, ignores completely the existence of xattrs. This change teaches
fssum to find xattrs and make them contribute to the checksum of a
filesystem, so that we can catch filesystem bugs regarding missing, corrupt
or not supposed to exist xattrs (i.e. that an incremental btrfs send does
not forget to create, update or remove xattrs).

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: add operation for listing xattrs from files and directories
Filipe Manana [Fri, 19 Apr 2019 10:55:00 +0000 (11:55 +0100)]
fsstress: add operation for listing xattrs from files and directories

The previous patches added support for operations to set, get and delete
xattrs on regular files and directories, this patch just adds an operation
to list the xattrs of a file/directory.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: add operation for deleting xattrs from files and directories
Filipe Manana [Fri, 19 Apr 2019 10:54:48 +0000 (11:54 +0100)]
fsstress: add operation for deleting xattrs from files and directories

The previous patches added support for operations to set and get xattrs on
regular files and directories, this patch just adds one operation to delete
xattrs on files and directories.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: add operation for reading xattrs from files and directories
Filipe Manana [Fri, 19 Apr 2019 10:54:22 +0000 (11:54 +0100)]
fsstress: add operation for reading xattrs from files and directories

The previous patch added support for an operation to set xattrs on regular
files and directories, this patch just adds one operation to read (get)
them.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: add operation for setting xattrs on files and directories
Filipe Manana [Fri, 19 Apr 2019 10:54:08 +0000 (11:54 +0100)]
fsstress: add operation for setting xattrs on files and directories

Currently fsstress does not exercise creating, reading or deleting xattrs
on files or directories. This change adds support for setting xattrs on
files and directories, using only the xattr user namespace (the other
namespaces are not general purpose and are used for security, capabilities,
ACLs, etc). This adds a counter for each file entry structure that keeps
track of the number of xattrs set for the file entry, and each new xattr
has a name that includes the counter's value (example: "user.x4").
Values for the xattrs have at most 100 bytes, which is more than the
maximum size supported for all major filesystems.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: allow afsync on directories too
Filipe Manana [Thu, 4 Apr 2019 16:30:06 +0000 (17:30 +0100)]
fsstress: allow afsync on directories too

Currently the afsync function can only be performed against regular files.
Allow it to operate on directories too, to increase test coverage and
allow for chances of finding bugs in a filesystem's implementation of
fsync against directories.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agofsstress: allow fsync on directories too
Filipe Manana [Thu, 4 Apr 2019 16:29:52 +0000 (17:29 +0100)]
fsstress: allow fsync on directories too

Currently the fsync function can only be performed against regular files.
Allow it to operate on directories too, to increase test coverage and
allow for chances of finding bugs in a filesystem's implementation of
fsync against directories.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoclonerange: test remapping the rainbow
Darrick J. Wong [Mon, 8 Apr 2019 21:56:28 +0000 (14:56 -0700)]
clonerange: test remapping the rainbow

Add some more clone range tests that missed various "wacky" combinations
of file state.  Specifically, we test reflinking into and out of rainbow
ranges (a mix of real, unwritten, hole, delalloc, and shared extents),
and also we test that we can correctly handle double-inode locking no
matter what order of inodes or the filesystem's locking rules.

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>
5 years agogeneric/504: fix hard coded fd number
Murphy Zhou [Mon, 8 Apr 2019 02:38:59 +0000 (10:38 +0800)]
generic/504: fix hard coded fd number

Bash supports file discriptor assignment in this way. So remove the hard
coded numbers. Also close this opened fd in cleanup.

Signed-off-by: Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/048: amend property validation cases
Anand Jain [Wed, 3 Apr 2019 17:04:37 +0000 (01:04 +0800)]
btrfs/048: amend property validation cases

Add more property validation cases which are fixed by the patches [1]
 [1]
  btrfs: fix vanished compression property after failed set
  btrfs: fix zstd compression parameter

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofsx: test copy_file_range() using non-zero length copy
Brian Foster [Wed, 10 Apr 2019 11:13:59 +0000 (07:13 -0400)]
fsx: test copy_file_range() using non-zero length copy

The copy_file_range() test detection code performs a zero-length
copy to determine whether to perform such calls during the test run.
While this detects the common case of syscall availability,
copy_file_range() has a somewhat variable implementation on the
kernel side that can depend on certain per-filesystem features, etc.
In some implementations, a zero length copy can shortcut and return
success before ever invoking per-filesystem functionality and thus
not thoroughly testing the copy mechanism on the current system.
This can cause the test detection code to pass only to run into an
immediate failure on the first copy_file_range() call during the
test.

Tweak test_copy_range() to perform a small single byte copy to avoid
this problem. Also fix a typo bug in the errno check of the clone
range detection logic.

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>
5 years agogeneric/230: reset grace time before overcome hardlimit
zhangyi (F) [Tue, 9 Apr 2019 11:04:34 +0000 (19:04 +0800)]
generic/230: reset grace time before overcome hardlimit

Currently, we call repquota to report the latest quota information
after each test case. But repquota will invoke Q_SYNC on the ext4 file
system with old quota, which may be time consuming on the low speed or
busy scratch device. If we call repquota between the "overcome
softlimit" and the "overcome hardlimit" cases, the softlimit grace time
may be exceed after repquota return, and lead to test failure.

Now, we capture the following failure when the disk is busy:

   pwrite: Disk quota exceeded
   Touch 3+4
   Touch 5+6
  +touch: cannot touch 'SCRATCH_MNT/file5': Disk quota exceeded
   touch: cannot touch 'SCRATCH_MNT/file6': Disk quota exceeded
   Touch 5
   touch: cannot touch 'SCRATCH_MNT/file5': Disk quota exceeded

This patch reset grace time before the "overcome hardlimit" case to
avoid this failure.

Signed-off-by: zhangyi (F) <yi.zhang@huawei.com>
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>