]> www.infradead.org Git - users/hch/xfstests-dev.git/log
users/hch/xfstests-dev.git
2 years agobtrfs/271: use the common fail_request setup helpers btrfs
Christoph Hellwig [Tue, 23 Aug 2022 19:29:29 +0000 (21:29 +0200)]
btrfs/271: use the common fail_request setup helpers

Use the helpers from common/fail_make_request instead of open coding
them.  This switches to using a higher error count than the existing
code, which was the intention from the very beginning (and doesn't
actuallt matter for the short sequences in this test).

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 years agobtrfs/271: include common/fail_make_request
Christoph Hellwig [Tue, 23 Aug 2022 19:23:41 +0000 (21:23 +0200)]
btrfs/271: include common/fail_make_request

This tests needs the _require_fail_make_request helper from
common/fail_make_request, so include that file to avoid a test failure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
2 years agosrc/t_ofd_locks.c: Reset errno to zero
Yang Xu [Thu, 4 Aug 2022 06:18:52 +0000 (14:18 +0800)]
src/t_ofd_locks.c: Reset errno to zero

It seems I met libcap errno bug again when using libcap-2.48-4.el8.x86_64.
But this time, errno is EINVAL if c program link with lcap.
Lastest upstream libcap doesn't have bug and it should be backport bug.

generic/478 will become not run because of this. To fix this that only
exists on some distributions, reset errno to zero.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: add btrfs fs-verity send/recv test
Boris Burkov [Fri, 19 Aug 2022 19:34:05 +0000 (12:34 -0700)]
fstests: add btrfs fs-verity send/recv test

Test btrfs send/recv support for fs-verity. Includes tests for
signatures, salts, and interaction with chmod/caps. The last of those is
to ensure the various features that go in during inode_finalize interact
properly.

This depends on the kernel patch adding support for send:
btrfs: send: add support for fs-verity

And the btrfs-progs patch adding support for recv:
btrfs-progs: receive: add support for fs-verity

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: test i_blocks for large files
Pavel Reichl [Fri, 19 Aug 2022 14:31:35 +0000 (16:31 +0200)]
generic: test i_blocks for large files

This is a regression test for an incorrect
computation of i_blocks for files larger than
4 GiB. Bug was filed for exFAT.

Signed-off-by: Pavel Reichl <preichl@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: add missing _require_scratch
Wang Yugui [Thu, 18 Aug 2022 02:56:14 +0000 (10:56 +0800)]
fstests: add missing _require_scratch

When $SCRATCH_DEV is not defined correctly, we need _require_scratch to skip
the tests that need $SCRATCH_DEV without an error.

so add missing _require_scratch.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofail_make_request: teach helpers about external devices
Darrick J. Wong [Wed, 3 Aug 2022 04:22:20 +0000 (21:22 -0700)]
fail_make_request: teach helpers about external devices

Teach the fail_make_request helpers about external log and realtime
devices so that we can use generic/019 on exotic XFS configurations.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon: refactor fail_make_request boilerplate
Darrick J. Wong [Wed, 3 Aug 2022 04:22:15 +0000 (21:22 -0700)]
common: refactor fail_make_request boilerplate

Refactor the control functions from generic/019 into a common helper to
be used by all three tests that use fail_make_requests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agodmerror: support external log and realtime devices
Darrick J. Wong [Tue, 9 Aug 2022 21:01:06 +0000 (14:01 -0700)]
dmerror: support external log and realtime devices

Upgrade the dmerror code to coordinate making external scratch log and
scratch realtime devices error out along with the scratch device.  Note
that unlike SCRATCH_DEV, we save the old rt/log devices in a separate
variable and overwrite SCRATCH_{RT,LOG}DEV so that all the helper
functions continue to work properly.

This is very similar to what we did for dm-flakey a while back.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon/ext4: provide custom ext4 scratch fs options
Darrick J. Wong [Tue, 9 Aug 2022 21:00:58 +0000 (14:00 -0700)]
common/ext4: provide custom ext4 scratch fs options

Create a _scratch_options backend for ext* so that we can inject
pathnames to external log devices into the scratch fs mount options.
This enables common/dm* to install block device filters, e.g. dm-error
for stress testing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon/rc: move XFS-specific parts of _scratch_options into common/xfs
Darrick J. Wong [Tue, 9 Aug 2022 21:00:52 +0000 (14:00 -0700)]
common/rc: move XFS-specific parts of _scratch_options into common/xfs

Move all the non-XFS code in _scratch_options into a
_scratch_xfs_options helper in common/xfs, in preparation to add ext4
bits.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro zlang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon/rc: move ext4-specific helpers into a separate common/ext4 file
Darrick J. Wong [Tue, 9 Aug 2022 21:00:46 +0000 (14:00 -0700)]
common/rc: move ext4-specific helpers into a separate common/ext4 file

Move the ext4-specific parts of common/rc into a separate file and
source it when we test that.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs/{015,042,076}: fix mkfs failures with nrext64=1
Darrick J. Wong [Tue, 9 Aug 2022 21:00:37 +0000 (14:00 -0700)]
xfs/{015,042,076}: fix mkfs failures with nrext64=1

One of my XFS fstests systems is configured with multiple 34G block
devicesm each with a 4k LBA size for the scratch filesystem.  If I turn
on large extent counts with -i nrext64=1, I see the following failures
from each of these three tests:

-used inodes is in range
+max log size 4083 smaller than min log size 4287, filesystem is too small

Note that this particular output is dependent on having a recent
xfsprogs with "mkfs: complain about impossible log size constraints"
applied, else you get a far more obscure message about the log being too
small.

It turns out that you can simulate this pretty easily:

# truncate -s 34G /tmp/a; losetup -f -b 4096 /tmp/a
# truncate -s 34G /tmp/b; losetup -f -b 4096 /tmp/b
# mkfs.xfs -f -N /dev/loop0  -r rtdev=/dev/loop1 -d rtinherit=1,size=32m -i nrext64=1
max log size 4083 smaller than min log size 4287, filesystem is too small

If I turn off nrext64, the fs geometry I get is:

meta-data=/dev/loop0             isize=512    agcount=2, agsize=4096 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=0    bigtime=1 inobtcount=1 nrext64=0
data     =                       bsize=4096   blocks=8192, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=954, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =/dev/loop1             extsz=4096   blocks=8912896, rtextents=8912896

So it's pretty obvious what happened here -- the AG size is 4096 blocks.
mkfs has to leave enough free space in each AG to handle the AG space
btree roots, the AG headers, and the AGFL, which means the log can't be
more than 4083 blocks.  libxfs computes the minimum log size to be 4287
blocks, which is why the format fails.

Fix this problem by bumping the filesystems up to 96M, which provides
enough space in each AG to handle a ~20M internal log.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: add memory failure test for partly-reflinked&dax file
Shiyang Ruan [Wed, 3 Aug 2022 04:51:31 +0000 (04:51 +0000)]
xfs: add memory failure test for partly-reflinked&dax file

Verify that dax-rmap works for both normal extent and shared extent.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: add memory failure test for dax&reflink mode
Shiyang Ruan [Wed, 3 Aug 2022 04:51:30 +0000 (04:51 +0000)]
xfs: add memory failure test for dax&reflink mode

Verify that the dax-rmap feature works.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: add memory failure test for dax mode
Shiyang Ruan [Wed, 3 Aug 2022 04:51:29 +0000 (04:51 +0000)]
xfs: add memory failure test for dax mode

Make sure memory failure mechanism works when filesystem is mounted with
dax option.

Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: add tests for fscrypt policies with HCTR2
Nathan Huckleberry [Wed, 3 Aug 2022 22:41:21 +0000 (15:41 -0700)]
generic: add tests for fscrypt policies with HCTR2

This patch adds fscrypt policy tests for filename encryption using
HCTR2.

More information on HCTR2 can be found here: "Length-preserving
encryption with HCTR2" https://ia.cr/2021/1441

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Tested-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofscrypt-crypt-util: add HCTR2 implementation
Nathan Huckleberry [Wed, 3 Aug 2022 22:41:20 +0000 (15:41 -0700)]
fscrypt-crypt-util: add HCTR2 implementation

This patch adds an implementation of HCTR2 to the fscrypt testing
utility.

More information on HCTR2 can be found here: "Length-preserving
encryption with HCTR2": https://ia.cr/2021/1441

Signed-off-by: Nathan Huckleberry <nhuck@google.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Tested-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs/018: fix LARP testing for small block sizes
Darrick J. Wong [Fri, 5 Aug 2022 00:55:52 +0000 (17:55 -0700)]
xfs/018: fix LARP testing for small block sizes

Fix this test to work properly when the filesystem block size is less
than 4k.  Tripping the error injection points on shape changes in the
xattr structure must be done dynamically.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs/533: fix false negatives for this test
Darrick J. Wong [Thu, 4 Aug 2022 16:26:49 +0000 (09:26 -0700)]
xfs/533: fix false negatives for this test

xfsprogs 5.19 will change the error message that gets printed when the
primary superblock validation fails.  Filter the _get_metadata_field
output so that the new message looks like the old message.

While we're at it, _notrun this test on V4 filesystems because the
validation messages are in the V5 superblock validation functions.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs/291: convert open-coded _scratch_xfs_repair usage
Darrick J. Wong [Wed, 3 Aug 2022 04:21:31 +0000 (21:21 -0700)]
xfs/291: convert open-coded _scratch_xfs_repair usage

Convert this test to use _scratch_xfs_repair, since the only variance
from the standard usage is that it's called against a sparse file into
which the scratch filesystem has been metadumped and mdrestored.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs/432: fix this test when external devices are in use
Darrick J. Wong [Wed, 3 Aug 2022 04:21:26 +0000 (21:21 -0700)]
xfs/432: fix this test when external devices are in use

This program exercises metadump and mdrestore being run against the
scratch device.  Therefore, the test must pass external log / rt device
arguments to xfs_repair -n to check the "restored" filesystem.  Fix the
incorrect usage, and report repair failures, since this test has been
silently failing for a while now.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: add more dmerror related test cases into eio group
Zorro Lang [Sun, 31 Jul 2022 04:46:50 +0000 (12:46 +0800)]
fstests: add more dmerror related test cases into eio group

The g/484, g/628 and g/629 calls _dmerror_init and load error table
for testing, better to count them in eio test group, then we won't
miss them when we want to run all eio related cases.

Signed-off-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoseek_sanity_test: use XFS ioctls to determine file allocation unit size
Darrick J. Wong [Thu, 28 Jul 2022 18:17:26 +0000 (11:17 -0700)]
seek_sanity_test: use XFS ioctls to determine file allocation unit size

liuyd.fnst@fujitsu.com reported that my recent change to the seek sanity
test broke NFS.  I foolishly thought that st_blksize was sufficient to
find the file allocation unit size so that applications could figure out
the SEEK_HOLE granularity.  Replace that with an explicit callout to XFS
ioctls so that xfs realtime will work again.

Fixes: e861a302 ("seek_sanity_test: fix allocation unit detection on XFS realtime")
Reported-by: liuyd.fnst@fujitsu.com
Tested-by: liuyd.fnst@fujitsu.com
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocommon/rc: wait for udev before creating dm targets
Darrick J. Wong [Tue, 26 Jul 2022 19:48:36 +0000 (12:48 -0700)]
common/rc: wait for udev before creating dm targets

Every now and then I see a failure when running generic/322 on btrfs:

QA output created by 322
failed to create flakey device

Looking in the 322.full file, I see:

device-mapper: reload ioctl on flakey-test (253:0) failed: Device or resource busy
Command failed.

And looking in dmesg, I see:

device-mapper: table: 8:3: linear: Device lookup failed (-16)
device-mapper: ioctl: error adding target to table

/dev/block/8:3 corresponds to the SCRATCH_DEV on this system.  Given the
failures in 322.out, I think this is caused by generic/322 calling
_init_flakey -> _dmsetup_create -> $DMSETUP_PROG create being unable to
open SCRATCH_DEV exclusively.  Add a call to $UDEV_SETTLE_PROG prior to
the creation of the target to try to calm the system down sufficiently
that the test can proceed.

Note that I don't have any hard evidence that it's udev at fault here --
the few times I've caught this thing, udev *has* been active spraying
error messages for nonexistent sysfs paths to journald and adding a
'udevadm settle' seems to fix it... but that's still only
circumstantial.  Regardless, it seems to have fixed the test failure.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agodmlogwrites: skip generic tests when external logdev in use
Darrick J. Wong [Tue, 26 Jul 2022 19:48:51 +0000 (12:48 -0700)]
dmlogwrites: skip generic tests when external logdev in use

Currently, dm-logwrites and common/dmlogwrites don't seem to have any
means to coordinate the event numbers across multiple devices, and the
fstests setup code is sufficiently intense that it doesn't seem like
there's support for multi-disk filesystems.  For now, we'll _notrun the
tests when we have external log devices, even though that seems like
something we'd _really_ want to test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: add test case to make sure btrfs can handle one corrupted device
Qu Wenruo [Wed, 27 Jul 2022 05:41:48 +0000 (13:41 +0800)]
btrfs: add test case to make sure btrfs can handle one corrupted device

The new test case will verify that btrfs can handle one corrupted device
without affecting the consistency of the filesystem.

Unlike a missing device, one corrupted device can return garbage to the fs,
thus btrfs has to utilize its data/metadata checksum to verify which
data is correct.

The test case will:

- Create a small fs
  Mostly to speedup the test

- Fill the fs with a regular file

- Use fsstress to create some contents

- Save the fssum for later verification

- Corrupt one device with garbage but keep the primary superblock
  untouched

- Run fssum verification

- Run scrub to fix the fs

- Run scrub again to make sure the fs is fine

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs/253: skip on zoned mode as we cannot change the chunk size
Naohiro Aota [Tue, 26 Jul 2022 07:57:59 +0000 (16:57 +0900)]
btrfs/253: skip on zoned mode as we cannot change the chunk size

On zoned mode, we have a fixed chunk size which is equal to the zone size.
So, we cannot change the chunk size, and running this test results in a
failure with below.

    --- tests/btrfs/253.out     2021-12-10 04:33:53.000000000 +0000
    +++ /host/results/btrfs/253.out.bad 2022-07-26 05:58:10.000000000 +0000
    @@ -2,9 +2,16 @@
     Capture default chunk sizes.
     First allocation.
     Second allocation.
    +./common/rc: line 4670: echo: write error: Invalid argument
    +./common/rc: line 4670: echo: write error: Invalid argument
     Calculate request size so last memory allocation cannot be completely fullfilled.
     Third allocation.
    ...

It is no use to test this feature on zoned mode. So, just skip it.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/191: Add missing xfsprogs commit
Yang Xu [Thu, 28 Jul 2022 04:36:31 +0000 (12:36 +0800)]
xfs/191: Add missing xfsprogs commit

xfs_repair also needs to think empty xattr leaf block isn't corruption, so
case can pass.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: test mkfs.xfs whether terminate getsubopt arrays properly
Yang Xu [Fri, 22 Jul 2022 03:43:04 +0000 (11:43 +0800)]
xfs: test mkfs.xfs whether terminate getsubopt arrays properly

When I run xfs/144 manually, the step as below:
mkfs.xfs -f -d agcount=3200,size=6366g -d file,n

I accidentally pressed the Enter key, it triggers Segmentation fault.
Then I found Darrick has fixed this one week ago. So add this test.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: test xfs_db whether still can get corrupted field value
Yang Xu [Tue, 19 Jul 2022 08:31:13 +0000 (16:31 +0800)]
xfs: test xfs_db whether still can get corrupted field value

This is a regression test that xfs_db code doesn't clean up the
LIBXFS_READBUF_SALVAGE call sites in set_cur so that we can't use the
return value directly and scraping it out later.

Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/270: Fix syntax error
Yang Xu [Tue, 19 Jul 2022 08:31:12 +0000 (16:31 +0800)]
xfs/270: Fix syntax error

Without xfsprogs commit
f4afdcb0a ("xfs_db: clean up the salvage read callsites in set_cur()"),
this case will fail as below:

+/var/lib/xfstests/tests/xfs/270: line 51: [: !=: unary operator expected

With this xfsprogs bug, xfs_db can't get new_ro_compat value, so report
this bash syntax error.

Fix this and add a helper output for xfsprogs bug.

Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4: resize an ext4 which resize_inode feature is disabled but has reserved GDT...
Sun Ke [Wed, 27 Jul 2022 07:11:40 +0000 (15:11 +0800)]
ext4: resize an ext4 which resize_inode feature is disabled but has reserved GDT blocks.

A regression test for b55c3cd102a6 ("ext4: add reserved GDT blocks
check"). Make sure there's not kernel crash, if resize an ext4 which
resize_inode feature is disabled but has reserved GDT blocks.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4: set 256 blocks in a block group then apply io pressure
Sun Ke [Wed, 13 Jul 2022 09:28:59 +0000 (17:28 +0800)]
ext4: set 256 blocks in a block group then apply io pressure

Set 256 blocks in a block group, then inject I/O pressure, it will
trigger off kernel BUG in ext4_mb_mark_diskspace_used.

Regression test for commit a08f789d2ab5 ext4: fix bug_on
ext4_mb_use_inode_pa.

Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoreport: add support for the xunit-quiet format
Theodore Ts'o [Wed, 20 Jul 2022 16:43:53 +0000 (12:43 -0400)]
report: add support for the xunit-quiet format

The xunit-quiet format excludes the NNN.{full,dmesg,bad} files in
<system-out> and <system-err> nodes which are included in the xunit
report format.

For test runners that save the entire results directory to preserve
all of the test artifacts, capturing the NNN.{full,dmesg,bad} in the
results.xml file is redundant.  In addition, if the NNN.bad is too
large, it can cause the junitparser python library to refuse to parse
the XML file to prevent potential denial of service attacks[1].  A
simple way to avoid this problem is to simply to omit the <system-out>
and <system-err> nodes in the results.xml file.

[1] https://gitlab.com/gitlab-org/gitlab/-/issues/268035

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4: add test for ext4 uuid get/set ioctls during fsstress.
Jeremy Bongio [Thu, 21 Jul 2022 22:39:30 +0000 (15:39 -0700)]
ext4: add test for ext4 uuid get/set ioctls during fsstress.

Adds a utility to get/set uuid through ext4 ioctl. Executes the ioctls
while running fsstress. These ioctls are used by tune2fs to safely change
the uuid without racing other filesystem modifications.

Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Jeremy Bongio <bongiojp@gmail.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agopunch: skip fpunch tests when page size not congruent with file allocation unit
Darrick J. Wong [Tue, 19 Jul 2022 21:38:01 +0000 (14:38 -0700)]
punch: skip fpunch tests when page size not congruent with file allocation unit

Skip the generic fpunch tests on a file when the file's allocation unit
size is not congruent with the system page size.  This is needed for
testing swapfiles and mmap collisions wiht fallocate.

Assuming this edgecase configuration of an edgecase feature is
vanishingly rare, let's just _notrun the tests instead of rewriting a
ton of tests to do their integrity checking by hand.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agofilter: report data block mappings and od offsets in multiples of allocation units
Darrick J. Wong [Tue, 19 Jul 2022 21:37:55 +0000 (14:37 -0700)]
filter: report data block mappings and od offsets in multiples of allocation units

All the tests that use these two filter functions also make all of their
fallocate calls in units of file allocation units, not filesystem
blocks.  Make them transform the file offsets to multiples of file
allocation units (via _get_file_block_size) so that xfs/242 and xfs/252
will work with XFS with a rt extent size set.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agopunch: skip fpunch tests when op length not congruent with file allocation unit
Darrick J. Wong [Tue, 19 Jul 2022 21:37:50 +0000 (14:37 -0700)]
punch: skip fpunch tests when op length not congruent with file allocation unit

Skip the generic fpunch tests on a file when the file's allocation unit
size is not congruent with the proposed testing operations.

This can be the case when we're testing reflink and fallocate on the XFS
realtime device.  For those configurations, the file allocation unit is
a realtime extent, which can be any integer multiple of the block size.
If the request length isn't an exact multiple of the allocation unit
size, reflink and fallocate will fail due to alignment issues, so
there's no point in running these tests.

Assuming this edgecase configuration of an edgecase feature is
vanishingly rare, let's just _notrun the tests instead of rewriting a
ton of tests to do their integrity checking by hand.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agopunch: use allocation unit to test punching holes
Darrick J. Wong [Tue, 19 Jul 2022 21:37:44 +0000 (14:37 -0700)]
punch: use allocation unit to test punching holes

In step 17 of _test_generic_punch, we want to test that we can write
a file with a single block, use one of unresvsp, fpunch, or fzero to
modify the file, and then check that the file has one written block
followed by a hole.

Unfortunately, the test helper uses _get_block_size to determine how
much data to write to the test file.  For filesystems with an allocation
unit size that is not the fs block size (e.g. XFS realtime with a rt
extent size), this produces unwritten extents in the fiemap output,
which causes test failures.

Fix step 17 to obtain the file allocation unit size with
_get_file_block_size.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agomisc: avoid tests encoding FIEMAP/BMAP golden output with weird file blocksizes
Darrick J. Wong [Tue, 19 Jul 2022 21:37:39 +0000 (14:37 -0700)]
misc: avoid tests encoding FIEMAP/BMAP golden output with weird file blocksizes

Some tests encode FIEMAP/XFS_IOC_BMAP results in the golden output.
Typically these tests cannot handle a filesystem that chooses to
allocate extents that are much larger than the filesystem block size
(aka XFS rt extents and ext4 bigalloc).  Since these tests are /never/
going to pass, disable them when these configurations are detected.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agomisc: skip extent size hint tests when hint not congruent with file allocation unit
Darrick J. Wong [Tue, 19 Jul 2022 21:37:33 +0000 (14:37 -0700)]
misc: skip extent size hint tests when hint not congruent with file allocation unit

XFS files have an extent size hint, which tells the block allocator that
it should try to allocate larger aligned blocks when possible.  These
hints must be some integer multiple of the allocation unit size, which
is one fs block for files on the data device, and one rt extent for
files on the realtime device.  For tests that are hardwired to a static
extent size hint, the fssetxattr call will fail if the hint isn't
congruent, so just skip those tests.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agomisc: skip remap/fallocate tests when op length not congruent with file allocation...
Darrick J. Wong [Tue, 19 Jul 2022 21:37:27 +0000 (14:37 -0700)]
misc: skip remap/fallocate tests when op length not congruent with file allocation unit

Nearly all of the reflink and fpunch/fcollapse/finsert tests that I have
written assumed that it was ok to use 64k as the fundamental unit of
allocation.  This works fine for testing the XFS data device, since the
file allocation unit is always a power of two, and never larger than
64k.  Making this assumption allows those tests to encode md5sums in the
golden output for easy file data integrity checking.

Unfortunately, this isn't necessarily the case when we're testing
reflink and fallocate on the XFS realtime device.  For those
configurations, the file allocation unit is a realtime extent, which can
be any integer multiple of the block size.  If the request length isn't
an exact multiple of the allocation unit size, reflink and fallocate
will fail due to alignment issues, so there's no point in running these
tests.

Assuming this edgecase configuration of an edgecase feature is
vanishingly rare, let's just _notrun the tests instead of rewriting a
ton of tests to do their integrity checking by hand.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agomisc: use _get_file_block_size for block (re)mapping tests
Darrick J. Wong [Tue, 19 Jul 2022 21:37:22 +0000 (14:37 -0700)]
misc: use _get_file_block_size for block (re)mapping tests

Tests that exercise block remapping functionality such as reflink,
hole punching, fcollapse, and finsert all require the input parameters
to be aligned to allocation unit size for regular files.  This could be
different from the fundamental filesystem block size (think ext4
bigalloc or xfs realtime), so use the appropriate function here.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
signed-off-by: Zorro Lang <zlang@kernel.org>

3 years agogeneric: test fs-verity EFBIG scenarios
Boris Burkov [Wed, 20 Jul 2022 00:49:50 +0000 (17:49 -0700)]
generic: test fs-verity EFBIG scenarios

btrfs, ext4, and f2fs cache the Merkle tree past EOF, which restricts
the maximum file size beneath the normal maximum. Test the logic in
those filesystems against files with sizes near the maximum.

To work properly, this does require some understanding of the practical
but not standardized layout of the Merkle tree. This is a bit unpleasant
and could make the test incorrect in the future, if the implementation
changes. On the other hand, it feels quite useful to test this tricky
edge case. It could perhaps be made more generic by adding some ioctls
to let the file system communicate the maximum file size for a verity
file or some information about the storage of the Merkle tree.

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: test verity orphans with dmlogwrites
Boris Burkov [Wed, 20 Jul 2022 00:49:49 +0000 (17:49 -0700)]
btrfs: test verity orphans with dmlogwrites

The behavior of orphans is most interesting across mounts, interrupted
at arbitrary points during fsverity enable. To cover as many such cases
as possible, use dmlogwrites and dmsnapshot as in
log-writes/replay-individual.sh. As we replay the log events, we run a
state machine with different invariants enforced at each state.

There are three possible states for a given point in the log:
0. Verity has not yet started
1. Verity has started but not finished
2. Verity has finished.

The possible transitions with causes are:
0->1: We see an orphan item for the file.
1->2: Running 'fsverity measure' succeeds on the file.

Each state has its own invariant for testing:
0: No verity items exist.
1: Mount should handle the orphan and blow away verity data: expect 0
   Merkle items after mounting.
2: The orphan should be gone and mount should not blow away merkle
   items. Expect the same number of merkle items before and after
   mounting.

As a result, we can be confident that if the file system loses power at
any point during enabling verity on a file, the work is either completed,
or gets rolled-back by mount.

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: test btrfs specific fsverity corruption
Boris Burkov [Wed, 20 Jul 2022 00:49:48 +0000 (17:49 -0700)]
btrfs: test btrfs specific fsverity corruption

There are some btrfs specific fsverity scenarios that don't map
neatly onto the tests in generic/574 like holes, inline extents,
and preallocated extents. Cover those in a btrfs specific test.

This test relies on the btrfs implementation of fsverity in the patch:
btrfs: initial fsverity support

and on btrfs-corrupt-block for corruption in the patches titled:
btrfs-progs: corrupt generic item data with btrfs-corrupt-block
btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocommon/verity: support btrfs in generic fsverity tests
Boris Burkov [Wed, 20 Jul 2022 00:49:47 +0000 (17:49 -0700)]
common/verity: support btrfs in generic fsverity tests

generic/572-579 have tests for fsverity. Now that btrfs supports
fsverity, make these tests function as well. For a majority of the tests
that pass, simply adding the case to mkfs a btrfs filesystem with no
extra options is sufficient.

However, generic/574 has tests for corrupting the merkle tree itself.
Since btrfs uses a different scheme from ext4 and f2fs for storing this
data, the existing logic for corrupting it doesn't work out of the box.
Adapt it to properly corrupt btrfs merkle items.

576 does not run because btrfs does not support transparent encryption.

This test relies on the btrfs implementation of fsverity in the patch:
btrfs: initial fsverity support

and on btrfs-corrupt-block for corruption in the patches titled:
btrfs-progs: corrupt generic item data with btrfs-corrupt-block
btrfs-progs: expand corrupt_file_extent in btrfs-corrupt-block

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocommon/verity: require corruption functionality
Boris Burkov [Wed, 20 Jul 2022 00:49:46 +0000 (17:49 -0700)]
common/verity: require corruption functionality

Corrupting ext4 and f2fs relies on xfs_io fiemap. Btrfs corruption
testing will rely on a btrfs specific corruption utility. Add the
ability to require corruption functionality to make this properly
modular. To start, just check for fiemap, as that is needed
universally for _fsv_scratch_corrupt_bytes.

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agogeneric/275: fix premature enospc errors when fs block size is large
Darrick J. Wong [Tue, 19 Jul 2022 21:37:13 +0000 (14:37 -0700)]
generic/275: fix premature enospc errors when fs block size is large

When running this test on an XFS filesystem with a 64k block size, I
see this error:

generic/275       - output mismatch (see /var/tmp/fstests/generic/275.out.bad)
    --- tests/generic/275.out   2021-05-13 11:47:55.694860280 -0700
    +++ /var/tmp/fstests/generic/275.out.bad    2022-07-19 10:38:41.840000000 -0700
    @@ -2,4 +2,7 @@
     ------------------------------
     write until ENOSPC test
     ------------------------------
    +du: cannot access '/opt/tmp1': No such file or directory
    +stat: cannot statx '/opt/tmp1': No such file or directory
    +/tmp/fstests/tests/generic/275: line 74: [: -lt: unary operator expected
     done
    ...
    (Run 'diff -u /tmp/fstests/tests/generic/275.out /var/tmp/fstests/generic/275.out.bad'  to see the entire diff)

The 275.full file indicates that the test was unable to recreate the
$SCRATCH_MNT/tmp1 file after we freed all but the last 256K of free
space in the filesystem.  I mounted the scratch fs, and df reported
exactly 256K of free space available, which means there are 4 blocks
left in the filesystem for user programs to use.

Unfortunately for this test, xfs_create requires sufficient free blocks
in the filesystem to handle full inode btree splits and the maximal
directory expansion for a new dirent.  In other words, there must be
enough free space to handle the worst case space consumption.  That
quantity is 26 blocks, hence the last dd in the test fails with ENOSPC,
which makes the test fail.

Fix all this by creating the file that we use to test the low-space file
write *before* we drain the free space down to 256K.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs/257: not run if we have compression enabled
Josef Bacik [Tue, 19 Jul 2022 15:27:35 +0000 (11:27 -0400)]
btrfs/257: not run if we have compression enabled

This fails on all of our compression config variations because it
depends on specific file extent layout.  Add _require_btrfs_no_compress
so we don't complain about failures that don't apply.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs/270: fix uncompressed data from previously bad mirror
Christoph Hellwig [Tue, 19 Jul 2022 06:14:54 +0000 (08:14 +0200)]
btrfs/270: fix uncompressed data from previously bad mirror

The commited old version test the broken behavior of the current
upstream code that writes the uncompressed data into a previously
bad mirror.  Fix the test to check that the compressed data gets
re-replicated and add it to the compress group while we're at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/144: fix test mkfs.xfs sizing of internal logs that overflow the AG for-next v2022.07.10
Darrick J. Wong [Tue, 5 Jul 2022 22:02:08 +0000 (15:02 -0700)]
xfs/144: fix test mkfs.xfs sizing of internal logs that overflow the AG

Fix a few problems with this test -- one of the things we test require
mkfs to run in -N mode, so we need to have a certain amount of free
space, and fix that test not to use -N mode.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/547: fix problems with realtime
Darrick J. Wong [Tue, 5 Jul 2022 22:02:19 +0000 (15:02 -0700)]
xfs/547: fix problems with realtime

This test needs to fragment the free space on the data device so that
each block added to the attr fork gets its own mapping.  If the test
configuration sets up a rt device and rtinherit=1 on the root dir, the
test will erroneously fragment space on the *realtime* volume.  When
this happens, attr fork allocations are contiguous and get merged into
fewer than 10 extents and the test fails.

Fix this test to force all allocations to be on the data device, and fix
incorrect variable usage in the error messages.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: make sure that we handle empty xattr leaf blocks ok
Darrick J. Wong [Fri, 8 Jul 2022 17:44:23 +0000 (10:44 -0700)]
xfs: make sure that we handle empty xattr leaf blocks ok

Make sure that the kernel can handle empty xattr leaf blocks properly,
since we've screwed this up enough times.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/288: skip repair -n when checking empty root leaf block behavior
Darrick J. Wong [Tue, 5 Jul 2022 22:02:34 +0000 (15:02 -0700)]
xfs/288: skip repair -n when checking empty root leaf block behavior

Update this test to reflect the (once again) corrected behavior of the
xattr leaf block verifiers.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: test raid1 write error handling
Christoph Hellwig [Sat, 2 Jul 2022 09:33:30 +0000 (11:33 +0200)]
btrfs: test raid1 write error handling

Test that a write with a single bad mirror works fine but reports errors
in the error counters, and that a write with two bad mirrors fails.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: add -L <n> parameter to rerun failed tests
David Disseldorp [Fri, 8 Jul 2022 08:51:42 +0000 (10:51 +0200)]
check: add -L <n> parameter to rerun failed tests

If check is run with -L <n>, then a failed test will be rerun <n> times
before proceeding to the next test. Following completion of the rerun
loop, aggregate pass/fail statistics are printed.

Rerun tests will be tracked as a single failure in overall pass/fail
metrics (via @try and @bad), with .out.bad, .dmesg, .core, .hints,
.notrun and .full saved using a .rerun# suffix.

Suggested-by: Theodore Ts'o <tytso@mit.edu>
Link: https://lwn.net/Articles/897061/
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: append bad / notrun arrays in helper function
David Disseldorp [Fri, 8 Jul 2022 08:51:41 +0000 (10:51 +0200)]
check: append bad / notrun arrays in helper function

Currently the @try, @bad and @notrun arrays are appended with seqnum at
different points in the main run_section() loop:
- @try: shortly prior to test script execution
- @notrun: on list (check -n), or after .notrun flagged test completion
- @bad: at the start of subsequent test loop and loop exit

For future loop-test-following-failure functionality it makes sense to
combine some of these steps. This change moves both @notrun and @bad
appends into a helper function which is called at the end of each loop
iteration.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: make a few variables local
David Disseldorp [Fri, 8 Jul 2022 08:51:40 +0000 (10:51 +0200)]
check: make a few variables local

The variables aren't used outside of function scope. Also convert one
timestamp output to use the helper.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoreport: pass through most details as function parameters
David Disseldorp [Fri, 8 Jul 2022 08:51:39 +0000 (10:51 +0200)]
report: pass through most details as function parameters

Report generation currently involves reaching into a whole bunch of
globals for things like section name and start/end times. Pass these
through as explicit function parameters to avoid unintentional breakage.

One minor fix included is the default xunit error message, which used
$sequm instead of $seqnum.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoreport: use array for REPORT_ENV_LIST
David Disseldorp [Fri, 8 Jul 2022 08:51:38 +0000 (10:51 +0200)]
report: use array for REPORT_ENV_LIST

There's no need for multiple assignments.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: test xfs_copy doesn't do cached read before libxfs_mount master v2022.07.03
Darrick J. Wong [Thu, 30 Jun 2022 00:48:14 +0000 (17:48 -0700)]
xfs: test xfs_copy doesn't do cached read before libxfs_mount

This is a regression test for an xfs_copy fix that ensures that it
doesn't perform a cached read of an XFS filesystem prior to initializing
libxfs, since the xfs_mount (and hence the buffer cache) isn't set up
yet.

[zlang: change the supported fs from generic to xfs]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: test mkfs.xfs sizing of internal logs that
Darrick J. Wong [Tue, 28 Jun 2022 20:21:34 +0000 (13:21 -0700)]
xfs: test mkfs.xfs sizing of internal logs that

This is a regression test that exercises the mkfs.xfs code that creates
log sizes that are very close to the AG size when stripe units are in
play and/or when the log is forced to be in AG 0.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/166: fix golden output failures when multipage folios enabled
Darrick J. Wong [Tue, 28 Jun 2022 20:22:02 +0000 (13:22 -0700)]
xfs/166: fix golden output failures when multipage folios enabled

Beginning with 5.18, some filesystems support creating large folios for
the page cache.  A system with 64k pages can create 256k folios, which
means that with the old file size of 1M, the last half of the file is
completely converted from unwritten to written by page_mkwrite.  The
test encodes a translated version of the xfs_bmap output in the golden
output, which means that the test now fails on 64k pages.  Fixing the
64k page case by increasing the file size to 2MB broke fsdax because
fsdax uses 2MB PMDs, hence 12MB.

Increase the size to prevent this from happening.  This may require
further revision if folios get larger or fsdax starts supporting PMDs
that are larger than 2MB.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/109: handle larger minimum filesystem size
Darrick J. Wong [Tue, 28 Jun 2022 20:21:51 +0000 (13:21 -0700)]
xfs/109: handle larger minimum filesystem size

mkfs will soon refuse to format a filesystem smaller than 300MB, so
increase the size of the filesystem to keep this test scenario
realistic.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: document mkfs.xfs reliance on fstests exports
Darrick J. Wong [Tue, 28 Jun 2022 20:21:45 +0000 (13:21 -0700)]
check: document mkfs.xfs reliance on fstests exports

There are a number of fstests that employ special (and now unsupported)
XFS filesystem configurations to perform testing in a controlled
environment.  The presence of the QA_CHECK_FS and MSGVERB variables are
used by mkfs.xfs to detect that it's running inside fstests, which
enables the unsupported configurations.  Nobody else should be using
filesystems with tiny logs, non-redundant superblocks, or smaller than
the (new) minimum supported size.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoseek_sanity_test: fix allocation unit detection on XFS realtime
Darrick J. Wong [Tue, 28 Jun 2022 20:21:23 +0000 (13:21 -0700)]
seek_sanity_test: fix allocation unit detection on XFS realtime

The seek sanity test tries to figure out a file space allocation unit by
calling stat and then using an iterative SEEK_DATA method to try to
detect a smaller blocksize based on SEEK_DATA's consultation of the
filesystem's internal block mapping.  This was put in (AFAICT) because
XFS' stat implementation returns max(filesystem blocksize, PAGESIZE) for
most regular files.

Unfortunately, for a realtime file with an extent size larger than a
single filesystem block this doesn't work at all because block mappings
still work at filesystem block granularity, but allocation units do not.
To fix this, detect the specific case where st_blksize != PAGE_SIZE and
trust the fstat results.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4: create file systems with the encrypt feature as necessary
Theodore Ts'o [Thu, 30 Jun 2022 14:46:37 +0000 (10:46 -0400)]
ext4: create file systems with the encrypt feature as necessary

The linux kernel commit 5f41fdaea63d ("ext4: only allow
test_dummy_encryption when supported") the kernel will reject mounts
with the test_dummy_encryption option if the ext4 file system does not
have the encrypt feature enabled.

There are a handful of tests (ext4/003, ext4/035, ext4/306, and
generic/260) which will format the scratch file system using a
hard-coded set of mkfs.ext4 parameters ignoring the MKFS_OPTION that
is set by the file system test config.

For file system configs which includes test_dummy_encryption in
MOUNT_OPTIONS and "-O encrypt" in MKFS_OPTIONS, we need to test for
test_dummy_encryption and force the hard-coded mkfs options to enable
the encrypt feature.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/035: skip this test if the scratch device does not support 1k block sizes
Theodore Ts'o [Thu, 30 Jun 2022 14:46:36 +0000 (10:46 -0400)]
ext4/035: skip this test if the scratch device does not support 1k block sizes

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/055: skip test if dax mount option is used
Theodore Ts'o [Thu, 30 Jun 2022 14:46:35 +0000 (10:46 -0400)]
ext4/055: skip test if dax mount option is used

This test creates a 1k block file system with the quota feature
enabled.   As such, it is incompatible with DAX.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/054: skip test if the dax mount option is enabled
Theodore Ts'o [Thu, 30 Jun 2022 14:46:34 +0000 (10:46 -0400)]
ext4/054: skip test if the dax mount option is enabled

The ext4/054 test explicitly creates a file system with a 1k
blocksize.  This can't possibly work on if the dax mount option is
enabled, so change ext4/054 to use _scratch_mkfs_blocksized, and and a
check to _scratch_mkfs_blocksized to _notrun the test if the block
size is less than the page size.

Also remove an unnecessary _require_test declaration since this test
does not use the test device.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/045: _require_dumpe2fs doesn't take any arguments so remove them
Theodore Ts'o [Thu, 30 Jun 2022 14:46:33 +0000 (10:46 -0400)]
ext4/045: _require_dumpe2fs doesn't take any arguments so remove them

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/044: skip test if the file system does not have a journal
Theodore Ts'o [Thu, 30 Jun 2022 14:46:32 +0000 (10:46 -0400)]
ext4/044: skip test if the file system does not have a journal

This test mounts the file system using "mount -t ext3"; if the file
system config creates the file system without the jbd2 journal, the
"mount -t ext3" will fail.  So skip this test in that case.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/050: support indirect as well as extent mapped journals
Theodore Ts'o [Thu, 30 Jun 2022 14:46:31 +0000 (10:46 -0400)]
ext4/050: support indirect as well as extent mapped journals

Simplify the test and fix ext4/050 failures when running ext4 without
extents enabled (e.g., in ext3 emulation mode).

Instead of relying on parsing debugfs output's (which varies depending
on whether the journal inode is extent mapped or indirect block
mapped), use debugfs's "cat" command to get the contents of the
journal.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoceph/005: verify correct statfs behaviour with quotas
Luís Henriques [Mon, 27 Jun 2022 10:26:31 +0000 (11:26 +0100)]
ceph/005: verify correct statfs behaviour with quotas

When using a directory with 'max_bytes' quota as a base for a mount,
statfs shall use that 'max_bytes' value as the total disk size.  That
value shall be used even when using subdirectory as base for the mount.

A bug was found where, when this subdirectory also had a 'max_files'
quota, the real filesystem size would be returned instead of the parent
'max_bytes' quota value.  This test case verifies this bug is fixed.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Xiubo Li <xiubli@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: test read repair on a corrupted compressed extent
Christoph Hellwig [Wed, 22 Jun 2022 04:58:44 +0000 (06:58 +0200)]
btrfs: test read repair on a corrupted compressed extent

Exercise read repair on a corrupted compressed sector.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: test checker pattern corruption on raid10
Christoph Hellwig [Wed, 22 Jun 2022 04:58:43 +0000 (06:58 +0200)]
btrfs: test checker pattern corruption on raid10

Check read repair for the case where the corruption is spread over
the different legs of a raid10 set.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs; add a test for impossible repair cases
Christoph Hellwig [Wed, 22 Jun 2022 04:58:42 +0000 (06:58 +0200)]
btrfs; add a test for impossible repair cases

Verify that a repair attempt that can't succeed because all copies are
bad returns a proper I/O error and doesn't cause any deadlocks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs: fix the_btrfs_get_physical invocation in btrfs-map-logical
Christoph Hellwig [Wed, 22 Jun 2022 04:58:41 +0000 (06:58 +0200)]
btrfs: fix the_btrfs_get_physical invocation in btrfs-map-logical

The -b flag without an argument is not supported, so remove it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/{422,517}: kill background jobs on test termination v2022.06.26
Amir Goldstein [Tue, 21 Jun 2022 17:37:29 +0000 (20:37 +0300)]
xfs/{422,517}: kill background jobs on test termination

Those tests failed to cleanup background jobs properly after test
is interrupted and even sometimes when it completed succefully.

xfs/517 would sometime fails randomally with this false positive error:
     QA output created by 517
     Format and populate
     Concurrent fsmap and freeze
    +Terminated
     Test done

The tests have several background sub-shells that spawn short lived
programs in a loop.  By killing the spawned programs using killall,
killall could find no process to kill and the sub-shell loop could still
spawn another process that is not going to be killed and in the worst
case, the freeze_loop() could spawn the xfs_io "freeze" command after
test has thawn the fs before exit, which leaves the fs frozen after the
test.

The "Terminated" output is emitted by the sub-shell when killing the
programs that it has spawned when the loop did not finish before test
timeout.  By killing the sub-shell and not the spawned programs, we
avoid the false positive "Terminated" error.

Use a helper to perform this cleanup dance:
First kill and wait the freeze_loop so it won't try to freeze fs again
Then make sure fs is not frozen.
Then kill and wait for the rest of the sub-shells, because
if fs is frozen a killed writer process will never exit.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agofstests: unfreeze fs on cleanup routines
Amir Goldstein [Tue, 21 Jun 2022 17:37:28 +0000 (20:37 +0300)]
fstests: unfreeze fs on cleanup routines

Many of tests that freeze fs do not make sure that fs is unfrozen on
test termination.

Some tests also need to kill and wait for writer processes after
unfreezing the fs.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agofstests: add missing _require_freeze() to tests
Amir Goldstein [Tue, 21 Jun 2022 17:37:27 +0000 (20:37 +0300)]
fstests: add missing _require_freeze() to tests

And add a few tests that use freeze to the freeze group

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoext4/053: test changing test_dummy_encryption on remount
Eric Biggers [Thu, 23 Jun 2022 18:41:13 +0000 (11:41 -0700)]
ext4/053: test changing test_dummy_encryption on remount

The test_dummy_encryption mount option isn't supposed to be settable or
changeable via a remount, so add test cases for this.  This is a
regression test for a bug that was introduced in Linux v5.17 and fixed
in v5.19-rc3 by commit 85456054e10b ("ext4: fix up test_dummy_encryption
handling for new mount API").

Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/122: escape %zu in printf with %% not \\%
Eric Sandeen [Mon, 20 Jun 2022 21:43:31 +0000 (16:43 -0500)]
xfs/122: escape %zu in printf with %% not \\%

The standard way to escape % in a printf is with %%; although \\%zu
seems to have worked in awk until recently, an upgrade on Fedora 36
has started failing:

awk: cmd. line:1: (FILENAME=- FNR=1) fatal: not enough arguments to satisfy format string
        'printf("sizeof(%s) = \%zu\n", sizeof(%s));
    '
                                              ^ ran out for this one
Switching the escape to "%%" fixes this for me, and also works
on my very old RHEL7 mcahine.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: remove err and first_test variables
David Disseldorp [Mon, 20 Jun 2022 19:29:34 +0000 (21:29 +0200)]
check: remove err and first_test variables

tc_status can be used for both of these.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: use arrays instead of separate n_ counters
David Disseldorp [Mon, 20 Jun 2022 19:29:33 +0000 (21:29 +0200)]
check: use arrays instead of separate n_ counters

The separate n_try, n_bad and n_notrun counters are unnecessary when
the corresponding lists are switched to bash arrays.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoreport: fix xunit tests count
David Disseldorp [Mon, 20 Jun 2022 19:29:32 +0000 (21:29 +0200)]
report: fix xunit tests count

The xunit "section report" provides a tests attribute, which according
to https://llg.cubic.org/docs/junit/ represents:
tests=""     <!-- The total number of tests in the suite, required. -->

The current value is generated as a sum of the $n_try and $n_notrun
counters. This is incorrect as the $n_try counter already includes tests
which are run but complete with _notrun.
One special case exists for $showme (check -n), where $n_try remains
zero, so $n_notrun can be used as-is.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoreport: drop unused _xunit_make_section_report parameter
David Disseldorp [Mon, 20 Jun 2022 19:29:31 +0000 (21:29 +0200)]
report: drop unused _xunit_make_section_report parameter

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: simplify check.time parsing
David Disseldorp [Mon, 20 Jun 2022 19:29:30 +0000 (21:29 +0200)]
check: simplify check.time parsing

There's no need to use grep and awk when the latter can do all that's
needed, including the pretty printing.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocheck: avoid FSTYP=<fstyp parameter> repetition
David Disseldorp [Mon, 20 Jun 2022 19:29:29 +0000 (21:29 +0200)]
check: avoid FSTYP=<fstyp parameter> repetition

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agogeneric/486: adjust the max xattr size
Luís Henriques [Mon, 13 Jun 2022 11:31:42 +0000 (12:31 +0100)]
generic/486: adjust the max xattr size

CephFS doesn't have a maximum xattr size.  Instead, it imposes a maximum
size for the full set of xattrs names+values, which by default is 64K.  And
since it reports 4M as the blocksize (the default ceph object size),
generic/486 will fail in ceph because the XATTR_SIZE_MAX value can't be used
in attr_replace_test.

The fix is to add a new argument to the test so that the max size can be
passed in instead of trying to auto-probe a value for it.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agogeneric/020: adjust max_attrval_size for ceph
Luís Henriques [Mon, 13 Jun 2022 11:31:41 +0000 (12:31 +0100)]
generic/020: adjust max_attrval_size for ceph

CephFS doesn't have a maximum xattr size.  Instead, it imposes a maximum
size for the full set of xattrs names+values, which by default is 64K.

This patch fixes the max_attrval_size for ceph so that it is takes into
account any already existing attrs in the file.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: Verify correctness of upgrading an fs to support large extent counters v2022.06.12
Chandan Babu R [Sat, 11 Jun 2022 11:10:37 +0000 (16:40 +0530)]
xfs: Verify correctness of upgrading an fs to support large extent counters

This commit adds a test to verify upgrade of an existing V5 filesystem to
support large extent counters.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs: Verify that the correct inode extent counters are updated with/without nrext64
Chandan Babu R [Sat, 11 Jun 2022 11:10:36 +0000 (16:40 +0530)]
xfs: Verify that the correct inode extent counters are updated with/without nrext64

This commit adds a new test to verify if the correct inode extent counter
fields are updated with/without nrext64 mkfs option.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocommon/xfs: Add helper to check if nrext64 option is supported
Chandan Babu R [Sat, 11 Jun 2022 11:10:35 +0000 (16:40 +0530)]
common/xfs: Add helper to check if nrext64 option is supported

This commit adds a new helper to allow tests to check if xfsprogs and xfs
kernel module support nrext64 option.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agoxfs/270: Fix ro mount failure when nrext64 option is enabled
Chandan Babu R [Sat, 11 Jun 2022 11:10:34 +0000 (16:40 +0530)]
xfs/270: Fix ro mount failure when nrext64 option is enabled

With nrext64 option enabled at run time, the read-only mount performed by the
test fails because,
1. mkfs.xfs would have calculated log size based on reflink being enabled.
2. Clearing the reflink ro compat bit causes log size calculations to yield a
   different value.
3. In the case where nrext64 is enabled, this causes attr reservation to be
   the largest among all the transaction reservations.
4. This ends up causing XFS to require a larger ondisk log size than that
   which is available.

This commit fixes the problem by setting features_ro_compat to the value
obtained by the bitwise-OR of features_ro_compat field with 2^31.

This commit includes changes suggested by Dave Chinner to replace bashisms
with invocations to inline awk scripts.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agobtrfs/220: zoned: skip nodatacow mount option for zoned btrfs
Naohiro Aota [Tue, 7 Jun 2022 08:06:35 +0000 (17:06 +0900)]
btrfs/220: zoned: skip nodatacow mount option for zoned btrfs

The nodatacow mount option is not allowed on zoned btrfs and failing the
test. Skip the cases for zoned btrfs.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 years agocommon/filter: filter out extra mount error output
Zorro Lang [Fri, 27 May 2022 12:11:15 +0000 (20:11 +0800)]
common/filter: filter out extra mount error output

The lastest mount command (from util-linux) merged below commit:
  79534c0d7e0f ("mount: add hint about dmesg(8) to error messages")
which brought in a new error output when mount fails, no matter
ro/rw/busy mount fails.

That cause some cases (e.g. xfs/005) fail as:
  mount: Structure needs cleaning
         dmesg(1) may have more information after failed mount system call

More failed cases like generic/050, ext4/002, xfs/154, xfs/158 etc.
Especially xfs/154 and xfs/158, need to change their _filter_scratch
to _filter_error_mount.

Signed-off-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Andrey Albershteyn <aalbersh@redhat.com>
3 years agoxfs: corrupted xattr should not block removexattr
Zorro Lang [Fri, 3 Jun 2022 08:24:57 +0000 (16:24 +0800)]
xfs: corrupted xattr should not block removexattr

After we corrupted an attr leaf block (under node block), getxattr
might hit EFSCORRUPTED in xfs_attr_node_get when it does
xfs_attr_node_hasname. A known bug cause xfs_attr_node_get won't do
xfs_buf_trans release job, then a subsequent removexattr will hang.

This case covers a1de97fe296c ("xfs: Fix the free logic of state in
xfs_attr_node_hasname")

Signed-off-by: Zorro Lang <zlang@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>