xfstests-dev.git
4 years agogeneric/405: test mkfs against thin provision device
Boyang Xue [Wed, 18 Jan 2017 09:27:24 +0000 (17:27 +0800)]
generic/405: test mkfs against thin provision device

Test mkfs against thin provision device, which has very small
backing size and very big virtual size. mkfs should return error
when it hits EIO.

Signed-off-by: Boyang Xue <bxue@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/dmthin: call $UDEV_SETTLE_PROG before 'dmsetup remove'
Boyang Xue [Wed, 18 Jan 2017 09:27:23 +0000 (17:27 +0800)]
common/dmthin: call $UDEV_SETTLE_PROG before 'dmsetup remove'

Wait for device to be fully settled so that 'dmsetup remove' doesn't
fail due to EBUSY.

Signed-off-by: Boyang Xue <bxue@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agotools: compare-failures script
Eric Sandeen [Fri, 13 Jan 2017 14:56:15 +0000 (08:56 -0600)]
tools: compare-failures script

This is a simple script to compare failures across runs.

Given files containing stdout from several runs, each of which contains
a Failures: line, it will print a table of all failures for each run.
Test subdir names are abbreviated for compactness, i.e. generic->g.
For 7 results files named test 1 through test 7:

Failures:
g/075 g/082 g/209 g/233 g/270 g/388 x/004 x/073 x/076
-----------------------------------------------------
      g/082       g/233             x/004 x/073       test1
      g/082       g/233             x/004 x/073 x/076 test2
      g/082                         x/004 x/073 x/076 test3
      g/082                   g/388 x/004 x/073       test4
      g/082             g/270       x/004 x/073       test5
      g/082                         x/004 x/073       test6
g/075 g/082 g/209 g/233             x/004 x/073       test7

This lets us easily spot unique failures and outliers.

This could be enhanced to output CSV etc, but for now I think it's
helpful to visualize changes in failures across multiple runs.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/btrfs: add helper to detect dump-super or btrfs-show-super
David Sterba [Mon, 16 Jan 2017 15:35:12 +0000 (16:35 +0100)]
common/btrfs: add helper to detect dump-super or btrfs-show-super

The command btrfs-show-super is not supposed to be distributed but
was useful for testing. The same functionality is now present as
'btrfs inspect-internal dump-super', let's detect which one is
available and use it in btrfs/011 that fails with btrfs-progs 4.8.4+

Signed-off-by: David Sterba <dsterba@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test concurrent copy up
Amir Goldstein [Mon, 16 Jan 2017 12:42:25 +0000 (14:42 +0200)]
overlay: test concurrent copy up

Run 4 process pairs, each competing over copy up of 1K files
in 1 directory. One opponent touches all files in the directory
and the other truncates all files in the directory.

This test does NOT check for concurrent copy up support. It only
fails on unexpected errors of any of the touch/truncate operations.

The test full output should demonstrate the expected results -
for kernel with concurrent copy up support, truncate workers are
not delayed by touch workers. As a result, truncate workers will
finish their work much sooner than a test run without concurrent
copy up support.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoREADME: Fix Quick start typo
Lakshmipathi.G [Mon, 16 Jan 2017 23:13:41 +0000 (04:43 +0530)]
README: Fix Quick start typo

Signed-off-by: Lakshmipathi.G <Lakshmipathi.G@giis.co.in>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: Fix _supports_filetype function
Xiao Yang [Mon, 16 Jan 2017 08:07:20 +0000 (16:07 +0800)]
common/rc: Fix _supports_filetype function

generic/401 failed on RHEL6.8GA because "--output=xxx"
option is not supported by df.  So we remove it.

Signed-off-by: Xiao Yang <yangx.jy@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/004: account for XFS reservations changes in 4.10-rc
Christoph Hellwig [Fri, 13 Jan 2017 17:05:40 +0000 (18:05 +0100)]
xfs/004: account for XFS reservations changes in 4.10-rc

And drop support for some really old kernels to clean things up.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: use /bin/bash in _user_do()
Christoph Hellwig [Fri, 13 Jan 2017 16:38:16 +0000 (17:38 +0100)]
common/rc: use /bin/bash in _user_do()

Without this the epressions in generic/256 will fail on a system
where /bin/sh is the Default (e.g. modern Debian versions).

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: remove unused XFSPROGS_VERSION check
David Disseldorp [Thu, 12 Jan 2017 17:18:48 +0000 (18:18 +0100)]
common: remove unused XFSPROGS_VERSION check

This was only used to check for mkfs.xfs -n version=ci support,
which is carried in xfsprogs >= 2.10. _require_xfs_mkfs_ciname() is
now used to explicitly check for the mkfs parameter.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/188: add and use _require_xfs_mkfs_ciname
David Disseldorp [Thu, 12 Jan 2017 17:18:47 +0000 (18:18 +0100)]
xfs/188: add and use _require_xfs_mkfs_ciname

Use an explicit mkfs -n version=ci test to check whether the test
should run, instead of checking the xfsprogs version.

Suggested-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoRevert "generic/38[3-6]: require project quota to be enabled on SCRATCH_DEV"
Eryu Guan [Fri, 16 Dec 2016 04:14:14 +0000 (12:14 +0800)]
Revert "generic/38[3-6]: require project quota to be enabled on SCRATCH_DEV"

Commit 23f60ef304d ("generic/38[3-6]: require project quota to be
enabled on SCRATCH_DEV") introduced a regression that leads
_require_projquota, which uses src/feature to call a quotactl,
operate before the filesystem is mounted, and results in tests not
run on XFS and ext4.

Revert the problematic patch first, because don't want to lose
project quota test coverage on XFS and ext4. We can fix the false
failure on ext3/2 later,

Reported-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: reproduce ext4 bugs in a shift extents logic
Roman Pen [Wed, 11 Jan 2017 09:52:39 +0000 (10:52 +0100)]
generic: reproduce ext4 bugs in a shift extents logic

Regression test which targets two nasty ext4 bugs in a logic which
shifts extents:

1) 14d981f468a1 ("ext4: Include forgotten start block on fallocate insert range")

Test tries to insert many blocks at the same offset to reproduce
the following layout on ext4:

   block #0  block #1
   |ext0 ext1|ext2 ext3 ...|
        ^
     insert of a new block

Because of an incorrect range first block is never reached,
thus ext1 is untouched, resulting to a hole at a wrong offset:

What we got:

   block #0   block #1
   |ext0 ext1|   ext2 ext3 ...|
              ^
              hole at a wrong offset

What we expect:

   block #0    block #1
   |ext0   ext1|ext2 ext3 ...|
        ^
        hole at a correct offset

2) 2b3864b32403 ("ext4: do not polute the extents cache while shifting extents")

Extents status tree is filled in with outdated offsets while doing
extent shift, that leads to wrong data blocks.   That's why md5sum
of a result file is being checked after each block insert.

Signed-off-by: Roman Pen <roman.penyaev@profitbricks.com>
Cc: "Theodore Ts'o <tytso@mit.edu>"
Cc: Eryu Guan <eguan@redhat.com>
Cc: linux-ext4@vger.kernel.org
Cc: fstests@vger.kernel.org
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: test handling of invalid inode modes
Amir Goldstein [Mon, 9 Jan 2017 13:39:11 +0000 (15:39 +0200)]
xfs: test handling of invalid inode modes

Set all possible file type values for different types of files
and verify that xfs_repair detects the correct errors.

When setting invalid file type values (e.g. core.mode = 0170644),
all files are expected to have been junked by xfs_repair.

When setting valid file type values to non matching file types,
xfs_repair would either detect wrong format and junk the file, e.g.:
  would have junked entry "DATA" in directory PARENT_INO
or detect a ftype mismatch error, e.g.:
  would fix ftype mismatch (5/3) in directory/child PARENT_INO/FIFO_INO

If ftype feature is enabled, when setting file type to one of the
special types (i.e. FIFO(1), CHRDEV(2),BLKDEV(6),SOCKET(14)),
xfs_repair is expected to detect ftype mismatch error. Otherwise,
xfs_repair is not expected to detect ftype mismatch error.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/ext4: check negative inode size
Darrick J. Wong [Mon, 9 Jan 2017 20:55:18 +0000 (12:55 -0800)]
xfs/ext4: check negative inode size

Craft a malicious filesystem image with a negative inode size,
then try to trigger a kernel DoS by appending data to the file.
Ideally this should trigger verifier errors instead of hanging.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agodedupe: fix consistent error message prefixes for dedupe tests
Darrick J. Wong [Mon, 9 Jan 2017 20:54:18 +0000 (12:54 -0800)]
dedupe: fix consistent error message prefixes for dedupe tests

Since we're fixing the xfs_io dedupe command to consistently
print the dedupe ioctl name on error, fix the tests too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoreflink: make error reporting consistent when simulating EIO
Darrick J. Wong [Thu, 5 Jan 2017 01:05:08 +0000 (17:05 -0800)]
reflink: make error reporting consistent when simulating EIO

When we're using dm-error to simulate failed devices, we don't really
know if the write or the fdatasync is going to receive the EIO.  For
tests that make a single (failed) write attempt and never retry, it's
sufficient to check that the file md5 doesn't change after recovery.
For tests that /do/ retry the write, we should capture the entire output
and just look for the word error instead of enshrining the exact perror
message (filename/function call and everything) in the golden output.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoreflink: fix quota tests to work properly
Darrick J. Wong [Mon, 9 Jan 2017 20:53:35 +0000 (12:53 -0800)]
reflink: fix quota tests to work properly

Fix the reflink quota tests to su to the fsgqa user so that we actually
test enforcement of quotas.  Seems that XFS enforces user quotas even
if root is writing to a user file, whereas everything else lets root
writes through.  Also clean up some of the variable usage and
_require_user.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoocfs2/reflink: fix file block size reporting
Darrick J. Wong [Thu, 5 Jan 2017 01:04:55 +0000 (17:04 -0800)]
ocfs2/reflink: fix file block size reporting

Some of the reflink tests try to require a specific filesystem block
size so that they can test file block manipulation functions.  That's
straightforward for most filesystems but ocfs2 throws in the additional
twist that data fork block mappings are stored in units of clusters, not
blocks, which causes these reflink tests to fail.

Therefore, introduce a new helper that retrieves the file minimum block
size and adapt the reflink tests to use that instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: add leading underscore to get_block_size
Darrick J. Wong [Thu, 5 Jan 2017 01:04:48 +0000 (17:04 -0800)]
common: add leading underscore to get_block_size

Add a leading underscore to the get_block_size helper since it's a
common function.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoocfs2: test reflinking to inline data files
Darrick J. Wong [Thu, 5 Jan 2017 01:04:42 +0000 (17:04 -0800)]
ocfs2: test reflinking to inline data files

Make sure that we can handle reflinking from and to inline-data files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/010: explicitly allow corrupted write in xfs_db
Eric Sandeen [Mon, 9 Jan 2017 16:49:21 +0000 (10:49 -0600)]
xfs/010: explicitly allow corrupted write in xfs_db

xfs/010 wants to write corruption and test how xfs_repair
deals, but when:

  xfs: forbid AG btrees with level == 0

is merged to userspace, this new test fails the write verifier
in xfs_db.

Add "-c" to allow the corrupted write, do the corruptions all
in one xfs_db command (so it doesn't have to re-read the
corrupted data on 2nd startup), and filter out the

  "Allowing write of corrupted data and bad CRC"

output from the "write -c" command.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/081: hack around the lvm unmount race
Christoph Hellwig [Mon, 9 Jan 2017 13:38:18 +0000 (14:38 +0100)]
generic/081: hack around the lvm unmount race

This is butt ugly, but I see no better way than to wait a bit to
work around the race between the weird umount in LVM, and the mount
ismounted checks.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: racing getxattr requests against xattr add/remove
Brian Foster [Fri, 6 Jan 2017 19:39:30 +0000 (14:39 -0500)]
generic: racing getxattr requests against xattr add/remove

This test reproduces a bug in XFS where a getxattr of an existing
xattr returns failure due to a race with a setxattr that causes
inode attribute fork conversion.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/118: add to dangerous group
Eric Sandeen [Sat, 7 Jan 2017 16:32:01 +0000 (10:32 -0600)]
xfs/118: add to dangerous group

Failure results in an oops, so add it to dangerous.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/158,304: filter dedupe error message
Eryu Guan [Fri, 30 Dec 2016 03:34:19 +0000 (11:34 +0800)]
generic/158,304: filter dedupe error message

Kernel commit 22725ce4e4a0 ("vfs: fix isize/pos/len checks for reflink &
dedupe") added more checks on reflink and dedupe, rejected dedupe past
EOF early and explicitly, and causes generic/158 and generic/304 to fail.

  Try dedupe from past EOF
 -dedupe: Invalid argument
 +XFS_IOC_FILE_EXTENT_SAME: Invalid argument
  Try dedupe to past EOF, destination offset beyond EOF

Also there's an xfsprogs patch from Darrick ("xfs_io: prefix dedupe
command error messages consistently") to change all xfs_io dedupe
error message prefixes to "XFS_IOC_FILE_EXTENT_SAME".

So introduce a new _filter_dedupe_error, change all "dedupe" prefix
to XFS_IOC_FILE_EXTENT_SAME, make tests pass with both old/new
kernel & userspace.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: copy up and remove from another namespace
Xiong Zhou [Wed, 4 Jan 2017 08:59:11 +0000 (16:59 +0800)]
overlay: copy up and remove from another namespace

Via unshare, copy up dir from lower dir then remove
them in another unshared namespace.

This would fail before v4.7 kernel with EPERM.

Kernel commit 3fe6e52f
  ovl: override creds with the ones from the superblock mounter
fixed this issue, with this reproducer provided. Original
reproducer was written by commit author:
Antonio Murdaca <amurdaca@redhat.com>

Signed-off-by: Xiong Zhou <xzhou@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: Add tests for inode timestamp policy
Deepa Dinamani [Wed, 4 Jan 2017 03:51:11 +0000 (19:51 -0800)]
generic: Add tests for inode timestamp policy

The test helps to validate clamping and mount behaviors
according to supported file system timestamp ranges.

Note that the test can fail on 32-bit systems for a
few file systems. This will be corrected when vfs is
transitioned to use 64-bit timestamps.

Signed-off-by: Deepa Dinamani <deepa.kernel@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: document tests include/exclude options
Amir Goldstein [Tue, 3 Jan 2017 09:15:14 +0000 (11:15 +0200)]
check: document tests include/exclude options

Add argument description and examples to usage() for the
various tests include and exclude options.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: support include/exclude of sub groups
Amir Goldstein [Mon, 2 Jan 2017 13:22:59 +0000 (15:22 +0200)]
check: support include/exclude of sub groups

Allow including and/or excluding tests by test dir and group.
-g and -x command line arguments can take the form of
<subdir>/<group>.

For example:

./check -n -g xfs/quick
./check -n -g stress -x xfs/stress
./check -n -g xfs/punch -x dangerous_fuzzers

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: factor out get_sub_group_list() helper
Amir Goldstein [Mon, 2 Jan 2017 13:22:58 +0000 (15:22 +0200)]
check: factor out get_sub_group_list() helper

This helper gets a list of tests that belong to a group
under a specific tests subdir.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/006: Fix false alert due to output change
Su Yue [Tue, 3 Jan 2017 03:16:17 +0000 (22:16 -0500)]
btrfs/006: Fix false alert due to output change

Btrfs-progs v4.9 changed "device status" output by adding one more
space, which differs from golden output.

Fix it by using filter '_filter_spaces' to convert multi space into
one.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/104: Redirect mkfs output to avoid false alert
Su Yue [Fri, 30 Dec 2016 04:14:09 +0000 (23:14 -0500)]
btrfs/104: Redirect mkfs output to avoid false alert

btrfs/104 doesn't redirect mkfs output correctly, which leads to
false alert.

Fix it.

Signed-off-by: Su Yue <suy.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/012: Enable test to be executed on non-4k block size filesystems
Chandan Rajendra [Mon, 26 Dec 2016 17:32:32 +0000 (23:02 +0530)]
btrfs/012: Enable test to be executed on non-4k block size filesystems

To get the test to work on non-4k block sized filesystems, this
commit obtains the block size of the Btrfs filesystem from
$TEST_DIR.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/132: wait the writer to avoid EBUSY
Qu Wenruo [Mon, 26 Dec 2016 04:57:52 +0000 (12:57 +0800)]
btrfs/132: wait the writer to avoid EBUSY

The kill and wait method will only wait for the children process to
exit, while the xfs_io can still run at background.

This makes the test always fails on HDD backed physical machine.

Use the "while ps aux | grep" method in btrfs/069 to truely wait the
xfs_io to finish.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test correct d_type values
Amir Goldstein [Wed, 21 Dec 2016 13:50:21 +0000 (15:50 +0200)]
generic: test correct d_type values

Verify correct d_type values of dir entries.

This test does NOT require that file system support the filetype
feature.  It verifies that either all file types are reported as
DT_UNKNOWN or that all file types are reported correctly.

For fs for which we know how to test the filetype feature (xfs|ext*)
verify getting DT_UNKNOWN IFF filetype feature is disabled.

Special dir entries . and .. MAY be reported as DT_UNKNOWN IF
filetype feature is disabled (ext4), but MAY also be reported as
DT_DIR in this case (xfs).

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: add generic file type support check
Amir Goldstein [Tue, 20 Dec 2016 13:17:34 +0000 (15:17 +0200)]
common/rc: add generic file type support check

_supports_filetype() helper checks if the filetype feature
is enabled for xfs and ext* file sytems.

Add a check for the generic case where we don't know
how to test file system filetype feature.

Introduce a helper utility t_dir_type that lists directory
entries filtered by file type.

Check for filetype feature by expecting to find no directory
entries listed as DT_UNKNOWN inside a test directory.

[eguan: declare temp vars as local]

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/rc: factor out _supports_filetype() helper
Amir Goldstein [Tue, 20 Dec 2016 13:17:33 +0000 (15:17 +0200)]
common/rc: factor out _supports_filetype() helper

_overlay_mount_dirs() checks for the filetype feature
on upper dir fs.

factor out that feature test to a helper.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: stress test changes to top and bottom layers simultaneously
Theodore Ts'o [Thu, 22 Dec 2016 19:53:46 +0000 (14:53 -0500)]
overlay: stress test changes to top and bottom layers simultaneously

Introduce a test which runs fsstress on the top and bottom overlayfs
directories simultaneously to find potential races that plagued
wrapfs derived file systems.

[eguan: add copyright info and fix minor code style issue]

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: add _require_getnextquota helper
Eric Sandeen [Sat, 24 Dec 2016 10:11:41 +0000 (18:11 +0800)]
common: add _require_getnextquota helper

Add a helper to determine if the kernel supports
the GETNEXTQUOTA quotactl.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/244: remove extra junk
Eric Sandeen [Thu, 22 Dec 2016 01:23:06 +0000 (19:23 -0600)]
generic/244: remove extra junk

Lots of pointless mounting & unmounting & quotaon etc,
get rid of it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test GETNEXTQUOTA near INT_MAX
Eric Sandeen [Sat, 24 Dec 2016 10:07:45 +0000 (18:07 +0800)]
generic: test GETNEXTQUOTA near INT_MAX

XFS kernel code had a bug where GETNEXTQUOTA-type
quotactls requesting an ID near UINT_MAX could overflow
and return 0 as the "next" active ID.

This test checks that by creating an active quota near
UINT_MAX, then asking for the next one after it.

The proper answer is ENOENT, but if we wrap we'll return
ID 0.

This also changes test-nextquota.c so that it checks
both GETNEXTQUOTA and XGETNEXTQUOTA even if one fails;
it stores the failure conditions and returns 1 if either
of them fails.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test for weaknesses in filesystem encryption
Eric Biggers [Wed, 21 Dec 2016 21:22:02 +0000 (13:22 -0800)]
generic: test for weaknesses in filesystem encryption

Add an xfstest which can detect some basic crypto mistakes that would
reduce the confidentiality guarantee provided by filesystem encryption.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test enforcement of one encryption policy per tree
Eric Biggers [Thu, 15 Dec 2016 20:26:24 +0000 (12:26 -0800)]
generic: test enforcement of one encryption policy per tree

Add an xfstest which verifies that the filesystem forbids operations
that would violate the constraint that all files in an encrypted
directory tree use the same encryption policy.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test encrypted file access
Eric Biggers [Thu, 15 Dec 2016 20:26:23 +0000 (12:26 -0800)]
generic: test encrypted file access

Test accessing encrypted files and directories, both with and
without the encryption key.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test validation of encryption policy structure
Eric Biggers [Thu, 15 Dec 2016 20:26:22 +0000 (12:26 -0800)]
generic: test validation of encryption policy structure

Add an xfstest which verifies the kernel performs basic validation
of the encryption policy structure.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: test setting and getting encryption policies
Eric Biggers [Thu, 15 Dec 2016 20:26:21 +0000 (12:26 -0800)]
generic: test setting and getting encryption policies

Several kernel bugs were recently fixed regarding the constraints
for setting encryption policies.  Add tests for these cases and a
few more.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoencrypt: add utilities for testing filesystem encryption
Eric Biggers [Thu, 15 Dec 2016 20:26:20 +0000 (12:26 -0800)]
encrypt: add utilities for testing filesystem encryption

Add utility functions for testing filesystem-level encryption via
the common API currently supported by ext4 and f2fs, in development
for ubifs and planned for xfs.  Setting and getting encryption
policies will use new commands being added to xfs_io, while adding
and removing encryption keys will use keyctl.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/047: Remove test since upstream don't accept stream-version
Qu Wenruo [Tue, 20 Dec 2016 01:24:56 +0000 (09:24 +0800)]
btrfs/047: Remove test since upstream don't accept stream-version

Btrfs upstream doesn't accept stream-version, so the test is never
ran on upstream kernel nor btrfs-progs.

Just remove it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: teach _scratch_mkfs to handle mkfs option conflicts
Eryu Guan [Sun, 4 Dec 2016 16:15:08 +0000 (00:15 +0800)]
fstests: teach _scratch_mkfs to handle mkfs option conflicts

Currently in _scratch_mkfs only xfs and ext4 could handle the mkfs
failure caused by conflicts between $MKFS_OPTIONS and mkfs options
specified by tests, because of _scratch_mkfs_xfs and
_scratch_mkfs_ext4. This is a very useful functionality that allows
tests to specify mkfs options safely and to test specific fs
configurations, without worrying about mkfs failures caused by these
options.

Now teach _scratch_mkfs to handle such mkfs option conflicts for
other filesystems too, i.e. mkfs again only with mkfs options
specified by tests. Also add the ability to filter unnecessary
messages from mkfs stderr.

Also update some btrfs tests to throw away _scratch_mkfs stdout,
because previously _scratch_mkfs did this for btrfs.

Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: make sure file size resource limit is honored by fs
Eryu Guan [Sat, 3 Dec 2016 05:23:59 +0000 (13:23 +0800)]
generic: make sure file size resource limit is honored by fs

If a file size limitation is set, underlying filesystem should not
break the limit and exceed the max file size.

Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test hardlink breakage on copy up
Amir Goldstein [Tue, 13 Dec 2016 05:12:37 +0000 (07:12 +0200)]
overlay: test hardlink breakage on copy up

Introduce a new test to demonstrate a known issue with overlayfs:
- file A and B are hardlinked in lower
- modify A to trigger copy up
- file A is no longer a hardlink of file B

There is no fix for this issue at this time.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/062: don't assume same readdir order after re-creating directory
Eric Biggers [Tue, 13 Dec 2016 06:57:01 +0000 (22:57 -0800)]
generic/062: don't assume same readdir order after re-creating directory

generic/062 uses getfattr to dump xattrs for a directory tree, then
deletes and recreates that directory tree, then dumps the xattrs
again and compares the dump to the original.  This was failing when
run on ext4 with encryption enabled because getfattr's output is in
readdir order, but ext4 encryption by design chooses unpredictable
encrypted filenames for each new directory, causing the readdir
order to change after backup and restore.  It is not really a valid
assumption that the readdir order will always be the same, so update
the test to sort the filenames, removing this assumption.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: associate tests to copyup group
Amir Goldstein [Mon, 12 Dec 2016 09:32:12 +0000 (11:32 +0200)]
overlay: associate tests to copyup group

Tests 016 and 013 both test behavior of concurrent
file access during copy up (truncate+exec and read+write).

Associate those tests to the copyup group.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test unstable inode number
Amir Goldstein [Tue, 13 Dec 2016 06:18:29 +0000 (08:18 +0200)]
overlay: test unstable inode number

Introduce a new test to demonstrate a known issue with overlayfs:
- stat file A shows inode number X
- modify A to trigger copy up
- stat file A shows inode number Y != X

Also test if d_ino of readdir entries changes after copy up.

There is a POC patch by Miklos Szeredi that fixes this issue.

Not dealing with hardlinks here, because there is more to test
then stable inode number.
Hardlinks will get a test of their own.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/016: do not cd into $SCRATCH_MNT
Amir Goldstein [Tue, 13 Dec 2016 06:15:29 +0000 (08:15 +0200)]
overlay/016: do not cd into $SCRATCH_MNT

Avoid cd into $SCRATCH_MNT

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: make 17[1-4] work well when btrfs compression is enabled
Wang Xiaoguang [Wed, 2 Nov 2016 04:07:27 +0000 (12:07 +0800)]
generic: make 17[1-4] work well when btrfs compression is enabled

When enabling btrfs compression, original codes can not fill fs
correctly, here we introduce _fill_fs() in common/rc, which'll keep
creating and writing files until enospc error occurs. Note _fill_fs
is copied from tests/generic/256, but with some minor modifications.

Signed-off-by: Wang Xiaoguang <wangxg.fnst@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoreflink: don't test disjoint block sharing sets
Darrick J. Wong [Sun, 11 Dec 2016 21:53:22 +0000 (13:53 -0800)]
reflink: don't test disjoint block sharing sets

Unlike xfs/btrfs which store refcounting information as part of the
space metadata, ocfs2 implements block sharing (reflink) by creating
refcount btrees that are shared between subsets of files.  Effectively,
this means that a ocfs2 can have multiple disjoint sets of files that
share blocks, which also means that blocks cannot be reflinked between
two disjoint refcounted-file-sets.  generic/119 tests the ability to do
this, so we cannot run it for ocfs2.  Create a _require helper to check
for this.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: fix excluding test groups
Amir Goldstein [Fri, 9 Dec 2016 08:50:46 +0000 (10:50 +0200)]
check: fix excluding test groups

The -x flag is used to exclude tests that belong to
certain groups from the test args list.

When the test args list is expressed as a match pattern,
-x fails to exclude the tests that match the pattern
and belong to excluded groups.

For example:
$ ./check -n xfs/??? | wc -l
341
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l
341

After the fix:
$ ./check -n -x fuzzers,dangerous_fuzzers xfs/??? | wc -l
315

This bug seems to date back to this git repo epoc.

The fix also sorts out filtering of test that are not found
in group files for the patten match input.

For example:
$ ./check xfs/001*
...
xfs/001  2s
xfs/001.out  [failed, exit status 127] - no qualified output

After the fix:
$ ./check -n xfs/001*
xfs/001.out - unknown test, ignored
...
xfs/001 2s

[eguan: use grep -q and fix if-then-fi style]

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/016: use xfs_io -C for executing commands
Amir Goldstein [Thu, 8 Dec 2016 10:52:21 +0000 (12:52 +0200)]
overlay/016: use xfs_io -C for executing commands

This test requires a fix to xfs_io to support
-C one shot commands and -c "open foo" command.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: implement _require_xfs_io_command "open"
Amir Goldstein [Thu, 8 Dec 2016 10:52:20 +0000 (12:52 +0200)]
common: implement _require_xfs_io_command "open"

-c "open $f" is broken in xfs_io <= 4.8. Using it results
in an endless loop and xfs_io exists with error EMFILE.

A fix for that bug makes "open" a 'one shot' command.
Along with this fix, a new -C flag was introduced to explicitly
request to execute a one shot command.

Check for -C flag support as an indication that -c "open $f"
is not broken.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: Use _require_btrfs_qgroup_report to replace open code
Qu Wenruo [Fri, 9 Dec 2016 01:19:59 +0000 (09:19 +0800)]
btrfs: Use _require_btrfs_qgroup_report to replace open code

Introduce new _require_btrfs_qgroup_report function, which will
check the accessibility to "btrfs check --qgroup-report", then set a
global flag to info _check_scratch_fs() to do extra qgroup check.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon/btrfs: rename and enhance _require_btrfs to _require_btrfs_command
Qu Wenruo [Thu, 8 Dec 2016 08:12:12 +0000 (16:12 +0800)]
common/btrfs: rename and enhance _require_btrfs to _require_btrfs_command

Rename _require_btrfs() to _require_btrfs_command() to avoid
confusion, as all other _require_btrfs_* has a quite clear suffix,
like _require_btrfs_mkfs_feature() or _require_btrfs_fs_feature().

Also enhance _require_btrfs_command() to accept 2nd level commands
or options.

Options will be determined by the first "-" char.  This is quite
useful for case like "btrfs inspect-internal dump-tree" and "btrfs
check --qgroup-report".

[eguan: make local vars in _require_btrfs_command "local"]

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobuild: fix build warnings and notify_others() bug
Ross Zwisler [Wed, 7 Dec 2016 04:04:01 +0000 (21:04 -0700)]
build: fix build warnings and notify_others() bug

This patch addresses the following build warnings:

fsx.c: In function 'do_punch_hole':
fsx.c:940:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (!quiet && testcalls > simulatedopcount)
   ^~
fsx.c:942:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
log4(OP_PUNCH_HOLE, offset, length, FL_SKIPPED);
^~~~
fsx.c:947:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (!quiet && testcalls > simulatedopcount)
   ^~
fsx.c:949:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
log4(OP_PUNCH_HOLE, offset, length, FL_SKIPPED);
^~~~
fsx.c: In function 'do_zero_range':
fsx.c:995:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if (!quiet && testcalls > simulatedopcount)
   ^~
fsx.c:997:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
log4(OP_ZERO_RANGE, offset, length, FL_SKIPPED |
^~~~
[CC]    growfiles
growfiles.c: In function 'notify_others':
growfiles.c:1458:6: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
  if ( Forker_pids[ind] != Pid )
  ^~
growfiles.c:1462:10: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
  kill(Forker_pids[ind], SIGUSR2);
  ^~~~

The warnings in fsx.c were just spacing issues of the form:

if (length == 0) {
if (!quiet && testcalls > simulatedopcount)
prt("skipping zero length punch hole\n");
log4(OP_PUNCH_HOLE, offset, length, FL_SKIPPED);
return;
}

Where the log4() call just needs to be unindented.  log4() calls
elsewhere in that same file are not protected with any sort of
'quiet' check, and commonly follow prt() calls which are.  See
doread(), domapread(), etc.

The warning from growfiles.c was actually a bug.  notify_others() is
looping through the Forker_pids[] array and sending SIGUSR2 to all
other processes.  However, with the current logic it only *logs* the
kill for other processes, and kills all other processes plus the
Forker_pids[] entry that matches 'Pid'.

Signed-off-by: Ross Zwisler <ross.zwisler@linux.intel.com>
Cc: Dave Chinner <david@fromorbit.com>
Cc: Lukas Czerner <lczerner@redhat.com>
Cc: Allison Henderson <achender@vnet.ibm.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Nathan Scott <nathans@sgi.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/35[67]: disable swapfile tests on Btrfs
Omar Sandoval [Tue, 6 Dec 2016 01:01:28 +0000 (17:01 -0800)]
generic/35[67]: disable swapfile tests on Btrfs

Btrfs doesn't support swapfiles (yet?), so generic/356 fails
erroneously, and generic/357 only passes by accident. Let's add a
_require_scratch_swapfile helper and add it to these tests.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobuild: allow building with latest xfslibs on 32-bit Linux
Eric Biggers [Wed, 30 Nov 2016 22:31:42 +0000 (14:31 -0800)]
build: allow building with latest xfslibs on 32-bit Linux

The next version of xfslibs will require that its users enable
transparent largefile support.  This broke building xfstests on
32-bit Linux because _FILE_OFFSET_BITS=64 was not getting defined
when testing for xfs headers.  Fix this by defining
_FILE_OFFSET_BITS=64 when doing configure checks for the xfs
headers.

It was not necessary to define _FILE_OFFSET_BITS=64 for the actual
build because it's already done, in builddefs.in.

The problem could also be solved by adding AC_SYS_LARGEFILE to
configure.ac.  It's debatable, but I chose not to do that because it
might give the impression that it affects the actual compilation of
the test programs and not just the configure checks.  (Since not all
.c files include config.h first, a _FILE_OFFSET_BITS definition in
config.h wouldn't always take effect.)

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: split Btrfs functions from common/rc
Dave Chinner [Tue, 29 Nov 2016 21:32:33 +0000 (08:32 +1100)]
common: split Btrfs functions from common/rc

Similar to common/xfs, for the same reasons.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: split XFS functions from common/rc
Dave Chinner [Tue, 29 Nov 2016 21:32:32 +0000 (08:32 +1100)]
common: split XFS functions from common/rc

common/rc has become a dumping ground for common functions that
don't have a specific topic file. It's getting huge and difficiult
to manage, and people are duplicating functionality because they
can't easily find existing functions in the mess.

Let's start to make it a little easier to manage by splitting out
the XFS specific functions into common/xfs and source that from
common/rc automatically.  Other filesytems can follow suit in
future, leaving us with only generic functionality in common/rc.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/095: add iomap_dio_rw() to the dmesg filter
Dave Chinner [Wed, 30 Nov 2016 04:59:08 +0000 (15:59 +1100)]
generic/095: add iomap_dio_rw() to the dmesg filter

Oops, we did it again - we moved the XFS dio code warning to a new
function with the iomap direct IO rework. Update the filter to pick
up the new warning location.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocheck: add brief result summaries
Dave Chinner [Tue, 29 Nov 2016 02:48:09 +0000 (13:48 +1100)]
check: add brief result summaries

When running multiple sections and hundreds of tests in each config
section, it's hard to see what failed from the summary output
because of the hundreds of tests listed in the "tests run" and
"tests not run" output. Add a "-b" option for brief result summaries
that only output the tests that failed and the summary count of
tests failed.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/dirstress: Allow ESTALE as well as ENOENT
J. Bruce Fields [Sat, 26 Nov 2016 01:39:39 +0000 (20:39 -0500)]
src/dirstress: Allow ESTALE as well as ENOENT

In the NFS case an attempt to chdir out of a removed directory could
result in ESTALE, and that should not cause the test to fail.

This was causing intermittent failures on generic/011 on NFS.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoREADME: Document fstests mailing list
J. Bruce Fields [Sat, 26 Nov 2016 01:39:01 +0000 (20:39 -0500)]
README: Document fstests mailing list

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoext4/001: Fixup file layout with DAX
Jan Kara [Tue, 22 Nov 2016 10:16:35 +0000 (11:16 +0100)]
ext4/001: Fixup file layout with DAX

Since commit 9538d1b69399 (ext4: avoid split extents for DAX
writes), currently sitting in ext4 tree, the block layout of files
has changed when the filesystem is mounted with -o dax and now
matches 'nodelalloc' variant instead of 'nozero'. Fixup the test
configuration.

Signed-off-by: Jan Kara <jack@suse.cz>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay: test ro/rw fd data inconsistecies
Amir Goldstein [Thu, 24 Nov 2016 20:12:12 +0000 (22:12 +0200)]
overlay: test ro/rw fd data inconsistecies

Introduce a new test to demonstrates a known issue with overlayfs:
- process A opens file F for read
- process B writes new data to file F
- process A reads old data from file F

This issue is about to be fixed with a patch set by Miklos Szeredi.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs/124-5: add missing umount for raid5 tests
Filipe Manana [Thu, 24 Nov 2016 06:25:19 +0000 (06:25 +0000)]
btrfs/124-5: add missing umount for raid5 tests

The tests mount the second device in the device pool but never
unmount it, causing the next test to fail.

Example:

$ cat local.config
export TEST_DEV=/dev/sdb
export TEST_DIR=/home/fdmanana/btrfs-tests/dev
export SCRATCH_MNT="/home/fdmanana/btrfs-tests/scratch_1"
export SCRATCH_DEV_POOL="/dev/sdc /dev/sdd /dev/sde /dev/sdf /dev/sdg"
export FSTYP=btrfs

$ ./check btrfs/125 btrfs/126
FSTYP         -- btrfs
PLATFORM      -- Linux/x86_64 debian3 4.8.0-rc8-btrfs-next-35+
MKFS_OPTIONS  -- /dev/sdc
MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

btrfs/125 23s ... 22s
btrfs/126 1s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/126.out.bad)
    --- tests/btrfs/126.out 2016-11-24 06:11:42.048372385 +0000
    +++ /home/fdmanana/git/hub/xfstests/results//btrfs/126.out.bad 2016-11-24 06:16:35.987988895 +0000
    @@ -1,2 +1,5 @@
     QA output created by 126
    -pwrite: Disk quota exceeded
    +ERROR: /dev/sdc is mounted
    +mount: /dev/sdc is already mounted or /home/fdmanana/btrfs-tests/scratch_1 busy
    +       /dev/sdc is already mounted on /home/fdmanana/btrfs-tests/scratch_1
    +/home/fdmanana/btrfs-tests/scratch_1/test_file: Disk quota exceeded
    ...
    (Run 'diff -u tests/btrfs/126.out /home/fdmanana/git/hub/xfstests/results//btrfs/126.out.bad'  to see the entire diff)
Ran: btrfs/125 btrfs/126
Failures: btrfs/126
Failed 1 of 2 tests

So just make sure those test unmount the device before they finish.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/182: retain existing btrfs behavior when len == 0
Darrick J. Wong [Thu, 24 Nov 2016 01:51:15 +0000 (17:51 -0800)]
generic/182: retain existing btrfs behavior when len == 0

Since btrfs has always interpreted src_length=0 as "return 0 having
taken no action", test for that instead.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: check some inline truncation behaviors
Jaegeuk Kim [Fri, 18 Nov 2016 19:36:51 +0000 (11:36 -0800)]
generic: check some inline truncation behaviors

This patch introduces a new testcase to test some small truncations
to check inline_data and its cached data are truncated correctly at
the same time.

The inline_data feature was introduced in ext4 and f2fs as follows.
 ext4 : http://lwn.net/Articles/468678/
 f2fs : http://lwn.net/Articles/573408/

The basic idea is embedding small-sized file's data into relatively
large inode space.
In ext4, up to 132 bytes of data can be stored in 256 bytes-sized inode.
In f2fs, up to 3.4KB of data can be embedded into 4KB-sized inode block.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: check inode metadata on f{data}sync after power-cut
Jaegeuk Kim [Mon, 21 Nov 2016 20:02:49 +0000 (12:02 -0800)]
generic: check inode metadata on f{data}sync after power-cut

This patch adds case to test fsync and fdatasync with power-cuts.

The rule to check is:
1) fsync should guarantee all the inode metadata after power-cut,
2) fdatasync should guarantee i_size and i_blocks at least after
   power-cut.

Note that, in XFS, it allocates more blocks when doing writes, so it
should close the file before fsync in order to get actual i_blocks
after power-cut.  Or, it needs to do truncate the file with a
specific size to turn it off at the beginning.

Suggested-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: Introduce check for explicit SHARED extent flag reporting
Qu Wenruo [Thu, 17 Nov 2016 02:06:48 +0000 (10:06 +0800)]
fstests: Introduce check for explicit SHARED extent flag reporting

For fs support reflink, some of them (OK, btrfs again) doesn't split
SHARED flag for extent fiemap reporting.

For example:
  0         4K         8K
   / File1: Extent 0  \
  /                    \
  |<- On disk Extent-->|
  |        /
  | File2 /
    Extent: 0

Fs supports explicit SHARED extent reporting should report fiemap like:
File1: 2 extents
Extent 0-4K: SHARED
Extent 4-8K:
File2: 1 extents
Extent 0-4K: SHARED

Fs doesn't support explicit reporting will report fiemap like:
File1: 1 extent
Extent 0-8K: SHARED
File2: 1 extent
Extent 0-4K: SHARED

Test case like generic/372 require explicit reporting will cause
false alert on btrfs.

Add such runtime check for that requirememt.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: concurrent non-overlapping direct I/O on the same extents
Omar Sandoval [Thu, 17 Nov 2016 00:29:34 +0000 (16:29 -0800)]
generic: concurrent non-overlapping direct I/O on the same extents

There have been a couple of logic bugs in `btrfs_get_extent()` which
could lead to spurious -EEXIST errors from read or write. This test
exercises those conditions by having two threads race to add an
extent to the extent map.

This is fixed by Linux commit 8dff9c853410 ("Btrfs: deal with
duplciates during extent_map insertion in btrfs_get_extent") and the
patch "Btrfs: deal with existing encompassing extent map in
btrfs_get_extent()"
(http://marc.info/?l=linux-btrfs&m=147873402311143&w=2).

Although the bug is Btrfs-specific, nothing about the test is.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/098: update test for truncating a file into the middle of a hole
Liu Bo [Wed, 16 Nov 2016 19:17:03 +0000 (11:17 -0800)]
generic/098: update test for truncating a file into the middle of a hole

This updates generic/098 by adding a sync option, i.e. 'sync' after
the second write, and with btrfs's NO_HOLES, we could still get
wrong isize after remount.

This gets fixed by the patch

'Btrfs: fix truncate down when no_holes feature is enabled'

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/298: cd to / instead of ~
Omar Sandoval [Wed, 16 Nov 2016 00:34:01 +0000 (16:34 -0800)]
xfs/298: cd to / instead of ~

In our kernel testing infrastructure, "$HOME" isn't defined.
Everywhere else in xfstests does `cd /` instead, so let's just do
that.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: fix $tmp path in tests
Eryu Guan [Sat, 12 Nov 2016 18:12:33 +0000 (02:12 +0800)]
generic: fix $tmp path in tests

Some tests use "tmp/$$" as $tmp, and this would result in ENOENT
failure if $tmp is referenced in helpers or tests, because we have
no "tmp" dir in pwd.

Fix them to use "/tmp/$$" as all other tests do.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/38[3-6]: require project quota to be enabled on SCRATCH_DEV
Eryu Guan [Sat, 12 Nov 2016 17:22:26 +0000 (01:22 +0800)]
generic/38[3-6]: require project quota to be enabled on SCRATCH_DEV

generic/38[3-6] are made generic from xfs tests to test project
quota on other filesystems, e.g. ext4. But we should make sure
project quota is enabled in between of _scratch_enable_pquota and
_qmount. Otherwise mount will fail if there's no project quota
support on SCRATCH_DEV, e.g. ext2 and ext3.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/37[3-4]: use bind mount instead of 2nd _scratch_mount
Amir Goldstein [Sun, 13 Nov 2016 13:49:37 +0000 (15:49 +0200)]
generic/37[3-4]: use bind mount instead of 2nd _scratch_mount

generic/373 and generic/374 test that cross-mountpoint reflink/dedupe
fail with EXDEV.

For this test, _scratch_mount is called a 2nd time with same mount
arguments, but a different value of SCRATCH_MNT.

This practice is incorrect for overlayfs, which should not be using
the same upper/work dirs on two different overlay super blocks.

Change the test to use bind mount instead, which results in the
expected setup for both block device mount and overlay mount.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: fix fsx fallocate error messages
Christoph Hellwig [Sat, 12 Nov 2016 16:48:49 +0000 (08:48 -0800)]
fstests: fix fsx fallocate error messages

Many of the commands using fallocate had an extra % at the beggining
of the error messages, missed the 0x prefix for hex output and printed
the length where it should print the end of the region.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs: testcase for kernelspace xfs_fsr extent handling flaw
Eric Sandeen [Sat, 5 Nov 2016 02:00:09 +0000 (21:00 -0500)]
xfs: testcase for kernelspace xfs_fsr extent handling flaw

This is a testcase for a bug which goes way back; googling
"xfs_trans_log_inode NULL pointer dereference" yields sporadic
reports over several years.

The test sets up several two-extent files with speculative
preallocation on them, and then runs xfs_fsr.  The kernelside
code ignores the preallocation, and therefore sets up the
temporary inode incorrectly after the inode fork swap.

It is a "dangerous" test because the extent mishandling on
the temporary inode causes a null pointer dereference and
oops when the inode's i_itemp pointer gets overwritten
and we blow up in logging code that tries to use it.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/021: filter out detailed array element info from xfs_db
Eryu Guan [Fri, 4 Nov 2016 16:16:10 +0000 (00:16 +0800)]
xfs/021: filter out detailed array element info from xfs_db

Starting from xfsprogs commit 384283555871 ("xfs_db: print one array
element per line"), xfs_db prints one array element per line. This
breaks the filter in xfs/021, which now fails as:

  hdr.freemap[0-2] = [base,size] [FREEMAP..]
 +0:[104,1892]
 +1:[0,0]
 +2:[0,0]
  entries[0-2] = [hashval,nameidx,incomplete,root,local] [ENTRIES..]

So we have extra lines that need to be filtered out,

Reviewed-by: Zorro Lang <zlang@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: fix some minor problems testing ocfs2
Darrick J. Wong [Wed, 9 Nov 2016 23:00:17 +0000 (15:00 -0800)]
fstests: fix some minor problems testing ocfs2

There are a a few things about ocfs2 tools that need special-casing in
xfstests, so fix them so that we can start testing ocfs2.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agobtrfs: Check false ENOSPC bug caused by incorrect metadata reserve
Qu Wenruo [Thu, 10 Nov 2016 03:18:48 +0000 (11:18 +0800)]
btrfs: Check false ENOSPC bug caused by incorrect metadata reserve

Due to the fact that btrfs uses different max extent size for
compressed and non-compressed write, it calculates metadata
reservation incorrectly.

This can leads to false ENOSPC alert for compressed write.

This test case will check it by using small fs and do parallel write
to trigger it.

It's highly recommened to use MOUNT_OPTIONS="-o compress" and
MKFS_OPTIONS="-n 64k" to trigger it. Without compression, it won't
be triggered.

The fix is not merged and may change in the future, but the function
is good enough:

btrfs: improve inode's outstanding_extents computation
btrfs: fix false enospc for compression

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: test xfs_copy V5 XFS without -d option
Zorro Lang [Tue, 8 Nov 2016 05:33:50 +0000 (13:33 +0800)]
fstests: test xfs_copy V5 XFS without -d option

Before xfsprogs commit a872b62 (xfs_copy: band-aids for CRC
filesystems), xfs_copy requires the "-d" option to copy a V5 XFS,
because it can't rewrite the UUID of V5 XFS properly.

Now xfs_copy already full support to copy a V5 XFS. But for above
old problem, xfstests use below patch to make sure xfs_copy always
use "-d" option to copy a V5 XFS:

  8346e53 common: append -d option to XFS_COPY_PROG when testing v5 xfs

That cause xfstests miss the coverage of copying a V5 XFS without
"-d". For test this feature I did below things:

  1. Changed init_rc(), add "-d" to $XFS_COPY_PROG if xfs_copy can't
     copy a V5 XFS properly.
  2. xfs/073 test V4 xfs forcibly by specify "-m crc=0" in case. I
     think it's useless now, so remove it.
  3. Changed xfs/032. If xfs_copy full support to copy a V5 XFS, test
     with and without "-d" option, or only test with "-d" option.

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric: multi-thread freeze/unfreeze test under fsstress
Zorro Lang [Mon, 7 Nov 2016 06:30:12 +0000 (14:30 +0800)]
generic: multi-thread freeze/unfreeze test under fsstress

Multi-threads freeze/unfreeze maybe trigger some bugs, e.g: panic,
hang or data corruption etc. It does't check the return value of
freeze/unfreeze, but it tries to make sure fsstress won't run fails,
and no any other bugs happen.

[eguan: add comment on why we check _scratch_mount failure]

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofstests: make xfs_io mandatory
Eryu Guan [Sun, 6 Nov 2016 17:43:33 +0000 (01:43 +0800)]
fstests: make xfs_io mandatory

_test_inode_flag() and _test_inode_extsz() use "which $XFS_IO_PROG"
to check if xfs_io command is available. And "-i" option was added
to XFS_IO_PROG varibable by commit 54659ecdb575 ("fstests: run
xfs_io with -i option if supported"). So the command becomes "which
/usr/sbin/xfs_io -i", and it stops and waits for input from stdin,
because "-i" option of "which" means "Read aliases from stdin".

I've seen xfs/008 hang when testing with latest xfsprogs, where
xfs_io has "-i" support.

Fix it by removing the xfs_io command detections, and making xfs_io
mandatory in common/config.

Also fix the indentions in these functions, use tab instead of
spaces, while we're at it.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agocommon: add CephFS support
Joao Eduardo Luis [Fri, 4 Nov 2016 10:04:39 +0000 (11:04 +0100)]
common: add CephFS support

Add basic CephFS support. No new CephFS specific tests are included,
just FSTYP="ceph" enablement.

Signed-off-by: Joao Eduardo Luis <joao@suse.de>
Reviewed-by: David Disseldorp <ddiss@suse.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agofilter: xfs_io output has dropped "64" from error messages
Dave Chinner [Wed, 2 Nov 2016 21:15:25 +0000 (08:15 +1100)]
filter: xfs_io output has dropped "64" from error messages

Upstream xfs_io has been converted to always use LFS compliant
(i.e. 64 bit) pwrite() rather than pwrite64(). Similar changes have
been made for multiple syscalls that have "*64" variants. hence the
error output of all these commands has changed, such as "pwrite64:
..." to "pwrite: ....".

Make a filter to catch the *64 variants and strip it, and
convert all the golden output to use the non-*64 variant. This will
make all golden output matching work correctly regardless of what
version of xfs_io is in use.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agosrc/seek_sanity_test: discover allocation size
Benjamin Coddington [Mon, 24 Oct 2016 13:52:41 +0000 (09:52 -0400)]
src/seek_sanity_test: discover allocation size

Try to discover the allocation size.  For NFS, the st_blksize is
optimized for the network, and will usually be much larger than the
allocation size of the exported filesystem, which may trigger
preallocation strategies in the exported filesystem causing the seek
tests here to fail.

Signed-off-by: Benjamin Coddington <bcodding@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agoxfs/054: only filter ROOT_INO at the beginning
Eryu Guan [Sat, 22 Oct 2016 05:27:33 +0000 (13:27 +0800)]
xfs/054: only filter ROOT_INO at the beginning

In the test ROOT_INO is filtered out and/or replaced, but if
ROOT_INO is also 32, more "32"s are filtered and replaced than
expected. This happens to me when testing 512B block size XFS and 1k
block size CRC enabled XFS.

Fix it by filtering out only ROOT_INO at the beginning of a line,
and removing all "g" modifiers in sed expressions.

Also the ROOT_INO should be the root inode number of TEST_DIR not
SCRATCH_MNT.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agogeneric/314: remove from acl group
Eric Biggers [Fri, 21 Oct 2016 21:22:06 +0000 (14:22 -0700)]
generic/314: remove from acl group

generic/314 no longer tests POSIX ACLs.  It only tests the SGID bit.
Therefore, it should not be in the acl group anymore.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/013: adjust test expectation to kernel v4.8
Amir Goldstein [Wed, 19 Oct 2016 08:52:33 +0000 (11:52 +0300)]
overlay/013: adjust test expectation to kernel v4.8

Commit 4d0c5ba (vfs: do get_write_access() on upper layer of overlayfs)
that was merged for kernel v4.8 changes the behavior of execve+truncate
in a subtle way.

When file is executed from lower and then truncated, the truncation is
allowed, becasue it only affects the size of the copied up file and does
not affect the VM mapping of the executed lower file.

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
4 years agooverlay/013: fix bug in test_upper creation
Amir Goldstein [Wed, 19 Oct 2016 08:52:32 +0000 (11:52 +0300)]
overlay/013: fix bug in test_upper creation

test_upper file was supposed to be in upper layer,
but it was wrongly created in lower layer.

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