xfstests-dev.git
5 years agofsstress: fix compiler warnings
Darrick J. Wong [Fri, 7 Dec 2018 06:23:18 +0000 (22:23 -0800)]
fsstress: fix compiler warnings

Fix all the gcc warnings in fsstress, and resize buffers to avoid
overflows.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstest: CrashMonkey 'hard link' tests ported to xfstest
Jayashree [Tue, 20 Nov 2018 23:51:04 +0000 (17:51 -0600)]
fstest: CrashMonkey 'hard link' tests ported to xfstest

This patch aims to add more tests to the xfstest suite to check
whether the target file system recovers correctly after a crash.
These test cases are generated by CrashMonkey, a
crash-consistency testing framework built at the SASLab at UT Austin.

This patch batches 37 crash-consistency tests into a xfstest test,
each of which checks the hard link behavior under different scenarios.
This test creates hard-links between files in the same directory or
across directories, while allowing fsync of either the files involved,
their parent directories, or unrelated sibling files. After each sub
test, the metadata of the persisted file is checked for the correct
link count. Additionally, each sub test is followed by fsck to check
for inconsistencies. The tests run on a 256MB file system, and
the working directory is cleaned up after every sub test.

Signed-off-by: Jayashree Mohan <jaya@cs.utexas.edu>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/002: Fix obsolete TEST_DEV/TEST_DIR in _check_ext4_eof_flag()
Xiao Yang [Thu, 29 Nov 2018 07:15:32 +0000 (15:15 +0800)]
ext4/002: Fix obsolete TEST_DEV/TEST_DIR in _check_ext4_eof_flag()

Commit 6b06a9bb6fb0 has used SCRATCH_DEV/SCRATCH_MNT rather than
TEST_DEV/TEST_DIR for holding the test files, so we need to use
SCRATCH_DEV/SCRATCH_MNT in _check_ext4_eof_flag() as well.

Fixes: 6b06a9bb6fb0 ("ext4/002: Work with 64k block size")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/021: Work with 64k block size
Chandan Rajendra [Fri, 23 Nov 2018 05:59:30 +0000 (11:29 +0530)]
ext4/021: Work with 64k block size

For 64k blocksize, 10MiB as the filesystem size isn't sufficient to have
a journal included. Hence this commit computes the test FS size based on
the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/002: Work with 64k block size
Chandan Rajendra [Fri, 23 Nov 2018 05:59:29 +0000 (11:29 +0530)]
ext4/002: Work with 64k block size

This commit changes the script to operate on FS blocks by obtaining the
block size from the underlying filesystem and using it to perform I/O in
units of block sizes.

This commit also uses $SCRATCH_MNT rather than $TEST_DIR for holding the
test files since the FS on $TEST_DIR might be created with a different
block size than the one specified in $MKFS_OPTIONS.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: Add _require_filefrag_options() to check options for filefrag
Xiao Yang [Fri, 23 Nov 2018 05:24:23 +0000 (13:24 +0800)]
common/rc: Add _require_filefrag_options() to check options for filefrag

In generic/519, filefrag command use FIBMAP ioctl(-B option) to print
output in extent format(-e option) on purpose and sync file(-s option),
so add _require_filefrag_options() to check if the command supports
all of these options.

References:
1) filefrag supports -e option by commit 2508eaa since e2fsprogs v1.42.7.
2) filefrag supports -B option by commit 5d5e01d since e2fsprogs v1.41.9.
3) filefrag supports -s option by commit e62847c since e2fsprogs v1.41.6.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/t_stripealign.c: Use block size reported by fstatfs()
Chandan Rajendra [Wed, 21 Nov 2018 16:26:46 +0000 (21:56 +0530)]
src/t_stripealign.c: Use block size reported by fstatfs()

On ppc64le, block size reported by fstat(2) is 64k (the page size)
i.e. the "preferred I/O size". However src/t_stripealign.c requires the
actual block size of the filesystem. Hence this commit now makes use of
the block size reported by fstatfs(2) syscall.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: Fix the situation that mount operation rejects corrupted XFS
Xiao Yang [Tue, 20 Nov 2018 11:58:28 +0000 (19:58 +0800)]
xfs: Fix the situation that mount operation rejects corrupted XFS

On upstream kernel, running some tests which corrupt XFS on purpose
got the mismatched output. e.g. running xfs/087:
------------------------------------------------
 + check fs
 + corrupt image
 + mount image
-+ modify files
-broken: 1
 + repair fs
 + mount image (2)
------------------------------------------------

It is reasonable for corrupted XFS to be caught and rejected by mount
or read/write operation.

Fixes: 0828657542ea ("xfs: fix blocktrash fuzzers")
Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: xfs_fsr requires working preallocation support
Christoph Hellwig [Sat, 10 Nov 2018 11:51:44 +0000 (12:51 +0100)]
xfs: xfs_fsr requires working preallocation support

Check that the file system actually supports preallocation for defrag
tests that end up calling xfs_fsr, as they can't be supported in
always_cow mode.

[Eryu: add comments in code as well]

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: don't assume preallocation is always supported on XFS
Christoph Hellwig [Sat, 10 Nov 2018 11:51:43 +0000 (12:51 +0100)]
xfs: don't assume preallocation is always supported on XFS

The always_cow mode can't usefull preallocate space gіven that it
always has to write out of place, and thus will reject falloc or
ioctl calls to preallocate space in a file.  Add explicit checks for
preallocation support in various XFS-specific tests to support this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: don't assume preallocation is supported when reflinks are supported
Christoph Hellwig [Sat, 10 Nov 2018 11:51:42 +0000 (12:51 +0100)]
generic: don't assume preallocation is supported when reflinks are supported

Various reflink tests currently use fallocate to preallocate space
without first checking that preallocations are supported. Add
explicit checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test send after radical changes in a complex directory hierarchy
Filipe Manana [Wed, 14 Nov 2018 18:32:56 +0000 (18:32 +0000)]
btrfs: test send after radical changes in a complex directory hierarchy

Test an incremental send operation in a scenario where the relationship
of ancestor-descendant between multiple directories is inversed, and
where multiple directories that were previously ancestors of another
directory now become descendents of multiple directories that used to be
their ancestors in the parent snapshot. This used to trigger an
infinite loop in the kernel code.

This is motivated by a bug found in btrfs which is fixed by the following
patch for the linux kernel:

  "Btrfs: send, fix infinite loop due to directory rename dependencies"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/205: Fix that b2 variable is treated as octal vaule
Xiao Yang [Mon, 12 Nov 2018 08:01:03 +0000 (16:01 +0800)]
xfs/205: Fix that b2 variable is treated as octal vaule

Running xfs/205 triggers the following error:
----------------------------------------------
QA output created by 205
+./tests/xfs/205: line 61: 098: value too great for base (error token is "098")
...
----------------------------------------------

If b2 variable is a 2-digit number beginning with 0(e.g. 098),
it will be treated as octal vaule instaed of decimal value.  We
try to declare it as decimal value forcely.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay: create directory over deleted whiteout
Miklos Szeredi [Mon, 12 Nov 2018 09:48:18 +0000 (10:48 +0100)]
overlay: create directory over deleted whiteout

There's a bug in the overlayfs implementation starting from the very
first merged version that may cause an Oops of various forms if a
directory is created over a whiteout dentry, but the actual whiteout
on the upper layer was removed to the directory creation.

Reported by: kaixuxia <xiakaixu1987@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/034: filter out the specified vaule of $SCRATCH_MNT
xiaoli feng [Tue, 13 Nov 2018 10:53:15 +0000 (18:53 +0800)]
ext4/034: filter out the specified vaule of $SCRATCH_MNT

In 034.out, the $SCRATCH_MNT is specified by "/mnt/scratch". It's
not flexible. Modify it to fit the different vaule of $SCRATCH_MNT.

Signed-off-by: xiaoli feng <xifeng@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4: regression test for a ENOSPC warning
Liu Bo [Sat, 10 Nov 2018 15:14:49 +0000 (23:14 +0800)]
ext4: regression test for a ENOSPC warning

This adds a regression test for a ENOSPC warning which can be
triggered if '-odioread_nolock,nodelalloc' and quota are used.

The bug was fixed by patch

"Ext4: fix ENOSPC when both quota and dioread_nolock are enabled".

[Eryu: add comments on using syncfs instead of sync]

Signed-off-by: Liu Bo <bo.liu@linux.alibaba.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/398: filter out extra string from newer mv
Xiong Murphy Zhou [Fri, 9 Nov 2018 04:19:13 +0000 (12:19 +0800)]
generic/398: filter out extra string from newer mv

mv command produces a leading string "renamed" from some time.
This breaks generic/398. Adding a _filter_mv to filter it out.
Tested this patch on Fedora 28.

sh-4.2$ rpm -qf /usr/bin/mv
coreutils-8.22-23.el7.x86_64
sh-4.2$ mv -v 1 2
‘1’ -> ‘2’
sh-4.2$

h-4.4# rpm -qf /usr/bin/mv
coreutils-8.30-5.el8.x86_64
sh-4.4# mv -v 1 2
renamed '1' -> '2'
sh-4.4#

igned-off-by: Xiong Murphy Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test balance and resize with an active swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:42 +0000 (14:29 -0700)]
btrfs: test balance and resize with an active swap file

Make sure we don't shrink the device past an active swap file, but allow
shrinking otherwise, as well as growing and balance.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test device add/remove/replace with an active swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:41 +0000 (14:29 -0700)]
btrfs: test device add/remove/replace with an active swap file

Make sure that we don't remove or replace a device with an active swap
file but can add, remove, and replace other devices.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test swap files on multiple devices
Omar Sandoval [Fri, 2 Nov 2018 21:29:40 +0000 (14:29 -0700)]
btrfs: test swap files on multiple devices

Swap files currently need to exist on exactly one device in exactly one
place.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test invalid operations on a swap file
Omar Sandoval [Fri, 2 Nov 2018 21:29:39 +0000 (14:29 -0700)]
btrfs: test invalid operations on a swap file

Btrfs forbids some operations which should not be done on a swap file.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test swap file activation restrictions
Omar Sandoval [Fri, 2 Nov 2018 21:29:38 +0000 (14:29 -0700)]
btrfs: test swap file activation restrictions

Swap files on Btrfs have some restrictions not applicable to other
filesystems.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: fix computation of max fs size for multiple device fs tests
Filipe Manana [Tue, 6 Nov 2018 15:34:37 +0000 (15:34 +0000)]
btrfs: fix computation of max fs size for multiple device fs tests

We were sorting numerical values with the 'sort' tool without telling it
that we are sorting numbers, giving us unexpected ordering. So just pass
the '-n' option to the 'sort' tool.

Example:

$ echo -e "11\n9\n20" | sort
11
20
9

$ echo -e "11\n9\n20" | sort -n
9
11
20

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: verify FIBMAP address overlap
Zorro Lang [Tue, 6 Nov 2018 04:43:38 +0000 (12:43 +0800)]
generic: verify FIBMAP address overlap

xfstests doesn't cover FIBMAP test, it cause we brought in a
regression bug fixed by "79b3dbe4adb3 fs: fix iomap_bmap position
calculation".

Although FIBMAP is old, there're still some programs use it, likes
LILO. This case tests if there's physical address overlap returned
by FIBMAP.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agopopulate: fix leafn creation test for v4 filesystems
Darrick J. Wong [Mon, 5 Nov 2018 17:25:47 +0000 (09:25 -0800)]
populate: fix leafn creation test for v4 filesystems

The leafn creation test doesn't work on some v4 filesystems
because the field names change.  Rearrange the code somewhat so that it
works properly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: add new filter for file cloning error translation
Filipe Manana [Mon, 5 Nov 2018 11:15:24 +0000 (11:15 +0000)]
btrfs: add new filter for file cloning error translation

A bug in file cloning/reflinking was recently found that afftected both
Btrfs and XFS, which was caused by allowing the cloning of an eof block
into the middle of a file when the eof is not aligned to the filesystem's
block size.

The fix consists of returning the errno -EINVAL to user space when the
arguments passed to the system call lead to the scenario of data
corruption. However this overlaps with some cases where the system call,
in Btrfs, returned -EOPNOTSUPP, which means we are trying to reflink
inline extents. That is unsupported in Btrfs due to the huge complexity
of supporting it (due to copying and trimming inline extents, deal with
eventual compression, etc).

We have a few btrfs test cases that verify that attempts to clone inline
extents result in a failure, and are currently expecting an -EINVAL error
message from the output of the cloner program. So create a filter that
converts error messages related to the -EOPNOTSUPP error to messages
related to the -EINVAL error, so that the test can run both on patched
and non-patched linux kernels.

The corresponding btrfs patch for the linux kernel is titled:

 "Btrfs: fix data corruption due to cloning of eof block"

And the VFS change that introduces the -EINVAL error return was introduced
by the following linux kernel commit (landed in 4.20-rc1):

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")

The btrfs patch is not yet in Linus' tree (it was submitted around the
same time as this change) and the VFS change was introduced in 4.10-rc1.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test attempt to reflink eof block into the middle of a file
Filipe Manana [Mon, 5 Nov 2018 11:15:01 +0000 (11:15 +0000)]
generic: test attempt to reflink eof block into the middle of a file

Test that we can not clone a range from a file A into the middle of a file B
when the range includes the last block of file A and file A's size is not
aligned with the filesystem's block size. Allowing such case would lead to
data corruption since the data between EOF and the end of its block is
undefined.

This is motivated by a bug recently found that affects both Btrfs and XFS
and is fixed by the following commits/patches for the linux kernel:

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")
 b39989009bdb ("xfs: fix data corruption w/ unaligned reflink ranges")
 Btrfs: fix data corruption due to cloning of eof block

The VFS patch landed in kernel 4.20-rc1 and the XFS patch landed in 4.19.
The Btrfs fix is very recent and it is not yet in Linus' tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test attempt to dedup eof block into the middle of a file
Filipe Manana [Mon, 5 Nov 2018 11:14:45 +0000 (11:14 +0000)]
generic: test attempt to dedup eof block into the middle of a file

Test that deduplication of an entire file that has a size that is not
aligned to the filesystem's block size into the middle of a different
file does not corrupt the destination's file data by reflinking the last
(eof) block.

This test is motivated by a bug recently found that affects both Btrfs
and XFS, and is fixed by the following commits/patches for the linux
kernel:

 07d19dc9fbe9 ("vfs: avoid problematic remapping requests into partial EOF block")
 dceeb47b0ed6 ("xfs: fix data corruption w/ unaligned dedupe ranges")
 de02b9f6bb65 ("Btrfs: fix data corruption when deduplicating between different files")
 Btrfs: fix infinite loop on inode eviction after deduplication of eof block

The VFS patch was added to kernel 4.20-rc1 and the XFS and first Btrfs
patches were added to kernel 4.19. The second patch for Btrfs is very
recent and it is not yet in Linus' tree.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agooverlay: test file handle decode with multi lower layers on same fs
Amir Goldstein [Mon, 5 Nov 2018 05:18:15 +0000 (07:18 +0200)]
overlay: test file handle decode with multi lower layers on same fs

This test is for a regression that was introduced in kernel v4.17 by
commit 8b58924ad55c ("ovl: lookup in inode cache first when decoding
lower file handle").

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/{472,496}: fix swap file creation on Btrfs
Omar Sandoval [Fri, 2 Nov 2018 21:29:37 +0000 (14:29 -0700)]
generic/{472,496}: fix swap file creation on Btrfs

The swap file must be set nocow before it is written to, otherwise it is
ignored and Btrfs refuses to activate it as swap.

Fixes: 25ce9740065e ("generic: test swapfile creation, activation, and deactivation")
Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/{472,496,497}: fix $seeqres typo
Omar Sandoval [Fri, 2 Nov 2018 21:29:36 +0000 (14:29 -0700)]
generic/{472,496,497}: fix $seeqres typo

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agomisc: force the exact quota options coded into the test
Darrick J. Wong [Thu, 1 Nov 2018 23:19:46 +0000 (16:19 -0700)]
misc: force the exact quota options coded into the test

Several tests require setting exactly the quota mount options that are
encoded in the test.  Unfortunately, quota mount options set by the user
in MOUNT_OPTIONS can turn on other quota types, which causes the golden
outputs to be off for various reasons (quota report output, behavior
changes, etc.)

So use _qmount_option to delete all the quota mount options in these
tests so that the test itself can run with exactly the config for which
it was written.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/205: update for v5 filesystems
Darrick J. Wong [Thu, 1 Nov 2018 23:19:40 +0000 (16:19 -0700)]
xfs/205: update for v5 filesystems

Update this test to work with v5 filesystems, which have a minimum block
size of 1k.  Adapt the script to sense the amount of free space reported
so that we can get close to ENOSPC instead of hardcoding.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/266: fix restore summary counter when quotas are enabled
Darrick J. Wong [Thu, 1 Nov 2018 23:19:33 +0000 (16:19 -0700)]
xfs/266: fix restore summary counter when quotas are enabled

When quotas are enabled, an incremental backup has to record the quota
file updates too.  Inside a dump the quota files are stored as special
files under the root dump directory.  xfsrestore reports the dump dir
in its restore summary counts even if the dump dir was only there for
the sake of the quota updates, which makes the test fail.  Fix this by
massaging the output when quotas are turned on.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agodump: don't fail if multi-file dumps don't all contain quota info
Darrick J. Wong [Thu, 1 Nov 2018 23:19:27 +0000 (16:19 -0700)]
dump: don't fail if multi-file dumps don't all contain quota info

When xfsdump is making multi-file dumps, the quota information are
written into the last dump file.  However, the multi-file restore script
(as written) expects to see quota information restored by every dump
file and fails.  This is silly, so fix it.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: force unlink metadata updates to disk
Darrick J. Wong [Thu, 1 Nov 2018 23:19:15 +0000 (16:19 -0700)]
xfs: force unlink metadata updates to disk

In xfs/318 and xfs/325 we inject errors on extent freeing then delete
some files to see if we can make the filesystem go offline.  However,
with the advent of deferred inode inactivation, sync won't guarantee
that unlinked inodes removal is actually pushed to disk since the "inode
needs to be deallocated" state is persisted to disk.  Freeze achieves
this, however, so inject a freeze/thaw cycle to make sure we hit the
injected error.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoquota: clean out speculative preallocations when checking quota usage
Darrick J. Wong [Thu, 1 Nov 2018 23:19:09 +0000 (16:19 -0700)]
quota: clean out speculative preallocations when checking quota usage

On XFS, the only reliable way to clean out speculative post-eof
preallocations, delayed allocations, and speculative cow preallocations
is to cycle the filesystem mount.  Since we're comparing the post-test
quota counts against a freshly quotacheck to look for leaks, it's fine
to cycle the mount.  This eliminates sporadic quota count failures when
running xfstests with quotas enabled.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: fuzz directories containing single leafn blocks
Darrick J. Wong [Tue, 30 Oct 2018 18:03:41 +0000 (11:03 -0700)]
xfs: fuzz directories containing single leafn blocks

Test scrub, repair, and metadata verifiers on directories containing
fuzzed single-leafn blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
5 years agoxfs: test repair regression of dir w/ single leafn block
Darrick J. Wong [Tue, 30 Oct 2018 18:03:35 +0000 (11:03 -0700)]
xfs: test repair regression of dir w/ single leafn block

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agopopulate: create leafn dir when populating xfs filesystem
Darrick J. Wong [Tue, 30 Oct 2018 18:03:28 +0000 (11:03 -0700)]
populate: create leafn dir when populating xfs filesystem

We've had some problems lately with directories containing a single
leafn directory.  It turns out that the populate script doesn't create
these, so teach it to do so.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: test packaged crc32c code
Darrick J. Wong [Mon, 29 Oct 2018 18:12:42 +0000 (11:12 -0700)]
xfs: test packaged crc32c code

Use the new crc32selftest command in xfs_io to check the correct
operation of the packaged xfsprogs, on the off chance that the packages
were cross compiled on a different machine type (which means the build
time test doesn't hold much water).

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocheck: use full paths for diff on error
Dave Chinner [Fri, 2 Nov 2018 01:09:48 +0000 (12:09 +1100)]
check: use full paths for diff on error

i don't run fstests from the source directory, so when I get a
golden image mismatch the relative path to the golden output is
not useful:

(Run 'diff -u tests/generic/013.out /home/dave/src/xfstests-dev/results//xfs_64k/generic/013.out.bad'  to see the entire diff)

Change the output to emit the real path for the golden out so this
can be cut and pasted and run from anywhere.

(Run 'diff -u /home/dave/src/xfstests-dev/tests/generic/013.out /home/dave/src/xfstests-dev/results//xfs_64k/generic/013.out.bad'  to see the entire diff)

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstests: fix fssum to actually ignore file holes when supposed to
Filipe Manana [Mon, 29 Oct 2018 09:43:40 +0000 (09:43 +0000)]
fstests: fix fssum to actually ignore file holes when supposed to

Unless the '-s' option is passed to fssum, it should not detect file holes
and have their existence influence the computed checksum for a file. This
tool was added to test btrfs' send/receive feature, so that it checks for
any metadata and data differences between the original filesystem and the
filesystem that receives send streams.

For a long time the test btrfs/007, which tests btrfs' send/receive with
fsstress, fails sporadically reporting data differences between files.
However the md5sum/sha1sum from the reported files in the original and
new filesystems are the same. The reason why fssum fails is because even
in normal mode it still accounts for number of holes that exist in the
file and their respective lengths. This is done using the SEEK_DATA mode
of lseek. The btrfs send feature does not preserve holes nor prealloc
extents (not supported by the current protocol), so whenever a hole or
prealloc (unwritten) extent is detected in the source filesystem, it
issues a write command full of zeroes, which will translate to a regular
(written) extent in the destination filesystem. This is why fssum reports
a different checksum. A prealloc extent also counts as hole when using
lseek.

For example when passing a seed of 1540592967 to fsstress in btrfs/007,
the test fails, as file p0/d0/f7 has a prealloc extent in the original
filesystem (in the incr snapshot).

Fix this by making fssum just read the hole file and feed its data to the
digest calculation function when option '-s' is not given. If we ever get
btrfs' send/receive to support holes and fallocate, we can just change
the test and pass the '-s' option to all fssum calls.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs/057: Fix false alerts due to orphan files
Qu Wenruo [Tue, 30 Oct 2018 10:18:19 +0000 (18:18 +0800)]
btrfs/057: Fix false alerts due to orphan files

For any recent kernel, there is a chance that btrfs/057 reports false
errors.

The false error would look like:
  btrfs/057 4s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/057.out.bad)
      --- tests/btrfs/057.out 2017-08-21 09:25:33.166666666 +0800
      +++ /home/adam/xfstests-dev/results//btrfs/057.out.bad 2018-10-29 14:07:28.443651293 +0800
      @@ -1,3 +1,3 @@
       QA output created by 057
       4096 4096
      -4096 4096
      +28672 28672

This is related to the fact that "btrfs subvolume sync" (or
vanilla sync) will not ensure orphan (unlinked but still exist) files to
be removed.

In fact, for that false error case, if inspecting the fs after umount,
its qgroup number is correct and btrfs check won't report qgroup error.

To fix the false alerts, just skip any manual qgroup number comparison,
and let fsck done after the test case to detect problem.

This also elimiate the necessary of using specified mount and mkfs
option, allowing us to improve coverage.

Reported-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: update group file to indicate generic/456 uses {collapse,zero}_range
Theodore Ts'o [Fri, 26 Oct 2018 11:53:49 +0000 (07:53 -0400)]
generic: update group file to indicate generic/456 uses {collapse,zero}_range

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Bill O'Donnell <billodo@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstests: add some tests to the 'log' group that use dmflakey
Filipe Manana [Sat, 27 Oct 2018 08:48:58 +0000 (09:48 +0100)]
fstests: add some tests to the 'log' group that use dmflakey

Some tests that use dmflakey to test filesystem consistency after a power
failure are in the 'log' group while others are not. So fix the
incosistency and put them all under the 'log' group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: fix classification of a couple btrfs tests
Filipe Manana [Sat, 27 Oct 2018 08:48:38 +0000 (09:48 +0100)]
btrfs: fix classification of a couple btrfs tests

Test btrfs/108 does not test collapse, in fact btrfs does not even support
the fallocate collapse operation, so remove it.
Test btrfs/159 does not test collapse either, it tests hole punching, so
replace the collapse group with the punch group.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/508: fix to check inode creation time feature on scratch mountpoint
Chao Yu [Sat, 27 Oct 2018 01:55:20 +0000 (09:55 +0800)]
generic/508: fix to check inode creation time feature on scratch mountpoint

_require_btime() just check inode creation time feature on TEST_DIR
mountpoint, but generic/508 needs to do that check on SCRATCH_MNT
mountpoint. Let's add _require_scratch_btime() for that, meanwhile
handling scratch_{mkfs,mount,umount} inside the function to decouple
with caller.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test reflink side effects
Darrick J. Wong [Tue, 16 Oct 2018 03:29:13 +0000 (20:29 -0700)]
generic: test reflink side effects

Test that ctime gets updated and suid is cleared when we reflink.
Ensure we can't reflink about RLIMIT_FSIZE.  Ensure that we can't
expose stale preallocation block data when reflinking above EOF.
Make sure dedupe actually catches a single different byte.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: fix test btrfs/007 to not leave temporary files in /tmp
Filipe Manana [Mon, 15 Oct 2018 09:22:46 +0000 (10:22 +0100)]
btrfs: fix test btrfs/007 to not leave temporary files in /tmp

This test was using the "mktemp -d" command to create a temporary
directory for storing send streams and computations from fssum,
without ever deleting them when it finishes. Therefore after running
it for many times it filled up all space from /tmp.

Fix this by using a temporary directory in TEST_DEV instead, as all
the more recent send/receive tests do, to store these files, and
making sure they get deleted when the test finishes. On average the
sum of the size of those files is between 5.5Mb to 6Mb, but changing
the number of operations for fsstress makes it even bigger.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test fsync after fallocate on a very small file
Filipe Manana [Mon, 15 Oct 2018 08:51:17 +0000 (09:51 +0100)]
generic: test fsync after fallocate on a very small file

Test that if we have a very small file, with a size smaller than the
block size, then fallocate a very small range within the block size
but past the file's current size, fsync the file and then power
fail, after mounting the filesystem all the file data is there and
the file size is correct.

This test is motivated by a failure in btrfs where it triggered an
assertion when using the no-holes feature, that is, when running
with MKFS_OPTIONS="-O no-holes". The btrfs issue is fixed by a patch
for the linux kernel titled:

 "Btrfs: fix assertion on fsync of regular file when using no-holes
  feature"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/140: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:03 +0000 (11:53 +0530)]
xfs/140: work with 1k block size

Commit 7a7641063ac3a7ae051c9e1959f4d7b1a25bb91c (xfs/140: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by resetting AG size to 16MiB if (8192 *
block size) results in a value less than 16MiB. Later the test file size
and the test file block count are then appropriately calculated.

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/139: work with 1k block size
Chandan Rajendra [Mon, 8 Oct 2018 06:23:02 +0000 (11:53 +0530)]
xfs/139: work with 1k block size

Commit 0e2b99951fa11ea8a8adf4676aef130cfeeb5250 (xfs/139: work with 64k
block size) created a test filesystem with AG size set to (8192 * block
size). When working with a 1k block sized XFS filesystem, this tries to
set the AG size to 8MiB which is less than the minimum AG size of
16MiB. Hence creation of the filesystem had actually failed.

This commit fixes the issue by setting AG size to be (16384 * block
size).

Reported-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agosrc/fiemap-tester: fix getting blocksize on overlayfs
Amir Goldstein [Thu, 11 Oct 2018 14:41:06 +0000 (17:41 +0300)]
src/fiemap-tester: fix getting blocksize on overlayfs

There was a regression in v4.19-rc1 that caused FIGETBSZ ioctl
to return 0 on an overlayfs file.

That regression went unnoticed because the xfstests that run
fiemap-tester program terminated in success status after not doing
much instead of failing.

Check for invalid value of block size returned by FIGETBSZ ioctl,
so these tests can detect the regression.

Fallback to statfs(2) for getting the filesystem blocksize if
FIGETBSZ ioctl fails (i.e. on overlayfs).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/288: shut up verifier error
Darrick J. Wong [Fri, 5 Oct 2018 00:19:39 +0000 (17:19 -0700)]
xfs/288: shut up verifier error

Ignore the verifier errors when we fuzz hdr.count to zero.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/270: use _scratch_xfs_set_metadata_field to fuzz rocompat bits
Darrick J. Wong [Fri, 5 Oct 2018 00:19:33 +0000 (17:19 -0700)]
xfs/270: use _scratch_xfs_set_metadata_field to fuzz rocompat bits

Use the helper to set the metadata field so that we can bypass write
verifier checks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/189: skip 'barrier' mount option test on newer kernels
Darrick J. Wong [Fri, 5 Oct 2018 00:19:26 +0000 (17:19 -0700)]
xfs/189: skip 'barrier' mount option test on newer kernels

Starting in Linux 4.19 the 'barrier' and 'nobarrier' mount options were
removed.  If mount complains about a bad option when we remount with
'barrier', just skip the test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs: test mount time summary counter check and fix
Darrick J. Wong [Fri, 5 Oct 2018 00:19:20 +0000 (17:19 -0700)]
xfs: test mount time summary counter check and fix

Tests to ensure that the xfs mount code can detect obviously bad fs
summary counters at mount time and fix them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: another mread-after-eof test
Darrick J. Wong [Fri, 5 Oct 2018 00:19:14 +0000 (17:19 -0700)]
generic: another mread-after-eof test

Add Brian Foster's alternate reproducer code for the mread-after-eof
problem so that we increase the chances that either this or generic/499
will catch the problem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneirc/077: fix min size for btrfs
Anand Jain [Thu, 11 Oct 2018 07:55:28 +0000 (15:55 +0800)]
geneirc/077: fix min size for btrfs

If btrfs need to be tested at its default blockgroup which is non-mixed,
then it needs at least 256mb.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test for file fsync after moving it to a new parent directory
Filipe Manana [Tue, 9 Oct 2018 14:05:35 +0000 (15:05 +0100)]
generic: test for file fsync after moving it to a new parent directory

Test that if we move a file from a directory B to a directory A, replace
directory B with directory A, fsync the file and then power fail, after
mounting the filesystem the file has a single parent, named B and there
is no longer any directory with the name A.

This test is motivated by a bug found in btrfs which is fixed by a patch
for the linux kernel titled:

  "Btrfs: fix wrong dentries after fsync of file that got its parent
   replaced"

This test passes on ext4, xfs and patched btrfs but it hangs on f2fs (the
fsck.f2fs process seems stuck).

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test mounting filesystem after fsync of a tmpfile
Filipe Manana [Mon, 8 Oct 2018 10:13:13 +0000 (11:13 +0100)]
generic: test mounting filesystem after fsync of a tmpfile

Test that if we fsync a tmpfile, without adding a hard link to it, and
then power fail, we will be able to mount the filesystem without
triggering any crashes, warnings or corruptions.

This test is motivated by an issue in btrfs where this scenario triggered
a warning (without any side effects). The following linux kernel patch
fixes the issue in btrfs:

  "Btrfs: fix warning when replaying log after fsync of a tmpfile"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: fix check for yp
Johannes Thumshirn [Fri, 12 Oct 2018 11:50:55 +0000 (13:50 +0200)]
common/rc: fix check for yp

Only testing if a domainname is set and ypcat is installed is not a
sufficient criteria to check if NIS is actually active.

Check for a running ypbind in rpcinfo as well.

Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/reflink: fix error messages in _require_scratch_dedupe()
Anthony Iliopoulos [Wed, 10 Oct 2018 23:55:50 +0000 (01:55 +0200)]
common/reflink: fix error messages in _require_scratch_dedupe()

In case dedupe returns an error in _require_scratch_dedupe(),
report the error for the scratch rather than for the test
filesystem.

Signed-off-by: Anthony Iliopoulos <ailiopoulos@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoext4/018: fix mismatch wildcard with debugfs
Yufen Yu [Thu, 11 Oct 2018 13:14:10 +0000 (21:14 +0800)]
ext4/018: fix mismatch wildcard with debugfs

For the new version of debugfs(v1.44.0+), it changes "File ACL:" format
from "%sFile ACL: %llu    Directory ACL: %d\n" to "%sFile ACL: %llu\n".

Thus, update this case accordingly.

Signed-off-by: Yufen Yu <yuyufen@huawei.com>
Reviewed-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test creation time recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:48 +0000 (20:25 +0800)]
generic: test creation time recovery after power failure

After fsync, filesystem should guarantee inode metadata including
creation time being persisted, so even after sudden power-cut, during
mount, we should recover i_crtime_{,nsec} fields correctly, in order
to not loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Note that, it needs inode creation time support on specified filesystem.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test i_flags recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:47 +0000 (20:25 +0800)]
generic: test i_flags recovery after power failure

After fsync, filesystem should guarantee inode metadata including
i_flags being persisted, so even after sudden power-cut, during
mount, we should recover i_flags fields correctly, in order to not
loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

We only check below attribute modification which most filesystem
supports:
- no atime updates (A)
- secure deletion (s)
- synchronous updates (S)
- undeletable (u)

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test project id recovery after power failure
Chao Yu [Sun, 7 Oct 2018 12:25:46 +0000 (20:25 +0800)]
generic: test project id recovery after power failure

After fsync, filesystem should guarantee inode metadata including
project id being persisted, so even after sudden power-cut, during
mount, we should recover project_id fields correctly, in order to
not loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/387: fix _scratch_mkfs_sized option for btrfs
Anand Jain [Tue, 25 Sep 2018 04:24:22 +0000 (12:24 +0800)]
generic/387: fix _scratch_mkfs_sized option for btrfs

btrfs needs 256mb to create a fs with default block group which is
non mixed, so pass 256mb to _scratch_mkfs_sized().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/449: fix fs size for _scratch_mkfs_sized for btrfs
Anand Jain [Tue, 25 Sep 2018 04:24:21 +0000 (12:24 +0800)]
generic/449: fix fs size for _scratch_mkfs_sized for btrfs

btrfs needs 256m to create btrfs with default options like non mixed
block groups.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/083: fix btrfs fs size for default mode
Anand Jain [Tue, 25 Sep 2018 04:24:17 +0000 (12:24 +0800)]
generic/083: fix btrfs fs size for default mode

btrfs needs at least 256mb to create a FS with the defaults options.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/015: fix to test the default non-mixed mode
Anand Jain [Tue, 25 Sep 2018 04:24:15 +0000 (12:24 +0800)]
generic/015: fix to test the default non-mixed mode

commit 97575acd7495 (generic/015: Change the test filesystem size to
101mb), created 101mb FS instead of 100mb FS to make sure we create
a FS which is non mixed mode.

btrfs-progs commit 18e2663db3e1 (btrfs-progs: Add minimum device
size check) added a more accurate minimum required space to create
the btrfs FS in non mixed mode depending on the group profile, and
considering any group profiles we would need at least 256MB (with
upward round off).

So this patch changes the FS size to be created by
_scratch_sized_mkfs() to 256MB so that we create the FS in non mixed
mode for any group profile.

Mixed blockgroup can be tested using the MKFS_OPTIONS explicitly.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: _scratch_mkfs_sized fix min size without mixed option
Anand Jain [Tue, 25 Sep 2018 04:24:14 +0000 (12:24 +0800)]
btrfs: _scratch_mkfs_sized fix min size without mixed option

As of now _scratch_mkfs_sized() checks if the requested size is
below 1G and forces the --mixed option for the mkfs.btrfs. Well the
correct size considering all possible group profiles at which we
need to force the mixed option is roughly 256Mbytes. So fix that.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agobtrfs: test unaligned punch hole at ENOSPC
Anand Jain [Sun, 30 Sep 2018 01:39:52 +0000 (09:39 +0800)]
btrfs: test unaligned punch hole at ENOSPC

Try to punch hole with unaligned size and offset when the FS is
full. Mainly holes are punched at locations which are unaligned
with the file extent boundaries when the FS is full by data.
As the punching holes at unaligned location will involve
truncating blocks instead of just dropping the extents, it shall
involve reserving data and metadata space for delalloc and so data
alloc fails as the FS is full.

btrfs_punch_hole()
 btrfs_truncate_block()
   btrfs_check_data_free_space() <-- ENOSPC

We don't fail punch hole if the holes are aligned with the file
extent boundaries as it shall involve just dropping the related
extents, without truncating data extent blocks.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/122: add struct xfs_unmount_log_format
Eric Sandeen [Thu, 4 Oct 2018 17:27:32 +0000 (12:27 -0500)]
xfs/122: add struct xfs_unmount_log_format

struct xfs_unmount_log_format used to be anonymous and gained a name
in 4.19, so add that to the list of expected structures in xfs/122.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/quota: adapt _require_prjquota() for f2fs
Chao Yu [Sun, 30 Sep 2018 09:26:53 +0000 (17:26 +0800)]
common/quota: adapt _require_prjquota() for f2fs

In _require_prjquota(), let's check project quota support as below
for f2fs:

- For image support, check 'project_quota' on enabled feature list
  of specified device.
- For kernel support, check /sys/fs/f2fs/features/project_quota
  sysfs entry status.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/108: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:42 +0000 (20:49 +0530)]
generic/108: work with 64k block size

This commit increases the size of the scsi debug device to 300MiB to
accommodate a 275MiB sized XFS filesystem with 64k block size. mkfs.xfs
fails to create a 64k block sized filesystem on devices with capacity
less than 275MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/018: to work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:41 +0000 (20:49 +0530)]
generic/018: to work with 64k block size

This commit replaces the hard coded bsize variable with the block size
obtained from the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/459: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:40 +0000 (20:49 +0530)]
generic/459: work with 64k block size

With 64k block size, 200MiB disk space is not sufficient to create an
XFS filesystem. Hence this commit increases the size of the
overprovisioned dm-thin device to 300MiB. The commit also increases the
other associated disk sizes (original physical size and new physical
size) appropriately.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/235: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:39 +0000 (20:49 +0530)]
generic/235: work with 64k block size

With 64k blocksized filesystem, this test fails since a single 8k write
will actually end up consuming 64k. Hence this commit writes 64k data
into the test file.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/230: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:38 +0000 (20:49 +0530)]
generic/230: work with 64k block size

This commit changes the test to work on file offsets that are aligned
with the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/177: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:37 +0000 (20:49 +0530)]
generic/177: work with 64k block size

This commit changes the test to work on file offsets that are aligned
with the block size of the underlying filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/punch: Filter fiemap output by FS block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:36 +0000 (20:49 +0530)]
common/punch: Filter fiemap output by FS block size

When testing FS instances of block size other than 4k, the output of
fiemap command will not match those in *.out files. This commit adds
an optional "block size" argument to _filter_fiemap() which prints
fiemap output in units of block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/172: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:35 +0000 (20:49 +0530)]
generic/172: work with 64k block size

For 64k block size, With 256MiB as the XFS filesystem size and 168 MiB
as the size of the clone source file, we end up hitting ENOSPC when
cloning the source file. This happens due to lack of space for housing
the corresponding metadata. This scenario also occurs when using a
512MiB XFS filesystem and 300MiB clone source file.

Hence this commit increases the size of the test filesystem to 1 GiB and
the size of the clone source file to 768MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric/102: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:34 +0000 (20:49 +0530)]
generic/102: work with 64k block size

With 64k block size, mkfs.xfs fails with the following message when the
filesystem size is 512MiB in size,

"log size 2037 blocks too small, minimum size is 2473 blocks"

Hence this commit increases the test filesystem size to 1GiB. Also, the
size of the test file is increased to 800MiB which is ~80% of the test
filesystem size. This is in proportion to the 400MiB test file used with
the original 512MiB test filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/325: Inject free_extent error after CoW operation
Chandan Rajendra [Mon, 24 Sep 2018 15:19:33 +0000 (20:49 +0530)]
xfs/325: Inject free_extent error after CoW operation

On a 64k blocksized filesystem, when the test CoWs the file2's offset
range [10 * 64k, 19 * 64k], the call to xfs_bmapi_reserve_delalloc()
allocates 32 64k blocks. This is because XFS_DEFAULT_COWEXTSZ_HINT has
the value of 32 and xfs_get_cowextsz_hint() uses this to compute the
extent alignment. This leads to xfs_bmapi_reserve_delalloc() to reserve
space corresponding to the file range [0, 32 * 64k] in the inode's
cow fork area. On completion of write I/O corresponding to file2's range
[10 * 64k, 19 * 64k], xfs_end_io() moves 10 out of the originally
allocated 32 64k blocks to the data fork area. The remaining 22 64k
blocks linger on in cow fork area of the inode.

Later, when servicing the exit() syscall for the xfs_io process,
xfs_free_eofblocks() ends up invoking xfs_reflink_cancel_cow_blocks()
since i_delayed_blks has the value 22. xfs_reflink_cancel_cow_blocks()
indirectly invokes __xfs_free_extent() which returns EIO since
XFS_ERRTAG_FREE_EXTENT has been set. This leads to the filesystem to be
shutdown. The "rm" command invoked later ends up returning an
error and hence the test fails. The test actually requires that the
filesystem gets shutdown when executing the "rm" command.

To fix the problem, this commit injects the free_extent error after we
CoW file2's [10 * 64k, 19 * 64k] range.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/299: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:32 +0000 (20:49 +0530)]
xfs/299: work with 64k block size

This commit changes the test to calculate quota limits based on the
block size of the underlying filesystem. Also, the sizes of the test
files are now made to be a multiple of the filesystem block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/299: Fix "Push past soft inode limit" case
Chandan Rajendra [Mon, 24 Sep 2018 15:19:31 +0000 (20:49 +0530)]
xfs/299: Fix "Push past soft inode limit" case

The test sets an inode soft limit of four but only three files are
created. This commit creates two more files in order to really push past
the soft inode limit.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/190: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:30 +0000 (20:49 +0530)]
xfs/190: work with 64k block size

This commit describes "file hole" ranges in multiples of block sizes
rather than using constants.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/140: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:29 +0000 (20:49 +0530)]
xfs/140: work with 64k block size

For 64k block size, the agsize provided in the test causes mkfs.xfs to
fail due to insufficient log space. Hence this commit computes agsize
based on block size of the filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/139: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:28 +0000 (20:49 +0530)]
xfs/139: work with 64k block size

For 64k block size, the agsize provided in the test causes mkfs.xfs to
fail due to insufficient log space. Hence this commit computes agsize
based on block size of the filesystem.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/127: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:27 +0000 (20:49 +0530)]
xfs/127: work with 64k block size

With reflink feature enabled, we require atleast 500MiB of
disk space to create a filesystem with 64k block size. Hence this commit
sets the size of the scratch filesystem to 512MiB.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/074: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:26 +0000 (20:49 +0530)]
xfs/074: work with 64k block size

This commit makes file and extent size calculations to be a function of
the filesystem's block size. It also adds a brief description of the
bug that is being tested.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/050: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:25 +0000 (20:49 +0530)]
xfs/050: work with 64k block size

This commit changes the test to calculate quota limits based on the
block size of the underlying filesystem. Also, the sizes of the test
files are now made to be a multiple of the filesystem block size.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/050: Fix "Push past soft inode limit" case
Chandan Rajendra [Mon, 24 Sep 2018 15:19:24 +0000 (20:49 +0530)]
xfs/050: Fix "Push past soft inode limit" case

The test sets an inode soft limit of four but only three files are
created. This commit creates two more files in order to really push past
the soft inode limit.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/009: work with 64k block size
Chandan Rajendra [Mon, 24 Sep 2018 15:19:23 +0000 (20:49 +0530)]
xfs/009: work with 64k block size

xfs_alloc_file_space() rounds up allocation requests by the filesystem
block size. Hence this commit changes the test to work with block size
units rather than with a multiple of 4096 bytes.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Tested-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agogeneric: test uid/gid recovery after power failure
Chao Yu [Tue, 25 Sep 2018 08:45:58 +0000 (16:45 +0800)]
generic: test uid/gid recovery after power failure

After fsync, filesystem should guarantee inode metadata including
uid/gid being persisted, so even after sudden power-cut, durign
mount, we should recover uid/gid fields correctly, in order to not
loss those meta info.

So adding this testcase to check whether generic filesystem can
guarantee that.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agoxfs/270: allow corrupted xfs_db write
Eric Sandeen [Tue, 25 Sep 2018 18:16:16 +0000 (13:16 -0500)]
xfs/270: allow corrupted xfs_db write

Upcoming verifiers treat the unknown ro_compat flag written via xfs_db
as corruption, so use the -d flag to allow it, and filter our the
resulting informational message.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agofstests: fix _test_generic_punch() to fit 64k extent
Anand Jain [Wed, 12 Sep 2018 07:48:44 +0000 (15:48 +0800)]
fstests: fix _test_generic_punch() to fit 64k extent

14 test cases use _test_generic_punch(), and they work well as long
as the ext4/xfs blocksize or btrfs sectorsize is below 4K.

In the system with 64K pagesize, as the blocksize can be upto 64K or the
sectorsize can be 64K so 13/14 test cases fail, because the
test-file-size (20k) and thus the extent boundary offsets aren't
big enough to fit the larger than 4k extent size.

Commit 2f194e4e820e6acfcfdadf9f488a162b22db9d86 (generic/009: don't run
for btrfs if PAGE_SIZE > 4096) tried to address this by calling the
not_run in generic/009.

And in the function _test_generic_punch() we use multiple=4 to address
the similar problem but its limited to the subcommand fcollapse.

Now to run these test cases successfully on systems with pagesize 64k,
this patch propose to increase the default multiple=1 to multiple=16.
With this we increase the test file size from 20k to 320k and thus it
encapsulates maximum extent size of 64k here. And we can drop the
multiple=4 which is just being done similar for the cases of fcollapse
subcommand only. And it appears to me there is no harm in increasing
the file size and offsets in general for all commands instead of just
fcollapse command.

This change is tested on ext4, xfs and btrfs on system with pagesize
4K and 64K.

With this patch, these 14 test cases runs fine on system with 64K
pagesize as well as pagesize 4K. However we may hit the same
limitation at some point when we want to validate the FSs with
pagesizes -gt 64K. And this patch does not address that part as of
now.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Tested-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
5 years agocommon/rc: fix check for disabled kmemleak
Amir Goldstein [Sat, 22 Sep 2018 15:23:39 +0000 (18:23 +0300)]
common/rc: fix check for disabled kmemleak

With kernel commit b353756b2b71 ("kmemleak: always register debugfs
file") that was merged to v4.19-rc3, the kmemleak debugfs knob
exists even if kmemleak is disabled, but returns EBUSY on write.

Suppress EBUSY errors in tests by disabling _check_kmemleak() calls
if the write to kmemleak knob failed on _init_kmemleak().

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>