xfstests-dev.git
4 years agogeneric: test corrupting verity files
Eric Biggers [Mon, 30 Sep 2019 21:15:50 +0000 (14:15 -0700)]
generic: test corrupting verity files

This test corrupts various parts of the contents of a verity file, or
parts of its Merkle tree, by writing directly to the block device.  It
verifies that this causes I/O errors when the relevant part of the
contents is later read by any means.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test access controls on the fs-verity ioctls
Eric Biggers [Mon, 30 Sep 2019 21:15:49 +0000 (14:15 -0700)]
generic: test access controls on the fs-verity ioctls

Test access controls on the fs-verity ioctls.  FS_IOC_MEASURE_VERITY is
allowed on any file, whereas FS_IOC_ENABLE_VERITY requires write access.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test general behavior of verity files
Eric Biggers [Mon, 30 Sep 2019 21:15:48 +0000 (14:15 -0700)]
generic: test general behavior of verity files

This is a basic fs-verity test which verifies:

- conditions for enabling verity
- verity files have expected contents and size
- can't change contents of verity files, but can change metadata
- can retrieve a verity file's measurement via FS_IOC_MEASURE_VERITY

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/verity: add common functions for testing fs-verity
Eric Biggers [Mon, 30 Sep 2019 21:15:47 +0000 (14:15 -0700)]
common/verity: add common functions for testing fs-verity

Add common functions for setting up and testing fs-verity.  fs-verity is
an ext4 and f2fs filesystem feature which provides Merkle tree based
hashing (similar to dm-verity) for individual read-only files, mainly
for the purpose of efficient authenticity verification.  Other
filesystems may add fs-verity support later, using the same API.

Running the fs-verity tests will require:

- Kernel v5.4-rc1 or later configured with CONFIG_FS_VERITY=y

- The 'fsverity' utility program from
  https://git.kernel.org/pub/scm/linux/kernel/git/ebiggers/fsverity-utils.git

- e2fsprogs v1.45.2 or later for ext4 tests, or f2fs-tools v1.11.0 or
  later for f2fs tests

Some individual tests will have additional requirements.

For more information about fs-verity, see
https://www.kernel.org/doc/html/latest/filesystems/fsverity.html

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/filter: add _filter_xfs_io_fiemap()
Eric Biggers [Mon, 30 Sep 2019 21:15:46 +0000 (14:15 -0700)]
common/filter: add _filter_xfs_io_fiemap()

Add _filter_xfs_io_fiemap() to clean up the output of
'xfs_io -c fiemap'.  This will be used by a function in common/verity.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: Add lease testing
Ira Weiny [Mon, 23 Sep 2019 17:59:59 +0000 (10:59 -0700)]
generic: Add lease testing

The actual lease test code has been added to src/locktest.c (see
previous commits), now create a new lease test script to drive the
test.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/locktest: Add common locktest functions
Ira Weiny [Mon, 23 Sep 2019 17:59:58 +0000 (10:59 -0700)]
common/locktest: Add common locktest functions

Move common test functions to common directory and call them from the
lock test.  This is in preparation for adding a separate lease test.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Add truncate lease tests
Ira Weiny [Mon, 23 Sep 2019 17:53:34 +0000 (10:53 -0700)]
src/locktest: Add truncate lease tests

Add verification of signal reception on truncate:

/*  9 */"Write lease gets SIGIO on truncate",
/* 10 */"Read lease gets SIGIO on truncate",

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Add lease testing for basic signal reception
Ira Weiny [Mon, 23 Sep 2019 17:53:33 +0000 (10:53 -0700)]
src/locktest: Add lease testing for basic signal reception

/* 5 */"Read lease gets SIGIO on write open",
/* 6 */"Write lease gets SIGIO on read open",
/* 7 */"Read lease does _not_ get SIGIO on read open",
/* 8 */"Read lease gets SIGIO on write open",

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Add simple lease testing
Ira Weiny [Mon, 23 Sep 2019 17:53:32 +0000 (10:53 -0700)]
src/locktest: Add simple lease testing

/*  1 */"Take Read Lease",
/*  2 */"Take Write Lease",
/*  3 */"Fail Write Lease if file is open somewhere else",
/*  4 */"Fail Read Lease if opened with write permissions",

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Add run() function
Ira Weiny [Mon, 23 Sep 2019 17:53:31 +0000 (10:53 -0700)]
src/locktest: Add run() function

Separate the functionality of main() into socket set up and run().  Pass
the test information to run() rather than have it be gloabal.  This is
in preparation for adding a separate lease test array.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Audit all debug output
Ira Weiny [Mon, 23 Sep 2019 17:53:30 +0000 (10:53 -0700)]
src/locktest: Audit all debug output

Audit all the debug output to be clear on what failed so that we can
remove the debug flag from the script.

Specifically, remove the need for a debug flag on system call error
output.  This helps to indicate what happened when an individual test
step fails.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Clean up error output
Ira Weiny [Mon, 23 Sep 2019 17:53:29 +0000 (10:53 -0700)]
src/locktest: Clean up error output

Add some debugging
Make sure all errors go to stderr
Clean up formatting and make failures stand out
Report test results for the client not just the server

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/131: Save stderr for debugging
Ira Weiny [Mon, 23 Sep 2019 17:53:28 +0000 (10:53 -0700)]
generic/131: Save stderr for debugging

Details of which internal step failed within a test are lost without
additional debugging output.  Save that output by separating stdout and
stderr.

This allows the server port to be written solely to stdout for
consumption by the script.  Then all error output can be sent to the
seqres.full file in the event of a failure.  Then, depend on the return
code of the server _and_ the client to detect failure and save the error
output for inspection.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/131: Clean up pid variables
Ira Weiny [Mon, 23 Sep 2019 17:53:27 +0000 (10:53 -0700)]
generic/131: Clean up pid variables

Change the name of the variables to reflect the client vs server.  This
will help in future patches.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest.c: Fix return code if last test fails
Ira Weiny [Mon, 23 Sep 2019 17:53:26 +0000 (10:53 -0700)]
src/locktest.c: Fix return code if last test fails

If anything but the first step of the last test fails, the exit code
(fail_count) was not properly set.  Fix this such that follow on patches
will be able to save error output and correctly inform the script that a
failure has occurred rather than just expecting random output to fail
the diff check.

The issue is last_test is not properly tracking which test the loop is
currently on.  Therefore fail_count would not be incremented correctly.

Remove the special case of checking for the end of the steps array and
track last_test properly.  Then adjust test_count to be correct for the
new code.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest.c: Clean up client command passing
Ira Weiny [Mon, 23 Sep 2019 17:53:25 +0000 (10:53 -0700)]
src/locktest.c: Clean up client command passing

The client was using the test index rather than the values being passed
to it for a command.  While this technically worked it is cleaner to
fully initialize the command message and use the values in that message.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Add get_cmd_str
Ira Weiny [Mon, 23 Sep 2019 17:53:24 +0000 (10:53 -0700)]
src/locktest: Add get_cmd_str

Rather than open code printing the strings, use a helper function.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Change command macro names
Ira Weiny [Mon, 23 Sep 2019 17:53:23 +0000 (10:53 -0700)]
src/locktest: Change command macro names

The macro names for commands are not consistent.  Change them such that
they are not confused with other flags and macros within the test.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Remove OPEN macro
Ira Weiny [Mon, 23 Sep 2019 17:53:22 +0000 (10:53 -0700)]
src/locktest: Remove OPEN macro

The code is much cleaner without this macro.  While here add extra debug
output as well.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Remove unnecessary sleep
Ira Weiny [Mon, 23 Sep 2019 17:53:21 +0000 (10:53 -0700)]
src/locktest: Remove unnecessary sleep

There is no need to sleep because we asked for debugging.  Remove extra
sleep code.

Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test balance profile convert functionality
Nikolay Borisov [Tue, 1 Oct 2019 09:04:19 +0000 (12:04 +0300)]
btrfs: test balance profile convert functionality

Add basic test to ensure btrfs conversion functionality is tested.
This test exercies conversion to all possible types of the data
portion. This is sufficient since from the POV of relocation we are
only moving blockgroups.

v5.3 and later kernel needs the following patch to pass the test

btrfs: Fix a regression which we can't convert to SINGLE profile

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: convert spaces to tabs in help msg
Po-Hsu Lin [Fri, 4 Oct 2019 04:04:10 +0000 (12:04 +0800)]
check: convert spaces to tabs in help msg

There are some mix use of spaces and tabs in the help message:
$ ./check --help
Usage: ./check [options] [testlist]

check options
    -nfs                test NFS
    -glusterfs                test GlusterFS
    -cifs               test CIFS
    -9p test 9p
    -overlay test overlay
    -pvfs2          test PVFS2
    -tmpfs              test TMPFS
    -ubifs              test ubifs

unify them with tabs.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: Add regression test to check if btrfs can handle high devid
Qu Wenruo [Thu, 3 Oct 2019 07:53:50 +0000 (15:53 +0800)]
btrfs: Add regression test to check if btrfs can handle high devid

Add a regression test to check if btrfs can handle high devid.

The test will add and remove devices to a btrfs fs, so that the devid
will increase to uncommon but still valid values.

The regression is introduced by kernel commit ab4ba2e13346 ("btrfs:
tree-checker: Verify dev item").
The fix is titled "btrfs: tree-checker: Fix wrong check on max devid".

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/493: add missing dedupe group
Chao Yu [Fri, 27 Sep 2019 10:08:10 +0000 (18:08 +0800)]
generic/493: add missing dedupe group

We missed to add the dedupe group, fix it.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: check that we can't write to swap files
Darrick J. Wong [Tue, 24 Sep 2019 16:39:37 +0000 (09:39 -0700)]
generic: check that we can't write to swap files

While active, the media backing a swap file is leased to the kernel.
Userspace has no business writing to it.  Make sure we can't do this.

The two kernel patches titled as below should fix the bug:

mm: set S_SWAPFILE on blockdev swap devices
vfs: don't allow writes to swap files

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>
4 years agocommon/rc: Remove special handing of 'dup' argument for btrfs
Nikolay Borisov [Fri, 27 Sep 2019 10:52:32 +0000 (13:52 +0300)]
common/rc: Remove special handing of 'dup' argument for btrfs

_scratch_pool_mkfs special cases the command executed when 'dup'
option is used when creating a filesystem. This is not true anymore,
since 'dup' works for all profiles and number of devices since
4.5-ish. This is manifested while exercising btrfs' balance argument
combinations test.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: fallocate two bytes at block boundary
Max Reitz [Fri, 27 Sep 2019 10:38:46 +0000 (12:38 +0200)]
generic: fallocate two bytes at block boundary

Allocating two bytes at a block boundary with fallocate should allocate
both blocks involved.  Test this by writing data to both bytes
afterwards and see whether the on-disk size increases (it should not).

This is a regression test for the kernel patch "xfs: Fix tail rounding
in xfs_alloc_file_space()".

Signed-off-by: Max Reitz <mreitz@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/011: Fill the fs to ensure we have enough data for dev-replace
Qu Wenruo [Fri, 27 Sep 2019 09:58:43 +0000 (17:58 +0800)]
btrfs/011: Fill the fs to ensure we have enough data for dev-replace

[BUG]
When btrfs/011 is executed on a fast enough system (fully memory backed
VM, with test device has unsafe cache mode), the test can fail like
this:

  btrfs/011 43s ... [failed, exit status 1]- output mismatch (see /home/adam/xfstests-dev/results//btrfs/011.out.bad)
    --- tests/btrfs/011.out     2019-07-22 14:13:44.643333326 +0800
    +++ /home/adam/xfstests-dev/results//btrfs/011.out.bad      2019-09-18 14:49:28.308798022 +0800
    @@ -1,3 +1,4 @@
     QA output created by 011
     *** test btrfs replace
    -*** done
    +failed: '/usr/bin/btrfs replace cancel /mnt/scratch'
    +(see /home/adam/xfstests-dev/results//btrfs/011.full for details)
    ...

[CAUSE]
Looking into the full output, it shows:
  ...
  Replace from /dev/mapper/test-scratch1 to /dev/mapper/test-scratch2

  # /usr/bin/btrfs replace start -f /dev/mapper/test-scratch1 /dev/mapper/test-scratch2 /mnt/scratch
  # /usr/bin/btrfs replace cancel /mnt/scratch
  INFO: ioctl(DEV_REPLACE_CANCEL)"/mnt/scratch": not started
  failed: '/usr/bin/btrfs replace cancel /mnt/scratch'

So this means the replace is already finished before we cancel it.
For fast system, it's very common.

[FIX]
In fill_scratch() after all the original file creations, do a timer
based direct IO write.
The extra write will take 2 * $wait_time, utilizing direct IO with 64K
block size, the write performance should be very comparable (although a
little faster) to replace performance.

So later cancel should be able to really cancel the dev-replace without
it finished too early.

Also, do extra check about the above write. If we hit ENOSPC we just
skip the test as the system is really too fast and the fs is not large
enough.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/xfs: wipe the XFS superblock of each AGs
Zorro Lang [Tue, 24 Sep 2019 10:09:19 +0000 (18:09 +0800)]
common/xfs: wipe the XFS superblock of each AGs

xfs/030 always fails after d0e484ac699f ("check: wipe scratch devices
between tests") get merged.

Due to xfs/030 does a sized(100m) mkfs. Before we merge above commit,
mkfs.xfs detects an old primary superblock, it will write zeroes to
all superblocks before formatting the new filesystem. But this won't
be done if we wipe the first superblock(by merging above commit).

That means if we make a (smaller) sized xfs after wipefs, those *old*
superblocks which created by last time mkfs.xfs will be left on disk.
Then when we do xfs_repair, if xfs_repair can't find the first SB, it
will go to find those *old* SB at first. When it finds them,
everyting goes wrong.

So I try to wipe each XFS superblock if there's a XFS ondisk, then
try to erase superblock of each XFS AG by default mkfs.xfs geometry.
Thanks Darrick J. Wong helped to analyze this issue.

Reported-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/036: fix sporadic failures when unmounting scratch filesystem
Filipe Manana [Tue, 24 Sep 2019 09:49:02 +0000 (10:49 +0100)]
btrfs/036: fix sporadic failures when unmounting scratch filesystem

Often this test can fail on unmount because a 'btrfs subvolume snapshot'
command is still running and using the scratch the mount point:

  btrfs/036 168s ... umount: /home/fdmanana/btrfs-tests/scratch_1: target is busy
          (In some cases useful info about processes that
           use the device is found by lsof(8) or fuser(1).)
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  (see /home/fdmanana/git/hub/xfstests/results//btrfs/036.full for details)

This happens because when we kill the process running the do_snapshots()
function we only kill the subshell and don't wait for any processes it
has spawned to finish before the subshell exits. Fix this by setting a
trap in the do_snapshots() function, so that when the subshell receives
a SIGTERM signal it waits for any running 'btrfs subvolume snapshot'
to finish before exitting. We were also not waiting for the subshell
to exit after sending it the SIGTERM signal, so fix that as well by
calling the 'wait' command after calling 'kill' to send that signal.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agooverlay: Enable character device to be the base fs partition
Zhihao Cheng [Wed, 25 Sep 2019 06:35:33 +0000 (14:35 +0800)]
overlay: Enable character device to be the base fs partition

When running overlay tests using character devices as base fs partitions,
all overlay usecase results become 'notrun'. Function
'_overay_config_override' (common/config) detects that the current base
fs partition is not a block device and will set FSTYP to base fs. The
overlay usecase will check the current FSTYP, and if it is not 'overlay'
or 'generic', it will skip the execution.

For example, using UBIFS as base fs skips all overlay usecases:

  FSTYP         -- ubifs       # FSTYP should be overridden as 'overlay'
  MKFS_OPTIONS  -- /dev/ubi0_1 # Character device
  MOUNT_OPTIONS -- -t ubifs /dev/ubi0_1 /tmp/scratch

  overlay/001 [not run] not suitable for this filesystem type: ubifs
  overlay/002 [not run] not suitable for this filesystem type: ubifs
  overlay/003 [not run] not suitable for this filesystem type: ubifs

When checking that the base fs partition is a block/character device,
FSTYP is overwritten as 'overlay'. This patch allows the base fs
partition to be a character device that can also execute overlay
usecases (such as ubifs).

Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/14[89]: Remove xfs_prepair64 and xfs_prepair tests
Yang Xu [Thu, 19 Sep 2019 10:08:15 +0000 (18:08 +0800)]
xfs/14[89]: Remove xfs_prepair64 and xfs_prepair tests

The two commands have obsoleted long time ago, they don't run on
most systems. So I think we can remove them.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon: check if a given rename flag is supported in _require_renameat2
kaixuxia [Wed, 18 Sep 2019 11:47:47 +0000 (19:47 +0800)]
common: check if a given rename flag is supported in _require_renameat2

Some testcases may require a special rename flag, such as
RENAME_WHITEOUT, so add support check for if a given rename flag is
supported in _require_renameat2.

[Eryu: rename the helper to _require_renameat2 while we're at it,
and add 'exchange' check to generic/398 and generic/419]

Signed-off-by: kaixuxia <kaixuxia@tencent.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/028: Don't pollute golden output for killing already finished process
Qu Wenruo [Wed, 18 Sep 2019 06:56:25 +0000 (14:56 +0800)]
btrfs/028: Don't pollute golden output for killing already finished process

Sometimes on fast enough test vm, btrfs/028 fails like:

  btrfs/028 31s ... - output mismatch (see /home/adam/xfstests-dev/results//btrfs/028.out.bad)
    --- tests/btrfs/028.out     2019-07-22 14:13:44.646666660 +0800
    +++ /home/adam/xfstests-dev/results//btrfs/028.out.bad      2019-09-18 14:14:45.442131411 +0800
    @@ -1,2 +1,3 @@
     QA output created by 028
    +/home/adam/xfstests-dev/tests/btrfs/028: line 64: kill: (2459) - No such process
     Silence is golden
    ...

It's caused by killing already finished process.

There is no need for kill command to pollute the golden output, so
just redirect all of its stdout and stderr to null.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: Verify falloc on multiple holes won't leak qgroup reserved data space
Qu Wenruo [Sun, 15 Sep 2019 07:22:30 +0000 (15:22 +0800)]
btrfs: Verify falloc on multiple holes won't leak qgroup reserved data space

Add a test case where falloc is called on multiple holes with qgroup
enabled.

This can cause qgroup reserved data space leak and false EDQUOT
error even we're not reaching the limit.

The fix is titled:
"btrfs: qgroup: Fix the wrong target io_tree when freeing
 reserved data space"

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/566: use _require_xfs_quota_foreign and remove -f option
Yang Xu [Mon, 9 Sep 2019 22:11:43 +0000 (06:11 +0800)]
generic/566: use _require_xfs_quota_foreign and remove -f option

xfstests should decide if xfs_quota needs the -f option by
_require_xfs_quota_foreign, not write the -f option after
$XFS_QUOTA_PROG manually. The later way will cause unexpected error
on an old system which xfsprogs doesn't support the -f option.

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Tested-by: Murphy Zhou <jencce.kernel@gmail.com>
Acked-by: Murphy Zhou <jencce.kernel@gmail.com>
Acked-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/564: fix copy_range -f availability test
Eric Sandeen [Thu, 12 Sep 2019 16:15:49 +0000 (11:15 -0500)]
generic/564: fix copy_range -f availability test

generic/564 wants to test for copy_range -f, but as it's implemented
it calls copy_range with a length of zero which will silently return
success from the VFS (at least on some kernels) even if the underlying
fs doesn't support it.

So patch this up 2 ways; perform the test with an explicit length
so it's not a no-op, and go ahead test copy_range w/o -f in the test
first just to be on the safe side (and for clearer failure messages.)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: Check snapshot creation and deletion with dm-logwrites
Qu Wenruo [Tue, 10 Sep 2019 01:53:11 +0000 (09:53 +0800)]
btrfs: Check snapshot creation and deletion with dm-logwrites

We have generic dm-logwrites with fsstress test case (generic/482),
but it doesn't cover fs specific operations like btrfs snapshot
creation and deletion.

Furthermore, that test is not heavy enough to bump btrfs tree height
by its short runtime.

And finally, btrfs check doesn't consider dirty log as an error,
unlike ext*/xfs, that's to say we don't need to mount the fs to
replay the log, but just running btrfs check on the fs is enough.

So introduce a similar test case but for btrfs only.

The test case will stress btrfs by:
- Use small nodesize to bump tree height
- Create a base tree which is already high enough
- Trim tree blocks to find possible trim bugs
- Call snapshot creation and deletion along with fsstress

Also it includes certain workaround for btrfs:
- Allow _log_writes_mkfs to accept extra mkfs options
- Use no-holes feature
  To avoid missing hole file extents.
  Although that behavior doesn't follow the on-disk format spec, it
  doesn't cause data loss. And will follow the new on-disk format spec
  of no-holes feature, so it's better to workaround it.

And an optimization for btrfs only:
- Use replay-log --fsck/--check command
  Since dm-log-writes records bios sequentially, there is no way to
  locate certain entry unless we iterate all entries.
  This is becoming a big performance penalty if we replay certain a
  range, check the fs, then re-execute replay-log to replay another
  range.

  We need to records the previous entry location, or we need to
  re-iterate all previous entries.

  Thankfully, replay-log has already address it by providing --fsck and
  --check command, thus we don't need to break replay-log command.

Please note, for fast storage (e.g. fast NVME or unsafe cache mode),
it's recommended to use log devices larger than 15G, or we can't
record the full log of just 30s fsstress run.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/079: fix failure to umount scratch fs due to running filefrag process
Filipe Manana [Tue, 10 Sep 2019 14:26:01 +0000 (15:26 +0100)]
btrfs/079: fix failure to umount scratch fs due to running filefrag process

The test fails sporadically when trying to unmount the scratch filesystem
because a filefrag process is still running against a file that exists on
the scrach filesystem. This is because killing the subshell running the
fiemap_work() function does not wait for any filefrag process to complete
first. We need to set a trap for the SIGTERM signal on the subshell so
that it waits for any filefrag process before exitting.

The failure resulted in error messages like the following:

  btrfs/079 57s ... umount: /home/fdmanana/btrfs-tests/scratch_1: target is busy
          (In some cases useful info about processes that
           use the device is found by lsof(8) or fuser(1).)
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  (see /home/fdmanana/git/hub/xfstests/results//btrfs/079.full for details)

Fix this by adding a trap for SIGTERM.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test mmap write vs. hole punching
Andreas Gruenbacher [Fri, 6 Sep 2019 16:53:04 +0000 (18:53 +0200)]
generic: test mmap write vs. hole punching

On file systems with a block size smaller than the page size, hole
punching can leave the pages at the beginning and the end of the
hole partially mapped to disk blocks.  Make sure writes to those
pages are handled correctly.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs/048: fix test failure when fs mounted with v2 space cache option
Filipe Manana [Thu, 5 Sep 2019 15:37:00 +0000 (16:37 +0100)]
btrfs/048: fix test failure when fs mounted with v2 space cache option

In order to check that the filesystem generation does not change
after failure to set a property, the test expects a specific
generation number of 7 in its golden output. That currently works
except when using the v2 space cache mount option (MOUNT_OPTIONS="-o
space_cache=v2"), since the filesystem generation is 8 because
creating a v2 space cache adds an additional transaction commit. So
update the test to not hardcode specific generation numbers in its
golden output and just output an unexpected message if the
generation number changes.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Remove unused buf allocation
Ira Weiny [Tue, 3 Sep 2019 21:08:15 +0000 (14:08 -0700)]
src/locktest: Remove unused buf allocation

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Update test header comment
Ira Weiny [Tue, 3 Sep 2019 21:08:14 +0000 (14:08 -0700)]
src/locktest: Update test header comment

The offset is also used as flags for the OPEN commands.

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agosrc/locktest: Remove D_flag
Ira Weiny [Tue, 3 Sep 2019 21:08:13 +0000 (14:08 -0700)]
src/locktest: Remove D_flag

This flag is never set.  Furthermore, there does not seem to be any need
to set O_DIRECT for lock testing.

Remove the D_flag

Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Reviewed:-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/25[02]: Increase fs size to 196 mb
Nikolay Borisov [Mon, 2 Sep 2019 08:34:18 +0000 (11:34 +0300)]
generic/25[02]: Increase fs size to 196 mb

Those 2 tests fail on btrfs on a ppc64 system with 64k pages. This is
caused by the improved minimum device size calculation in upstream
btrfs-progs (commit: 31d228a2eb98 ("btrfs-progs: mkfs: Enhance minimal
device size calculation to fix mkfs failure on small file")).i

Xfstests implicitly uses '--mixed' options for filesystems smaller than
256mb thus the minimum filesystem size require is derived from the
following equation: 2 * (4mb + nodesize << 10). On a 64k page system
this evaluates to 2 * (4m + 64m) = 136m. This resuts in failures such:
mkfs.btrfs  -b $((100 * 1048576)) btrfs-test.img

    ERROR: size 104857600 is too small to make a usable filesystem
    ERROR: minimum size for btrfs filesystem is 114294784

when running _scratch_mkfs_sized $((100 * 1048576)).

Fix this by increasing the minimum filesystem size to 196 megabytes
which makes mkfs.btrfs happy again and allows the test to proceed.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/casefold: only check for the Casefold flag
Theodore Ts'o [Mon, 26 Aug 2019 17:50:20 +0000 (13:50 -0400)]
common/casefold: only check for the Casefold flag

The _casefold_lsattr_dir function lists all of the file attributes.
As result, tests/generic/556.out has an ext4-specific assumption
that the test directories will have the Extents attribute. That
won't be true for all file systems, and it won't even be true for
ext4 file systems that do not have the extents feature enabled.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test for failure to unlock inode after chgrp fails with EDQUOT
Darrick J. Wong [Tue, 27 Aug 2019 15:08:50 +0000 (08:08 -0700)]
generic: test for failure to unlock inode after chgrp fails with EDQUOT

This is a regression test that checks for xfs drivers that fail to
unlock the inode after changing the group id fails with EDQUOT.  It
pairs with "xfs: fix missing ILOCK unlock when xfs_setattr_nonsize fails
due to EDQUOT".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agot_stripealign: Fix fibmap error handling
Carlos Maiolino [Fri, 23 Aug 2019 09:25:30 +0000 (11:25 +0200)]
t_stripealign: Fix fibmap error handling

FIBMAP only returns a negative value when the underlying filesystem
does not support FIBMAP or on permission error. For the remaining
errors, i.e. those usually returned from the filesystem itself, zero
will be returned.

We can not trust a zero return from the FIBMAP, and such behavior
made generic/223 succeed when it should not.

Also, we can't use perror() only to print errors when FIBMAP failed,
or it will simply print 'success' when a zero is returned.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/500: doesn't work for btrfs
Josef Bacik [Thu, 15 Aug 2019 18:26:59 +0000 (14:26 -0400)]
generic/500: doesn't work for btrfs

Btrfs does COW, so when we unlink the file we need to update
metadata and write it to a new location, which we can't do because
the thinp is full.  This results in an EIO during a metadata write,
which makes us flip read only, thus making it impossible to fstrim
the fs.  Just make it so we skip this test for btrfs.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/322: fix bad xfs_io sync_range command
Andreas Gruenbacher [Mon, 19 Aug 2019 08:57:36 +0000 (10:57 +0200)]
generic/322: fix bad xfs_io sync_range command

Add the missing range arguments to the sync_range command in this test:
according to Josef Bacik, the sync_range command is required to make the test
reproduce the critical situation reliably.

[Eryu: fix dumping xfs_io output to $seqres.full, don't check
xfs_io's exit status]

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Suggested-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon: filter aiodio dmesg after fs/iomap.c to fs/iomap/ move
Darrick J. Wong [Thu, 15 Aug 2019 15:19:12 +0000 (08:19 -0700)]
common: filter aiodio dmesg after fs/iomap.c to fs/iomap/ move

Since the iomap code are moving to fs/iomap/ we have to add new
entries to the aiodio dmesg filter to reflect this.  It's still
possible for filesystems using iomap for directio to cough up
WARNings when a direct write collides with a buffered write, since
in some cases we catch that early enough to have the direct write
return EIO (which was covered by filter $warn7 previously).

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>
4 years agogeneric/561: kill duperemove directly
Darrick J. Wong [Thu, 15 Aug 2019 15:19:06 +0000 (08:19 -0700)]
generic/561: kill duperemove directly

While the kill statement added in the previous patch usually
suffices to shut down the bash loop that runs the duperemove
processes, for whatever reason this sometimes fails to kill
duperemove.  Kill the duperemove processes directly after removing
the run file, which should cause the bash loop to exit immediately.

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>
4 years agogeneric/081: fix lvm config not being cleaned up properly
Darrick J. Wong [Thu, 15 Aug 2019 15:18:59 +0000 (08:18 -0700)]
generic/081: fix lvm config not being cleaned up properly

Fix a race between _cleanup and dmeventd that causes the lvm
configuration not to be cleaned up and subsequent tests to fail.

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>
4 years agogeneric/519: Optimize overlap detection
Nikolay Borisov [Thu, 15 Aug 2019 10:22:40 +0000 (13:22 +0300)]
generic/519: Optimize overlap detection

Currently generic/519 takes around 5-10 minutes for me. This is
mainly due to the fact it uses a bunch of commands which spawn
processes. This, coupled by the fact the algorithm is O(n^2) in the
number of lines (624) for the sparse file and that test feels like
it's hung.

Fix this by re-implementing the existing logic in awk. This causes a
s single processes to be spawned and the rest of the processing is
done in-memory. This makes the test complete in 2 seconds for me.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/517: make test work on filesystems with block size greater than 4Kb
Filipe Manana [Tue, 13 Aug 2019 16:22:55 +0000 (17:22 +0100)]
generic/517: make test work on filesystems with block size greater than 4Kb

The test currently fails on filesystems with a block size greater
than 4Kb, as dedupe operations fail with -EINVAL because the file
offsets used are not multiples of such block sizes (but they are
multiples of 4Kb, 2Kb and 1Kb).

So update the test to use offsets that are multiples of 64Kb, since
that allows the test to work on filesystems with any block size
between 4Kb and 64Kb (8Kb, 16Kb, 32Kb). Verified it works as
expected on kernels that have the fixes for the issue tested by this
test case (listed in the changelog of commit
91540ef980110f78161893f98d946e2afa0c1f4a), and on systems without
those fixes (a 4.18 kernel), it fails as it is supposed to.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoseek_sanity_test: Repair check for unwritten extent support
Andreas Gruenbacher [Wed, 7 Aug 2019 11:25:14 +0000 (13:25 +0200)]
seek_sanity_test: Repair check for unwritten extent support

In test_basic_support, commit f3c1bca7fb25 ("generic: Test that
SEEK_HOLE can find a punched hole") cleverly punched a hole in the test
file in the middle of the check for unwritten extent support, making
sure we would never detect when unwritten extent support is missing.
Fix that.

While at it, explicitly check for SEEK_DATA support as well:  so far, we
were assuming that SEEK_HOLE support implies SEEK_DATA support, but it
won't hurt to actually check.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoaio-dio-regress: code clarification
Andreas Gruenbacher [Mon, 5 Aug 2019 22:49:29 +0000 (00:49 +0200)]
aio-dio-regress: code clarification

In this test, FILE_SIZE is defined as 300 but that definition isn't
used consistently.  Make the code more obvious.

(Used by generic/210.)

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/097: always mkfs with finobt enabled
Yong Sun [Wed, 7 Aug 2019 09:21:27 +0000 (09:21 +0000)]
xfs/097: always mkfs with finobt enabled

xfs/097 already requires finobt support by

_require_xfs_mkfs_finobt
_require_xfs_finobt

Always enable finobt feature at mkfs time, so test runs even finobt
is not set in MKFS_OPTIONS.

[Eryu: rewrite commit summary and log]

Signed-off-by: Yong Sun <yosun@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agolog-writes: Handle unrecognized options to prevent segfault
Qu Wenruo [Thu, 8 Aug 2019 07:29:40 +0000 (15:29 +0800)]
log-writes: Handle unrecognized options to prevent segfault

[BUG]
When using --help parameter (unrecognized) after valid --log/--replay,
log-writes just crashes:
  Starting program: replay-log --log /dev/test/test  --replay /dev/test/scratch1 --help
  /home/adam/xfstests-dev/src/log-writes/replay-log: unrecognized option '--help'

  Program received signal SIGSEGV, Segmentation fault.
  0x00007ffff7f5cc55 in __strlen_avx2 () from /usr/lib/libc.so.6
  (gdb) bt
  #0  0x00007ffff7f5cc55 in __strlen_avx2 () from /usr/lib/libc.so.6
  #1  0x00007ffff7e89363 in strdup () from /usr/lib/libc.so.6
  #2  0x00005555555554ac in main (argc=6, argv=0x7fffffffea78)
      at replay-log.c:219

[CAUSE]
We didn't check return value from getopt_long() for unrecognized
parameter, thus we reuse the old opt_index, and if that option needs an
parameter, we will access optarg which can be NULL and cause segfault.

[FIX]
Check return value from getopt_long() for '?' to handle unrecognized
options correctly.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/quota: enable project quota correctly on f2fs
Chao Yu [Mon, 29 Jul 2019 11:56:20 +0000 (19:56 +0800)]
common/quota: enable project quota correctly on f2fs

Add a case for f2fs on _scratch_enable_pquota() to enable
dependent features of project quota by mkfs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test statfs on project quota directory
Zorro Lang [Sun, 28 Jul 2019 09:07:15 +0000 (17:07 +0800)]
xfs: test statfs on project quota directory

There's a bug on xfs cause statfs get negative f_ffree value from
a project quota directory. It's fixed by "de7243057 fs/xfs: fix
f_ffree value for statfs when project quota is set". So add statfs
testing on project quota block and inode count limit.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: test new v5 bulkstat commands
Darrick J. Wong [Thu, 1 Aug 2019 01:43:10 +0000 (18:43 -0700)]
xfs: test new v5 bulkstat commands

Check that the new v5 bulkstat commands do everything the old one do,
and then make sure the new functionality actually works.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/xfs: refactor agcount calculation for mounted filesystems
Darrick J. Wong [Thu, 1 Aug 2019 01:43:04 +0000 (18:43 -0700)]
common/xfs: refactor agcount calculation for mounted filesystems

Create a helper function to return the number of AGs of a mounted
filesystem so that we can get rid of the open-coded versions in various
tests.  The new helper will be used in a subsequent patch.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/122: add the new v5 bulkstat/inumbers ioctl structures
Darrick J. Wong [Thu, 1 Aug 2019 01:42:57 +0000 (18:42 -0700)]
xfs/122: add the new v5 bulkstat/inumbers ioctl structures

The new v5 bulkstat and inumbers structures are correctly padded so that
no format changes are necessary across platforms, so add them to the
output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/122: mask wonky ioctls
Darrick J. Wong [Thu, 1 Aug 2019 01:42:47 +0000 (18:42 -0700)]
xfs/122: mask wonky ioctls

Don't check the structure size of the inogrp/bstat/fsop_bulkreq
structures because they're incorrectly padded.  When we remove the
old typdefs the old filter stops working.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/122: ignore inode geometry structure
Darrick J. Wong [Thu, 1 Aug 2019 01:42:41 +0000 (18:42 -0700)]
xfs/122: ignore inode geometry structure

Ignore new in-core structure.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/194: unmount forced v4 fs during cleanup
Darrick J. Wong [Thu, 25 Jul 2019 18:04:13 +0000 (11:04 -0700)]
xfs/194: unmount forced v4 fs during cleanup

Unmount the V4 filesystem we forcibly created to run this test during
test cleanup so that the post-test wrapup checks won't try to remount
the filesystem with different MOUNT_OPTIONS (specifically, the ones
that get screened out by _force_xfsv4_mount_options) and fail.

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>
4 years agoxfs/033: filter out root inode nlink repair
Darrick J. Wong [Wed, 24 Jul 2019 15:56:31 +0000 (08:56 -0700)]
xfs/033: filter out root inode nlink repair

A couple of releases ago, xfs_repair was patched to set the root inode
link count correctly when messing around with lost inodes.  However, the
old xfs_repair remains in the golden output, so remove it and filter the
line so that we don't cause 'new' regressions on old software.

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>
4 years agofstests: disable quotas before running test
Darrick J. Wong [Wed, 24 Jul 2019 15:56:10 +0000 (08:56 -0700)]
fstests: disable quotas before running test

For all the tests which require that quotas be disabled, remove the
quota mount options before mounting the scratch filesystem.

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>
4 years agogeneric/506: mount scratch fs before testing for prjquota presence
Darrick J. Wong [Wed, 24 Jul 2019 15:55:43 +0000 (08:55 -0700)]
generic/506: mount scratch fs before testing for prjquota presence

On XFS, the _require_prjquota helper takes a path to a block device,
but (unintuitively) requires the block device to be mounted for the
detection to work properly.  Fix the detection code in generic/506.

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>
4 years agogeneric/561: kill duperemove after sleep_time
Darrick J. Wong [Wed, 24 Jul 2019 04:13:06 +0000 (21:13 -0700)]
generic/561: kill duperemove after sleep_time

generic/561 can take a very long time to run on XFS (45+ minutes)
because it kicks off fsstress and a lot of duperemove processes,
waits 50 seconds, and then waits for the duperemove processes to
finish.  duperemove, however, fights with fsstress for file locks
and can take a very long time to make even a single pass over the
filesystem and exit, which means the test just takes forever to run.

Once we've decided to tear down the duperemove processes let's just send
them SIGINT and then wait for them to exit.

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>
4 years agoxfs/504: fix bogus test description
Darrick J. Wong [Wed, 24 Jul 2019 04:13:00 +0000 (21:13 -0700)]
xfs/504: fix bogus test description

Fix the description of this test to reflect what it actually checks.

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>
4 years agooverlay/065: adjust test to expect EBUSY only with index=on
Amir Goldstein [Sun, 28 Jul 2019 10:21:24 +0000 (13:21 +0300)]
overlay/065: adjust test to expect EBUSY only with index=on

This is needed to support the kernel regression fix commit 0be0bfd2de9d
("ovl: fix regression caused by overlapping layers detection").

Overlayfs mount is not supposed to fail due to upper/work dir in-use
by other mount unless option index=on is enabled.

Add test variants for index=on and index=off.

Fix some wrong comments and clean noise lines in golden output.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: ceph only supports default SEEK_HOLE behavior
Jeff Layton [Fri, 26 Jul 2019 13:45:52 +0000 (09:45 -0400)]
common/rc: ceph only supports default SEEK_HOLE behavior

CephFS currently has only a very primitive SEEK_HOLE implementation,
and always sets the offset to EOF when it's used. Remove it from the
whitelist.

Cc: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: check quota sysfile feature for f2fs
Chao Yu [Tue, 23 Jul 2019 09:25:29 +0000 (17:25 +0800)]
common/rc: check quota sysfile feature for f2fs

In _require_prjquota(), f2fs missed to check whether we have enabled
quota sysfile feature in the image, add it.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/quota: support f2fs in _require_quota() and _check_quota_usage()
Chao Yu [Tue, 23 Jul 2019 09:25:28 +0000 (17:25 +0800)]
common/quota: support f2fs in _require_quota() and _check_quota_usage()

This can let f2fs pass the check of quota testcases.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: cross-device copy_file_range test
Amir Goldstein [Mon, 15 Jul 2019 12:55:16 +0000 (15:55 +0300)]
generic: cross-device copy_file_range test

Old kernels do not support cross-device copy_file_range.

This is a regression test for kernel commit:

  5dae222a5ff0 vfs: allow copy_file_range to copy across devices

[Amir] Split out cross-device copy_range test to a new test and
_notrun if kernel/filesystem do not support cross-device copy_range.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: copy_file_range bounds test
Amir Goldstein [Mon, 15 Jul 2019 12:55:15 +0000 (15:55 +0300)]
generic: copy_file_range bounds test

Test that copy_file_range will return the correct errors for various
error conditions and boundary constraints.

This is a regression test for kernel commit:

  96e6e8f4a68d ("vfs: add missing checks to copy_file_range")

[Amir] Split out cross-device copy_range test and use only test dev.
Split out immutable/swapfile test cases to reduce the requirements to
run the bounds check to minimum and get coverage for more filesystems.
Remove the tests for read past EOF and write after chmod -r,
because we decided to stick with read(2)/write(2) semantics.
Add requirements needed for large size copy tests and fifo test.
Use existing char/block devices for char/block dev tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: check support for xfs_io copy_range -f N
Amir Goldstein [Mon, 15 Jul 2019 12:55:14 +0000 (15:55 +0300)]
common/rc: check support for xfs_io copy_range -f N

Implement "_require_xfs_io_command copy_range -f" to check for
the option added by following xfsprogs commit:

  10d4ca4aeff5 ("xfs_io: allow passing an open file to copy_range")

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared/011: move to generic/
Christoph Hellwig [Mon, 15 Jul 2019 08:25:23 +0000 (10:25 +0200)]
shared/011: move to generic/

Now that we run the test for all block device based file systems, there
is no reason to keep it out of generic.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared/011: run for all block device based file systems
Christoph Hellwig [Mon, 15 Jul 2019 08:25:22 +0000 (10:25 +0200)]
shared/011: run for all block device based file systems

Cgroupv2 writeback support can't be easily detected.  But it is
kindof expected from block based file systems and can be easily
added, so just assume support and fail if it doesn't work.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/cgroup2: better error message if cgroup2 fs is not mounted
Christoph Hellwig [Mon, 15 Jul 2019 08:25:21 +0000 (10:25 +0200)]
common/cgroup2: better error message if cgroup2 fs is not mounted

Improve the _require_cgroup2 helper to print a more useful message
if the cgroup2 fs is not mounted.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agobtrfs: test incremental send after deduplication on both snapshots
Filipe Manana [Wed, 17 Jul 2019 12:24:39 +0000 (13:24 +0100)]
btrfs: test incremental send after deduplication on both snapshots

Test that an incremental send operation works after deduplicating into the
same file in both the parent and send snapshots.

This currently fails on btrfs and a kernel patch to fix it was submitted
with the subject:

  Btrfs: fix incremental send failure after deduplication

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: set max label length for f2fs
Chao Yu [Thu, 18 Jul 2019 09:11:54 +0000 (17:11 +0800)]
common/rc: set max label length for f2fs

f2fs can support FS_IOC_{GET,SET}FSLABEL now, set max label length
to enable generic/492 testcase for f2fs.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/119: fix MKFS_OPTIONS exporting
Darrick J. Wong [Tue, 9 Jul 2019 17:49:53 +0000 (10:49 -0700)]
xfs/119: fix MKFS_OPTIONS exporting

This test originally exported its own MKFS_OPTIONS to force the tested
filesystem config to the mkfs defaults + test-specific log size options.
This overrides whatever the test runner might have set in MKFS_OPTIONS.

In commit 2fd273886b525 ("xfs: refactor minimum log size formatting
code") we fail to export our test-specific MKFS_OPTIONS before
calculating the minimum log size, which leads to the wrong min log size
being calculated once we fixed the helper to be smarter about mkfs options.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/016: calculate minimum log size and end locations
Darrick J. Wong [Tue, 9 Jul 2019 17:49:47 +0000 (10:49 -0700)]
xfs/016: calculate minimum log size and end locations

xfs/016 looks for corruption in the log when the log wraps.  However,
it hardcodes the minimum log size and the "95%" point where it wants to
start the "nudge and check for corruption" part of the test.  New
features require larger logs, which causes the test to fail when it
can't mkfs with the smaller log size and when that 95% point doesn't put
us within 20x "_log_traffic 2"s of the end of the log.

Fix the first problem by using the new min log size helper and replace
the 95% figure with an estimate of where we need to be to guarantee that
the 20x loop wraps the log.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Allison Collins <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs: rework min log size helper
Darrick J. Wong [Tue, 9 Jul 2019 17:49:41 +0000 (10:49 -0700)]
xfs: rework min log size helper

The recent _scratch_find_xfs_min_logblocks helper has a major thinko in
it -- it relies on feeding a too-small size to _scratch_do_mkfs so that
mkfs will tell us the minimum log size.  Unfortunately, _scratch_do_mkfs
will see that first failure and retry the mkfs without MKFS_OPTIONS,
which means that we return the minimum log size for the default mkfs
settings without MKFS_OPTIONS.

This is a problem if someone's running fstests with a set of
MKFS_OPTIONS that affects the minimum log size.  To fix this, open-code
the _scratch_do_mkfs retry behavior so that we only do the "retry
without MKFS_OPTIONS" behavior if the mkfs failed for a reason other
than the minimum log size check.

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>
4 years agobtrfs/189: make the test work on systems with a page size greater than 4Kb
Filipe Manana [Fri, 5 Jul 2019 11:26:21 +0000 (12:26 +0100)]
btrfs/189: make the test work on systems with a page size greater than 4Kb

The test currently uses offsets and lengths which are multiples of
4K, but not multiples of 64K (or any other page size between 4Kb and
64Kb). This makes the reflink calls fail with -EINVAL because
reflink only operates on ranges that are aligned to the the
filesystem's block size.

Fix this by ensuring all ranges passed to the reflink calls are
aligned to 64K, so that the test works on any system regardless of
its page size.  The test still fails without the corresponding
kernel fix applied [1] as it is supposed to.

[1] 3c850b45110950 ("Btrfs: incremental send, fix emission of invalid clone operations")

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/399: don't rely on xfs_io exit status
Eric Biggers [Mon, 8 Jul 2019 20:32:39 +0000 (13:32 -0700)]
generic/399: don't rely on xfs_io exit status

Unexpectedly, 'xfs_io -f $file -c "pwrite 0 1M"' exits with failure
status if the file can't be created, but exits with success status if an
error occurs actually writing data.  As discussed previously, xfs_io's
exit status has always been broken, and it will be difficult to fix:
https://marc.info/?l=linux-xfs&m=151269053129101&w=2

Because of this, generic/399 fails on ext4 if "-I 256" (256-byte inodes)
is specified in the mkfs options, e.g. with 'kvm-xfstests -c ext4/adv
generic/399'.  This is because the test tries to fill a filesystem
entirely with 1 MiB encrypted files, and it expects the xfs_io commands
to start failing when no more files should be able to fit.  But when the
filesystem supports in-inode xattrs, no blocks need to be allocated for
the encryption xattrs, so empty encrypted files can continue to be
created even after all the filesystem's blocks are in-use.

For better or worse, the convention for xfstests is to ignore the exit
status of xfs_io and instead rely on the printed error messages.  Thus,
other tests don't run into this problem.  So for now, let's fix the test
failure by making generic/399 do the same.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoxfs/449: test xfs_info on a mounted block device
Zorro Lang [Sat, 6 Jul 2019 14:52:17 +0000 (22:52 +0800)]
xfs/449: test xfs_info on a mounted block device

There was a bug, xfs_info fails on a mounted block device:

  # xfs_info /dev/mapper/testdev
  xfs_info: /dev/mapper/testdev contains a mounted filesystem

  fatal error -- couldn't initialize XFS library

  xfsprogs has fixed it by:

    bbb43745 xfs_info: use findmnt to handle mounted block devices

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/rc: print out kernel version too
Mauricio Faria de Oliveira [Wed, 10 Jul 2019 17:58:09 +0000 (14:58 -0300)]
common/rc: print out kernel version too

The kernel version (uname -v) may also be needed in addition to
the kernel release (uname -r) in order to properly identify and
distinguish different kernel builds in some cases/distributions.

For example, in the Ubuntu kernel package the test/debug string
is usually a suffix to the version field, not the release field.

  $ uname -rv
  4.15.0-51-generic #55-Ubuntu SMP Wed May 15 14:27:21 UTC 2019

  $ uname -rv
  4.15.0-51-generic #55+test20190520b1 SMP Mon May 20 11:57:40 -03 2019

Looking at other OSes uname(1) man pages it looks like '-v' is
quite standard, and the Linux man page only cites '-p' and '-i'
as non-portable, so the change should be OK. The only caller is
the 'check' script for the header print out, so it's contained.

Signed-off-by: Mauricio Faria de Oliveira <mfo@canonical.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric/553[4]: correct kernel fix commit
Yang Xu [Wed, 10 Jul 2019 11:35:22 +0000 (19:35 +0800)]
generic/553[4]: correct kernel fix commit

commit 96e6e8f4a68d ("vfs: add missing checks to copy_file_range")
adds checks for immutablefile and swapfile instead of commit a31713517d
("vfs: introduce generic_file_rw_checks()").

Signed-off-by: Yang Xu <xuyang2018.jy@cn.fujitsu.com>
Reviewed-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agogeneric: test cloning large exents to a file with many small extents
Filipe Manana [Fri, 28 Jun 2019 22:08:36 +0000 (23:08 +0100)]
generic: test cloning large exents to a file with many small extents

Test that if we clone a file with some large extents into a file
that has many small extents, when the fs is nearly full, the clone
operation does not fail and produces the correct result.

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

 [PATCH 1/2] Btrfs: factor out extent dropping code from hole punch handler
 [PATCH 2/2] Btrfs: fix ENOSPC errors, leading to transaction aborts, when
             cloning extents

The test currently passes on xfs.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared,generic: move tests using duperemove to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:10 +0000 (18:59 -0400)]
shared,generic: move tests using duperemove to generic/

Add _require_scratch_duperemove which validates that the file system
supports duperemove.  This allows us to move three tests from shared/
to generic/.  This means these tests will automatically adapt when
duperemove supports other file systems.  Tests moved are:

shared/008 --> generic/559
shared/009 --> generic/560
shared/010 --> generic/561

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared,generic: move shared/006 to generic/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:09 +0000 (18:59 -0400)]
shared,generic: move shared/006 to generic/

The shared/006 uses _scratch_mkfs_sized to create a limited size
file system, and then creates inodes until it gets ENOSPC, and then
checks to make sure the file system is consistent.  It then remounts
the file system, removes all of the files, and makes sure the file
system is consistent afterwards. This test was marked as only being
supported on ext[234] and xfs, and so it was in shared.

Now introduce a new _require_inode_limits() rule to run test on
filesystems that have a fixed inode number, then move the test to
generic.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared,ext4: move ext[234]-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:08 +0000 (18:59 -0400)]
shared,ext4: move ext[234]-specific tests out of shared/

Move the following tests:

shared/005 --> ext4/040
shared/007 --> ext4/041
shared/289 --> ext4/042

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocheck: add ext4 group list when testing ext2 and ext3
Theodore Ts'o [Fri, 28 Jun 2019 22:59:07 +0000 (18:59 -0400)]
check: add ext4 group list when testing ext2 and ext3

Modern kernels use the ext4 implementation to support ext2 and ext3
mounts, and a number of the ext4 tests are actually suitable for
ext2 and ext3.  We're trying to move tests out of shared anyway, so
instead of moving tests from ext4/NNN to shared, let's just include
the ext4 group list when FSTYP is ext2 or ext3.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agoshared,ext4: move ext4-specific tests out of shared/
Theodore Ts'o [Fri, 28 Jun 2019 22:59:06 +0000 (18:59 -0400)]
shared,ext4: move ext4-specific tests out of shared/

The tests shared/{001,003,004,272} test behaviour around the ext4's
journal.  As such, they are pointless to run on ext2, and ext3 no
longer is in kernels newer than 4.3.  (And most enterprise
distributions have been using ext4 to support the ext3 file system;
that capability has been around since 2.6.33.)  So we can move these
tests out of shared and into the ext4 class of tests:

shared/001 --> ext4/036
shared/003 --> ext4/037
shared/004 --> ext4/038
shared/272 --> ext4/039

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
4 years agocommon/encrypt: check that contents encryption is usable
Eric Biggers [Mon, 1 Jul 2019 17:12:55 +0000 (10:12 -0700)]
common/encrypt: check that contents encryption is usable

In _require_encryption_policy_support(), when checking whether the
encryption policy is usable, try creating a nonempty file rather
than an empty one.  This ensures that both the contents and
filenames encryption modes are available, rather than just the
filenames mode.

On f2fs this makes generic/549 be correctly skipped, rather than
failed, when run on a kernel built from the latest fscrypt.git tree
with CONFIG_CRYPTO_SHA256=n.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>