xfstests-dev.git
5 months agogeneric/003: Amend the test for exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:05 +0000 (11:49 +0200)]
generic/003: Amend the test for exfat

Update the test so it can be run even for exfat which has 2 seconds
granularity for access_time and does not have a timestamp for
metadata change.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/554: hide permision warning on exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:04 +0000 (11:49 +0200)]
generic/554: hide permision warning on exfat

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon: hide permision warning from mkswap for exfat
Pavel Reichl [Thu, 15 Apr 2021 09:49:03 +0000 (11:49 +0200)]
common: hide permision warning from mkswap for exfat

exfat does not support posix file permisions, so warning from mkswap is
inavitable. This patch hides the warning message so the test won't fail.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/305: make sure that fsstress is still running when we quotaoff
Darrick J. Wong [Wed, 14 Apr 2021 01:05:26 +0000 (18:05 -0700)]
xfs/305: make sure that fsstress is still running when we quotaoff

Greatly increase the number of fs ops that fsstress is supposed to run
in in this test so that we can ensure that it's still running when the
quotaoff gets run.  1000 might have been sufficient in 2013, but it
isn't now.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/{094,225}: skip test when the xfs rt extent size is larger than 1 fsb
Darrick J. Wong [Wed, 14 Apr 2021 01:05:20 +0000 (18:05 -0700)]
generic/{094,225}: skip test when the xfs rt extent size is larger than 1 fsb

These two tests call various fallocate modes on a file and compare the
FIEMAP output to some golden output.  Unfortunately, the golden output
doesn't take into account the possibility that (on XFS) the files could be
created on a realtime volume with a large rt extent size set.

Under such a configuration, fpunch operations that are aligned to the fs
block size but not the rt extent size simply result in those blocks
being set to unwritten status.  Unfortunately, the test expects holes
and fails.  Therefore, detect the situation and skip the tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/620: fix order of require_scratch calls
Darrick J. Wong [Wed, 14 Apr 2021 01:05:14 +0000 (18:05 -0700)]
generic/620: fix order of require_scratch calls

_require_scratch_16T_support does not itself check that the scratch
device exists, which means that it depends on someone else to call
_require_scratch.  Document this dependency and fix this test so that we
can run:

./check --exact-order generic/374 generic/620

on an ext4 filesystem without g/620 tripping over the mess left by g/374
when it calls _notrun.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agomisc: replace more open-coded _scratch_xfs_db calls
Darrick J. Wong [Wed, 14 Apr 2021 01:05:07 +0000 (18:05 -0700)]
misc: replace more open-coded _scratch_xfs_db calls

Replace the last remaining open-coded calls to xfs_db for the scratch
device with calls to _scratch_xfs_db.  This fixes these tests when
external logs are enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/dump: filter out xfs_restore messages about fallocate failures
Darrick J. Wong [Wed, 14 Apr 2021 01:04:54 +0000 (18:04 -0700)]
common/dump: filter out xfs_restore messages about fallocate failures

fallocate is not supported on XFS filesystems that are running in
"always COW" mode.  This leads to false test regressions because
xfs_restore complains about EOPNOTSUPP in the golden output.  The
preallocation isn't required for correct xfs_restore operation, so
filter out the EOPNOTSUPP messages.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/521,530: refactor scratch fs check
Darrick J. Wong [Wed, 14 Apr 2021 01:04:48 +0000 (18:04 -0700)]
xfs/521,530: refactor scratch fs check

Use the existing _check_scratch_fs helper to check the (modified)
scratch filesystem in these tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/563: selectively remove the io cgroup controller
Darrick J. Wong [Wed, 14 Apr 2021 01:04:42 +0000 (18:04 -0700)]
generic/563: selectively remove the io cgroup controller

If a system configuration tool such as systemd sets up the io cgroup
controller for its own purposes, it's possible that the last line of
this test will not be able to remove the io controller from the system
configuration.  This causes the test to fail even though the inability
to tear down systemd should not be considered (in this case) a failure.

Change this test to set the "io" component of subtree control back to
whatever it was when the test started.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/506: fix regression on freshly quotachecked filesystem
Darrick J. Wong [Wed, 14 Apr 2021 01:04:36 +0000 (18:04 -0700)]
xfs/506: fix regression on freshly quotachecked filesystem

The first thing this test checks is that the health command reports that
nothing has been checked.  This isn't true if we regenerated the quota
counts when we mounted the filesystem (and hence they're marked healthy
and checked), so cycle the mount to get rid of that state.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: quotas on idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:08 +0000 (13:57 +0200)]
xfs: quotas on idmapped mounts

This is basically a re-implementation of xfs/050 but each file creation
call is done through an idmapped mount which verifies that the semantics
are identical even when the mount is idmapped.

Cc: Eryu Guan <guan@eryu.me>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: quotas and idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:07 +0000 (13:57 +0200)]
xfs: quotas and idmapped mounts

Test that xfs quota behave correctly on idmapped mounts.
Mount a scratch device with user and group quota support enabled. Create
directories "unmapped" and "idmapped". Create files in the unampped
mount and verify quota behavior. Create files through the idmapped mount
and verify identical behavior.

Cc: Eryu Guan <guan@eryu.me>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/quota: move _qsetup() helper to common code
Christian Brauner [Mon, 12 Apr 2021 11:57:06 +0000 (13:57 +0200)]
common/quota: move _qsetup() helper to common code

It's already used in two tests and will be used in a third.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: fstests@vger.kernel.org
Suggested-by: Eryu Guan <guan@eryu.me>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/rc: add _scratch_{u}mount_idmapped() helpers
Christian Brauner [Mon, 12 Apr 2021 11:57:05 +0000 (13:57 +0200)]
common/rc: add _scratch_{u}mount_idmapped() helpers

They will be used in follow-up patches for xfs quota tests but might be
useful for other tests in the future.

Cc: Eryu Guan <guan@eryu.me>
Cc: Christoph Hellwig <hch@lst.de>
Cc: David Howells <dhowells@redhat.com>
Cc: fstests@vger.kernel.org
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric: add fstests for idmapped mounts
Christian Brauner [Mon, 12 Apr 2021 11:57:04 +0000 (13:57 +0200)]
generic: add fstests for idmapped mounts

Add a test suite to verify the behavior of idmapped mounts. The test
suite also includes a range of vfs tests to verify that no regressions
are introduced by idmapped mounts. The following tests are currently
available with more to come in the future:

01. posix acls on regular and idmapped mounts
02. create operations in user namespace
03. device node creation in user namespace
04. expected ownership on idmapped mounts
05. fscaps on regular mounts
06. fscaps on idmapped mounts
07. fscaps on idmapped mounts in user namespace
08. fscaps on idmapped mounts in user namespace
    with different id mappings
09. mapped fsids
10. unmapped fsids
11. cross mount hardlink
12. cross idmapped mount hardlink
13. hardlinks from idmapped mounts
14. hardlinks from idmapped mounts in user namespace
15. io_uring
16. io_uring in user namespace
17. io_uring from idmapped mounts
18. io_uring from idmapped mounts in user namespace
19. io_uring from idmapped mounts with unmapped ids
20. io_uring from idmapped mounts with unmapped ids in user namespace
21. following protected symlinks on regular mounts
22. following protected symlinks on idmapped mounts
23. following protected symlinks on idmapped mounts in user namespace
24. cross mount rename
25. cross idmapped mount rename
26. rename from idmapped mounts
27. rename from idmapped mounts in user namespace
28. symlink from regular mounts
29. symlink from idmapped mounts
30. symlink from idmapped mounts in user namespace
31. setid binaries on regular mounts
32. setid binaries on idmapped mounts
33. setid binaries on idmapped mounts in user namespace
34. setid binaries on idmapped mounts in user namespace
    with different id mappings
35. sticky bit unlink operations on regular mounts
36. sticky bit unlink operations on idmapped mounts
37. sticky bit unlink operations on idmapped mounts in user namespace
38. sticky bit rename operations on regular mounts
39. sticky bit rename operations on idmapped mounts
40. sticky bit rename operations on idmapped mounts in user namespace
41. create operations in directories with setgid bit set
42. create operations in directories with setgid bit set
    on idmapped mounts
43. create operations in directories with setgid bit set
    on idmapped mounts in user namespace
44. verify create operations and ownership with racing threads idmapping
    a mount
45. setattr truncate operations on regular mounts
46. setattr truncate operations on idmapped mounts
47. setattr truncate operations on idmapped mounts in user namespace

Here's some sample output when running with DEBUG_TRACE defined:

Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Eryu Guan <guan@eryu.me>
Cc: fstests@vger.kernel.org
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric: add test for detached mount propagation
Christian Brauner [Mon, 12 Apr 2021 11:57:03 +0000 (13:57 +0200)]
generic: add test for detached mount propagation

Regression test to verify that creating a series of detached mounts,
attaching them to the filesystem, and unmounting them does not trigger an
integer overflow in ns->mounts causing the kernel to block any new mounts in
count_mounts() and returning ENOSPC because it falsely assumes that the
maximum number of mounts in the mount namespace has been reached, i.e. it
thinks it can't fit the new mounts into the mount namespace anymore.

The test is written in a way that it will leave the host's mount
namespace intact so we are sure to never make the host's mount namespace
unuseable!

Link: https://git.kernel.org/torvalds/c/ee2e3f50629f17b0752b55b2566c15ce8dafb557
Cc: Eryu Guan <guan@eryu.me>
Cc: David Howells <dhowells@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/591: add _require_odirect
Sun Ke [Mon, 12 Apr 2021 07:34:03 +0000 (03:34 -0400)]
generic/591: add _require_odirect

src/splice-test will open a file with O_DIRECT flag, so add
_require_odirect.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/xfs: work around a hang-on-stdin bug in xfs_admin 5.11
Darrick J. Wong [Wed, 31 Mar 2021 01:08:15 +0000 (18:08 -0700)]
common/xfs: work around a hang-on-stdin bug in xfs_admin 5.11

xfs_admin in xfsprogs 5.11 has a bug wherein a caller who specifies an
external log device forces xfs_db to be invoked, potentially with zero
command arguments.  When this happens, xfs_db will wait for input on
stdin, which causes fstests to hang.  Since xfs_admin is not an
interactive tool, redirect stdin from /dev/null to prevent this issue.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/xfs: support realtime devices with _scratch_xfs_admin
Darrick J. Wong [Wed, 31 Mar 2021 01:08:10 +0000 (18:08 -0700)]
common/xfs: support realtime devices with _scratch_xfs_admin

Teach _scratch_xfs_admin to support passing the realtime device to
xfs_admin so that we can actually test xfs_admin functionality with
those setups.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/23[12]: abstractify the XFS cow prealloc trimming interval
Darrick J. Wong [Wed, 31 Mar 2021 01:09:05 +0000 (18:09 -0700)]
xfs/23[12]: abstractify the XFS cow prealloc trimming interval

Create a couple of helper functions to get and set the XFS copy on write
preallocation garbage collection interval.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/502: scale file count based on AG count to avoid thrashing
Brian Foster [Fri, 9 Apr 2021 19:08:34 +0000 (15:08 -0400)]
xfs/502: scale file count based on AG count to avoid thrashing

xfs/502 currently creates a default of 30k unlinked files per CPU.
While this completes in a reasonable amount of time on systems with
lesser numbers of CPUs, this scales poorly on high CPU count systems
that are otherwise testing smaller default filesystems. For example,
on an 80xcpu box and a 15GB (4 AG) XFS filesystem, xfs/502 requires
3 hours to complete. The same test on a 4xcpu vm (or the 80xcpu
hardware with an 80AG filesystem instead of the default of 4AGs)
completes in a little over 5 minutes. This is a rather severe
thrashing breakdown that doesn't add much value to the test
coverage.

Address this problem by scaling the file count to the AG count of
the filesystem rather than the CPU count of the test system. Since
the AG count is likely to be less than the CPU count, bump the
default scaling factor a bit from 30k per CPU to 50k per AG. From
there, larger counts can still be exercised via the global load
factor configuration.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/53[238]: Disable realtime inherit flag
Chandan Babu R [Fri, 9 Apr 2021 12:49:03 +0000 (18:19 +0530)]
xfs/53[238]: Disable realtime inherit flag

The minimum length space allocator (i.e.
xfs_bmap_exact_minlen_extent_alloc()) depends on the underlying
filesystem to be fragmented so that there are enough one block sized
extents available to satify space allocation requests.

xfs/{532,533,538} tests issue space allocation requests for metadata
(e.g. for blocks holding directory and xattr information). With
realtime filesystem instances, these tests would end up fragmenting
the space on realtime device. Hence minimum length space allocator
fails since the regular filesystem space is not fragmented and hence
there are no one block sized extents available.

Thus, this commit disables realtime inherit flag (if any) on root
directory so that space on data device gets fragmented rather than
realtime device.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reported-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agofstests: Fix tests to execute in multi-block directory config
Chandan Babu R [Fri, 2 Apr 2021 02:49:40 +0000 (08:19 +0530)]
fstests: Fix tests to execute in multi-block directory config

xfs/{529,531,532,534,535} attempt to create test files after injecting
reduce_max_iextents error tag. Creation of test files fails when using a
multi-block directory test configuration because,

1. A directory can have a pseudo maximum extent count of 10.
2. In the worst case a directory entry creation operation can consume
   (XFS_DA_NODE_MAXDEPTH + 1 + 1) * (Nr fs blocks in a single directory block)
   extents.
   With 1k fs block size and 4k directory block size, this evaluates to,
   (5 + 1 + 1) * 4
   = 7 * 4
   = 28
   > 10 (Pseudo maximum inode extent count).

This commit fixes the issue by creating test files before injecting
reduce_max_iextents error tag.

Reported-by: Darrick J. Wong <djwong@kernel.org>
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/529: Execute chown on an existing directory entry
Chandan Babu R [Fri, 2 Apr 2021 02:49:39 +0000 (08:19 +0530)]
xfs/529: Execute chown on an existing directory entry

chown command is being executed on $testfile which is actually
deleted just before the execution of quota inode extent count
overflow test. Hence the test was not getting exercised at all.

This commit fixes the bug by using $fillerdir as the target of chown
command.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/608: Add new regression test
Xiao Yang [Tue, 30 Mar 2021 02:06:55 +0000 (10:06 +0800)]
generic/608: Add new regression test

Write data into a file and then enable DAX on the file immediately,
the written data which is still in the buffer should be synchronized
to disk instead of discarded when the corresponding inode is evicted.

It's a regression test for commit 88149082bb8e ("fs: Handle
I_DONTCACHE in iput_final() instead of generic_drop_inode()")

Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/608: Remove drop cache and umount & mount cycle
Xiao Yang [Tue, 30 Mar 2021 02:06:54 +0000 (10:06 +0800)]
generic/608: Remove drop cache and umount & mount cycle

Since commit 77573fa310d9, toggling FS_XFLAG_DAX on an existing file can make
S_DAX on the file change immediately when all applications close the file.
As a result, we don't need the redundant drop cache and umount & mount cycle.

Signed-off-by: Xiaoli Feng <xifeng@redhat.com>
Signed-off-by: Xiao Yang <yangx.jy@fujitsu.com>
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/233,270: unlimit the max locked memory size for io_uring
Zorro Lang [Tue, 30 Mar 2021 00:59:42 +0000 (08:59 +0800)]
generic/233,270: unlimit the max locked memory size for io_uring

The ltp/fsstress always fails on io_uring_queue_init() by returnning
ENOMEM. Due to io_uring accounts memory it needs under the rlimit
memlocked option, which can be quite low on some setups, especially
on 64K pagesize machine. root isn't under this restriction, but
regular users are. So only g/233 and g/270 which use $qa_user to run
fsstress are failed.

To avoid this failure, set max locked memory to unlimited before
doing fsstress, then restore it after test done.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/629: add missing copy_range command check
Chao Yu [Mon, 29 Mar 2021 01:40:13 +0000 (09:40 +0800)]
generic/629: add missing copy_range command check

Otherwise, if xfs_io doesn't support this command, it will report
that filesystem fails on this testcase.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: test the xfs_db ls command
Darrick J. Wong [Thu, 25 Mar 2021 16:36:25 +0000 (09:36 -0700)]
xfs: test the xfs_db ls command

Make sure that the xfs_db ls command works the way the author thinks it
does.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: test the xfs_db path command
Darrick J. Wong [Tue, 23 Mar 2021 04:20:24 +0000 (21:20 -0700)]
xfs: test the xfs_db path command

Add a new test to make sure the xfs_db path command works the way the
author thinks it should.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/rc: don't rely on /proc/partitions for device size
Johannes Thumshirn [Fri, 26 Mar 2021 15:34:37 +0000 (00:34 +0900)]
common/rc: don't rely on /proc/partitions for device size

Non-partitionable devices, like zoned block devices, aren't showing
up in in /proc/partitions and therefore we cannot rely on it to get
a device's size.

Use blockdev --getsz to get the block device size.

Cc: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agobtrfs: add test for send/receive with file capabilities set
Filipe Manana [Fri, 26 Mar 2021 12:15:32 +0000 (12:15 +0000)]
btrfs: add test for send/receive with file capabilities set

Test that if we set a capability on a file but not on the next files we
create, send/receive operations only apply the capability to the first
file, the one for which we have set a capability.

This is motivated by a regression that started to happen with kernel 5.8,
caused by an incompatibility between kernel commit 89efda52e6b693
("btrfs: send: emit file capabilities after chown") and a workaround for
send/receive added to btrfs-progs several years ago by btrfs-progs
commit 123a2a085027e ("btrfs-progs: receive: restore capabilities after
chown"). That workaround in btrfs-progs was added in btrfs-progs 4.1.

That kernel commit ended up fixing the bugs the btrfs-progs commit
targeted, as well as other bugs around btrfs send and capabilities.
However it did not play nice with the btrfs-progs workaround.
The kernel fix was backported to all stable kernels and the btrfs-progs
workaround was later removed from btrfs-progs by commit 81d8ea9346c6ee
("btrfs-progs: receive: remove workaround for setting capabilities"),
introduced in btrfs-progs 5.11.

The test currently fails on any environment using kernel 5.8+ and a
btrfs-progs version between 4.1 and 5.10. Updating btrfs-progs to
version 5.11 makes the test pass.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric: test a deadlock in xfs_rename when whiteing out files
Darrick J. Wong [Tue, 23 Mar 2021 04:20:17 +0000 (21:20 -0700)]
generic: test a deadlock in xfs_rename when whiteing out files

wenli xie reported a buffer cache deadlock when an overlayfs is mounted
atop xfs and overlayfs tries to replace a single-nlink file with a
whiteout file.  This test reproduces that deadlock.

Reported-by: wenli xie <wlxie7296@gmail.com>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/rc: refactor _require_{ext2,tmpfs} helpers
Darrick J. Wong [Tue, 23 Mar 2021 04:20:11 +0000 (21:20 -0700)]
common/rc: refactor _require_{ext2,tmpfs} helpers

Combine these two helpers into a single generic function so that we can
use it in the next patch to test a regression when running overlayfs
atop xfs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: test rtalloc alignment and math errors
Darrick J. Wong [Tue, 23 Mar 2021 04:20:06 +0000 (21:20 -0700)]
xfs: test rtalloc alignment and math errors

Add a couple of regression tests for "xfs: make sure the rt allocator
doesn't run off the end" and "xfs: ensure that fpunch, fcollapse, and
finsert operations are aligned to rt extent size".

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agogeneric/556: Fix rename test
André Almeida [Wed, 24 Mar 2021 22:48:17 +0000 (19:48 -0300)]
generic/556: Fix rename test

Casefold rename test should check if renaming a file to an equivalent
name fails as expect (e.g. renaming from "file.txt" to "FILE.TXT") and
`mv` correctly identifies that those names refers to the same file.
Currently, the test doesn't do what is expected given that it doesn't
have the file to be renamed, and `mv` returns "No such file or
directory". Fix that by creating test files and checking the correct
output.

Fixes: 12b7dddbc265fcb ("generic: Add tests for filename casefolding feature")
Signed-off-by: André Almeida <andrealmeid@collabora.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon: Escape SCRATCH_DEV variable
André Almeida [Wed, 24 Mar 2021 22:48:16 +0000 (19:48 -0300)]
common: Escape SCRATCH_DEV variable

Escape SCRATCH_DEV variable so it prints its name, instead of printing
the value. If the value is "", the error message will not be very
informative.

Signed-off-by: André Almeida <andrealmeid@collabora.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/populate: change how we describe cached populated images
Darrick J. Wong [Wed, 24 Mar 2021 18:17:48 +0000 (11:17 -0700)]
common/populate: change how we describe cached populated images

The device name of a secondary storage device isn't all that important,
but the size is.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agocommon/populate: create fifos when pre-populating filesystems
Darrick J. Wong [Tue, 23 Mar 2021 04:19:53 +0000 (21:19 -0700)]
common/populate: create fifos when pre-populating filesystems

Create fifos when populating the scratch filesystem for completeness.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agopopulate: create block devices when pre-populating filesystems
Darrick J. Wong [Tue, 23 Mar 2021 04:19:48 +0000 (21:19 -0700)]
populate: create block devices when pre-populating filesystems

I just noticed that the fs population helper creates a chardev file
"S_IFBLK" on the scratch filesystem.  This seems bogus (particularly
since we actually also create a chardev named S_IFCHR) so fix up the
mknod calls.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/122: embiggen struct xfs_agi size for inobtcount feature
Darrick J. Wong [Tue, 23 Mar 2021 04:20:55 +0000 (21:20 -0700)]
xfs/122: embiggen struct xfs_agi size for inobtcount feature

Make the expected AGI size larger for the inobtcount feature.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs/{010,030}: update repair output to deal with inobtcount feature
Darrick J. Wong [Tue, 23 Mar 2021 04:20:50 +0000 (21:20 -0700)]
xfs/{010,030}: update repair output to deal with inobtcount feature

Update both of these tests to filter out the new error messages from
repair when the inode btree counter feature is enabled.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 months agoxfs: no excessive warnings about dprecated mount options on remount
Pavel Reichl [Fri, 19 Mar 2021 22:20:19 +0000 (23:20 +0100)]
xfs: no excessive warnings about dprecated mount options on remount

Verify that warnings about deprecated mount options are properly
printed.

Verify that no excessive warnings are printed during remounts.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 months agoxfs: Stress test with bmap_alloc_minlen_extent error tag enabled
Chandan Babu R [Tue, 9 Mar 2021 05:01:24 +0000 (10:31 +0530)]
xfs: Stress test with bmap_alloc_minlen_extent error tag enabled

This commit adds a stress test that executes fsstress with
bmap_alloc_minlen_extent error tag enabled.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 months agosrc/chprojid_fail.c: Fix undefined compile error on old kernel
Yang Xu [Wed, 17 Mar 2021 10:11:13 +0000 (18:11 +0800)]
src/chprojid_fail.c: Fix undefined compile error on old kernel

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

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

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

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

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

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 months agobtrfs: test delayed subvolume deletion on mount and remount
Filipe Manana [Tue, 16 Mar 2021 16:54:28 +0000 (16:54 +0000)]
btrfs: test delayed subvolume deletion on mount and remount

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

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

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

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 months agocommon/rc: virtiofs does not support atime options
Max Reitz [Tue, 16 Mar 2021 13:01:31 +0000 (14:01 +0100)]
common/rc: virtiofs does not support atime options

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
6 months agofuzzy: capture core dumps from repair utilities
Darrick J. Wong [Wed, 10 Feb 2021 02:56:53 +0000 (18:56 -0800)]
fuzzy: capture core dumps from repair utilities

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

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

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

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

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

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

This enables us to mask off specific tests.

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

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

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>