xfstests-dev.git
2 months agofstests: fix group list generation for whacky test names
Dave Chinner [Tue, 17 May 2022 07:01:03 +0000 (17:01 +1000)]
fstests: fix group list generation for whacky test names

Darrick noticed that tests/xfs/191-input-validation didn't get
generated properly. Fix the regex to handle this.

$ grep -I -R "^_begin_fstest" tests/xfs | \
  sed -e 's/^.*\/\([0-9]*\):_begin_fstest/\1/' |grep 191
tests/xfs/191-input-validation:_begin_fstest auto quick mkfs realtime
$
$ grep -I -R "^_begin_fstest" tests/xfs | \
  sed -e 's/^.*\/\([0-9]*\).*:_begin_fstest/\1/ ' |grep 191
191 auto quick mkfs realtime
$

Use the regexes for matching test names defined in common/test_names
rather than trying to open code it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
2 months agofstests: remove xfs deprecated test
Dave Chinner [Tue, 17 May 2022 12:15:48 +0000 (20:15 +0800)]
fstests: remove xfs deprecated test

Remove xfs/018, xfs/081 and xfs/082 entirely, as they're deprecated
and obsolete for long time.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoxfs/191: remove broken test
Dave Chinner [Tue, 17 May 2022 07:01:11 +0000 (17:01 +1000)]
xfs/191: remove broken test

Test has been marked broken for a long time. Original intent of
validating all mkfs.xfs input is not realistic, nobody is going to
try to make that happen.

Remove it as it serves no useful purpose except to have a whacky
unique name that nobody expects or codes for.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoxfs/148: fix failure from bad shortform size assumptions
Dave Chinner [Tue, 17 May 2022 07:01:06 +0000 (17:01 +1000)]
xfs/148: fix failure from bad shortform size assumptions

We replaced an attr named:

slashstr="are_bad_for_you"

with this substitution:

cp $imgfile $imgfile.old
sed -b \
        -e "s/$nullstr/too_many\x00beans/g" \
        -e "s/$slashstr/are_bad\/for_you/g" \
        -i $imgfile

We then try to retreive the attr named 'a_are_bad/for_you'. The
failure is:

    -Attribute "a_are_bad/for_you" had a 3 byte value for TEST_DIR/mount-148/testfile:
    -heh
    +attr_get: No data available
    +Could not get "a_are_bad/for_you" for TEST_DIR/mount-148/testfile

The error returned is ENODATA - the xattr does not exist. While the
name might exist in the attr leaf block:

....
nvlist[0].valuelen = 3
nvlist[0].namelen = 17
nvlist[0].name = "a_are_bad/for_you"
nvlist[0].value = "heh"
nvlist[1].valuelen = 3
....

xattrs are not looked up by name matches when in leaf or node form
like they are in short form.  They are looked up by *name hash*
matches, and if the hash is not found, then the name does not exist.
Only if the has match is found, then it goes and retrieves the xattr
pointed to by the hash and checks the name.

At this point, it should be obvious that the hash of
"a_are_bad_for_you" is different to "a_a_are_bad/for_you". Hence the
leaf lookup is always rejected at the hash match stage and never
gets to the name compare stage.

IOWs, this test can *never* pass when the xattr is in leaf/node
form, only when it is in short form.

The reason the attr fork is in leaf form is that we are using
"-m crc=0" and so the inodes are only 256 bytes in size and can only
hold ~150 bytes in the literal area. That leaves ~100 bytes maximum
for shortform attr data. The test consumes ~80 bytes of shortform
space, so it should fit and the test pass.

However:

nvlist[4].valuelen = 37
nvlist[4].namelen = 7
nvlist[4].name = "selinux"
nvlist[4].value = "unconfined_u:object_r:unlabeled_t:s0\000"

Yes, I run the fstests with selinux enabled on some of test
machines. The selinux attr pushes the attr fork way over the size
that can fit in the shortform literal area, and so it moves to leaf
form as the attrs are initially added and the test fails.

Fix this by forcing the test to use 512 byte inodes, so as to
provide around 350 bytes of usable attr fork literal area so it's
not affected by security attributes.

While there, clean up the silly conditional loop device cleanup
code.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoxfs/148: make test debuggable
Dave Chinner [Tue, 17 May 2022 07:01:05 +0000 (17:01 +1000)]
xfs/148: make test debuggable

Don't clean up image files - leave them laying around on the test
device so that when the test fails there's a corpse left behind to
post-mortem....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoxfs/348: golden output is not correct
Dave Chinner [Tue, 17 May 2022 07:01:02 +0000 (17:01 +1000)]
xfs/348: golden output is not correct

The output of xfs/348 encodes the observed behaviour at the time the
test was written, not the correct behaviour that should occur.
Recent improvements in verification checking in the upstream kernel
(1eb70f54c445 "xfs: validate inode fork size against fork format")
have resulted in the kernel having correct behaviour and now the
test fails. Fix the test output to reflect correct behaviour.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoxfs/122: add attribute log formats to test output.
Dave Chinner [Tue, 17 May 2022 07:01:01 +0000 (17:01 +1000)]
xfs/122: add attribute log formats to test output.

Now that we have merged logged attributes, add the attribute log
format sizes to the on-disk structure size checking.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agofstests: filter quota warnings
Dave Chinner [Tue, 17 May 2022 07:01:00 +0000 (17:01 +1000)]
fstests: filter quota warnings

Quota warning code has been removed from the upstream kernel and now
returns -EINVAL errors. Seeing as we can't set warnings anymore and
they have always been non-functional in the kernel, just remove the
calls to set warnings filter those errors out so those tests pass
again.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agocommon/rc: fix test init performance regression on XFS
Dave Chinner [Fri, 20 May 2022 01:23:36 +0000 (11:23 +1000)]
common/rc: fix test init performance regression on XFS

I've been having problems over the past month with tests randomly
running much slower than they should. The overall effect has been
that running an auto group iterate has blown out from about 3
hours to almost 5 hours.

The problem has been that the root disks have been thrashing.
Thousands of iops and the backing store getting IO bound so all test
vms with root drive images hosted on that backing store then also
go slow.

I finally got to the bottom of it - it looked for all the world like
a qemu image format write amplification problem, because I couldn't
capture anything unusual from inside the guest. I converted all
the root images to raw format on fast SSD storage, and the problem
didn't go away - while some tests were faster, other tests were
still randomly slow.

Finally I tracked it down with blktrace/blkparse. All the IO was
coming from processes with the command line like:

 /sbin/mkfs.xfs -d file name=/tmp/791409.img size=512m

A quick grep then pointed me at common/rc::init_rc() where there is
a test for XFS specific on-disk format behaviour that uses that
exact command line.

init_rc() is run from _begin_fstest() so it is executed on every
test start. We run mkfs to create a 512MB filesystem in $tmp on
every test start. That's ..... not smart. And we do it so we can
change the setup of $XFS_COPY_PROG, which is only used in a handful
of tests. That's also .... not smart.

And then the penny dropped: we recently increased the default log
size of small filesystems, so this is now zeroing a 64MB log instead
of a 5-10MB log. And, of course it's on the root drive because of
the $tmp image prefix, which in this case is ext3, and it's
fragmenting the crap out of the writes and so it increases runtime
of the mkfs.xfs execution from nothing to 5-10s.

Then when one of these mkfs invocations co-incides with journal
flushing driven writeback, everything just stops until the writeback
stops thrashing. And so all tests are 5-10s slows, and random tests
take anywhere between 20-100s longer to start up....

Fix it by moving the setup of XFS_COPY_PROG to _require_xfs_copy()
so only the tests that use xfs_copy run this code.

Numbers don't lie:

generic/001 11s ...  6s
generic/002 9s ...  1s
generic/003 17s ...  10s
generic/004 12s ...  1s
generic/005 9s ...  1s
generic/006 9s ...  2s
generic/007 11s ...  3s
generic/008 5s ...  2s
generic/009 10s ...  2s
generic/010 5s ...  0s
generic/011 9s ...  1s
generic/012 7s ...  2s
generic/013 10s ...  5s
generic/014 11s ...  1s
generic/015 7s ...  1s
generic/016 7s ...  2s
.....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agofstests: tests should not source common/rc directly
Dave Chinner [Fri, 20 May 2022 01:23:35 +0000 (11:23 +1000)]
fstests: tests should not source common/rc directly

_begin_fstest() does this as every test needs it, so remove it from
all the tests that source it a second time.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agogeneric/556: add test case for top-level dir rename
Eric Biggers [Sat, 14 May 2022 18:01:46 +0000 (11:01 -0700)]
generic/556: add test case for top-level dir rename

Test renaming a casefolded directory located in the top-level directory,
while the cache is cold.  When $MOUNT_OPTIONS contains
test_dummy_encryption, this detects an f2fs bug.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agogeneric/556: Filter touch error message
Gabriel Krisman Bertazi [Fri, 20 May 2022 17:18:52 +0000 (13:18 -0400)]
generic/556: Filter touch error message

Coreutils commit d435cfc0bc55 ("touch: fix wrong
diagnostic (Bug#48106)"), released in coreutils v9.0, changed the error
reported by the tool when openat() fails with EINVAL.  Instead of
reporting a generic message for the failure of either openat() or the
following utimensat(), it now differentiates both failures with
different messages.

This change breaks generic/556, which relied on the parsing of that
message.  This test was originally developed by me on a Debian
Buster (coreutils v8.x), so I used the generic error message.  Now that
I tried to run it on a more modern distro, it reports a different error
message, which fails the test, as shown below:

  output mismatch (see /tmp/results/generic/556.out.bad)
      --- tests/generic/556.out 2022-05-20 13:15:00.447525770 -0400
      +++ /tmp/results/generic/556.out.bad 2022-05-20 13:15:24.988167427 -0400
      @@ -12,5 +12,5 @@
       # file: SCRATCH_MNT/xattrs/x/f1
       user.foo="bar"

      -touch: setting times of 'SCRATCH_MNT/strict/corac'$'\314\247\303': Invalid argument
      -touch: setting times of 'SCRATCH_MNT/strict/cora'$'\303\247\303': Invalid argument
      +touch: cannot touch 'SCRATCH_MNT/strict/corac'$'\314\247\303': Invalid argument
      +touch: cannot touch 'SCRATCH_MNT/strict/cora'$'\303\247\303': Invalid argument
      ...

The fix filters out the touch-specific parts of the touch error
messages, to prevent breakage from future changes, but preserves the
return code information, which is actually useful (and more stable).

There is no change in behavior on the kernel side, just a broken test.
On both older and new distros, the kernel correctly rejects this invalid
sequence with -EINVAL, as shown in the strace hunk below:

  [...]
  openat(AT_FDCWD, "/scratch_mnt/strict/corac\314\247\303", ...) = -1 EINVAL
  utimensat(AT_FDCWD, "/scratch_mnt/strict/corac\314\247\303", ...) = -1 EINVAL
  [...]

Tested on Debian sid (coreutils v8.32) and Fedora (coreutils 9.0).

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agofstests: add a btrfs read_repair group
Christoph Hellwig [Tue, 17 May 2022 06:35:02 +0000 (08:35 +0200)]
fstests: add a btrfs read_repair group

Add a new group to run all tests the exercise the btrfs read_repair code.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agogeneric/603: use project quota create and restore common helpers
Zorro Lang [Thu, 12 May 2022 15:16:56 +0000 (23:16 +0800)]
generic/603: use project quota create and restore common helpers

As common/quota has _create_project_quota and _restore_project_quota
helpers now, so replace local similar functions with them.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agogeneric: soft quota limits testing within grace time
Zorro Lang [Mon, 9 May 2022 17:17:22 +0000 (01:17 +0800)]
generic: soft quota limits testing within grace time

After soft limits are exceeded, within the grace time, fs quota
should allow more space allocation before exceeding hard limits,
even if allocating many small files.

This case can cover bc37e4fb5cac (xfs: revert "xfs: actually bump
warning counts when we send warnings"). And will help to expose
later behavior changes on this side.

Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@redhat.com>
2 months agocommon/rc: Modify _require_batched_discard to improve test coverage
Ojaswin Mujoo [Mon, 16 May 2022 08:45:05 +0000 (14:15 +0530)]
common/rc: Modify _require_batched_discard to improve test coverage

A recent ext4 patch discussed [1] that some devices (eg LVMs) can
have a discard granularity as big as 42MB which makes it larger
than the group size of ext4 FS with 1k BS.  This causes the FITRIM
IOCTL to fail.

This case was not correctly handled by this test since
"_require_batched_discard" incorrectly interpreted the FITRIM
failure as SCRATCH_DEV not supporting the IOCTL. This caused the test
to report "not run" instead of "failed" in case of large discard granularity.

Fix "_require_batched_discard" to use a more accurate method
to determine if discard is supported.

[1] commit 173b6e383d2
    ext4: avoid trim error on fs with small groups

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Reviewed-by: Ritesh Harjani <riteshh@linux.ibm.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agovfs/idmapped-mounts: remove invalid test v2022.05.15
Christian Brauner [Thu, 12 May 2022 16:52:50 +0000 (18:52 +0200)]
vfs/idmapped-mounts: remove invalid test

The threaded mount interaction test validates that the idmapping of a
mount behaves correctly when changed while another process already has a
writable file descriptor to that mount. In newer kernels it isn't
possible to change a mount's idmapped if someone has a writable file
descriptor to that mount.

Link: e1bbcd277a53 ("fs: hold writers when changing mount's idmapping")
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agovfstest: split out remaining idmapped mount tests
Christian Brauner [Thu, 12 May 2022 16:52:49 +0000 (18:52 +0200)]
vfstest: split out remaining idmapped mount tests

Split out all the remaining idmapped mount tests into the idmapped
mounts source file.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agovfstest: split out btrfs idmapped mounts test
Christian Brauner [Thu, 12 May 2022 16:52:48 +0000 (18:52 +0200)]
vfstest: split out btrfs idmapped mounts test

Split the btrfs specific idmapped mounts test into a separate source
file.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agovfstest: split idmapped mount tests into separate suite
Christian Brauner [Thu, 12 May 2022 16:52:47 +0000 (18:52 +0200)]
vfstest: split idmapped mount tests into separate suite

Now that we finished restructuring split the core idmapped mounts test
suite into a separate source file.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoutils: add struct test_suite
Christian Brauner [Thu, 12 May 2022 16:52:46 +0000 (18:52 +0200)]
utils: add struct test_suite

Provide a convenient wrapper struct which provides the tests and the
number of tests. The struct can be kept local to each source file so we
are sure that the tests and number of tests is correct.

In vfstest.c we provide a run_suite() function which expects a struct
test_suite and runs the tests provided by that suite.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agomissing: move sys_execveat() to missing.h
Christian Brauner [Thu, 12 May 2022 16:52:45 +0000 (18:52 +0200)]
missing: move sys_execveat() to missing.h

The missing.h header provides syscalls potentially missing from the used
libc. Move the sys_execveat() definition into it. It doesn't belong into
vfstest.c.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoutils: move helpers into utils
Christian Brauner [Thu, 12 May 2022 16:52:44 +0000 (18:52 +0200)]
utils: move helpers into utils

In order to split the test suite into multiple source files we need to
be able to access generic helpers in all source files not just one. So
move all generic helpers into utils.{c,h}.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoutils: add struct vfstest_info
Christian Brauner [Thu, 12 May 2022 16:52:43 +0000 (18:52 +0200)]
utils: add struct vfstest_info

So far we were able to rely on global variables as the idmapped mount
test suite was a single source file. But that gets messy when we split
it into multiple source files in the following patches. Instead of
global variables introduce struct vfstest_info which provides all
information about the test suite run and pass it to all tests.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoutils: add missing global.h include
Christian Brauner [Thu, 12 May 2022 16:52:42 +0000 (18:52 +0200)]
utils: add missing global.h include

Make sure that utils.{c,h} have access to the necessary defines created
during the configure stage when building xfstests.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agovfstest: rename struct t_idmapped_mounts
Christian Brauner [Thu, 12 May 2022 16:52:41 +0000 (18:52 +0200)]
vfstest: rename struct t_idmapped_mounts

The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.

As was discussed upstream it's time to rename it to something that
reflects its generic nature.

Rename the basic structure used for the tests from struct
t_idmapped_mounts to struct test_struct.

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agosrc/vfs: rename idmapped-mounts.c file
Christian Brauner [Thu, 12 May 2022 16:52:40 +0000 (18:52 +0200)]
src/vfs: rename idmapped-mounts.c file

The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.

As was discussed upstream it's time to rename it to something that
reflects its generic nature. So rename the source file from
idmapped-mounts.c to vfstest.c before we split it into multiple source
files in the next patches.

[Zorro: fix generic/689]

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agosrc: rename idmapped-mounts folder
Christian Brauner [Thu, 12 May 2022 16:52:39 +0000 (18:52 +0200)]
src: rename idmapped-mounts folder

The idmapped mounts test suite has grown to cover a lot of generic vfs
functionality that is not concerned with idmapped mounts at all.

As was discussed upstream it's time to rename it to something that
reflects its generic nature. So rename it from idmapped-mounts to vfs.

[Zorro: fix generic/689 and add it into idmapped test group]

Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agoidmapped-mounts: make all tests set their required feature flags
Christian Brauner [Thu, 12 May 2022 16:52:38 +0000 (18:52 +0200)]
idmapped-mounts: make all tests set their required feature flags

In commit 858a19c5e9b0 ("idmapped_mounts: Prepare for support for more
features") we introduced a flag argument to check for multiple features
and then decide based on the flag argument whether a test requires a
given feature and skip it if the kernel doesn't provide it.

However, not all tests were ported to the new flag argument and still
use the old infrastructure. Port them all.

Fixes: 858a19c5e9b0 ("idmapped_mounts: Prepare for support for more features")
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agocasefold: Fix expansion of seqres variable
Gabriel Krisman Bertazi [Wed, 11 May 2022 16:33:40 +0000 (12:33 -0400)]
casefold: Fix expansion of seqres variable

seqres is not properly expanded on these error paths, causing a file
called seqres.full to be created instead.

Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agocommon: xfstests support overlay+tmpfs
Baokun Li [Wed, 11 May 2022 08:34:04 +0000 (16:34 +0800)]
common: xfstests support overlay+tmpfs

The local.config of overlay+tmpfs is as follows:
```local.config.example
export FSTYP=tmpfs
export TEST_DEV=tmpfs_test
export TEST_DIR=/tmp/test
export SCRATCH_DEV=tmpfs_scratch
export SCRATCH_MNT=/tmp/scratch
```

Run `./check -overlay tests` to execute test case on overlay+tmpfs.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 months agogeneric/68[3-7]: Add separate sgid stripping sub-tests
Yang Xu [Tue, 10 May 2022 05:24:50 +0000 (13:24 +0800)]
generic/68[3-7]: Add separate sgid stripping sub-tests

Like xfstests commit 298f60c ("generic/673: Add separate sgid stripping sub-tests"),
we should also add separate sgid stripping sub-tests for each fallocate operation.

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 months agoext4/053: fix the rejected mount option testing
Eric Biggers [Sat, 30 Apr 2022 19:21:30 +0000 (12:21 -0700)]
ext4/053: fix the rejected mount option testing

'not_mnt OPTIONS' seems to have been intended to test that the
filesystem cannot be mounted at all with the given OPTIONS, meaning that
the mount fails as opposed to the options being ignored.  However, this
doesn't actually work, as shown by the fact that the test case 'not_mnt
test_dummy_encryption=v3' is passing in the !CONFIG_FS_ENCRYPTION case.
Actually ext4 ignores this mount option when !CONFIG_FS_ENCRYPTION.
(The ext4 behavior might be changed, but that is besides the point.)

The problem is that the do_mnt() helper function is being misused in a
context where a mount failure is expected, and it does some additional
remount tests that don't make sense in that context.  So if the mount
unexpectedly succeeds, then one of these later tests can still "fail",
causing the unexpected success to be shadowed by a later failure, which
causes the overall test case to pass since it expects a failure.

Fix this by reworking not_mnt() and not_remount_noumount() to use
simple_mount() in cases where they are expecting a failure.  Also fix
up some of the naming and calling conventions to be less confusing.
Finally, make sure to test that remounting fails too, not just mounting.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric: test fsync of directory with renamed symlink
Filipe Manana [Mon, 9 May 2022 14:31:02 +0000 (15:31 +0100)]
generic: test fsync of directory with renamed symlink

Test that if we fsync a directory, create a symlink inside it, rename
the symlink, fsync again the directory and then power fail, after the
filesystem is mounted again, the symlink exists with the new name and
it has the correct content.

This currently fails on btrfs, because the symlink ends up empty (which
is illegal on Linux), but it is fixed by kernel commit:

    d0e64a981fd841 ("btrfs: always log symlinks in full mode")

Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoidmapped-mounts: Add open with O_TMPFILE operation in setgid test v2022.05.08
Yang Xu [Sat, 7 May 2022 16:01:27 +0000 (00:01 +0800)]
idmapped-mounts: Add open with O_TMPFILE operation in setgid test

Since we can create temp file by using O_TMPFILE flag and filesystem driver also
has this api, we should also check this operation whether strip S_ISGID.

Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoidmapped-mounts: Add mknodat operation in setgid test
Yang Xu [Sat, 7 May 2022 16:01:26 +0000 (00:01 +0800)]
idmapped-mounts: Add mknodat operation in setgid test

Since mknodat can create file, we should also check whether strip S_ISGID.
Also add new helper caps_down_fsetid to drop CAP_FSETID because strip S_ISGID
depend on this cap and keep other cap(ie CAP_MKNOD) because create character
device needs it when using mknod.

Only test mknodat with character device in setgid_create function and the another
two functions test mknodat with whiteout device.

Since kernel commit a3c751a50 ("vfs: allow unprivileged whiteout creation") in
v5.8-rc1, we can create whiteout device in userns test. Since kernel 5.12, mount_setattr
and MOUNT_ATTR_IDMAP was supported, we don't need to detect kernel whether allow
unprivileged whiteout creation. Using fs_allow_idmap as a proxy is safe.

Tested-by: Christian Brauner (Microsoft)<brauner@kernel.org>
Reviewed-by: Christian Brauner (Microsoft)<brauner@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoidmapped-mounts: Reset errno to zero before run_test
Yang Xu [Sat, 7 May 2022 16:01:25 +0000 (00:01 +0800)]
idmapped-mounts: Reset errno to zero before run_test

If we run case on old kernel that doesn't support mount_setattr and
then fail on our own function before call is_setgid/is_setuid function
to reset errno, run_test will print "Function not implement" error.

We also check whether system support user namespace, so reset errno to
zero after userns check.

Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Yang Xu <xuyang2018.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoxfs/533: Delete test since directory's extent count can never overflow
Chandan Babu R [Fri, 6 May 2022 09:57:46 +0000 (15:27 +0530)]
xfs/533: Delete test since directory's extent count can never overflow

The maximum file size that can be represented by the data fork extent counter
in the worst case occurs when all extents are 1 block in length and each block
is 1KB in size.

With XFS_MAX_EXTCNT_DATA_FORK_SMALL representing maximum extent count and with
1KB sized blocks, a file can reach upto,
(2^31) * 1KB = 2TB

This is much larger than the theoretical maximum size of a directory
i.e. XFS_DIR2_SPACE_SIZE * 3 = ~96GB.

Since a directory can never overflow its data fork extent counter, the xfs
kernel driver removed code which checked for such a situation before any
directory modification operation could be executed. Instead, the kernel driver
verifies the sanity of directory's data fork extent counter when the inode is
read from disk.

This commit removes the test xfs/533 due to the reasons mentioned above.

Signed-off-by: Chandan Babu R <chandan.babu@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agofstests: faster group file creation
Dave Chinner [Fri, 6 May 2022 05:10:17 +0000 (15:10 +1000)]
fstests: faster group file creation

We don't need to execute every test just to check it's groups are
valid. Just grab all the groups with grep, pull out the unique ones,
then check them.

This also avoids the problem of editor swap files being present in
the test directory and breaking the build because they are not
executable.

Building on a clean, already built tree so it only builds the
group lists:

$ time make
....
Building udf
 [GROUP] /home/dave/src/xfstests-dev/tests/udf/group.list
Building xfs
 [GROUP] /home/dave/src/xfstests-dev/tests/xfs/group.list

real    0m36.917s
user    0m15.032s
sys     0m26.219s
$

Patched:

$ time make
....
Building udf
 [GROUP] /home/dave/src/xfstests-dev/tests/udf/group.list
Building xfs
 [GROUP] /home/dave/src/xfstests-dev/tests/xfs/group.list
groups "frobnozzle" not mentioned in documentation.
gmake[3]: *** [../../include/buildgrouplist:8: group.list] Error 1
gmake[2]: *** [../include/buildrules:31: xfs] Error 2
gmake[1]: *** [include/buildrules:31: tests] Error 2
make: *** [Makefile:51: default] Error 2

real    0m1.751s
user    0m0.863s
sys     0m1.067s

$

Just a little bit faster, and as you can see that it still detects
groups that are not documented. There was also an open .001.swp file
in the XFS directory and that doesn't throw a failure anymore,
either.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agocommon: print hints for reasons of test failures
Amir Goldstein [Tue, 19 Apr 2022 12:56:37 +0000 (15:56 +0300)]
common: print hints for reasons of test failures

Introduce helpers _fixed_by_{kernel,git}_commit() and
_fixed_in_{kernel_,}version() that can be used to hint testers why a
test might be failing and aid in auto-generating of expunge lists for
downstream kernel testing.

A test may be annotated with multiple hints, for example:

_fixed_by_kernel_commit 09889695864 xfs: foo
_fixed_by_kernel_commit 46464565465 ext4: bar
_fixed_in_version xfsprogs v5.15

Annotate fix kernel commits for some overlayfs tests.
Annotate fix kernel version for some overlayfs tests testing
for legacy behavior whose fixes are not likely to be backported
to stable kernels.

This is modeled after LTP's 'make filter-known-fails' and
print_failure_hints() using struct tst_tag annotations.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agocommon: support black listing fs in _supported_fs()
Amir Goldstein [Tue, 19 Apr 2022 12:56:36 +0000 (15:56 +0300)]
common: support black listing fs in _supported_fs()

For example:
_supported_fs ^xfs

There is no need to specify "generic" when using a block list
"all other fs are supported" is implied.

Converted some generic tests that open code this condition without
emitting a meaningful reason.

More generic test like generic/186,187 could use a block list, but
were not converted because they emit some meaningful reason:
  _notrun "Can't fragment free space on btrfs."

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agofstests: add some missing _require_loop's v2022.05.01
Josef Bacik [Thu, 28 Apr 2022 15:05:00 +0000 (11:05 -0400)]
fstests: add some missing _require_loop's

Got a new box running overnight fstests and noticed a couple of failures
because I forgot to enable loop device support.  Fix these two tests to
have _require_loop so they don't fail if there's no loop device support.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric/673: Add separate sgid stripping sub-tests
Yang Xu [Tue, 26 Apr 2022 08:55:45 +0000 (16:55 +0800)]
generic/673: Add separate sgid stripping sub-tests

Even kernel doesn't get ATTR_KILL_SGID mask and get ATTR_KILL_SUID mask,
we still can strip S_ISGID mode in setattr_prepare and setattr_copy.

We should check separate sgid stripping logic whether works well
on different filesystems.

Also fix comments error.

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 months agofsstress: remove ALLOCSP and FREESP operations entirely
Zorro Lang [Tue, 26 Apr 2022 06:24:11 +0000 (14:24 +0800)]
fsstress: remove ALLOCSP and FREESP operations entirely

Due to upstream linux has removed ALLOCSP/FREESP ioctls by commit:
4d1b97f9ce7c0 ("xfs: kill the XFS_IOC_{ALLOC,FREE}SP* ioctls"), so
let's remove ALLOCSP/FREESP testing from fsstress, to avoid more
mismatch problems.

Due to g/070 specified "-f allocsp" and "-f freesp=0", so remove
these two lines too.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agofstests: btrfs: test setting compression via xattr on nodatacow files
Chung-Chiang Cheng [Mon, 25 Apr 2022 04:22:26 +0000 (12:22 +0800)]
fstests: btrfs: test setting compression via xattr on nodatacow files

Compression and nodatacow are mutually exclusive. Besides ioctl, there
is another way to setting compression via xattrs, and shouldn't produce
invalid combinations.

Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agofstests: remove xfs/144
Eric Sandeen [Tue, 26 Apr 2022 05:14:53 +0000 (00:14 -0500)]
fstests: remove xfs/144

This test was designed to validate the quota warning limit, which in
theory was supposed to migrate from a soft quota to hard enforcement
after a certain number of warnings. However, the xfs kernel commit
which incremented the warning counter was reverted; see:

xfs: revert "xfs: actually bump warning counts when we send warnings"

in the kernel tree for an explanation of why. Due to that revert,
which removed this functionality, remove this test.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric/681, generic/682: add debugging information to $seqreq.full
Theodore Ts'o [Mon, 25 Apr 2022 21:14:50 +0000 (17:14 -0400)]
generic/681, generic/682: add debugging information to $seqreq.full

These two tests are checking whether a non-privileged user causing a
block allocation while expanding a directory block when over quota
will fail with an EDQUOT error.  There are three reasons why this can
fail.

* Aa test bug, where if the file system is using cluster allocation
  (for example, ext4 bigalloc) the test doesn't add enough directory
  entries to actually force directory grwoth.

* A file system bug, where the file system allocates blocks but for
  some reason isn't charging the space quota correctly (which
  currently seems to be the case in ext4 with fscrypt).

* A file system bug, where the file system is correctly charging the
  space quota to the unprivileged user, but isn't failing the system
  call with EDQUOT.

By adding some additional debugging information about whether
directory has grown or not (in addition to the existing repquota
output) to the the $seqres.full, it makes easier for the file system
developer to disambiguate between these possibilities.  It's cheap to
do this, and it could save developer time when trying to root cause
the failure.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agochown: fix ownership format string
Murphy Zhou [Mon, 25 Apr 2022 08:20:51 +0000 (16:20 +0800)]
chown: fix ownership format string

After coreutils rebasing to 9.1, chown(1) behavior changes:
"
   chown and chroot now warn about usages like "chown root.root f",
   which have the nonstandard and long-obsolete "." separator that
   causes problems on platforms where user names contain ".".
   Applications should use ":" instead of ".".
"

https://lwn.net/Articles/891574/

With this behavior change, old format of ownership string will cause
warning like this:
"
+chown: warning: '.' should be ':': '1000.1000'
+.chown: warning: '.' should be ':': '1100.1100'
+.chown: warning: '.' should be ':': '1200.1200'
+.chown: warning: '.' should be ':': '1300.1300'
+.chown: warning: '.' should be ':': '1400.1400'
"

The new format works fine with old versions of coreutils.

Signed-off-by: Murphy Zhou <jencce.kernel@gmail.com>
Reviewed-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric: add test for tmpfs POSIX ACLs
Christian Brauner [Wed, 20 Apr 2022 17:52:22 +0000 (19:52 +0200)]
generic: add test for tmpfs POSIX ACLs

Add a regression test for commit 705191b03d50 ("fs: fix acl translation").
This tests whether setting POSIX ACLs on a tmpfs mounted in a
non-initial user and mount namespace works as expected.

Note, once again the idmapped mount testsuite is grossly misnamed at
this point. It has morphed into a full-blown generic vfs feature
testsuite.

Cc: Eryu Guan <guaneryu@gmail.com>
Cc: Seth Forshee <sforshee@digitalocean.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Zorro Lang <zlang@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Zorro Lang <zlang@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric: ensure we drop suid after fallocate
Darrick J. Wong [Tue, 19 Apr 2022 17:32:21 +0000 (10:32 -0700)]
generic: ensure we drop suid after fallocate

fallocate changes file contents, so make sure that we drop privileges
and file capabilities after each fallocate operation.

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 months agoxfs: make sure syncfs(2) passes back super_operations.sync_fs errors
Darrick J. Wong [Tue, 19 Apr 2022 17:32:15 +0000 (10:32 -0700)]
xfs: make sure syncfs(2) passes back super_operations.sync_fs errors

This is a regression test to make sure that nonzero error returns from
a filesystem's ->sync_fs implementation are actually passed back to
userspace when the call stack involves syncfs(2).

[zlang@ add '_supported_fs xfs' in case]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agocephfs: add ceph-fuse suport for ceph-fuse
Rishabh Dave [Tue, 19 Apr 2022 17:58:11 +0000 (23:28 +0530)]
cephfs: add ceph-fuse suport for ceph-fuse

Currently tests in xfstests-dev can be executed against CephFS only by
mounting CephFS using kernel driver. Attempting to run tests against
CephFS using FUSE doesn't work because xfstests-dev would remount CephFS
using kernel. This patch adds the ability for xfstest-dev code to mount
CephFS using FUSE.

[Zorro add missed ";;" in common/rc]

Fixes: https://tracker.ceph.com/issues/55354
Signed-off-by: Rishabh Dave <ridave@redhat.com>
Reviewed-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric/019: fix incorrect unset statements
Darrick J. Wong [Tue, 19 Apr 2022 17:32:06 +0000 (10:32 -0700)]
generic/019: fix incorrect unset statements

Fix incorrect usage of unset -- one passes the name of the variable, not
the *value* contained within it.

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 months agoxfs/019: fix golden output for files created in setgid dir
Darrick J. Wong [Tue, 19 Apr 2022 17:32:00 +0000 (10:32 -0700)]
xfs/019: fix golden output for files created in setgid dir

A recent change to xfs/019 exposed a long-standing bug in mkfs where
it would always set the gid of a new child created in a setgid directory
to match the gid parent directory instead of what's in the protofile.

Ignoring the user's directions is not the correct behavior, so update
this test to reflect that.  Also don't erase the $seqres.full file,
because that makes forensic analysis pointlessly difficult.

Cc: Catherine Hoang <catherine.hoang@oracle.com>
Fixes: 7834a740 ("xfs/019: extend protofile test")
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoxfs: test xfsdump when an inode < root inode is present
Eric Sandeen [Mon, 18 Apr 2022 17:03:26 +0000 (01:03 +0800)]
xfs: test xfsdump when an inode < root inode is present

This tests a longstanding bug where xfsdumps are not properly
created when an inode is present on the filesytsem which has
a lower number than the root inode.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 months agofstests: remove _wipe_fs from dump testing entirely
Zorro Lang [Wed, 20 Apr 2022 16:07:56 +0000 (00:07 +0800)]
fstests: remove _wipe_fs from dump testing entirely

The _wipe_fs function in common/dump is a historical remnant of
xfstests, it's easy to cause confusion now. Now xfstests tend to
call `require_scratch && scratch_mkfs && scratch_mount` in each case
itself, we don't need to use a function to do that specially, so
remove _wipe_fs entirely.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
3 months agogeneric/633: Avoid failure without CONFIG_USER_NS
Jan Kara [Thu, 31 Mar 2022 11:19:20 +0000 (13:19 +0200)]
generic/633: Avoid failure without CONFIG_USER_NS

Some tests in idmapped_mounts fail without CONFIG_USER_NS because they
have implicit dependence on user namespaces and these tests are run
despite idmapped mount support not being detected. Detect whether at
least user namespaces are supported and skip tests needing them when
they are not.

Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agoidmapped_mounts: Prepare for support for more features
Jan Kara [Thu, 31 Mar 2022 11:19:19 +0000 (13:19 +0200)]
idmapped_mounts: Prepare for support for more features

Currently idmapped_mounts tests fail for kernels without CONFIG_USER_NS
because some tests are run despite missing support for idmapped mounts
and they implicitely require user namespace support. Prepare
idmapped_mounts to support more features a test may require to reliably
run.

Signed-off-by: Jan Kara <jack@suse.cz>
Tested-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
3 months agogeneric: test that renaming into a directory fails with EDQUOT
Darrick J. Wong [Mon, 11 Apr 2022 22:54:54 +0000 (15:54 -0700)]
generic: test that renaming into a directory fails with EDQUOT

Add a regression test to make sure that unprivileged userspace renaming
within a directory fails with EDQUOT when the directory quota limits have
been exceeded.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric: test that linking into a directory fails with EDQUOT
Darrick J. Wong [Mon, 11 Apr 2022 22:54:48 +0000 (15:54 -0700)]
generic: test that linking into a directory fails with EDQUOT

Add a regression test to make sure that unprivileged userspace linking
into a directory fails with EDQUOT when the directory quota limits have
been exceeded.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/019: kill background processes on interrupt
Dave Chinner [Mon, 11 Apr 2022 05:48:33 +0000 (15:48 +1000)]
generic/019: kill background processes on interrupt

If you ctrl-c generic/019, it leaves fsstress processes running.
Kill them in the cleanup function so that they don't have to be
manually killed after interrupting the test.

While touching the _cleanup() function, make it do everything that
the generic _cleanup function it overrides does and fix the
indenting.

[Eryu: unset fs_pid and fio_pid after wait]

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoxfs/216: handle larger log sizes
Darrick J. Wong [Fri, 15 Apr 2022 15:04:58 +0000 (08:04 -0700)]
xfs/216: handle larger log sizes

mkfs will soon refuse to format a log smaller than 64MB, so update this
test to reflect the new log sizing calculations.

[Eryu: add xfs/216.cfg and use _link_out_file_name to choose .out file]

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoxfs: test mkfs.xfs config file stack corruption issues
Darrick J. Wong [Mon, 11 Apr 2022 22:55:08 +0000 (15:55 -0700)]
xfs: test mkfs.xfs config file stack corruption issues

Add a new regression test for a stack corruption problem uncovered in
the mkfs config file parsing code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/rc: let xfs_scrub tell us about its unicode checker
Darrick J. Wong [Mon, 11 Apr 2022 22:55:02 +0000 (15:55 -0700)]
common/rc: let xfs_scrub tell us about its unicode checker

Now that xfs_scrub can report whether or not it was built with the
Unicode name checker, rewrite _check_xfs_scrub_does_unicode to take
advantage of that.  This supersedes the old method of trying to observe
dynamic library linkages and grepping the binary, neither of which
worked very well.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoceph/001: add extra check for remote object copies
Luís Henriques [Wed, 23 Mar 2022 16:09:25 +0000 (16:09 +0000)]
ceph/001: add extra check for remote object copies

Ceph kernel client now has a facility to check stats for certain
operations.  One of these operations is the 'copyfrom', the
operation that is used to offload to the OSDs the copy of objects
from, for example, the copy_file_range() syscall.

This patch changes ceph/001 to add an extra check to verify that the
copies performed by the test are _really_ remote copies and not
simple read+write operations.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/filter: extend _filter_xfs_io to match -nan
Eric Whitney [Thu, 14 Apr 2022 14:22:58 +0000 (10:22 -0400)]
common/filter: extend _filter_xfs_io to match -nan

When run on ext4 with sufficiently fast x86_64 hardware, generic/130
sometimes fails because xfs_io can report rate values as -nan:
0.000000 bytes, 0 ops; 0.0000 sec (-nan bytes/sec and -nan ops/sec)

_filter_xfs_io matches the strings 'inf' or 'nan', but not '-nan'.  In
that case it fails to convert the actual output to a normalized form
matching generic/130's golden output.  Extend the regular expression
used to match xfs_io's output to fix this.

Signed-off-by: Eric Whitney <enwlinux@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/encrypt: use a sub-keyring within the session keyring
Eric Biggers [Thu, 14 Apr 2022 07:19:32 +0000 (00:19 -0700)]
common/encrypt: use a sub-keyring within the session keyring

Make the encryption tests create and use a named keyring "xfstests" in
the session keyring that the tests happen to be running under, rather
than replace the session keyring using 'keyctl new_session'.
Unfortunately, the latter doesn't work when the session keyring is owned
by a non-root user, which (depending on the Linux distro) can happen if
xfstests is run in a sudo "session" rather than in a real root session.

This isn't a great solution, as the lifetime of the keyring will no
longer be tied to the tests as it should be, but it should work.  The
alternative would be the weird hack of making the 'check' script
re-execute itself using something like 'keyctl session - $0 $@'.

Reported-by: Ritesh Harjani <ritesh.list@gmail.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
3 months agocommon/rc: Skip virtiofs when _require_exportfs
Liu Yiding [Thu, 14 Apr 2022 02:34:47 +0000 (10:34 +0800)]
common/rc: Skip virtiofs when _require_exportfs

open_by_handle_at(2) is not supported by virtio-fs.
Reference:
https://gitlab.com/virtio-fs/qemu/-/issues/10

Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoxfs/187: don't rely on FSCOUNTS for free space data
Darrick J. Wong [Mon, 11 Apr 2022 22:54:22 +0000 (15:54 -0700)]
xfs/187: don't rely on FSCOUNTS for free space data

Currently, this test relies on the XFS_IOC_FSCOUNTS ioctl to return
accurate free space information.  It doesn't.  Convert it to use statfs,
which uses the accurate versions of the percpu counters.  Obviously,
this only becomes a problem when we convert the free rtx count to use
(sloppier) percpu counters instead of the (more precise and previously
buggy) ondisk superblock counts.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoxfs/507: add test to auto group
Darrick J. Wong [Mon, 11 Apr 2022 22:54:28 +0000 (15:54 -0700)]
xfs/507: add test to auto group

Add this regression test to the auto group now that it's been quite a
while since the fix patches went upstream.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/020: fix max_attrval_size output filter
David Disseldorp [Wed, 13 Apr 2022 16:44:22 +0000 (18:44 +0200)]
generic/020: fix max_attrval_size output filter

The current attr -g "$max_attrval_name" output filter is broken if
$max_attrval_size isn't 16-byte aligned, due to od's duplicate
suppression behaviour.
Fix it by having od only dump one byte per line.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/020: fix max_attrval_size for XFS, UDF, Btrfs and NFS
David Disseldorp [Wed, 13 Apr 2022 16:44:21 +0000 (18:44 +0200)]
generic/020: fix max_attrval_size for XFS, UDF, Btrfs and NFS

As found by Dave Chinner, fff4359d ("020: make this xattr test generic")
unintentionally changed the long attribute value length from 100K to 64
*bytes* for XFS, UDF and Btrfs.
Update XFS and UDF to use a 64K $max_attrval_size value. For Btrfs, use
the nodesize, xattr length and tree entry overhead sizes to calculate
the maximum.
NFS doesn't provide a way to find out the $max_attrval_size for the
underlying filesystem on the server, so just use a rough 1K limit.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/020: add and use _attr_get_max()
David Disseldorp [Wed, 13 Apr 2022 16:44:20 +0000 (18:44 +0200)]
generic/020: add and use _attr_get_max()

In preparation for taking into account the attr name length when
calculating $MAX_ATTRVAL_SIZE, put the current logic in a
_attr_get_max() helper function and set local $max_attrval_size /
$max_attrs variables instead of using export.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/020: move MAX_ATTRS and MAX_ATTRVAL_SIZE logic
David Disseldorp [Wed, 13 Apr 2022 16:44:19 +0000 (18:44 +0200)]
generic/020: move MAX_ATTRS and MAX_ATTRVAL_SIZE logic

No functional change. MAX_ATTRS and MAX_ATTRVAL_SIZE are only used
within generic/020, so move the logic for determining these values
over there.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/rc: fix _try_scratch_mount() and _test_mount() when mount fails
Filipe Manana [Mon, 11 Apr 2022 14:08:38 +0000 (15:08 +0100)]
common/rc: fix _try_scratch_mount() and _test_mount() when mount fails

After the recent commit 4a7b35d7a76cd9 ("common: allow to run all tests
on idmapped mounts"), some test that use _try_scratch_mount started to
fail. For example:

$ ./check btrfs/131 btrfs/220
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 debian9 5.17.0-rc8-btrfs-next-114 (...)
MKFS_OPTIONS  -- /dev/sdc
MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

btrfs/131 2s ... - output mismatch (see .../results//btrfs/131.out.bad)
    --- tests/btrfs/131.out 2020-06-10 19:29:03.818519162 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//btrfs/131.out.bad (...)
    @@ -6,8 +6,6 @@
     Disabling free space cache and enabling free space tree
     free space tree is enabled
     Trying to mount without free space tree
    -mount failed
    -mount failed
     Mounting existing free space tree
     free space tree is enabled
    ...
    (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/131.out ...
btrfs/220 7s ... - output mismatch (see .../results//btrfs/220.out.bad)
    --- tests/btrfs/220.out 2020-10-16 23:13:46.802162554 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//btrfs/220.out.bad (...)
    @@ -1,2 +1,32 @@
     QA output created by 220
    +Option fragment=invalid should fail to mount
    +umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
    +Option nologreplay should fail to mount
    +umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
    +Option norecovery should fail to mount
    +umount: /home/fdmanana/btrfs-tests/scratch_1: not mounted.
    ...
    (Run 'diff -u /home/fdmanana/git/hub/xfstests/tests/btrfs/220.out ...
Ran: btrfs/131 btrfs/220
Failures: btrfs/131 btrfs/220
Failed 2 of 2 tests

The reason is that if _try_scratch_mount() fails to mount the filesystem,
we don't return the failure, instead we call _idmapped_mount(), which
can succeed and make _try_scratch_mount() return 0 (success). The same
happens for _test_mount(), however a quick search revealed no tests
currently relying on the return value of _test_mount().

So fix that by making _try_scratch_mount() return immediately if it gets
a mount failure. Also do the same for _test_mount().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Acked-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agofstests: test dirty pipe vulnerability issue of CVE-2022-0847
Zorro Lang [Mon, 11 Apr 2022 16:37:10 +0000 (00:37 +0800)]
fstests: test dirty pipe vulnerability issue of CVE-2022-0847

Test for the Dirty Pipe vulnerability (CVE-2022-0847) caused by an
uninitialized  "pipe_buffer.flags" variable. The bug cause a file
can be overwritten even if a user/process is not permitted to write
it. It's fixed by 9d2231c5d74e ("lib/iov_iter: initialize "flags" in
new pipe_buffer").

Cc: Max Kellermann <max.kellermann@ionos.com>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agofstests: replace hexdump with od command
Zorro Lang [Mon, 11 Apr 2022 16:37:09 +0000 (00:37 +0800)]
fstests: replace hexdump with od command

The "od" is one of the most fundamental commands in GNU/Linux and
most Unix-like systems. So we nearly always can count on it, don't
need to check if it's installed.

The "hexdump" isn't such fundamental as "od", some systems don't
install it by default. And as "od" nearly can replace all functions
of "hexdump", so let's use an unified command "od" to do the hexdump
job in fstests cases.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon: allow to run all tests on idmapped mounts
Christian Brauner [Thu, 7 Apr 2022 11:21:57 +0000 (13:21 +0200)]
common: allow to run all tests on idmapped mounts

In addition to the generic and filesystem-specific idmapped mount
testsuites that already exist upstream today add simple
infrastructure so any test can be run on idmapped mounts simply by
setting IDMAPPED_MOUNTS=true in the config file or section. The main
user for now will be overlay to verify it works correctly on
idmapped mounts.

Note that the infrastructure is completely generic so every
filesystem that supports idmapped mounts can simply run all of their
tests idmapped. But note that not all ways to create a mount have
been converted yet. That includes e.g. _dmthin_mount and direct
calls to _mount in various tests.

In addition, there will be corner-cases. For example, xfs doesn't
allow bulkstat on idmapped mounts because it is a filesystem wide
operation, i.e. you can retrieve information for any inode in the
filesystem so the operation cannot be scoped reasonably under a
single mount. So xfstests testing bulkstat will fail as it's
blocked. Similar for some btrfs ioctl()s.

While we could of course restrict this testmode to -overlay for
which we know things work correctly we should not do this. It would
mean that people won't start using it and so we won't see issues
unless someone sits down and goes through more than 1000 tests and
figures out for each individual one whether it needs to be skipped
or not.

So instead allow this mode but for all filesystems so people can
start running and reporting failures and we can fix them up or block
them as we detect them.

Cc: Eryu Guan <guaneryu@gmail.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: <fstests@vger.kernel.org>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/encrypt: allow the use of 'fscrypt:' as key prefix
Luís Henriques [Tue, 5 Apr 2022 09:46:33 +0000 (10:46 +0100)]
common/encrypt: allow the use of 'fscrypt:' as key prefix

fscrypt keys have used the $FSTYP as prefix.  However this format is being
deprecated and newer kernels are expected to use the generic 'fscrypt:'
prefix instead.  This patch adds support for this new prefix, and only
uses $FSTYP on filesystems that didn't initially supported it, i.e. ext4 and
f2fs.  This will allow old kernels to be tested.

Signed-off-by: Luís Henriques <lhenriques@suse.de>
Reviewed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agobtrfs: drop no-op count=$(( count-- ))
David Disseldorp [Wed, 30 Mar 2022 11:45:40 +0000 (13:45 +0200)]
btrfs: drop no-op count=$(( count-- ))

This line doesn't result in a changed count value. The tests don't
appear to rely on a decremented value, so remove the line.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agofsx: remove XFS_IOC_ALLOCSP operation entirely
Zorro Lang [Wed, 30 Mar 2022 05:25:06 +0000 (13:25 +0800)]
fsx: remove XFS_IOC_ALLOCSP operation entirely

Due to XFS_IOC_ALLOCSP is nearly retired from linux xfs, and the
ALLOCSP testing in fsx easily trigger errors. So compare with
disable it by default, I'd like to remove it entirely. So this patch
revert two patches:

cd99a499 ("fsx: disable allocsp_calls if -F is specified")
a32fb1bb ("fsx: add support for XFS_IOC_ALLOCSP")

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agobtrfs/237: Use zone cap instead of zone size in fill_size and rest calculation
Pankaj Raghav [Fri, 25 Mar 2022 10:19:08 +0000 (11:19 +0100)]
btrfs/237: Use zone cap instead of zone size in fill_size and rest calculation

This test will break when zone capacity != zone size because the
calculation of the size to be filled is done using zone_size instead
of the actual capacity available per zone. Fix it by using zone
capacity.

As a zoned device can have variable capacity, use the btrfs utility
to get the zone capacity from the first data block group that the
test will be performed on.

The support to extract zone capacity was added to blkzone only from
version 2.37. So zcap will be used only when the blkzone version is
greater or equal to 2.37.

Signed-off-by: Pankaj Raghav <p.raghav@samsung.com>
Reviewed-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agobtrfs/194: allow it to be run on systems with page size larger than 4K
Qu Wenruo [Tue, 8 Mar 2022 13:18:49 +0000 (21:18 +0800)]
btrfs/194: allow it to be run on systems with page size larger than 4K

Since btrfs has subpage support since v5.15, there is no need to
require such hard requirement on 4K page size.

We only need to check if the current system support 4K as
sectorsize.

Now the test case can pass on aarch64 with 64K page size.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agocommon/btrfs: don't skip the test if BTRFS_PROFILE_CONFIGS contains unsupported profile
Qu Wenruo [Tue, 8 Mar 2022 13:03:42 +0000 (21:03 +0800)]
common/btrfs: don't skip the test if BTRFS_PROFILE_CONFIGS contains unsupported profile

[BUG]
Sometimes the tester wants to use $BTRFS_PROFILE_CONFIGS to limit the
tests to certain profiles.

This is especially useful for btrfs subpage tests, as we don't yet
support RAID56 for it yet.

But unfortunately, if we specify $BTRFS_PROFILE_CONFIGS with the
following content:

 export BTRFS_PROFILE_CONFIGS="single:single dup:single raid0:raid0 \
       raid1:raid1 raid10:raid10"

A lot of tests will not run, like:

  btrfs/064 30s ... [not run] Profile dup not supported for replace
  btrfs/065 26s ... [not run] Profile dup not supported for replace
  btrfs/066 27s ...  14s
  btrfs/069 25s ... [not run] Profile dup not supported for replace
  btrfs/070 59s ... [not run] Profile dup not supported for replace
  btrfs/071 25s ... [not run] Profile dup not supported for replace

[CAUSE]
Those test cases uses _btrfs_get_profile_configs() to grab the profiles
which support given workload (like replace/repace-missing).

But _btrfs_get_profile_configs() will behave different based on whether
BTRFS_PROFILE_CONFIGS is defined.

If not defined, it goes with default profiles, and just skip those
unsupported.
This is what we want.

But if the environment variable is defined, it will not run if there is
any unsupported profile in it.

[FIX]
Unify the behaivor by always skip the unsupported profiles, no matter if
$BTRFS_PROFILE_CONFIGS is defined or not.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agoxfs/019: extend protofile test
Catherine Hoang [Thu, 17 Mar 2022 23:24:08 +0000 (23:24 +0000)]
xfs/019: extend protofile test

This test creates an xfs filesystem and verifies that the filesystem
matches what is specified by the protofile.

This patch extends the current test to check that a protofile can
specify setgid mode on directories. Also, check that the created
symlink isn’t broken.

Signed-off-by: Catherine Hoang <catherine.hoang@oracle.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Allison Henderson <allison.henderson@oracle.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agobtrfs/029: change the cross vfsmount reflink test
Josef Bacik [Thu, 24 Mar 2022 20:24:34 +0000 (16:24 -0400)]
btrfs/029: change the cross vfsmount reflink test

We now allow cross vfsmount reflinks, change this test to make sure
we pass the cross-vfsmount reflink.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/374: validate cross-vfsmount dedupe
Josef Bacik [Thu, 24 Mar 2022 20:24:33 +0000 (16:24 -0400)]
generic/374: validate cross-vfsmount dedupe

We allow for cross-vfsmount dedupes now, change this test to
validate dedupe works properly cross-vfsmount.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/373: change test to validate cross-vfsmount reflink
Josef Bacik [Thu, 24 Mar 2022 20:24:32 +0000 (16:24 -0400)]
generic/373: change test to validate cross-vfsmount reflink

We now allow cross-vfsmount reflinks so change the test to validate
that cross-vfsmount reflinks work.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/674: replace _require_scratch_reflink with _require_scratch_dedupe
Boyang Xue [Wed, 30 Mar 2022 06:03:39 +0000 (14:03 +0800)]
generic/674: replace _require_scratch_reflink with _require_scratch_dedupe

Signed-off-by: Boyang Xue <bxue@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/066: attr1 is still there after log replay on f2fs
Sun Ke [Wed, 23 Mar 2022 08:37:24 +0000 (16:37 +0800)]
generic/066: attr1 is still there after log replay on f2fs

The test fail on f2fs:
     xattr names and values after second fsync log replay:
     # file: SCRATCH_MNT/foobar
    +user.attr1="val1"
     user.attr3="val3"

attr1 is still there after log replay. f2fs doesn't support fs-op level
transaction functionality. so it have no way to persist all metadata
updates in one transaction.  We can use "fastboot" mountoption for this
case, so during last fsync on qwerty, f2fs can trigger a checkpoint
which will persist all metadata updates before fsync().

Suggested-by: Chao Yu <chao@kernel.org>
Signed-off-by: Sun Ke <sunke32@huawei.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/631: use trusted.* extended attributes to filter NFS filesystem
Dai Shili [Fri, 25 Mar 2022 20:04:12 +0000 (16:04 -0400)]
generic/631: use trusted.* extended attributes to filter NFS filesystem

Since commit 2461e8901c ("generic/631: Add a check for extended
attributes"), check of user.* extended attributes was added to avoid
running this tests for filesystems that are not supported.

But it still fails on NFSv4.2 when mount overlayfs with the
following error.

/var/mnt/scratch/merged0: wrong fs type, bad option, bad superblock
on overlay, missing codepage or helper program, or other error.

dmesg log reports the following -
overlayfs: upper fs does not support xattr, falling back to index=off and metacopy=off.

As per the linux patch series(https://lwn.net/Articles/799185/ ), the
support of user extended attributes were added to NFSv4.2.  So this
case passed the check of extended attributes by _require_attrs.

As per the overlayfs documentation -

"The upper filesystem will normally be writable and if it is it must
support the creation of trusted.* and/or user.* extended attributes,
and must provide valid d_type in readdir responses, so NFS is not
suitable."

So we can replace user.* extended attributes check with trusted.* to
filter NFS filesystem.

Signed-off-by: Dai Shili <daisl.fnst@fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
3 months agogeneric/108: use blockdev utility to calculate physical and logical block size
Nitesh Shetty [Wed, 23 Mar 2022 18:06:43 +0000 (23:36 +0530)]
generic/108: use blockdev utility to calculate physical and logical block size

Reading sysfs to get physical and logical block fails,
if SCRATCH_DEV is partitioned device.

Signed-off-by: Nitesh Shetty <nj.shetty@samsung.com>
Reported-by: Darrick J. Wong <djwong@kernel.org>
Reported-by: Wang Yugui <wangyugui@e16-tech.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agogeneric: fallocate against a file range with a mix of holes and extents
Filipe Manana [Thu, 17 Mar 2022 16:34:32 +0000 (16:34 +0000)]
generic: fallocate against a file range with a mix of holes and extents

Test that if we call fallocate against a file range that has a mix
of holes and written extents, the fallocate succeeds if the
filesystem has enough free space to allocate extents for the holes.

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

    "btrfs: only reserve the needed data space amount during fallocate"

The test also fails on xfs, and after some discussion with Darrick,
it seems it's due to technical reasons that would require a
significant effort to xfs's implementation, and at the moment there
isn't enough motivation to do such change. The relevent thread is at:

    https://lore.kernel.org/linux-btrfs/20220315164011.GF8241@magnolia/

Therefore the test is intentionally skipped on xfs only. Ext4 and
f2fs pass this test.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agocommon/encrypt: verify the key identifiers
Eric Biggers [Sun, 13 Mar 2022 01:05:59 +0000 (17:05 -0800)]
common/encrypt: verify the key identifiers

As part of all the ciphertext verification tests, verify that the
filesystem correctly computed the key identifier from the key the test
generated.  This uses fscrypt-crypt-util to compute the key identifier.

Previously this was only being tested indirectly, via the tests that
happen to use the hardcoded $TEST_RAW_KEY and $TEST_KEY_IDENTIFIER.
The new check provides better coverage.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agocommon/encrypt: log full ciphertext verification params
Eric Biggers [Sun, 13 Mar 2022 01:05:58 +0000 (17:05 -0800)]
common/encrypt: log full ciphertext verification params

To help with debugging, log some additional information to $seqres.full.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agofscrypt-crypt-util: add support for dumping key identifier
Eric Biggers [Sun, 13 Mar 2022 01:05:57 +0000 (17:05 -0800)]
fscrypt-crypt-util: add support for dumping key identifier

Add an option to fscrypt-crypt-util to make it compute the key
identifier for the given key.  This will allow testing the correctness
of the filesystem's key identifier computation.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agofscrypt-crypt-util: refactor get_key_and_iv()
Eric Biggers [Sun, 13 Mar 2022 01:05:56 +0000 (17:05 -0800)]
fscrypt-crypt-util: refactor get_key_and_iv()

Split get_key_and_iv() into two distinct parts: (1) deriving the key and
(2) generating the IV.  Also, check for the presence of needed options
just before they are used rather than doing it all up-front.

These changes should make this code much easier to understand.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agofscrypt-crypt-util: use an explicit --direct-key option
Eric Biggers [Sun, 13 Mar 2022 01:05:55 +0000 (17:05 -0800)]
fscrypt-crypt-util: use an explicit --direct-key option

Make fscrypt-crypt-util use an option --direct-key to specify the use of
the DIRECT_KEY method for key derivation and IV generation.  Previously,
this method was implicitly detected via --mode-num being given without
either --iv-ino-lblk-64 or --iv-ino-lblk-32, or --kdf=none being given
in combination with --file-nonce.

The benefit of this change is that it makes the various options to
fscrypt-crypt-util behave more consistently.  --direct-key,
--iv-ino-lblk-64, and --iv-ino-lblk-32 now all work similarly (they
select a key derivation and IV generation method); likewise, --mode-num,
--file-nonce, --inode-number, and --fs-uuid now all work similarly (they
provide information that key derivation and IV generation may need).

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agoxfs/17[013]: fix intermittent failures when filesystem metadata gets large
Darrick J. Wong [Wed, 16 Mar 2022 22:13:26 +0000 (15:13 -0700)]
xfs/17[013]: fix intermittent failures when filesystem metadata gets large

These tests check that the filestreams allocator never shares an AG
across multiple streams when there's plenty of space in the filesystem.
Recent increases in metadata overhead for newer features (e.g. bigger
logs due to reflink) can throw this off, so add another AG to the
formatted filesystem to encourage it to avoid the AG with the log.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 months agoxfs/076: only create files on the data device
Darrick J. Wong [Wed, 16 Mar 2022 22:12:32 +0000 (15:12 -0700)]
xfs/076: only create files on the data device

This test checks that filesystems with sparse inode support can continue
to allocate inodes when free space gets fragmented.  Inodes only exist
on the data device, so we need to ensure that realtime is not enabled on
the filesystem so that the rt metadata doesn't mess with the inode usage
percentage and cause a test failure.

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