xfstests-dev.git
8 years agogeneric: xattr enospc cleanup test
Brian Foster [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
generic: xattr enospc cleanup test

XFS had a regression where inode reclaim in the unlink codepath would
not correctly tear down extended attribute forks where no xattr extents
are present. Add a generic test to create this condition.

The test sets extended attributes on a series of files under ENOSPC
conditions and then verifies that the files can be removed without
syslog warnings or errors.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: busy loop of dd and rm test
Wang Yanfeng [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
generic: busy loop of dd and rm test

Add a case for testing whether writing failed on NO_SPACE in a busy
loop of write and delete when disk almost full.  It is a long-term
problem since very beginning in btrfs, and has been fixed by
patchset titled "btrfs: Fix no_space on dd and rm loop" from
zhaolei@cn.fujitsu.com.

Signed-off-by: Wang Yanfeng <wangyf-fnst@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test for fsync after file truncations
Filipe Manana [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
generic: test for fsync after file truncations

Test that if we truncate a file to a smaller size, then truncate it to
its original size or a larger size, then fsyncing it and a power failure
happens, the file will have the range [first_truncate_size, last_size[
with all bytes having a value of 0x00 if we read it the next time the
filesystem is mounted.

This test is motivated by a bug found in btrfs, which is fixed by a patch
titled: "Btrfs: fix fsync after truncate when no_holes feature is enabled"

Tested against ext3/4, xfs, btrfs (with and without the fix, and with the
no_holes feature disabled), f2fs, reiserfs and nilfs2.

All filesystems pass the test except for unpatched btrfs with the
no_holes feature enabled (as expected) and f2fs. Both produce the
following file contents that differ from the golden output:

  File foo content after log replay:
  0000000 aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa aa
  *
  0200000 bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb bb
  *
  0372000
  File bar content after log replay:
  0000000 ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee ee
  *
  0200000 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
  *
  0372000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  *
  0772000

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test for truncating a file into the middle of a hole
Filipe Manana [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
generic: test for truncating a file into the middle of a hole

Test that after truncating a file into the middle of a hole causes the
new size of the file to be persisted after a clean unmount of the
filesystem (or after the inode is evicted). This is for the case where
all the data following the hole is not yet durably persisted, that is,
that data is only present in the page cache.

This test is motivated by an issue found in btrfs, which got fixed by
the patch titled:

  "Btrfs: fix shrinking truncate when the no_holes feature is enabled"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofstests: remove $seqres.full before tests run
Eryu Guan [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
fstests: remove $seqres.full before tests run

Some tests append logs to $seqres.full and never remove the log, which
keeps the log file growing. Remove $seqres.full before test in
following tests:

   ext4/271
   generic/019
   generic/269
   generic/270
   shared/272

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test zero range crossing isize within single block
Lukas Czerner [Tue, 4 Aug 2015 04:10:49 +0000 (14:10 +1000)]
generic: test zero range crossing isize within single block

Exercise the situation that cause ext4 to BUG_ON() when we use
zero range to zero a range which starts within the isize but ends
past the isize but still in the same block. This particular problem
has only been seen on systems with page_size > block_size.

This tests exercises the problem fixed in kernel with commit
0f2af21aae11972fa924374ddcf52e88347cf5a8
ext4: Allocate entire range in zero range

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: concurrent IO test with mixed IO types
Eryu Guan [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
generic: concurrent IO test with mixed IO types

Test concurrent buffered I/O, DIO, AIO, mmap I/O and splice I/O on the
same files.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agocommon: add filter to _check_dmesg
Eryu Guan [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
common: add filter to _check_dmesg

Introduce a parameter to _check_dmesg which allows callers to provide a
customized filter function to filter out intentional dmesg logs. The
default filter is a simple 'cat' command.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agocommon: move _check_dmesg to common/rc
Eryu Guan [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
common: move _check_dmesg to common/rc

Move _check_dmesg to common/rc so that tests could call it directly.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: add fiemap test that does prealloc
Josef Bacik [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
generic: add fiemap test that does prealloc

I noticed that btrfs wasn't setting unwritten on prealloc test, and then
subsequently noticed that we weren't testing fiemap on prealloc extents with the
fiemap-tester.  This patch adds another test that does the same as generic/225
only with prealloc enabled.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofiemap-tester: convert to use O_DIRECT
Josef Bacik [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
fiemap-tester: convert to use O_DIRECT

We want to test fiemap, so we want to lay out a file exactly a certain way.  XFS
tries to be smart and will allocate data in a hole if the write pattern is

[data][hole][data]

where the hole is small enough.  This screws with fiemap-tester sometimes, so
make it easy and just do O_DIRECT so that we get the layout we want and can get
back to testing fiemap.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoshared: test for fsync after adding xattrs to a file
Filipe Manana [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
shared: test for fsync after adding xattrs to a file

This test is motivated by an issue found in btrfs.

It test that after syncing the filesystem, adding many xattrs to a file,
syncing the filesystem again, writing to the file and then doing a fsync
against that file, all the xattrs still exists after a power failure.
That is, after the fsync log/journal is replayed, the xattrs still exist
and with the correct values.

The btrfs issue is fixed by the patch titled:

  "Btrfs: fix fsync xattr loss in the fast fsync path"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test for fsync after adding hard link to a file
Filipe Manana [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
generic: test for fsync after adding hard link to a file

This test is motivated by an issue found in btrfs.

It tests that after syncing the filesystem, adding a hard link to a file,
syncing the filesystem again, doing a write to the file that increases
its size and then doing a fsync against that file, durably persists the
data written to the file. That is, after log/journal replay, the data
is available.

The btrfs issue is fixed by the commit titled:

  "Btrfs: fix fsync data loss after append write"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoawk invocation cleanup for busybox support.
Ari Sundholm [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
awk invocation cleanup for busybox support.

These changes make it possible to run more of the tests on busybox.

Signed-off-by: Ari Sundholm <ari@tuxera.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: test premature submount unmounting when deleting default subvolume
Omar Sandoval [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
btrfs: test premature submount unmounting when deleting default subvolume

Add a regression test for a problem where attempting to delete the
default subvolume would fail (as expected), but not until after all
submounts under the subvolume were unmounted.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs: test inode allocation with fragmented free space
Brian Foster [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
xfs: test inode allocation with fragmented free space

XFS dynamic inode allocation has a fundamental limitation in that an
inode chunk requires a contiguous extent of a minimum size. Depending on
the level of free space fragmentation, inode allocation can fail with
ENOSPC where the filesystem might not be near 100% usage.

The sparse inodes feature was implemented to provide an inode allocation
strategy that maximizes the ability to allocate inodes under free space
fragmentation. This test fragments free space and verifies that
filesystems that support sparse inode allocation can allocate a minimum
percentage of inodes on the fs.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs/022: add a quota rescan -w to wait rescan finished.
Dongsheng Yang [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
btrfs/022: add a quota rescan -w to wait rescan finished.

When we enable quota, btrfs will rescan quota numbers. We need
to wait the rescan finished before any more operations on btrfs
qgroups. Otherwith, the new btrfs-progs would WARN out:

WARNING: Rescan is running, qgroup data may be incorrect.

It would make btrfs/022 failed.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs: test rw remount on norecovery ro mount
Eryu Guan [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
xfs: test rw remount on norecovery ro mount

Commit bbe051c841d5 ("xfs: disallow ro->rw remount on norecovery mount")
disabled rw remount on norecovery ro mount, this test makes sure the
behavior is correct.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/081: wait for lv to be settled before creating fs on it
Eryu Guan [Tue, 4 Aug 2015 04:10:48 +0000 (14:10 +1000)]
generic/081: wait for lv to be settled before creating fs on it

Call 'udevadm settle' or 'udevsettle' or 'sleep 1' to make sure new lv
is ready for use before making filesystem on it, depends on which
command is available on the system.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/288: correct the testcase description
Wang Sheng-Hui [Tue, 4 Aug 2015 04:10:44 +0000 (14:10 +1000)]
generic/288: correct the testcase description

The testcase tests 2 corner cases:
    Length is zero
    Length is smaller than block size
Correct the beginning description by changing "of" to "or".

Signed-off-by: Wang Sheng-Hui <shhuiw@foxmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs: test extent size hint size overflows
Dave Chinner [Tue, 4 Aug 2015 04:10:44 +0000 (14:10 +1000)]
xfs: test extent size hint size overflows

In certain cases, the extent size hints can cause maximum extent
size overflows resulting in extent tree corruptions. This test
exercises the original reproducer, and another corner case
demonstrated to expose problems on 1k block size filesystems.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
--
Version 2:
- TESTDIR->TEST_DIR
- append output to $seqres.full

8 years agofsstress: add the -c option
Theodore Ts'o [Tue, 4 Aug 2015 04:10:44 +0000 (14:10 +1000)]
fsstress: add the -c option

This option causes fsstress to delete the test directory between each
run.  This is the opposite from the ltp version of fsstress, which
deletes the test directory by default, and the -c option caused ltp's
fsstress _not_ to delete the test directory.

It can be useful to be able to have the same test behavior as ltp
version, and although reversing the sense of the option is
unfortunate, it also reserves the -c option, which makes it a bit
easier if we want to eventually have one version which is a superset
of the xfstest and ltp version of fsstress.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofsstress: add the [-l loops] option
Theodore Ts'o [Tue, 4 Aug 2015 04:10:44 +0000 (14:10 +1000)]
fsstress: add the [-l loops] option

This feature is in the ltp version of fsstress; port it into
xfstests.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoconfig: Fix sysfs paths for partitions
Matthew Wilcox [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
config: Fix sysfs paths for partitions

generic/019 was failing with:

./tests/generic/019: line 65: /sys/block/pmem0p2/make-it-fail: No such file or directory

When using a partition, the file needed is located at
/sys/block/pmem0/pmem0p2/make-it-fail.

Rather than attempt to deduce whether a block device is a partition
or not, use the symlinks located in /sys/dev/block/ to find the right
location for the make-it-fail file.

Also change btrfs/088 to use the new _sysfs_dev function.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfstests: correct comment in generic/135
Wang Sheng-Hui [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfstests: correct comment in generic/135

xfs_io '-d' specifies direct IO, not sync IO.

Signed-off-by: Wang Sheng-Hui <shhuiw@foxmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: add a test for fallocate+truncate
Josef Bacik [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
generic: add a test for fallocate+truncate

There was some confused about what the fs was supposed to do when you truncate
at i_size with preallocated space past i_size.  We decided on the following
things

1) truncate(i_size) will trim all blocks past i_size.
2) truncate(x) where x > i_size will not trim all blocks past i_size.

This test is to make sure we're all acting sanely.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs/111: make it work better
Eric Sandeen [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfs/111: make it work better

xfs/111 is failing today, primarily because it obliterates the
root inode chunk and the verifiers fail the mount - i.e. the test
fails to properly test the thing it's meant to test.

Change the test so that the induced corruption is further into the
filesystem, but still hitting the inodes which have been created
for the test, so that the fs can mount and continue.

This requires that the helper binary (itrash) take an offset, which
we will figure out by using xfs_db.

This changes the locations of the inodes we hit; we're not really
going to be able to predict that terribly well, so remove the
output which shows inode offsets, and just keep track of whether
we managed to obliterate any at all.

The test still fails, because the fs is corrupted; this was done
intentionally, so run xfs_repair before the test exits to fix
things up.

(This test doesn't run often; it's not in the auto group, and
all the failures are extremely noisy and time consuming...)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs/007: use gquotino for project quotas on pre-v5 superblocks
Brian Foster [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfs/007: use gquotino for project quotas on pre-v5 superblocks

This test checks block usage on quota inodes based on the inode number
values stored in the superblock. Version 5 superblocks (crc=1) have an
independent project quota inode field to support concurrent group and
project quotas. Older superblocks do not have the pquotino field. The
gquotino field is reused for project quotas.

The test currently unconditionally uses the pquotino field to determine
the project quota inode. This causes failures on pre-v5 superblocks as
the test queries the block usage of an incorrect inode number. Update
the test to use gquotino as the project quota inode on such filesystems.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years ago_require_command: quote commands correctly
Omer Zilberberg [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
_require_command: quote commands correctly

fixes 9435b92 common: _require_command needs to handle parameters

Also quoted $_command because _require_command may be called with an
empty $1 parameter, e.g.:
_require_command "$MY_UTIL_PROG" my_util  # but $MY_UTIL_PROG is empty

[ -x ] returns true.
[ -x "" ] returns false, as required here.

Signed-off-by: Omer Zilberberg <omzg@plexistor.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/082: add to the quota group
Andrew Price [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
generic/082: add to the quota group

generic/082 is a quota test so it should be in this group.

Signed-off-by: Andrew Price <anprice@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agocommon: set VFS_QUOTA for gfs2
Andrew Price [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
common: set VFS_QUOTA for gfs2

Use generic quota tools with gfs2.

Fixes "xfs_quota: cannot setup path for mount /mnt/scratch: No such
device or address"

Signed-off-by: Andrew Price <anprice@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs/032: properly test for corruption from xfs_copy
Eric Sandeen [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfs/032: properly test for corruption from xfs_copy

From the xfs_repair manpage:

    xfs_repair run without the -n option will always return
    a status code of 0.

So we must use "-n" to detect corruption in this test.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs: test repairing false positive reserved attr name use
Eric Sandeen [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfs: test repairing false positive reserved attr name use

xfs_repair compares attr names in the root namespace to
two special/reserved names, "SGI_ACL_FILE" and "SGI_ACL_DEFAULT"
and if the value in them aren't valid acls, flags this as
an inconsistency.

However, due to various bugs, xfs_repair may only compare
a smaller portion of the on-disk value; hence either
substrings or superstrings may match, and false-positive
corruption will be detected.  This test checks for those
false positives; i.e. the ACL names created in this test
may cause xfs_repair to "fix" them, but it should not.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/087,126: Test the permission to set file times
Andreas Gruenbacher [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
generic/087,126: Test the permission to set file times

Check if setting the file access and modification times to the current time
and to a specific timestamp is allowed when expected.

In generic/126, remove a left-over temporary file.

Signed-off-by: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs: be compatible with older mkfs.xfs which has no v5 support
Eryu Guan [Tue, 26 May 2015 02:51:57 +0000 (12:51 +1000)]
xfs: be compatible with older mkfs.xfs which has no v5 support

With the change to CRCs by default, some tests are updated to call mkfs
with "-m crc=0" option directly, and this breaks testings on older
distros where mkfs.xfs doesn't have crc support.

Introduce a new variable to tell if mkfs.xfs supports v5 xfs and do
tweaks in _scratch_mkfs_xfs_opts() based on it.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/275: writes may not partially succeed
Dave Chinner [Tue, 26 May 2015 02:51:56 +0000 (12:51 +1000)]
generic/275: writes may not partially succeed

When a large IO is done as a single buffer, there is no guarantee
that it will partially succeed when close to ENOSPC. The test
assumes that the kernel is going to break the write down into
smaller chunks (i.e. buffered IO breaking it down into PAGE_SIZE
allocations), but certain configurations will not do this. e.g.
extent size hints are set or DAX is being used) and hence the large
write fails completely as there is not space for the entire
allocation to be made.

Hence break the final write in the test up into multiple small
writes, thereby acheiving the same effect - ensuring that we can
write more data after removing some space....

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/223, xfs/203: IO is not well aligned
Dave Chinner [Tue, 26 May 2015 02:51:53 +0000 (12:51 +1000)]
generic/223, xfs/203: IO is not well aligned

On certain configurations (e.g. MOUNT_OPTIONS="-o dax") we get
different allocation patterns due to the writes being done in
multiple pwrite() calls. e.g. the write is 8k, but the buffer size
is 4k, and so the filesystem sees 4k writes. If the filesytem is not
using delayed allocation, then the allocation context is a 4k write
rather than an 8k write and so they don't get appropriately aligned.

Fix this by making the write buffer the same size and the writes
being done.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/018: use xfs_io and larger buffers for writes
Dave Chinner [Tue, 26 May 2015 02:50:53 +0000 (12:50 +1000)]
generic/018: use xfs_io and larger buffers for writes

The test currently uses 'dd' directly for writing to files; instead
we should be using the xfs_io pwrite command.

Also, when we have a configuration that does not do delayed
allocation (e.g. dax), there is no guarantee that the files will be
allocated in the pattern expected, so do all the writes from a
single buffer so the kernel can allocate extents in the manner the
test expects as much as possible.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: Fix _is_block_dev quoting
Andreas Gruenbacher [Thu, 14 May 2015 10:27:54 +0000 (20:27 +1000)]
generic: Fix _is_block_dev quoting

Add more quoting so that test cases that don't require a SCRATCH_DEV
won't fail.

Signed-off-by: Andreas Gruenbacher <andreas.gruenbacher@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agocheck: set failure status before exit
Eryu Guan [Thu, 14 May 2015 10:27:54 +0000 (20:27 +1000)]
check: set failure status before exit

check has trapped 'exit 1' and exit with $status, but check always
returns 0 on error because status never gets updated. This causes
problems while running some tests in a loop until it fails, e.g.

while ./check generic/081; do : ; done

Just set status to 1 before exit, as what we do in the tests.

Also remove an unused $flag while we're at it.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/076: fixed incorrect fsstress parameters
Omer Zilberberg [Thu, 14 May 2015 10:27:53 +0000 (20:27 +1000)]
generic/076: fixed incorrect fsstress parameters

Test was not run because directory parameter was omitted.

Signed-off-by: Omer Zilberberg <omzg@plexistor.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: test for send with compressed file extents
Filipe Manana [Thu, 14 May 2015 10:27:53 +0000 (20:27 +1000)]
btrfs: test for send with compressed file extents

Test that an incremental send issues valid clone operations for
compressed file extents.

For some compressed extents, namely those referred by a file extent item
with a non-zero data offset, btrfs could issue a clone operation in the
send stream with an offset and length pair that were not entirely
contained in the source file's range, causing the receiving side to get
-EINVAL errors from the clone ioctl when attempting to perform the clone
operations.

This issue was fixed by the following linux kernel btrfs patch:

  Btrfs: incremental send, fix clone operations for compressed extents

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: regression test for file range cloning
Filipe Manana [Thu, 14 May 2015 10:27:53 +0000 (20:27 +1000)]
btrfs: regression test for file range cloning

Test btrfs file range cloning with the same file as a source and
destination.

This tests a specific scenario where the extent layout of the file
confused the clone ioctl implementation making it return -EEXIST to
userspace. This issue was fixed by the following linux kernel patch:

   Btrfs: fix range cloning when same inode used as source and destination

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofilter: inode size output of mkfs.xfs can change
Dave Chinner [Thu, 14 May 2015 02:20:11 +0000 (12:20 +1000)]
filter: inode size output of mkfs.xfs can change

With the change to CRCs by default, the mkfs inode size is defaults
to 512 bytes and the minimum block size changes to 1024 bytes. This
causes mismatches with golden output that expects the inode size to
be 256 bytes, and some tests are tailored around the amount of space
inside a 256 byte inode. Fix them with appropriate filtering or mkfs
parameters to allow 256 byte inodes to be used.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfs/045: can't change UUID on v5 filesystems.
Dave Chinner [Thu, 14 May 2015 02:19:41 +0000 (12:19 +1000)]
xfs/045: can't change UUID on v5 filesystems.

So pass "-m crc=0" to the scratch_mkfs command so that we only run
on old v4 format filesystems where the UUID can be changed.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofilter: latest xfs_repair is more verbose
Dave Chinner [Thu, 14 May 2015 02:18:29 +0000 (12:18 +1000)]
filter: latest xfs_repair is more verbose

It detects more errors, so we need to filter them out to prevent
golden image mismatches on successful recovery.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agofilter: latest mkfs.xfs makes logical sector size noise
Dave Chinner [Thu, 14 May 2015 02:17:29 +0000 (12:17 +1000)]
filter: latest mkfs.xfs makes logical sector size noise

On devices that have a logical sector smaller than physical sector,
this extra, harmless output now occurs:

     QA output created by 060
    +specified blocksize 1024 is less than device physical sector size 4096
    +switching to logical sector size 512
     Creating directory system to dump using src/fill.
     Setup .......................................
     Dumping to files...

And it causes lots of tests to fail unnecessarily. Filter it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoxfstests: btrfs: 020 is bit diverted from its objective
Anand Jain [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
xfstests: btrfs: 020 is bit diverted from its objective

Not sure what this test case wanted to achieve by deleting the
source device before the replace.

As per the comments the objective of this test case seems to be

~~~~
btrfs device replace test on RO fs

Regression test for commit:
bbb651e Btrfs: don't allow the replace procedure on read only filesystems
~~~~~

Also there won't be EIO when you delete a loop device when its
still mounted. as shown below.

mount /dev/loop0 /mnt
losetup -d /dev/loop0
echo $?
0
dd if=/dev/zero of=/mnt/tf1 count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.00192936 s, 265 kB/s
cd /mnt
sync
losetup -a
/dev/loop0: [0802]:1291816 (/root/testdev/disk1)

No errors in the dmesg as well.

Instead of further confusing, I am deleting  the delete loop device part

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric/204: use more space for inode allocation
Eryu Guan [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
generic/204: use more space for inode allocation

On v4/512b and v5/1k xfs, there're not enough free inodes for new files
and generic/204 fails because of running out of inode not space.

Adding "-i maxpct=50" to MKFS_OPTIONS to bump up the inode limit at mkfs
time, and test could pass on all configurations.

Suggested-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoshared/289: do not special-case ext3
Eryu Guan [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
shared/289: do not special-case ext3

Commit "3574531 xfstests: count journal size in test 289" makes ext3 a
special case, but now it's not the case anymore after kernel commit

2046fd1 ext3: Count journal as bsddf overhead in ext3_statfs

So just remove the special case, now test passes on both ext3 and ext4,
also ext3 driven by ext4 module.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: add _require_metadata_journaling to more tests
Eryu Guan [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
generic: add _require_metadata_journaling to more tests

generic tests 039, 059 and 325 need _require_metadata_journaling too,
they use dm_flakey to trigger log replay. I've seen 039 and 059 failed
post-test fsck on ext2, 325 could possibly fail too.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test data corruption on ext4 caused by written/delayed extent
Lukas Czerner [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
generic: test data corruption on ext4 caused by written/delayed extent

This test exercises the problem with unwritten and delayed extents
in ext4 extent status tree where we might in some cases lose a block
worth of data. Even though this was a ext4 specific problem the
reproducer can be easily run on any file system so let's do that just
in case.

This test exercises the problem fixed in kernel with commit
"ext4: Fix data corruption caused by unwritten and delayed extents"

Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: test btrfs send after swapping directory names differently
Filipe Manana [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
btrfs: test btrfs send after swapping directory names differently

Test btrfs incremental send after renaming and moving directories around in a
way that ends up making a directory have different dentries with the same name
but pointing to different inodes in the parent and send snapshots, and also
inverting the ancestor-descendent relationship between one of those inodes and
some other inode.

Cases like this made an incremental send enter an infinite lopp when building
path strings, leading to -ENOMEM errors when the path string reached a length
of PATH_MAX.
This issue was fixed by the following linux kernel btrfs patch:

  Btrfs: incremental send, check if orphanized dir inode needs delayed rename

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: Incorrect exclusive reference number after file clone.
Qu Wenruo [Mon, 4 May 2015 12:56:13 +0000 (22:56 +1000)]
btrfs: Incorrect exclusive reference number after file clone.

[Problem]
Since commit fcebe4562dec83b3f8d308 ("Btrfs: rework qgroup accounting"),
quota data update is delayed after delayed_ref calculation, and lacks
correct protection to detect root reference which shouldn't be counted
in current sequence number but already written into extent backref.

This makes exclusive reference not decreased correctly and give incorrect
result.

[Test procedure]
1. Create a btrfs with 3 subvolumes, quota enabled and rescanned.
2. Create a file in 1st subvolume
3. Clone the file to 2nd and 3rd subvolume
4. Sync the fs to reflect the changes in qgroup.
5. Check the qgroup data

[Expected result]
None of the subvolume has exclusive reference to the file.

[Actual result]
The first subvolume still have exclusive reference to the file.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: Check return value of "btrfs filesystem show" command
Qu Wenruo [Mon, 4 May 2015 12:56:11 +0000 (22:56 +1000)]
btrfs: Check return value of "btrfs filesystem show" command

The return value should always be 0 if no problem happens, but
"btrfs filesystem show" executed on umounted device will always return 1
even there is no problem.

This testcase just checks it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test fs freeze/unfreeze and mount/umount race
Eryu Guan [Mon, 4 May 2015 12:55:47 +0000 (22:55 +1000)]
generic: test fs freeze/unfreeze and mount/umount race

Exercise fs freeze/unfreeze and mount/umount race, which could lead to
use-after-free oops.

This commit fixed the issue:
1494583 fix get_active_super()/umount() race

This test case is based on a script from Monakhov Dmitriy.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agoshared: test truncate orphan inodes when mounting extN
Eryu Guan [Mon, 4 May 2015 12:55:39 +0000 (22:55 +1000)]
shared: test truncate orphan inodes when mounting extN

ext4 should hold i_mutex when truncating orhpan inodes, or a WARNING
would be triggered. This commit fixed this issue.

721e3eb ext4: lock i_mutex when truncating orphan inodes

Though it's an ext4 specific issue, there's no harm to test on ext2/3
too, as debugfs is used to set orphan inode list.

This test is based on a script from Lukas Czerner.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Acked-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test hardlink to unlinked file
Eryu Guan [Mon, 4 May 2015 12:55:33 +0000 (22:55 +1000)]
generic: test hardlink to unlinked file

Kernel commit

aae8a97 fs: Don't allow to create hardlink for deleted file

disabled hardlink to unlinked file.

Test the race between link and unlink, which could end up adding link
count to an unlinked file and leading to fs corruption on xfs.

Test case was originally written by Eric Sandeen.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: test quota handling on remount ro failure
Eryu Guan [Mon, 4 May 2015 12:55:25 +0000 (22:55 +1000)]
generic: test quota handling on remount ro failure

Remount ro should not turn qouta off unconditionally, even remount ro
failed, also kernel should not oops on the next succeeded remount ro.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: exercise transaction abort on device with discard support
Filipe Manana [Mon, 4 May 2015 12:55:21 +0000 (22:55 +1000)]
btrfs: exercise transaction abort on device with discard support

Test that btrfs' transaction abortion does not corrupt a filesystem
mounted with -o discard nor allows a subsequent fstrim to corrupt the
filesystem (regardless of being mounted with or without -o discard).

This issue was fixed by the following linux kernel patch:

    Btrfs: fix fs corruption on transaction abort if device supports discard
    (commit 678886bdc6378c1cbd5072da2c5a3035000214e3)

Without the corresponding btrfs fix the fs becomes unmountable and fails
like this:

  $ ./check btrfs/089
  FSTYP         -- btrfs
  PLATFORM      -- Linux/x86_64 debian3 3.19.0-btrfs-next-7+
  MKFS_OPTIONS  -- /dev/sdc
  MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

  btrfs/089 2s ... - output mismatch (see /home/fdmanana/git/hub/xfstests/results//btrfs/089.out.bad)
      --- tests/btrfs/089.out 2015-04-03 19:29:42.969594083 +0100
      +++ /home/fdmanana/git/hub/xfstests/results//btrfs/089.out.bad 2015-04-03 19:42:37.419181019 +0100
      @@ -3,7 +3,10 @@
       XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
       wrote 1048576/1048576 bytes at offset 524288
       XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
      +mount: wrong fs type, bad option, bad superblock on /dev/sdc,
      +       missing codepage or helper program, or other error
      +       In some cases useful info is found in syslog - try
      +       dmesg | tail  or so
      ...
      (Run 'diff -u tests/btrfs/089.out /home/fdmanana/git/hub/xfstests/results//btrfs/089.out.bad'  to see the entire diff)
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent (see /home/fdmanana/git/hub/xfstests/results//btrfs/089.full)
  Ran: btrfs/089
  Failures: btrfs/089
  Failed 1 of 1 tests

  $ cat /home/fdmanana/git/hub/xfstests/results//btrfs/089.full
  Performing full device TRIM (100.00GiB) ...
  touch: cannot touch '/home/fdmanana/btrfs-tests/scratch_1/abc': Read-only file system
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  *** fsck.btrfs output ***
  Check tree block failed, want=29589504, have=0
  Check tree block failed, want=29589504, have=0
  Check tree block failed, want=29589504, have=0
  Check tree block failed, want=29589504, have=0
  Check tree block failed, want=29589504, have=0
  read block failed check_tree_block
  Couldn't read tree root
  Couldn't open file system
  (...)

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agobtrfs: test btrfs send after complex directory hierarchy changes
Filipe Manana [Mon, 4 May 2015 12:55:19 +0000 (22:55 +1000)]
btrfs: test btrfs send after complex directory hierarchy changes

Test a very complex scenario for a btrfs incremental send operation where a
large directory hierarchy had many subtrees moved between parent directories,
preserving the names of some directories and inverting the parent-child
relationship between some directories (a child in the parent snapshot became
a parent, in the send snapshot, of the directory that is its parent in the
parent snapshot).

This test made the incremental send fail with -ENOMEM because it entered an
infinite loop when building path strings that are used as operands of the
rename operations issued in the send stream.
This issue was fixed by the following linux kernel btrfs patch:

   Btrfs: incremental send, don't delay directory renames unnecessarily

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agocommon: _require_command needs to handle parameters
Dave Chinner [Mon, 4 May 2015 06:48:05 +0000 (16:48 +1000)]
common: _require_command needs to handle parameters

_require_command fails when a parameter based command is passed to
it, such as "xfs_io -F" or "btrfs filesystem defrag" as the command
string does not point at a binary.  Rather than hacking at all the
callers and limiting what we can do with $*_PROGS variables, just
make _require_command handle this case sanely.

Change _require_command to check for one or two variables passed to
it and to fail if none or more than 2 parameters are passed. This
will catch most cases where unquoted parameter-based commands are
passed. Further, for the command variable, the executable we need to
check for is always going to be the first token in the variable.
Hence we can simply ignore everything after the first token for the
purposes of existence and executable checks on the command.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
8 years agogeneric: LVM and ram disks don't play well
Dave Chinner [Mon, 4 May 2015 06:47:52 +0000 (16:47 +1000)]
generic: LVM and ram disks don't play well

The "brd" kernel ram disk abuses BLKFLSBUF to mean "free all memory
in the ram drive" when in fact it should mean "flush all dirty
buffers to stable storage". The brd driver ignores BLKFLSBUF if
there is an active reference to the block device, (e.g. a fs is
mounted on it), but when a device is layered over the top of it
(e.g. dm-flakey, lvm devices, etc) then the applications and
filesystems hold references to the upper device, not the brd device.
Hence when the upper device passes down BLKFLSBUF to brd, it removes
all the pages in the brd, effectively erasing it.  This causes all
sorts of problems.....

Fix this by black listing "/dev/ramXXX" devices from tests that
require DM in some way. The _requires_sane_bdev_flush() macro is
called by the _requires_dm.... checks so that we don't have to
remember to add this to all new tests that use dm in some way.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: test full dm snapshot devices
Eryu Guan [Wed, 1 Apr 2015 22:41:15 +0000 (09:41 +1100)]
generic: test full dm snapshot devices

Full DM snapshot devices can return unexpected errors from the
underlying device, and this causes problems for filesystems.  In
particular, xfs used to panic in this test, (fixed by commit 8d6c121
"xfs: fix buffer use after free on IO error"), and on current
4.0-rc3 kernels both ext4 and btrfs trigger WARNINGs.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobuild: Allow alphanumeric test name suffixes
Jan Tulak [Wed, 1 Apr 2015 22:23:10 +0000 (09:23 +1100)]
build: Allow alphanumeric test name suffixes

To allow test names to be more descriptive, allow a suffix to be
added to the numeric name of the test.  e.g. a test can be named
"tests/generic/001-some-descriptive-name".

Name suffixes are limited to alphanumeric characters and dash - the
name is always prefixed with an unique id for easy identification
of a specific test. Hence we can still use shorthand forms such as
"generic/001" when referring to a test and be clearly understood.

Signed-off-by: Jan Tulak <jtulak@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: test that mmap-write updates c/mtime
Omer Zilberberg [Wed, 1 Apr 2015 04:39:36 +0000 (15:39 +1100)]
generic: test that mmap-write updates c/mtime

When using mmap() for file i/o, writing to the file should update
it's c/mtime. Specifically if we first mmap-read from a page, then
memap-write to the same page.

This test was failing for the initial submission of DAX because
pfn based mapping do not have an page_mkwrite called for them.
The new Kernel patches that introduce pfn_mkwrite fixes this test.

Test adapted from a script originally written by Dave Chinner.

Signed-off-by: Omer Zilberberg <omzg@plexistor.com>
Signed-off-by: Boaz Harrosh <boaz@plexistor.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs: test cloning of zero length ranges
Filipe Manana [Wed, 1 Apr 2015 00:39:24 +0000 (11:39 +1100)]
btrfs: test cloning of zero length ranges

Test cloning a file range with a length of zero into a destination offset
greater than zero.

This made btrfs create an extent state record with a start offset greater than
the end offset, resulting in chaos such as an infinite loop when evicting an
inode.

This issue was fixed by the following linux kernel patch:

   Btrfs: fix inode eviction infinite loop after cloning into it

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs: fix _filter_mkfs regression
Eric Sandeen [Wed, 1 Apr 2015 00:38:40 +0000 (11:38 +1100)]
btrfs: fix _filter_mkfs regression

5e8b9e6 btrfs: add regression test for remount with thread_pool resized

did weird things to _filter_mkfs; aside from broken indentation,
it also short-circuited the default non-xfs behavior, which was to
emit a default block & inode size.  And that was all because btrfs/082
was using _filter_mkfs & not redirecting output away as per normal.

Granted, it's not super clear that _filter_mkfs serves this rather
unique purpose, but anyway...

And, while having this default seems to be of questionable value,
not emitting *anything* led to this on btrfs:

    +./tests/generic/204: line 76: space / (isize + dbsize): division by 0 (error token is ")")

because those variables don't get set for btrfs, thanks to the
above commit.

So take out the use of _filter_mkfs in btrfs/082, and take out the
munging of _filter_mkfs which broke generic/204, and get things back
to something semi-sane.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs: test orphan item cleanup
Jeff Mahoney [Wed, 1 Apr 2015 00:35:44 +0000 (11:35 +1100)]
btrfs: test orphan item cleanup

This test tests three conditions where orphan items need to be
cleaned up:

1) Default subvolume is fs tree root (mkfs default)
2) Default subvolume has been set explicitly to another subvolumei
   (set-default)
3) Looking up a subvolume during a traversal

In the kernel, these three cases use separate mechanisms to look up
the subvolumes. There was a bug in the kernel where case #2 wasn't
getting handled and so orphan items would never be cleaned up if the
default subvolume was explicitly set. This issue was fixed with the
upstream commit: btrfs: cleanup orphans while looking up default
subvolume.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofilter: btrfs-progs subvolume delete output changed
Eric Sandeen [Wed, 1 Apr 2015 00:34:45 +0000 (11:34 +1100)]
filter: btrfs-progs subvolume delete output changed

btrfs has started emitting new information from
cmd_subvol_delete(), so filter that out or it breaks btrfs/001:

    -Delete subvolume 'SCRATCH_MNT/snap'
    +Delete subvolume (no-commit): 'SCRATCH_MNT/snap'

(Spell "transaction" correctly while we're at it.)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofilter: btrfs-progs keeps changing version string
Eric Sandeen [Wed, 1 Apr 2015 00:33:17 +0000 (11:33 +1100)]
filter: btrfs-progs keeps changing version string

The btrfs cmd now sometimes emits "btrfs-progs" not "Btrfs-progs"
as it used to, so update the filter accordingly.

(This fixes a failure on btrfs/006 w/ btrfs-progs v3.19)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs: test incremental send/receive
Filipe Manana [Wed, 1 Apr 2015 00:32:01 +0000 (11:32 +1100)]
btrfs: test incremental send/receive

Test for incremental send where the difference between the parent and
send snapshots is that for a subtree with the same path in both snapshots
(p1/p2), the root directories were swapped.

This issue was fixed by the following linux kernel btrfs patch:

  Btrfs: incremental send, clear name from cache after orphanization

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs: test incremental send with directory renames
Filipe Manana [Wed, 1 Apr 2015 00:31:24 +0000 (11:31 +1100)]
btrfs: test incremental send with directory renames

Test for incremental send where the difference between the parent and
child snapshots is that a directory A was renamed and a directory B was
renamed to the name directory A had before (in the parent snapshot),
but directory A's rename must happen before some other directory C is
renamed.

This issue was fixed by the following linux kernel btrfs patch:

  Btrfs: incremental send, don't rename a directory too soon

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: test fsync after moving files across directories
Filipe Manana [Wed, 1 Apr 2015 00:31:03 +0000 (11:31 +1100)]
generic: test fsync after moving files across directories

Test file A fsync after moving one other unrelated file B between
directories and fsyncing B's old parent directory before fsyncing
the file A. Check that after a crash all the file A data we fsynced
is available.

This test is motivated by an issue discovered in btrfs which caused
the file data to be lost (despite fsync returning success to user
space). That btrfs bug is fixed by the following linux kernel patch:

   Btrfs: fix data loss in the fast fsync path

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: add test for truncate/collapse range race
Xiaoguang Wang [Wed, 1 Apr 2015 00:29:56 +0000 (11:29 +1100)]
generic: add test for truncate/collapse range race

This case tests truncate/collapse range race. If the race occurs, it
will trigger a BUG_ON(). And this kernel patch has fixed this race:
    23fffa9 fs: move falloc collapse range check into the filesystem methods

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric/077: add missing _require_scratch
Eryu Guan [Wed, 1 Apr 2015 00:29:16 +0000 (11:29 +1100)]
generic/077: add missing _require_scratch

generic/077 uses $SCRATCH_DEV without _require_scratch. Add it back.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs/014: replace df with $DF_PROG
Eryu Guan [Wed, 1 Apr 2015 00:29:04 +0000 (11:29 +1100)]
xfs/014: replace df with $DF_PROG

I've seen xfs/014 fails as

[root@dhcp-66-86-3 xfstests]# diff -u tests/xfs/014.out /var/lib/xfstests/results//xfs/014.out.bad

9 years agonfs: recognise IPv6 export in _require_scratch_nocheck()
Eryu Guan [Wed, 1 Apr 2015 00:28:18 +0000 (11:28 +1100)]
nfs: recognise IPv6 export in _require_scratch_nocheck()

This commit

73dfa4a common: Fixes for testing NFS over IPv6

adds NFS over IPv6 support, and commit

76c5f3c common: re-enable tests that require scratch dev on NFS

enables NFS tests on scratch device.

Now do the same updates to _require_scratch_nocheck() to enable NFS over
IPv6 support on scratch device.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: test some mount/umount corner cases
Eryu Guan [Wed, 1 Apr 2015 00:27:33 +0000 (11:27 +1100)]
generic: test some mount/umount corner cases

There're six test cases:
 - mount at a nonexistent mount point
 - mount a free loop device
 - mount with a wrong fs type
 - umount an symlink to device which is not mounted
 - umount a path with too long name
 - lazy umount a symlink

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs/078: remove loop device on failure
Dave Chinner [Wed, 1 Apr 2015 00:26:40 +0000 (11:26 +1100)]
xfs/078: remove loop device on failure

If the test fails for any reason, it fails to tear down the loop
device that was set up and hence the test device cannot be
unmounted, causing failures of subsequent tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agocommon: fix "utility required warning" with empty utility name
Zhao Lei [Wed, 18 Mar 2015 04:00:23 +0000 (15:00 +1100)]
common: fix "utility required warning" with empty utility name

In generic/019, if we hadn't install fio, we will get following output:

 generic/019      [not run]  utility required, skipped this test <- *
 Not run: generic/019
 Passed all 0 tests

When fio is not installed, "$FIO_PROG" is set to blank, and
_require_fio() call _require_command() with none arguments.

This patch fixed all misuse of _require_command(), add 2nd argument
to let _require_command() output right message, and add quotes to
first argument to avoid argument shifting.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofstests: generic test for fallocate
Filipe Manana [Wed, 18 Mar 2015 03:58:51 +0000 (14:58 +1100)]
fstests: generic test for fallocate

Test extent pre-allocation (using fallocate) into a region that already has a
pre-allocated extent that ends beyond the file's size. Verify that if the fs
is unmounted immediately after, the file's size and content are not lost.

This is motivated by a minor issue found in btrfs where the second fallocate
wouldn't update the inode's i_size on disk, fixed by the following btrfs
patch: "Btrfs: add missing inode item update in fallocate()".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs/073: be quiet about mouting with nouuid option
Eryu Guan [Wed, 18 Mar 2015 03:58:05 +0000 (14:58 +1100)]
xfs/073: be quiet about mouting with nouuid option

v4 and v5 xfs generate different outputs because v4 xfs only retries
mount with nouuid option once in the test, v5 xfs tries more times(with
xfs_copy running with -d option).

Just be quiet about mounting with nouuid option, it's much easier than
preparing two different 073.outs and selecting the proper one at runtime

Signed-off-by: Eryu Guan <eguan@redhat.com>
9 years agocommon: append -d option to XFS_COPY_PROG when testing v5 xfs
Eryu Guan [Wed, 18 Mar 2015 03:58:04 +0000 (14:58 +1100)]
common: append -d option to XFS_COPY_PROG when testing v5 xfs

xfs_copy doesn't work on v5 xfs without -d option, this fails xfs/073
when testing xfs with MKFS_OPTIONS="-m crc=1" set.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric/027: discard mkdir error message
Eryu Guan [Wed, 18 Mar 2015 03:57:49 +0000 (14:57 +1100)]
generic/027: discard mkdir error message

mkdir fails due to ENOSPC occasionally and will fail the whole test.
Redirect stdout and stderr to /dev/null.

Also fix the code style in _cleanup to use single tab.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agonew: fix template for new case to use a single tab not four spaces
Eryu Guan [Wed, 18 Mar 2015 03:57:33 +0000 (14:57 +1100)]
new: fix template for new case to use a single tab not four spaces

So we have preferred code style for all new test cases.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric/065: fsync file 'hello' before checking its content
Filipe Manana [Wed, 18 Mar 2015 03:56:40 +0000 (14:56 +1100)]
generic/065: fsync file 'hello' before checking its content

Explicitly fsync the file named 'hello' before checking its content.
This way there's only one expected result for all filesystems.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agocommon: fix a typo in _require_block_device()
Zhao Lei [Wed, 18 Mar 2015 03:55:58 +0000 (14:55 +1100)]
common: fix a typo in _require_block_device()

We need to check "$1" instead "$SCRATCH_DEV" in this function.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric: Add rudimetary RENAME_WHITEOUT test
Dave Chinner [Wed, 18 Mar 2015 03:55:21 +0000 (14:55 +1100)]
generic: Add rudimetary RENAME_WHITEOUT test

There is no API documentation for RENAME_WHITEOUT. There is no
developer documentation for RENAME_WHITEOUT. There are not comments
in the overlayfs or ext4 implementation of RENAME_WHITEOUT.

Hence, this test simply tries to expose basic RENAME_WHITEOUT
behaviour from ext4 so we can reverse-engineer and verify
bug-for-bug renameat2(RENAME_WHITEOUT) ext4 compatibility.

Note: uses generic/078 just to keep out of the way of the 6-7 other
pending new tests.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs/049: umount -d fails when kernel wins teardown race
Dave Chinner [Wed, 18 Mar 2015 03:54:44 +0000 (14:54 +1100)]
xfs/049: umount -d fails when kernel wins teardown race

When /etc/mtab is linked to /proc/mounts and we are using mount time
created loop devices (i.e. mount -o loop), the unmount can fail
with this amazingly informative error message:

umount: /mnt/scratch/test2: filesystem was unmounted, but mount(8) failed: Invalid argument

What it actually means in this case is that the kernel tore down the
loop device when the last reference went away, and it did it so fast
that mount was not able to find it in /etc/mtab after the unmount
syscall. Hence it could not find the loop device it was supposed to
tear down and has a hissy fit.

This is simple to fix: mount does not need to tear down the loop
device as the kernel does it automatically. Remove the "-d" from
the umount command, and the test passes again.

There's quite a few other tests that also use umount -d - fix them
as well.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs: don't output mkfs sector sizes into golden output
Dave Chinner [Wed, 18 Mar 2015 03:54:30 +0000 (14:54 +1100)]
xfs: don't output mkfs sector sizes into golden output

The mkfs sector sizes are dependent on the underlying device in use,
and so is not fixed. hence it needs to be filtered from any golden
output file, otherwise tests that just differ by sector size will
fail.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agoxfs/104: log size too small for 4k sector drives
Dave Chinner [Wed, 18 Mar 2015 03:54:08 +0000 (14:54 +1100)]
xfs/104: log size too small for 4k sector drives

xfs/104, xfs/119, xfs/291 and xfs/297 have small fixed log sizes. A
recent change to the kernel ramdisk changed it's physical sector
size from 512B to 4kB, and this results in mkfs calculating a log
size larger than the fixed test size and hence the tests fail.

Change the log size to a larger size that works with 4k sectors, and
also increase the size of the filesystem being created so that the
amount of data space in the filesystem does not change and hence
does not perturb the rest of the test.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofstests: generic test for fsync after removing xattrs
Filipe Manana [Wed, 25 Feb 2015 04:38:26 +0000 (15:38 +1100)]
fstests: generic test for fsync after removing xattrs

This test is motivated by an fsync issue discovered in btrfs.
The issue was that the fsync log replay code did not remove xattrs that
were deleted before the inode was fsynced. The result was unexpected
and differed from xfs and ext3/4 for example.

The btrfs issue was fixed by the following linux kernel patch:

   Btrfs: remove deleted xattrs on fsync log replay

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofstests: generic test for directory fsync after adding hard links
Filipe Manana [Wed, 25 Feb 2015 04:37:54 +0000 (15:37 +1100)]
fstests: generic test for directory fsync after adding hard links

This test is motivated by an fsync issue discovered in btrfs.
The issue was that after adding a new hard link to an existing file
(one that was created in a past transaction) and fsync'ing the parent
directory of the new hard link, after the fsync log replay the file's
inode link count did not get its link count incremented, while the new
directory entry was visible.
Also, unlike xfs and ext4, new files under the directory we fsync were
not being written to the fsync log, nor were any child directories and
new files and links under the children directories. So this test verifies
too that btrfs has the same behaviour as xfs and ext4.

The btrfs issue was fixed by the following linux kernel patch:

  Btrfs: fix metadata inconsistencies after directory fsync

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobuild: add missing files to gitignore
Omar Sandoval [Wed, 25 Feb 2015 04:37:16 +0000 (15:37 +1100)]
build: add missing files to gitignore

Several binaries show up in git status after running make in a fresh
clone, and so do files introduced by normal usage.

Signed-off-by: Omar Sandoval <osandov@osandov.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agocreate _require_metadata_journaling, and add to tests that need it
Eric Sandeen [Wed, 25 Feb 2015 04:36:52 +0000 (15:36 +1100)]
create _require_metadata_journaling, and add to tests that need it

Many tests use dm_flakey to trigger log replay, but for filesystems that
don't support metadata journaling, this causes failures when it shouldn't.
(i.e. we can hardly test log replay if there is no log, and the subsequent
filesystem check will turn up errors).

For some tests they actually sync everything we care about, and find
inconsistencies elsewhere, but I erred on the side of simply not running
the test in most cases.

Tested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Lukas Czerner <lczerner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agobtrfs/049: btrfs test, not generic
Eric Sandeen [Wed, 25 Feb 2015 04:35:56 +0000 (15:35 +1100)]
btrfs/049: btrfs test, not generic

It's not much fun to run btrfs-specific tests on non-btrfs
filesystems.  ;)

> EXT4-fs (dm-12): Unrecognized mount option "inode_cache" or missing value

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agogeneric/325: Fix test case to work on 64K page size.
Chandan Rajendra [Wed, 25 Feb 2015 04:35:20 +0000 (15:35 +1100)]
generic/325: Fix test case to work on 64K page size.

The test case passes 32K as the offset value to msync. This fails on machines
with 64K page size. Fix this by creating a larger file and passing offset
values which are multiples of 64K.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofsx: Add fallocate insert range operation
Namjae Jeon [Wed, 25 Feb 2015 04:35:08 +0000 (15:35 +1100)]
fsx: Add fallocate insert range operation

This commit adds fallocate FALLOC_FL_INSERT_RANGE support for fsx.

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
9 years agofsstress: Add fallocate insert range operation
Namjae Jeon [Wed, 25 Feb 2015 04:34:48 +0000 (15:34 +1100)]
fsstress: Add fallocate insert range operation

This commit adds insert operation support for fsstress, which is
meant to exercise fallocate FALLOC_FL_INSERT_RANGE support.

[dchinner: turn off this op for xfs/068, which expects an exact
outcome from the fsstress execution. ]

Signed-off-by: Namjae Jeon <namjae.jeon@samsung.com>
Signed-off-by: Ashish Sangwan <a.sangwan@samsung.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>