]> git.apps.os.sepia.ceph.com Git - xfstests-dev.git/log
xfstests-dev.git
2 years agocommon/fuzzy: split out each repair strategy into a separate helper
Darrick J. Wong [Fri, 30 Dec 2022 22:19:40 +0000 (14:19 -0800)]
common/fuzzy: split out each repair strategy into a separate helper

Refactor __scratch_xfs_fuzz_field_test to split out each repair strategy
into a separate helper function.

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 agofuzzy: don't fuzz xattr namespace flags and values
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: don't fuzz xattr namespace flags and values

Extended attribute namespace flags are controlled by userspace, and
there is no validation imposed on the values.  Don't bother fuzzing
either of these things.

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 agofuzzy: don't fuzz user-controllable inode flags
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: don't fuzz user-controllable inode flags

Don't fuzz the inode flags that are controlled by userspace and don't
actually have any other effects on the ondisk metadata.

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 agofuzzy: don't fuzz inode generation numbers
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: don't fuzz inode generation numbers

The inode generation number is a randomly selected 32-bit integer that
isn't itself validated anywhere.  No need to fuzz that.

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 agofuzzy: don't fuzz obsolete inode fields
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: don't fuzz obsolete inode fields

We don't really care about inode fields were used in V4 (deprecated) or
DMAPI (unsupported) so don't bother fuzzing them.

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 agofuzzy: don't fuzz the log sequence number
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: don't fuzz the log sequence number

Don't bother filtering log sequence numbers since xfs_db doesn't have
the ability to tell us the range of LSNs that would actually cause
validation failures.

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 agofuzzy: disable timstamp fuzzing by default
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: disable timstamp fuzzing by default

Don't fuzz timestamps since all bit patterns are valid and XFS itself
does not perform any validation on them.

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 agofuzzy: disable per-field random fuzzing by default
Darrick J. Wong [Fri, 30 Dec 2022 22:19:39 +0000 (14:19 -0800)]
fuzzy: disable per-field random fuzzing by default

Don't run the random fuzzer by default so that we can try to stabilize
the output somewhat.

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 agopopulate: fix some weirdness in __populate_check_xfs_agbtree_height v2023.02.19
Darrick J. Wong [Fri, 30 Dec 2022 22:19:36 +0000 (14:19 -0800)]
populate: fix some weirdness in __populate_check_xfs_agbtree_height

Use a for loop to scan the AGs, and make all the variables local like
you'd expect them to be.

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 agopopulate: take a snapshot of the filesystem if creation fails
Darrick J. Wong [Fri, 30 Dec 2022 22:19:36 +0000 (14:19 -0800)]
populate: take a snapshot of the filesystem if creation fails

There have been a few bug reports filed about people not being able to
use the filesystem metadata population code to create filesystems with
all types of metadata on them.  Right now this is super-annoying to
debug because we don't capture a metadump for easy debugging.  Fix that.

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/422: don't freeze while racing rmap repair and fsstress
Darrick J. Wong [Fri, 30 Dec 2022 22:19:33 +0000 (14:19 -0800)]
xfs/422: don't freeze while racing rmap repair and fsstress

Since we're moving away from freezing the filesystem for rmap repair,
remove the freeze/thaw race from this test to make it more interesting.

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: race fsstress with online repair for summary counters
Darrick J. Wong [Fri, 30 Dec 2022 22:19:30 +0000 (14:19 -0800)]
xfs: race fsstress with online repair for summary counters

Create tests to race fsstress with fs summary counter repair while
running fsstress in the background.

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: test fs summary counter online repair
Darrick J. Wong [Fri, 30 Dec 2022 22:19:30 +0000 (14:19 -0800)]
xfs: test fs summary counter online repair

Fuzz the fs summary counters in the primary super and see if online
repair can fix them.

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: race fsstress with inode link count check and repair
Darrick J. Wong [Fri, 30 Dec 2022 22:19:27 +0000 (14:19 -0800)]
xfs: race fsstress with inode link count check and repair

Race fsstress with inode link count checking and repair.

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: race fsstress with online scrub and repair for quotacheck
Darrick J. Wong [Fri, 30 Dec 2022 22:19:24 +0000 (14:19 -0800)]
xfs: race fsstress with online scrub and repair for quotacheck

Create tests to race fsstress with quota count check and repair while
running fsstress in the background.

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: race fsstress with online scrub and repair for quota metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:21 +0000 (14:19 -0800)]
xfs: race fsstress with online scrub and repair for quota metadata

Create tests to race fsstress with dquot repair while running fsstress
in the background.

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: race fsstress with online repair for special file metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:18 +0000 (14:19 -0800)]
xfs: race fsstress with online repair for special file metadata

For each XFS_SCRUB_TYPE_* that looks at symbolic link and special file
metadata, create a test that runs that repairer in the foreground and
fsstress in the background.

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: ensure that online file data fork repairs don't hit EDQUOT
Darrick J. Wong [Fri, 30 Dec 2022 22:19:18 +0000 (14:19 -0800)]
xfs: ensure that online file data fork repairs don't hit EDQUOT

Add a test to ensure that the sysadmin doesn't get EDQUOT if they try to
repair file data fork metadata when we've already exceeded a quota limit
somewhere.

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: race fsstress with online repair for inode and fork metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:18 +0000 (14:19 -0800)]
xfs: race fsstress with online repair for inode and fork metadata

For each XFS_SCRUB_TYPE_* that looks at inode and data/attr/cow fork
metadata, create a test that runs that repairer in the foreground and
fsstress in the background.

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: test rebuilding xattrs when the data fork is btree format
Darrick J. Wong [Fri, 30 Dec 2022 22:19:18 +0000 (14:19 -0800)]
xfs: test rebuilding xattrs when the data fork is btree format

Make sure we handle the case of rebuilding extended attributes properly
when the data fork is in btree format and we therefore cannot zap the
attr fork.

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: race fsstress with online repair for inode record metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:15 +0000 (14:19 -0800)]
xfs: race fsstress with online repair for inode record metadata

Create a test that runs the inode record repairer in the foreground and
fsstress in the background.

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: stress test ag repair functions
Darrick J. Wong [Fri, 30 Dec 2022 22:19:12 +0000 (14:19 -0800)]
xfs: stress test ag repair functions

Race fsstress and various AG repair functions.

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: test rebuilding the entire filesystem with online fsck
Darrick J. Wong [Fri, 30 Dec 2022 22:19:12 +0000 (14:19 -0800)]
xfs: test rebuilding the entire filesystem with online fsck

Add a new knob, TEST_XFS_SCRUB_REBUILD, that makes it so that we use
xfs_scrub to rebuild the ondisk metadata after every test.

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 agofuzzy: use FORCE_REBUILD over injecting force_repair
Darrick J. Wong [Fri, 30 Dec 2022 22:19:09 +0000 (14:19 -0800)]
fuzzy: use FORCE_REBUILD over injecting force_repair

For stress testing online repair, try to use the FORCE_REBUILD ioctl
flag over the error injection knobs whenever possible because the knobs
are very noisy and are not always available.

[zlang: do not export the SCRUBSTRESS_USE_FORCE_REBUILD]

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 agogeneric/604: fix test to actually create dirty inodes
Filipe Manana [Thu, 16 Feb 2023 16:21:50 +0000 (16:21 +0000)]
generic/604: fix test to actually create dirty inodes

The test case generic/604 aims to test a scenario where at unmount time we
have many dirty inodes, however the test does not actually creates any
files, because it calls xfs_io without the -f argument, so xfs_io fails
but any error is ignored because stderr is redirected to /dev/null.

Fix this by passing -f to xfs_io and also stop redirecting stderr to
/dev/null, so that in case of any unexpected failure creating files, the
test fails.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: btrfs/249: add _wants_kernel_commit and _fixed_by_git_commit
Anand Jain [Fri, 17 Feb 2023 23:57:58 +0000 (07:57 +0800)]
fstests: btrfs/249: add _wants_kernel_commit and _fixed_by_git_commit

Add the _wants_kernel_commit tag for kernel and _fixed_by_git_commit tag
for the btrfs-progs for the benefit of testing on the older kernels and
the older btrfs-progs.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: btrfs/185, 198 and 219 add _fixed_by_kernel_commit
Anand Jain [Wed, 15 Feb 2023 07:51:22 +0000 (15:51 +0800)]
fstests: btrfs/185, 198 and 219 add _fixed_by_kernel_commit

Recently, these test cases were added to the auto group. To ensure we have
some clues if they fail in older kernels, add "_fixed_by_kernel_commit"
for the fix and update the test summary.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: test block group size class loading logic
Boris Burkov [Thu, 16 Feb 2023 15:47:18 +0000 (07:47 -0800)]
btrfs: test block group size class loading logic

Add a new test which checks that size classes in freshly loaded block
groups after a cycle mount match size classes before going down

Depends on the kernel patch:
btrfs: add size class stats to sysfs

Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs/011: use $_btrfs_profile_configs to limit the tests
An Long [Wed, 15 Feb 2023 05:13:19 +0000 (13:13 +0800)]
btrfs/011: use $_btrfs_profile_configs to limit the tests

Generally the tester need BTRFS_PROFILE_CONFIGS to test certain
profeils. For example, skip raid56 as it's not supported.

For dup profile, add dup to default profile configs.

Signed-off-by: An Long <lan@suse.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: add 080 to the auto and quick groups v2023.02.12
Christoph Hellwig [Thu, 9 Feb 2023 05:13:55 +0000 (06:13 +0100)]
xfs: add 080 to the auto and quick groups

xfs/080 is not dangerous, isn't a known fail and runs very quickly.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: add 251 to the auto group
Christoph Hellwig [Thu, 9 Feb 2023 05:13:54 +0000 (06:13 +0100)]
generic: add 251 to the auto group

generic/251 isn't dangerous, doesn't takes overly long to run and doesn't
produce spurious failures, so add it to the auto group.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: add 125 to the auto group
Christoph Hellwig [Thu, 9 Feb 2023 05:13:53 +0000 (06:13 +0100)]
generic: add 125 to the auto group

This test is not dangerous and passes reliably.  Add it to the auto
group.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: add 042 to the auto and quick groups
Christoph Hellwig [Thu, 9 Feb 2023 05:13:52 +0000 (06:13 +0100)]
generic: add 042 to the auto and quick groups

generic/042 was removed from the auto group in 2015 by commit
7721b8501608 ("generic/042: remove from the 'auto' group") because it
always failed on XFS and wasn't run for other file systems back then.
Since then XFS fixed the problem it reproduces, and ext4 and f2fs
have grown shutdown support and also pass it reliably.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.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 years agobtrfs: add 185 to the auto and quick groups
Christoph Hellwig [Thu, 9 Feb 2023 05:13:51 +0000 (06:13 +0100)]
btrfs: add 185 to the auto and quick groups

btrfs/185 runs in a second, add it to the auto and quick group.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: add 125 to the auto and quick groups
Christoph Hellwig [Thu, 9 Feb 2023 05:13:50 +0000 (06:13 +0100)]
btrfs: add 125 to the auto and quick groups

btrfs/125 runs in 5 seconds on my VM setup, and found a regression in a
recent series.  Add it to the auto and quick groups.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: add 198 to the auto group
Christoph Hellwig [Thu, 9 Feb 2023 05:13:49 +0000 (06:13 +0100)]
btrfs: add 198 to the auto group

The quick group should be a strict subset of the auto group, so add these
two tests that are in the quick group to the auto group as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon/xfs: use whole-word matching for _require_xfsrestore_xflag
Darrick J. Wong [Tue, 7 Feb 2023 17:00:12 +0000 (09:00 -0800)]
common/xfs: use whole-word matching for _require_xfsrestore_xflag

On my system, the path to the xfsrestore binary is:

/code/xfsdump/build-x86_64/restore/xfsrestore

The grep command in _require_xfsrestore_xflag matches on the "build-x86"
part, even though my version of xfsrestore does not actually have a -x
flag.  Fix the string parsing to match entire words so that we only look
for -x in the help output.

(Maybe someone should patch xfsrestore -h to report basename(argv[0])
instead of argv[0]...)

Fixes: 1ffa16c573 ("xfs: test for fixing wrong root inode number in dump")
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 agocommon: Chown mount even if already idmapped to account for remounts
Gabriel Niebler [Fri, 3 Feb 2023 17:54:37 +0000 (18:54 +0100)]
common: Chown mount even if already idmapped to account for remounts

This is a logical consequence of introducing the chown check in _idmapped_mount,
since now a read-only mount can be made idmapped successfully. But if the mount
is then remounted rw the chown never happens, as _idmapped_mount sees that it's
already idmapped and bows out early.

This patch fixes that by simply moving the chown ahead of the idmapped check,
so it will be performed in any case, even on already idmapped mounts.

Signed-off-by: Gabriel Niebler <gniebler@suse.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon: Do not chown ro mountpoint when creating idmapped mount
Gabriel Niebler [Fri, 3 Feb 2023 14:35:45 +0000 (15:35 +0100)]
common: Do not chown ro mountpoint when creating idmapped mount

The function _idmapped_mount tries to change the ownership of the mountpoint
for which it aims to create an idmapped mount, to ensure that the mapped UID
and GID can actually create objects within it. Some tests set up a read-only
mount, however, which lets the chown call fail. This patch fixes the
function to check whether the mount is read-only and skip the chown, if so.

Signed-off-by: Gabriel Niebler <gniebler@suse.com>
Reviewed-by: Christian Brauner <brauner@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: add a stress test for send v2 streams
Filipe Manana [Thu, 2 Feb 2023 15:58:09 +0000 (15:58 +0000)]
btrfs: add a stress test for send v2 streams

Currently we don't have any test case in fstests to do randomized and
stress testing of the send stream v2, added in kernel 6.0 and support for
it in btrfs-progs v5.19. For the send v2 stream, we only have btrfs/281
that exercises a specific scenario which used to trigger a bug.

So add a test that uses fsstress to generate a filesystem and exercise
both full and incremental send operations using the v2 send stream with
compressed extents, and then receive the streams without and with
decompression, to verify they work and produce the same results as in
the original filesystem. This is the same base idea as btrfs/007, but
for the send v2 stream with compressed data.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric/676: Unstable d_type handling for NFS READDIR
Benjamin Coddington [Thu, 2 Feb 2023 14:48:04 +0000 (09:48 -0500)]
generic/676: Unstable d_type handling for NFS READDIR

The NFS client may send READDIR or READDIRPLUS to populate the dentry
cache, and switch between them to optimize for least RPC calls based on the
process' behavior.  When using READDIR, dentries will have d_type =
DT_UNKNOWN but with READDIRPLUS d_type will be set from the mode.

This heuristic will cause generic/676 to fail when comparing dentries
cached from one or the other call, since we compare d_type directly. Fix
this by bypassing the comparison of d_type if any entry is loaded with
DT_UNKNOWN.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon: Improve blocksize support for udf
Jan Kara [Tue, 31 Jan 2023 12:39:59 +0000 (13:39 +0100)]
common: Improve blocksize support for udf

Add better support for blocksize selection in _scratch_mkfs_sized
(accept another variant of mkfs options, select correct default block
size if not specified). Also add blocksize selection support to
_scratch_mkfs_blocksized.

For _check_udf_filesystem to keep working when blocksize is not
specified in MKFS_OPTIONS, add detection of blocksize from a mounted
filesystem.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon: Unmount udf filesystem prior checking
Jan Kara [Tue, 31 Jan 2023 12:39:58 +0000 (13:39 +0100)]
common: Unmount udf filesystem prior checking

_check_udf_filesystem forgot to unmount the filesystem prior to checking
it. That was leading to check failures.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon: Provide blocksize and ecclength to udf fsck
Jan Kara [Tue, 31 Jan 2023 12:39:57 +0000 (13:39 +0100)]
common: Provide blocksize and ecclength to udf fsck

udf_test program used for verifying filesystem is not able to determine
filesystem blocksize. Provide it in the options together with disabling
ecclength as it is not used on harddrives.

Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agocommon/btrfs: avoid reinitialization of unsupported profile array
David Disseldorp [Wed, 11 Jan 2023 10:58:27 +0000 (11:58 +0100)]
common/btrfs: avoid reinitialization of unsupported profile array

The _btrfs_get_profile_configs() unsupported array doesn't change
between configs, so avoid reinitializing it on each loop iteration.

Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: race fsstress with online scrubbers for file metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:06 +0000 (14:19 -0800)]
xfs: race fsstress with online scrubbers for file metadata

For each XFS_SCRUB_TYPE_* that looks at file metadata, create a test
that runs that scrubber in the foreground and fsstress in the
background.

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 agofuzzy: allow xfs scrub stress tests to pick preconfigured fsstress configs
Darrick J. Wong [Fri, 30 Dec 2022 22:19:06 +0000 (14:19 -0800)]
fuzzy: allow xfs scrub stress tests to pick preconfigured fsstress configs

Make it so that xfs_scrub stress tests can select what kind of fsstress
operations they want to run.  This will make it easier for, say,
directory scrubbers to configure fsstress to exercise directory tree
changes while skipping file data updates, because those are irrelevant.

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 agofuzzy: add a custom xfs find utility for scrub stress tests
Darrick J. Wong [Tue, 7 Feb 2023 17:01:41 +0000 (09:01 -0800)]
fuzzy: add a custom xfs find utility for scrub stress tests

Create a new find(1) like utility that doesn't crash on directory tree
changes (like find does due to bugs in its loop detector) and actually
implements the custom xfs attribute predicates that we need for scrub
stress tests.  This program will be needed for a future patch where we
add stress tests for scrub and repair of file metadata.

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: race fsstress with online scrubbers for AG and fs metadata
Darrick J. Wong [Fri, 30 Dec 2022 22:19:06 +0000 (14:19 -0800)]
xfs: race fsstress with online scrubbers for AG and fs metadata

For each XFS_SCRUB_TYPE_* that looks at AG or filesystem metadata,
create a test that runs that scrubber in the foreground and fsstress in
the background.

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/357: switch fuzzing to agi 1
Darrick J. Wong [Fri, 30 Dec 2022 22:19:06 +0000 (14:19 -0800)]
xfs/357: switch fuzzing to agi 1

Since we now require a working AGI 0 to mount the system, fuzz AGI 1
instead.

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/191: fix xattr leaf block emptying on 64k blocksized fses v2023.02.05
Anthony Iliopoulos [Fri, 3 Feb 2023 17:47:44 +0000 (18:47 +0100)]
xfs/191: fix xattr leaf block emptying on 64k blocksized fses

This test is failing on filesystems with 64k blocksize since the leaf
hdr.firstused field is 16 bit and as such trying to reset it to $dbsize
overflows and is rejected by xfs_db. The leaf is never properly resetted
and the discrepancy is picked up by xfs_repair, thus failing the test.

Fix it by setting it to XFS_ATTR3_LEAF_NULLOFF (0) as this is the proper
on-disk value to indicate an empty leaf on 64k blocksized fses.

Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Anthony Iliopoulos <ailiop@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: aiodio_sparse2.c, fix compiler warning buffer overflow
Anand Jain [Sun, 29 Jan 2023 02:42:33 +0000 (10:42 +0800)]
fstests: aiodio_sparse2.c, fix compiler warning buffer overflow

The warning is due to 'strncpy' with a maximum number of characters
equal to the destination buffer size, without space for null termination.

aiodio_sparse2.c: In function 'main':
aiodio_sparse2.c:404:9: warning: 'strncpy' specified bound 4096 equals destination size [-Wstringop-truncation]
  404 |         strncpy(filename, argv[argc-1], PATH_MAX);

However, PATH_MAX is including null termination at the end. Anyways, fix
warning by setting NULL.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: t_getcwd.c, fix a warning related to buffer overflow
Anand Jain [Sun, 29 Jan 2023 02:42:32 +0000 (10:42 +0800)]
fstests: t_getcwd.c, fix a warning related to buffer overflow

GCC reports warning related to 'strncpy' and its specified bound being
equal to the destination buffer size.

t_getcwd.c: In function 'do_rename':
t_getcwd.c:40:2: warning: 'strncpy' specified bound 256 equals destination size [-Wstringop-truncation]
  strncpy(c_name, prefix, BUF_SIZE);

A buffer overflow is unlikely here because the only caller for
do_rename() sends a 16 char long %prefix and BUF_SIZE is defined as 256.

The change is made to reduce the buffer length in order to silence
compilation warning.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: fstest.c, fix compile warnings replace sprintf with snprintf
Anand Jain [Sun, 29 Jan 2023 02:42:31 +0000 (10:42 +0800)]
fstests: fstest.c, fix compile warnings replace sprintf with snprintf

Fixes the buffer overflow warnings, by using snprintf instead of
sprintf.

fstest.c:95:20: warning: '/file' directive writing 5 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  sprintf(fname, "%s/file%d", dir, fnum);
                    ^~~~~
fstest.c:166:20: warning: '/file' directive writing 5 bytes into a region of size between 1 and 1024 [-Wformat-overflow=]
  sprintf(fname, "%s/file%d", dir, fnum);

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agofstests: doio.c, fix missing initialization of -C arg
Anand Jain [Sun, 29 Jan 2023 02:42:30 +0000 (10:42 +0800)]
fstests: doio.c, fix missing initialization of -C arg

Resolves GCC warnings on null values for %tok.

doio.c: In function 'parse_cmdline':
doio.c:3113:33: warning: '%s' directive argument is null [-Wformat-overflow=]
3113 | fprintf(stderr,
     | ^~~~~~~~~~~~~~~
3114 | "%s:  Illegal -C arg (%s).  Must be one of: ",
     | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3115 | Prog, tok);
     | ~~~~~~~~~~

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric/500: skip this test if formatting fails
Darrick J. Wong [Wed, 1 Feb 2023 00:51:40 +0000 (16:51 -0800)]
generic/500: skip this test if formatting fails

This testcase exercises what happens when we race a filesystem
perforing discard operations against a thin provisioning device that has
run out of space.  To constrain runtime, it creates a 128M thinp volume
and formats it.

However, if that initial format fails because (say) the 128M volume is
too small, then the test fails.  This is really a case of test
preconditions not being satisfied, so let's make the test _notrun when
this happens.

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 agogeneric/038: set a maximum runtime on this test
Darrick J. Wong [Wed, 1 Feb 2023 00:51:35 +0000 (16:51 -0800)]
generic/038: set a maximum runtime on this test

This test races multiple FITRIM calls against multiple programs creating
200k small files to ensure that there are no concurrency problems with
the allocator and the FITRIM code.  This is not necessarily quick, and
the test itself does not contain any upper bound on the runtime.  On my
system that simulates storage with DRAM this takes ~5 minutes to run; on
my cloud system with newly provided discard support, I killed the test
after 27 hours.

Constrain the runtime to about the customary 30s * TIME_FACTOR.

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 agogeneric/707: Test moving directory while being grown
Jan Kara [Tue, 31 Jan 2023 12:54:16 +0000 (13:54 +0100)]
generic/707: Test moving directory while being grown

Test how the filesystem can handle moving a directory to a different
directory (so that parent pointer gets updated) while it is grown. Ext4
and UDF had a bug where if the directory got converted to a different
type due to growth while rename is running, the filesystem got
corrupted.

Reviewed-by: Bill O'Donnell <bodonnel@redhat.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: test xfsrestore on multi-level dumpfiles with wrong root
Hironori Shiina [Mon, 30 Jan 2023 22:56:43 +0000 (17:56 -0500)]
xfs: test xfsrestore on multi-level dumpfiles with wrong root

While developing `xfsrestore -x`, we hit an issue at restoring a
renamed file in the cumulative mode (multi-level dumps):
  https://lore.kernel.org/linux-xfs/e61ae295-a331-d36a-cae1-646022dc2a6e@gmail.com/
Then, this patch adds test cases where '-x' flag is used in the
cumulative mode with various file operations referring to existing tests.

Signed-off-by: Hironori Shiina <shiina.hironori@fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: add helper to create fake root inode
Hironori Shiina [Mon, 30 Jan 2023 22:56:42 +0000 (17:56 -0500)]
xfs: add helper to create fake root inode

xfsdump used to cause a problem when there is an inode whose number is
lower than the root inode number. This patch adds a helper function to
reproduce such a situation for regression tests.

Signed-off-by: Hironori Shiina <shiina.hironori@fujitsu.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: test send optimal cloning behaviour
Filipe Manana [Wed, 25 Jan 2023 11:07:54 +0000 (11:07 +0000)]
btrfs: test send optimal cloning behaviour

Test that send operations do the best cloning decisions when we have
extents that are shared but some files refer to the full extent while
others refer to only a section of the extent.

This exercises an optimization that was added to kernel 6.2, by the
following commit:

  c7499a64dcf6 ("btrfs: send: optimize clone detection to increase extent sharing")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs/299: update kernel commit hash and subject
Filipe Manana [Wed, 25 Jan 2023 11:07:39 +0000 (11:07 +0000)]
btrfs/299: update kernel commit hash and subject

Test case btrfs/299 refers to a kernel patch with a subject of:

   "btrfs: fix logical_ino ioctl panic"

However when the patch was merged, the subject was renamed to:

   "btrfs: fix resolving backrefs for inline extent followed by prealloc"

So update the test with the correct subject and also add the commit's
hash from Linus' tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfstests: add fuse support v2023.01.22
Miklos Szeredi [Wed, 4 Jan 2023 19:39:33 +0000 (20:39 +0100)]
xfstests: add fuse support

This allows using any fuse filesystem that can be mounted with

  mount -t fuse$FUSE_SUBTYP ...

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Signed-off-by: Jakob Unterwurzacher <jakobunt@gmail.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agopopulate: improve attr creation runtime
Darrick J. Wong [Wed, 18 Jan 2023 00:44:18 +0000 (16:44 -0800)]
populate: improve attr creation runtime

Replace the file creation loops with a python script that does
everything we want from a single process.  This reduces the runtime of
_scratch_xfs_populate substantially by avoiding thousands of execve
overhead.  This patch builds on the previous one by reducing the runtime
of xfs/349 from ~45s to ~15s.

For people who don't have python3, use setfattr's "restore" mode to bulk
create xattrs.  This reduces runtime to about ~25s.

[zlang: add popattr.py into src/Makefile install list]

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 agopopulate: remove file creation loops that take forever
Darrick J. Wong [Wed, 18 Jan 2023 00:44:02 +0000 (16:44 -0800)]
populate: remove file creation loops that take forever

Replace the file creation loops with a perl script that does everything
we want from a single process.  This reduces the runtime of
_scratch_xfs_populate substantially by avoiding thousands of execve
overhead.  On my system, this reduces the runtime of xfs/349 (with scrub
enabled) from ~140s to ~45s.

[zlang: add popdir.pl into src/Makefile install list]

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 agopopulate: ensure btree directories are created reliably
Dave Chinner [Wed, 18 Jan 2023 00:43:47 +0000 (16:43 -0800)]
populate: ensure btree directories are created reliably

The population function creates an XFS btree format directory by
polling the extent count of the inode and creating new dirents until
the extent count goes over the limit that pushes it into btree
format.

It then removes every second dirent to create empty space in the
directory data to ensure that operations like metadump with
obfuscation can check that they don't leak stale data from deleted
dirents.

Whilst this does not result in directory data blocks being freed, it
does not take into account the fact that the dabtree index has half
the entries removed from it and that can result in btree nodes
merging and extents being freed. This causes the extent count to go
down, and the inode is converted back into extent form. The
population checks then fail because it should be in btree form.

Fix this by counting the number of directory data extents rather than
the total number of extents in the data fork. We can do this simply
by using xfs_bmap and counting the number of extents returned as it
does not report extents beyond EOF (which is where the dabtree is
located). As the number of data blocks does not change with the
dirent removal algorithm used, this will ensure that the inode data
fork remains in btree format.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
[djwong: make this patch first in line]
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agovarious: test is not appropriate for always_cow mode
Darrick J. Wong [Wed, 18 Jan 2023 00:43:31 +0000 (16:43 -0800)]
various: test is not appropriate for always_cow mode

When always_cow mode is enabled, thes tests cannot set up the
preconditions for the functionality that they wants to test and should
be skipped.

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/{080,329,434,436}: add missing check for fallocate support
Darrick J. Wong [Wed, 18 Jan 2023 00:43:16 +0000 (16:43 -0800)]
xfs/{080,329,434,436}: add missing check for fallocate support

Don't run this test if the filesystem doesn't support fallocate.  This
is only ever the case if always_cow is enabled.

The same logic applies to xfs/329, though it's more subtle because the
test itself does not explicitly invoke fallocate; rather, it is xfs_fsr
that requires fallocate.

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: skip fragmentation tests when alwayscow mode is enabled
Darrick J. Wong [Wed, 18 Jan 2023 00:43:00 +0000 (16:43 -0800)]
xfs: skip fragmentation tests when alwayscow mode is enabled

If the always_cow debugging flag is enabled, all file writes turn into
copy writes.  This dramatically ramps up fragmentation in the filesystem
(intentionally!) so there's no point in complaining about fragmentation.

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/182: fix spurious direct write failure
Darrick J. Wong [Wed, 18 Jan 2023 00:42:44 +0000 (16:42 -0800)]
xfs/182: fix spurious direct write failure

This test has some weird behavior that causes regressions when fsdax and
reflink are enabled.  The goal of this test is to set a cow extent size
hint, perform some random directio writes, perform a directio rewrite of
the entire file, and make sure that the file content (and extent count)
are sane afterwards.

Most of the time, the random directio writes will never touch the
8388609th byte, though if they do randomly select that EOF block, they'd
end up extending the file by $real_blksz bytes and causing spurious test
failures.

Then, the rewrite does this:

pwrite -S 0x63 -b $real_blksz 0 $((filesize + 1))

Note that we previously set filesize=8388608, which means that we're
asking for a series of direct writes that fill the first 8388608 bytes
with 'c'.  The last write in the series becomes a single byte direct
write.  For regular file access mode, this last write will fail with
EINVAL, since block devices do not support byte granularity writes and
XFS does not fall back to the pagecache for unaligned direct wites.
Hence we never wrote the 8388609th byte of the file.

However, fsdax *does* allow byte-granularity direct writes, which means
that the single-byte write succeeds.  There is no EINVAL return code,
and the 8388609th byte of the file is now 'c' instead of 'a'.  As a
result, the md5 of file2 is different.

Since fsdax+reflink is the newcomer, amend the direct writes in this
test so that they always end at the 8388608th byte, since we were never
really testing that last byte anyway.  This makes the test behavior
consistent across both access modes.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: fix reflink test failures when dax is enabled
Darrick J. Wong [Wed, 18 Jan 2023 00:42:29 +0000 (16:42 -0800)]
xfs: fix reflink test failures when dax is enabled

Turn off reflink tests that require delayed allocation to work, because
we don't use delayed allocation when fsdax mode is turned on.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: fix dax inode flag test failures
Darrick J. Wong [Wed, 18 Jan 2023 00:42:13 +0000 (16:42 -0800)]
xfs: fix dax inode flag test failures

Filter out the DAX inode flag because it's causing problems with this
test.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Xiao Yang <yangx.jy@fujitsu.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric/692: generalize the test for non-4K Merkle tree block sizes
Ojaswin Mujoo [Wed, 11 Jan 2023 20:58:28 +0000 (12:58 -0800)]
generic/692: generalize the test for non-4K Merkle tree block sizes

Due to the assumption of the Merkle tree block size being 4K, the file
size calculated for the second test case was taking way too long to hit
EFBIG in case of larger block sizes like 64K.  Fix this by generalizing
the calculation to any Merkle tree block size >= 1K.

Signed-off-by: Ojaswin Mujoo <ojaswin@linux.ibm.com>
Co-developed-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: update setgid tests
Christian Brauner [Thu, 5 Jan 2023 14:53:36 +0000 (15:53 +0100)]
generic: update setgid tests

Over mutiple kernel releases we have reworked setgid inheritance
significantly due to long-standing security issues, security issues that
were reintroduced after they were fixed, and the subtle and difficult
inheritance rules that plagued individual filesystems. We have lifted
setgid inheritance into the VFS proper in earlier patches. Starting with
kernel v6.2 we have made setgid inheritance consistent between the write
and setattr (ch{mod,own}) paths.

The gist of the requirement is that in order to inherit the setgid bit
the user needs to be in the group of the file or have CAP_FSETID in
their user namespace. Otherwise the setgid bit will be dropped
irregardless of the file's executability. Remove the obsolete tests as
they're not a security issue and will cause spurious warnings on older
distro kernels.

Note, that only with v6.2 setgid inheritance works correctly for
overlayfs in the write path. Before this the setgid bit was always
retained.

Link: https://lore.kernel.org/linux-ext4/CAOQ4uxhmCgyorYVtD6=n=khqwUc=MPbZs+y=sqt09XbGoNm_tA@mail.gmail.com
Link: https://lore.kernel.org/linux-fsdevel/20221212112053.99208-1-brauner@kernel.org
Link: https://lore.kernel.org/linux-fsdevel/20221122142010.zchf2jz2oymx55qi@wittgenstein
Cc: Amir Goldstein <amir73il@gmail.com>
Cc: Zorro Lang <zlang@redhat.com>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agoxfs: stress test xfs_scrub(8) with freeze and ro-remount loops v2023.01.15
Darrick J. Wong [Fri, 30 Dec 2022 22:13:00 +0000 (14:13 -0800)]
xfs: stress test xfs_scrub(8) with freeze and ro-remount loops

Make sure we don't trip over any asserts or livelock when scrub races
with filesystem freezing and readonly remounts.

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: stress test xfs_scrub(8) with fsstress
Darrick J. Wong [Fri, 30 Dec 2022 22:13:00 +0000 (14:13 -0800)]
xfs: stress test xfs_scrub(8) with fsstress

Port the two existing tests that check that xfs_scrub(8) (aka the main
userspace driver program) doesn't clash with fsstress to use our new
framework.

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: race fsmap with readonly remounts to detect crash or livelock
Darrick J. Wong [Fri, 30 Dec 2022 22:12:58 +0000 (14:12 -0800)]
xfs: race fsmap with readonly remounts to detect crash or livelock

Add a new test that races the GETFSMAP ioctl with ro/rw remounting to
make sure we don't livelock on the empty transaction that fsmap uses to
avoid deadlocking on rmap btree cycles.

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 agofuzzy: refactor fsmap stress test to use our helper functions
Darrick J. Wong [Fri, 30 Dec 2022 22:12:58 +0000 (14:12 -0800)]
fuzzy: refactor fsmap stress test to use our helper functions

Refactor xfs/517 (which races fsstress with fsmap) to use our new
control loop functions instead of open-coding everything.

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 agofuzzy: enhance scrub stress testing to use fsx
Darrick J. Wong [Thu, 5 Jan 2023 18:28:57 +0000 (10:28 -0800)]
fuzzy: enhance scrub stress testing to use fsx

Add a couple of new online fsck stress tests that race fsx against
online fsck.

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 agofuzzy: delay the start of the scrub loop when stress-testing scrub
Darrick J. Wong [Fri, 30 Dec 2022 22:12:55 +0000 (14:12 -0800)]
fuzzy: delay the start of the scrub loop when stress-testing scrub

By default, online fsck stress testing kicks off the loops for fsstress
and online fsck at the same time.  However, in certain debugging
scenarios it can help if we let fsstress get a head-start in filling up
the filesystem.  Plumb in a means to delay the start of the scrub loop.

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 agofuzzy: allow substitution of AG numbers when configuring scrub stress test
Darrick J. Wong [Fri, 30 Dec 2022 22:12:55 +0000 (14:12 -0800)]
fuzzy: allow substitution of AG numbers when configuring scrub stress test

Allow the test program to use the metavariable '%agno%' when passing
scrub commands to the scrub stress loop.  This makes it easier for tests
to scrub or repair every AG in the filesystem without a lot of work.

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 agofuzzy: make freezing optional for scrub stress tests
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: make freezing optional for scrub stress tests

Make the freeze/thaw loop optional, since that's a significant change in
behavior if it's enabled.

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 agofuzzy: clean up frozen fses after scrub stress testing
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: clean up frozen fses after scrub stress testing

Some of our scrub stress tests involve racing scrub, fsstress, and a
program that repeatedly freeze and thaws the scratch filesystem.  The
current cleanup code suffers from the deficiency that it doesn't
actually wait for the child processes to exit.  First, change it to do
that.

However, that exposes a second problem: there's a race condition with a
freezer process that leads to the stress test exiting with a frozen fs.
If the freezer process is blocked trying to acquire the unmount or
sb_write locks, the receipt of a signal (even a fatal one) doesn't cause
it to abort the freeze.  This causes further problems with fstests,
since ./check doesn't expect to regain control with the scratch fs
frozen.

Fix both problems by making the cleanup function smarter.

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 agofuzzy: increase operation count for each fsstress invocation
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: increase operation count for each fsstress invocation

For online fsck stress testing, increase the number of filesystem
operations per fsstress run to 2 million, now that we have the ability
to kill fsstress if the user should push ^C to abort the test early.
This should guarantee a couple of hours of continuous stress testing in
between clearing the scratch filesystem.

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 agofuzzy: clear out the scratch filesystem if it's too full
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: clear out the scratch filesystem if it's too full

If the online fsck stress tests run for long enough, they'll fill up the
scratch filesystem completely.  While it is interesting to test repair
functionality on a *nearly* full filesystem undergoing a heavy workload,
a totally full filesystem is really only exercising the ENOSPC handlers
in the kernel.  That's not what we came here to test, so change the
fsstress loop to detect a nearly full filesystem and erase everything
before starting fsstress again.

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 agofuzzy: abort scrub stress testing if the scratch fs went down
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: abort scrub stress testing if the scratch fs went down

There's no point in continuing a stress test of online fsck if the
filesystem goes down.  We can't query that kind of state directly, so as
a proxy we try to stat the mountpoint and interpret any error return as
a sign that the fs is down.

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 agofuzzy: make scrub stress loop control more robust
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: make scrub stress loop control more robust

Currently, each of the scrub stress testing background threads
open-codes logic to decide if it should exit the loop.  This decision is
based entirely on TIME_FACTOR*30 seconds having gone by, which means
that we ignore external factors, such as the user pressing ^C, which (in
theory) will invoke cleanup functions to tear everything down.

This is not a great user experience, so refactor the loop exit test into
a helper function and establish a sentinel file that must be present to
continue looping.  If the user presses ^C, the cleanup function will
remove the sentinel file and kill the background thread children, which
should be enough to stop everything more or less immediately.

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 agofuzzy: test the scrub stress subcommands before looping
Darrick J. Wong [Fri, 30 Dec 2022 22:12:54 +0000 (14:12 -0800)]
fuzzy: test the scrub stress subcommands before looping

Before we commit to running fsstress and scrub commands in a loop for
some time, we should check that the provided commands actually work on
the scratch filesystem.  The _require_xfs_io_command predicate only
detects the presence of the scrub ioctl, not any particular subcommand.

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 agofuzzy: give each test local control over what scrub stress tests get run
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
fuzzy: give each test local control over what scrub stress tests get run

Now that we've hoisted the scrub stress code to common/fuzzy, introduce
argument parsing so that each test can specify what they want to test.

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 agofuzzy: explicitly check for common/inject in _require_xfs_stress_online_repair
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
fuzzy: explicitly check for common/inject in _require_xfs_stress_online_repair

In _require_xfs_stress_online_repair, make sure that the test has
sourced common/inject before we try to call its functions.

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 agofuzzy: rework scrub stress output filtering
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
fuzzy: rework scrub stress output filtering

Rework the output filtering functions for scrub stress tests: first, we
should use _filter_scratch to avoid leaking the scratch fs details to
the output.  Second, for scrub and repair, change the filter elements to
reflect outputs that don't indicate failure (such as busy resources,
preening requests, and insufficient space to do anything).  Finally,
change the _require function to check that filter functions have been
sourced.

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 agofuzzy: clean up scrub stress programs quietly
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
fuzzy: clean up scrub stress programs quietly

In the cleanup function for online fsck stress test common code, send
SIGINT instead of SIGTERM to the fsstress and xfs_io processes to kill
them.  bash prints 'Terminated' to the golden output when children die
with SIGTERM, which can make a test fail, and we don't want a regular
cleanup function being the thing that prevents the test from passing.

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/422: rework feature detection so we only test-format scratch once
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
xfs/422: rework feature detection so we only test-format scratch once

Rework the feature detection in the one online fsck stress test so that
we only format the scratch device twice per test run.

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/422: move the fsstress/freeze/scrub racing logic to common/fuzzy
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
xfs/422: move the fsstress/freeze/scrub racing logic to common/fuzzy

Hoist all this code to common/fuzzy in preparation for making this code
more generic so that we implement a variety of tests that check the
concurrency correctness of online fsck.  Do just enough renaming so that
we don't pollute the test program's namespace; we'll fix the other warts
in subsequent patches.

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/422: create a new test group for fsstress/repair racers
Darrick J. Wong [Fri, 30 Dec 2022 22:12:53 +0000 (14:12 -0800)]
xfs/422: create a new test group for fsstress/repair racers

Create a new group for tests that race fsstress with online filesystem
repair, and add this to the dangerous_online_repair group too.

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 agocommon/rc: drop SGI DMF specific _mount_ops_filter
David Disseldorp [Tue, 10 Jan 2023 22:22:43 +0000 (23:22 +0100)]
common/rc: drop SGI DMF specific _mount_ops_filter

The _mount() helper function is the only caller of _mount_ops_filter(),
which appears to have been used in the past to replace the SGI DMF
specific mtpt= mount option setting.

_mount() invocations could now be replaced with $MOUNT_PROG calls
directly, but I've retained the helper function for readability.

Link: https://irix7.com/techpubs/007-3683-007.pdf
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agogeneric: test lseek with seek data mode on a one byte file
Filipe Manana [Mon, 9 Jan 2023 10:34:15 +0000 (10:34 +0000)]
generic: test lseek with seek data mode on a one byte file

Test that seeking for data on a 1 byte file works correctly, the returned
offset should be 0 if the start offset is 0.

This is a regression test motivated by a btrfs bug introduced in kernel
6.1, which got recently fixed by the following kernel commit:

  2f2e84ca6066 ("btrfs: fix off-by-one in delalloc search during lseek")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs/012: check if ext4 is available
Johannes Thumshirn [Tue, 10 Jan 2023 15:52:16 +0000 (07:52 -0800)]
btrfs/012: check if ext4 is available

btrfs/012 is requiring ext4 support to test the conversion, but the test
case is only checking if mkfs.ext4 is available, not if the filesystem
driver is actually available on the test host.

Check if the driver is available as well, before trying to run the test.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agobtrfs: add a test case to verify scrub speed throttle works
Qu Wenruo [Thu, 5 Jan 2023 07:18:19 +0000 (15:18 +0800)]
btrfs: add a test case to verify scrub speed throttle works

We introduced scrub speed throttle in commit eb3b50536642 ("btrfs: scrub:
per-device bandwidth control"),  but it is not that well documented
(e.g. what's the unit of the sysfs interface), nor tested by any test
case.

This patch will add a test case for this functionality.

The test case itself is pretty straightforward:

- Fill the fs with 2G file as scrub workload
- Scrub without any throttle to grab the initial speed
- Set the throttle to half of the initial speed
- Scrub again and check the speed against the throttle

The test case has an assumption that we can exclusively use all the
performance of the underlying disk.
But for cloud environment it's not ensured 100%, thus the test case is
not included in auto group to avoid false alerts.

[zlang: add auto group, remove useless comments]

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oralce.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
2 years agooverlay: avoid to use NULL OVL_BASE_FSTYP for mounting
Baokun Li [Thu, 29 Dec 2022 13:44:34 +0000 (21:44 +0800)]
overlay: avoid to use NULL OVL_BASE_FSTYP for mounting

Generally, FSTYP is used to specify OVL_BASE_FSTYP. When we specify FSTYP
through an environment variable, it is not converted to OVL_BASE_FSTYP.
In addition, sometimes we do not even specify the file type. For example,
we only use `./check -n -overlay -g auto` to list overlay-related cases.
If OVL_BASE_FSTYP is NULL, mounting fails and the test fails.

To solve this problem, try to assign a value to OVL_BASE_FSTYP when
specifying -overlay. In addition, in the _overlay_base_mount function,
the basic file system type of the overlay is specified only when
OVL_BASE_FSTYP is not NULL.

Reported-by: Murphy Zhou <jencce.kernel@gmail.com>
Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>