Commit Graph

104 Commits

Author SHA1 Message Date
Darrick J. Wong 2a885960ec reflink: test a big CoW operation
Test what happens when we send largeish buffers to CoW all at once.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-12-21 18:36:26 +11:00
Darrick J. Wong 8ceac6e2f7 reflink: test CoW with blocksize < pagesize
Test CoW operations when blocksize < pagesize and the only reflink
block is in the middle of the page.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-12-21 18:35:21 +11:00
Darrick J. Wong c8a13e5303 reflink: more CoW tests for reflink and dedupe
These tests examine the behavior of advanced and tricky copy on write
situations.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-12-21 18:27:04 +11:00
Darrick J. Wong 1b3dc467e4 reflink: more tests
Add more tests for unaligned copy-on-write things, and explicitly
test the ability to pass "len == 0" to mean reflink/dedupe all
the way to the end of the file".

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-12-21 18:13:37 +11:00
Xiaoguang Wang f2f13c3735 generic/275: add to the 'enospc' group
Currently we're developing a new in-band deduplication feature for btrfs,
when enabing this feature, it will take much long time to hit the enospc
condition which 275 tries to create. I think 275 is also certain enospc
test and we should add it to 'enospc' group, then we can skip it easily by
excluding 'enospc' group when running fstests.

Signed-off-by: Xiaoguang Wang <wangxg.fnst@cn.fujitsu.com>
2015-12-21 18:01:54 +11:00
Jeff Moyer 7721b85016 generic/042: remove from the 'auto' group
This test fails 100% of the time for me on xfs and current git head, and
is not run for ext4 since ext4 does not support shutdown.  After talking
with bfoster, it isn't expected to succeed right now.  Since the auto
group is for tests that *are* expected to succeed, let's move this one
out.

Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-12-21 18:01:47 +11:00
Filipe Manana 71f68b47e1 fstests: generic test for fsync after hole punching
Test that a file fsync works after punching a hole for the same file
range multiple times, and that after log/journal replay the file's
content and layout are correct.

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

  "Btrfs: fix hole punching when using the no-holes feature"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:41:18 +11:00
Darrick J. Wong 727d47730d reflink: test what happens when we hit resource limits
Add a few horrible opt-in stress tests to see what happens if we try
to reflink the same block billions of times, and what happens if we
run out of space while reflinking a file.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:40:17 +11:00
Darrick J. Wong db4284f312 reflink: test that CoW writes fail when we're out of space
Ensure that copy-on-writing a reflinked file when there's no free disk
space reflects the desired ENOSPC back to userspace during the write
call.  Tests the buffered IO, direct IO, and mmap write paths.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:40:08 +11:00
Darrick J. Wong 5fb5ee48b3 reflink: concurrent operations tests
Make sure that running reflink ops while other IO is ongoing doesn't
break the filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:40:02 +11:00
Darrick J. Wong f3965fde0a reflink: test error conditions due to bad inputs
Check that we can feed bad inputs to reflink/dedupe and it'll reject
them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:50 +11:00
Darrick J. Wong bed1fedae6 reflink: test accuracy of free block counts
Check that the free block counts seem to be handled correctly in
the reflink operation and subsequent attempts to rewrite reflinked
copies.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:43 +11:00
Darrick J. Wong c84e01bac3 reflink: test the various fallocate modes
Check that the variants of fallocate (allocate, punch, zero range,
collapse range, insert range) do the right thing when they're run
against a range of reflinked blocks.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:37 +11:00
Darrick J. Wong 6a4e8b81d9 reflink: test CoW behaviors of reflinked files
Ensure that CoW happens correctly with buffered, directio, and mmap writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:32 +11:00
Darrick J. Wong cc8e860cc9 reflink: basic tests of the reflink and dedupe ioctls
Test the operation of the btrfs (and now xfs) reflink and dedupe
ioctls at various file offsets and with matching and nonmatching
files.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:24 +11:00
Darrick J. Wong 5a7abc0f09 btrfs: move btrfs reflink tests to generic
Move the cp --reflink tests from btrfs/ to generic/ since xfs now
supports that ioctl.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-11-17 08:39:09 +11:00
Eric Sandeen cef2e7a583 generic: test extending sub-block AIO writes for races
This tests Brian Foster's fix for xfs:

   xfs: always drain dio before extending aio write submission

It launches four adjacent 1k IOs past EOF, then reads back
to see if we have 4k worth of the data we wrote, or something else -
possibly zeros from sub-block zeroing and eof racing.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-10-14 14:19:31 +11:00
Eryu Guan d7ae61359f generic: test partial block device failure
Calls like fsync() should report failure on partial I/O failure, e.g. a
single failed disk in a raid 0 stripe.

This test is motivated by an XFS bug, and this commit fixed the issue
xfs: return errors from partial I/O failures to files

This case is written by David Jeffery <djeffery@redhat.com> originally.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-09-21 13:06:18 +10:00
Jan Kara ed2732fd91 fstests: Add test of rename
Test renaming of various entry types in directories of various sizes.
Check that filesystem didn't get corrupted.

[dchinner: fixed missing bits from new test template, removed
 checking of scratch as harness does that. ]

Signed-off-by: Jan Kara <jack@suse.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-09-21 13:06:18 +10:00
Filipe Manana 1bea79d6c1 generic: fsync files with multiple links
Test that when we have a file with multiple hard links belonging to
different parent directories, if we remove one of those links, fsync the
file using one of its other links (that has a parent directory different
from the one we removed a link from), power fail and then replay the
fsync log/journal, the hard link we removed is not available anymore and
all the filesystem metadata is in a consistent state.

This test is motivated by an issue found in btrfs, where the test fails
with:

  generic/107 2s ... - output mismatch (see .../results/generic/107.out.bad)
    --- tests/generic/107.out	2015-08-04 09:47:46.922131256 +0100
    +++ /home/fdmanana/git/hub/xfstests/results//generic/107.out.bad
    @@ -1,3 +1,5 @@
     QA output created by 107
     Entries in testdir:
     foo2
    +foo3
    +rmdir: failed to remove '/home/fdmanana/btrfs-tests/scratch_1/testdir': Directory not empty
    ...
    (Run 'diff -u tests/generic/107.out .../generic/107.out.bad'  to see the entire diff)
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent (see .../generic/107.full)
  _check_dmesg: something found in dmesg (see .../generic/107.dmesg)

  $ cat /home/fdmanana/git/hub/xfstests/results//generic/107.full
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent
  *** fsck.btrfs output ***
  checking extents
  checking free space cache
  checking fs roots
  root 5 inode 257 errors 200, dir isize wrong
	unresolved ref dir 257 index 3 namelen 4 name foo3 filetype 1 \
          errors 5, no dir item, no inode ref

  $ cat /home/fdmanana/git/hub/xfstests/results//generic/107.dmesg
  (...)
  [188897.707311] BTRFS info (device dm-0): failed to delete reference to \
    foo3, inode 258 parent 257
  [188897.711345] ------------[ cut here ]------------
  [188897.713369] WARNING: CPU: 10 PID: 19452 at fs/btrfs/inode.c:3956 \
    __btrfs_unlink_inode+0x182/0x35a [btrfs]()
  [188897.717661] BTRFS: Transaction aborted (error -2)
  (...)
  [188897.747898] Call Trace:
  [188897.748519]  [<ffffffff8145f077>] dump_stack+0x4f/0x7b
  [188897.749602]  [<ffffffff81095de5>] ? console_unlock+0x356/0x3a2
  [188897.750682]  [<ffffffff8104b3b0>] warn_slowpath_common+0xa1/0xbb
  [188897.751936]  [<ffffffffa04c5d09>] ? __btrfs_unlink_inode+0x182/0x35a [btrfs]
  [188897.753485]  [<ffffffff8104b410>] warn_slowpath_fmt+0x46/0x48
  [188897.754781]  [<ffffffffa04c5d09>] __btrfs_unlink_inode+0x182/0x35a [btrfs]
  [188897.756295]  [<ffffffffa04c6e8f>] btrfs_unlink_inode+0x1e/0x40 [btrfs]
  [188897.757692]  [<ffffffffa04c6f11>] btrfs_unlink+0x60/0x9b [btrfs]
  [188897.758978]  [<ffffffff8116fb48>] vfs_unlink+0x9c/0xed
  [188897.760151]  [<ffffffff81173481>] do_unlinkat+0x12b/0x1fb
  [188897.761354]  [<ffffffff81253855>] ? lockdep_sys_exit_thunk+0x12/0x14
  [188897.762692]  [<ffffffff81174056>] SyS_unlinkat+0x29/0x2b
  [188897.763741]  [<ffffffff81465197>] system_call_fastpath+0x12/0x6f
  [188897.764894] ---[ end trace bbfddacb7aaada8c ]---
  [188897.765801] BTRFS warning (device dm-0): __btrfs_unlink_inode:3956: \
    Aborting unused transaction(No such entry).

Tested against ext3/4, xfs, reiserfs and f2fs too, and all these
filesystems currently pass this test (on a 4.1 linux kernel at least).

The btrfs issue is fixed by the linux kernel patch titled:
"Btrfs: fix stale dir entries after removing a link and fsync".

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-09-21 11:04:25 +10:00
Filipe Manana 3d0e7738dc generic: file fsync after unlink and inode eviction
Test that if we remove one hard link from an inode, evict the inode,
fsync the inode, power fail and then mount the filesystem, the hard
link we removed does not exists anymore and the filesystem metadata
is in a consistent state.

This test is motivated by an issue found on btrfs, and on an unpatched
btrfs it fails with:

  FSTYP         -- btrfs
  PLATFORM      -- Linux/x86_64 debian3 4.1.0-rc6-btrfs-next-11+
  MKFS_OPTIONS  -- /dev/sdc
  MOUNT_OPTIONS -- /dev/sdc /home/fdmanana/btrfs-tests/scratch_1

  generic/098 4s ... - output mismatch (see .../generic/098.out.bad)
    --- tests/generic/098.out	2015-07-23 18:01:12.616175932 +0100
    +++ .../generic/098.out.bad	2015-07-23 18:04:58.924138308 +0100
    @@ -1,3 +1,6 @@
     QA output created by 098
     Entries in testdir:
    +bar
     foo
    +rm: cannot remove '.../testdir/foo': Stale file handle
    +rmdir: failed to remove '.../scratch_1/testdir': Directory not empty
    ...
  _check_btrfs_filesystem: filesystem on /dev/sdc is inconsistent ...
  (...)

  $ cat /home/fdmanana/git/hub/xfstests/results/generic/098.full
  (...)
  checking fs roots
  root 5 inode 258 errors 2001, no inode item, link count wrong
   unresolved ref dir 257 index 0 namelen 3 name foo filetype 1 errors 6,\
       no dir index, no inode ref
   unresolved ref dir 257 index 3 namelen 3 name bar filetype 1 errors 5,\
       no dir item, no inode ref
  (...)

Tested against ext3/4, xfs, f2fs and reiserfs.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-08-04 14:10:49 +10:00
Filipe Manana 5b415d2be5 generic: test for fsync after adding hard links
Test that if we add hard links (in the same directory) to two files and
then fsync only one of the files, after the fsync log/journal is replayed
all the links exist and the filesystem metadata (directory and file
inodes) is in a consistent state.

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

  "Btrfs: fix stale directory entries after fsync log replay"

Verified against ext3/4, xfs, f2fs and reiserfs on a 4.1 linux kernel.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-08-04 14:10:49 +10:00
Brian Foster 67f0524ceb 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>
2015-08-04 14:10:49 +10:00
Wang Yanfeng b9982f9551 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>
2015-08-04 14:10:49 +10:00
Filipe Manana 9dcfb88ac6 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>
2015-08-04 14:10:49 +10:00