Commit Graph

136 Commits

Author SHA1 Message Date
Qu Wenruo 5c2fbcc69e generic: check fiemap SHARED flag on sync
The test case will check SHARED flag returned by fiemap ioctl on
reflinked files before and after sync.

Normally SHARED flag won't change just due to a normal sync
operation.

But btrfs doesn't handle SHARED flag well, and this time it won't
check any delayed extent tree(reverse extent searching tree)
modification, but only metadata already committed to disk.

So btrfs will not return correct SHARED flag on reflinked files if
there is no sync to commit all metadata.

This testcase will just check it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-06-15 15:14:35 +08:00
Qu Wenruo 6df776bae8 generic: extent map search on dedupe file
For fully deduped file, which means all its file exntents are
pointing to the same bytenr, btrfs can cause soft lockup when
calling fiemap ioctl on that file, like the following output:
------
CPU: 1 PID: 7500 Comm: xfs_io Not tainted 4.5.0-rc6+ #2
Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox
12/01/2006
task: ffff880027681b40 ti: ffff8800276e0000 task.ti: ffff8800276e0000
RIP: 0010:[<ffffffffa02583e4>]  [<ffffffffa02583e4>]
__merge_refs+0x34/0x120 [btrfs]
RSP: 0018:ffff8800276e3c08  EFLAGS: 00000202
RAX: ffff8800269cc330 RBX: ffff8800269cdb18 RCX: 0000000000000007
RDX: 00000000000061b0 RSI: ffff8800269cc4c8 RDI: ffff8800276e3c88
RBP: ffff8800276e3c20 R08: 0000000000000000 R09: 0000000000000001
R10: 0000000000000000 R11: 0000000000000000 R12: ffff880026ea3cb0
R13: ffff8800276e3c88 R14: ffff880027132a50 R15: ffff880027430000
FS:  00007f10201df700(0000) GS:ffff88003fa00000(0000)
knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f10201ec000 CR3: 0000000027603000 CR4: 00000000000406e0
Stack:
 0000000000000000 0000000000000000 0000000000000000 ffff8800276e3ce8
 ffffffffa0259f38 0000000000000005 ffff8800274c6870 ffff8800274c7d88
 0000000000c10000 0000000000000000 0000000000000001 0000000027431190
Call Trace:
 [<ffffffffa0259f38>] find_parent_nodes+0x448/0x740 [btrfs]
 [<ffffffffa025a4f2>] btrfs_check_shared+0x102/0x1b0 [btrfs]
 [<ffffffff811fdcad>] ? __might_fault+0x4d/0xa0
 [<ffffffffa021899c>] extent_fiemap+0x2ac/0x550 [btrfs]
 [<ffffffff811ce156>] ? __filemap_fdatawait_range+0x96/0x160
 [<ffffffffa01f8ee0>] ? btrfs_get_extent+0xb30/0xb30 [btrfs]
 [<ffffffffa01f5da5>] btrfs_fiemap+0x45/0x50 [btrfs]
 [<ffffffff81246bb8>] do_vfs_ioctl+0x498/0x670
 [<ffffffff81246e09>] SyS_ioctl+0x79/0x90
 [<ffffffff8184e997>] entry_SYSCALL_64_fastpath+0x12/0x6f
Code: 41 55 41 54 53 4c 8b 27 4c 39 e7 0f 84 e9 00 00 00 49 89 fd 49 8b
34 24 49 39 f5 48 8b 1e 75 17 e9 d5 00 00 00 49 39 dd 48 8b 03 <48> 89
de 0f 84 b9 00 00 00 48 89 c3 8b 46 2c 41 39 44 24 2c 75
------

Also btrfs will return wrong flag for all these extents, they should
have SHARED(0x2000) flags, while btrfs still consider them as
exclusive extents.

On the other hand, with unmerged xfs reflink patches, xfs can handle
it without problem, and for patched btrfs, it can also handle it.

This test case will create a large fully deduped file to check if
the fs can handle the fiemap ioctl and return correct SHARED flag
for any fs which support reflink.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
2016-06-15 15:09:17 +08:00
Dave Chinner 048edf0404 generic: renumber tests after merge
Some tests were merged with high, non-conflicting test numbers
(700+). Renumber them down to contiguous numbers now that all the
other tests have been added, as it's easier to do it this way rather
than having to rebase and have to fix all the conflicts early
renumbering will cause.

Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 16:03:29 +10:00
Filipe Manana 238397db22 generic: test creating a symlink and then fsync its parent directory
Test creating a symlink, fsync its parent directory, power fail and mount
again the filesystem. After these steps the symlink should exist and its
content must match what we specified when we created it (must not be
empty or point to something else).

This is motivated by an issue in btrfs where after the log replay happens
we get empty symlinks, which not only does not make much sense from a
user's point of view, it's also not valid to have empty links in linux
(wgich is explicitly forbidden by the symlink(2) system call).

The issue in btrfs is fixed by the following patch for the linux kernel:

  "Btrfs: fix empty symlink after creating symlink and fsync parent dir"

Tested against ext3, ext4, xfs, f2fs, reiserfs and nilfs2.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:57:39 +10:00
Eric Sandeen 1c299868dd dm-thinp demo test
Fairly trivial test to use the dm-thin infrastructure.

Right now it exhausts space in queue-on-error mode,
adds more space, does a bit more IO, then unmounts &
checks the fs.

Not sure if that's valid to test, but it works here and
demonstrates the common/dmthin helpers.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:55:24 +10:00
Jan Kara 507d31596c generic: Test races between processes doing mmap writes
Add test which spawns two processes both writing one file via mmap.
Then to the test when processes first prefault the file by reading it
via mmap. This is mainly interesting to uncover races in DAX fault
handling.

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:54:36 +10:00
Jan Kara 9e8b4e2755 generic: Test races between mmap and normal write for prefaulted ranges
Add test which spawns two threads both writing one file via mmap which
has been previously prefaulted by reading. Do the same test when one
thread accesses the file via mmap and the other one via normal write.
This is mainly interesting to uncover races in DAX fault handling and
between DAX fault handling and write path.

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:54:25 +10:00
Jan Kara 96a3ad1630 generic: Test races between mmap and normal writes
Add test which spawns two threads one writing to file via normal write
and one via mmap and checks the result. This is mainly interesting to
uncover races between DAX fault handling and write path.

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:54:10 +10:00
Darrick J. Wong 45da5f51d4 block: test fallocate for block devices
Now that we're wiring up fallocate's PUNCH_HOLE and ZERO_RANGE
features for block devices, add some tests to make sure they
work correctly.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:49:50 +10:00
Filipe Manana 31247b3f9c generic: test fsync after adding a link and moving other inode
Test that if we create a hard link for a file F in some directory A,
then move some directory or file B from its parent directory C into
directory A, fsync file F, power fail and mount the filesystem, the
directory/file B is located only at directory A and both links for
file F exist.

This test is motivated by an issue found in btrfs which is fixed by the
following patch for the linux kernel:

  Btrfs: fix for incorrect directory entries after fsync log replay

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

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-05-09 10:45:20 +10:00
Filipe Manana f02fe94911 generic: add test for fsync after renaming file
Test that if we rename a file, create a new file that has the old name
of the other file and is a child of the same parent directory, fsync the
new inode, power fail and mount the filesystem, we do not lose the first
file and that file has the name it was renamed to.

This test is motivated by an issue found in btrfs which is fixed by the
following patch for the linux kernel:

  "Btrfs: fix file loss caused by fsync after rename and new inode"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-04-05 11:47:55 +10:00
Filipe Manana 5b13255306 generic: add test for fsync after renaming directory
Test that if we rename a directory, create a new file or directory that
has the old name of our former directory and is a child of the same
parent directory, fsync the new inode, power fail and mount the
filesystem, we see our first directory with the new name and no files
under it were lost.

This test is motivated by an issue found in btrfs which is fixed by the
following patch for the linux kernel:

  "Btrfs: fix file loss caused by fsync after rename and new inode"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-04-05 11:47:31 +10:00
Jan Kara 450d833eba generic/338: Add mmap race test
Add test which spawns two threads racing to write to file via mmap and
checks the result. This is mainly interesting to uncover races in DAX
fault handling.

Signed-off-by: Jan Kara <jack@suse.cz>
Acked-by: Brian Boylston <brian.boylston@hpe.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-04-05 11:44:05 +10:00
Eryu Guan 848f580287 fstests: make xfs/006 generic
xfs/006 has no requirements that are specific to XFS, so make it generic
and other filesystems could get some coverage too.

Along with the movement, I also added a test that removes all created
dirs, as that's how the original bug was found.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-03-23 17:39:11 +11:00
Eryu Guan d00a869c2e generic: test I/O on dm error device
This is a test that performs simple I/O on dm error device, which
returns EIO on all I/O request.

This is motivated by an ext4 bug that crashes kernel on error path when
trying to update atime. Following kernel patch should fix the issue

  ext4: fix NULL pointer dereference in ext4_mark_inode_dirty()

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-03-23 17:39:11 +11:00
Filipe Manana 40d2678b7b fstests: generic test for listing an inode's xattrs
Test that the filesystem's implementation of the listxattrs system call
lists all the xattrs an inode has.

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

  "Btrfs: fix listxattrs not listing all xattrs packed in the same item"

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-02-29 10:18:51 +11:00
Theodore Ts'o d0a255e43a generic/125: add _require_odirect
Also remove generic/125 from the auto group, and add it to the new
pnfs group.  This is to document where this test might be useful; it's
not really going to be useful for most normal on-disk file systems, so
remove it from the auto group.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2016-02-29 10:17:56 +11:00
Filipe Manana e2d866668a generic: test file fsync after rename operation
Test that if we have a file F1 with two links, one in a directory A and
the other in directory B, if we remove the link in directory B, move some
other file F2 from directory B into directory C, fsync inode F1, power
fail and remount the filesystem, file F2 exists and is located only in
directory C.

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

   "Btrfs: fix file loss on log replay after renaming a file and fsync"

Tested against ext3, ext4, 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>
2016-02-19 12:15:33 +11:00
Filipe Manana 72da52702a generic: test directory fsync after rename operation
Test that if we move one file between directories, fsync the parent
directory of the old directory, power fail and remount the filesystem,
the file is not lost and it's located at the destination directory.

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

  "Btrfs: fix file loss on log replay after renaming a file and fsync"

Tested against ext3, ext4, 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>
2016-02-19 12:15:17 +11:00
Darrick J. Wong c6f5bb394a reflink: kick the slow tests out of the 'quick' group
Since 'quick' tests are supposed to run in < 15s, kick out the ones
that can't finish that soon even on fast storage.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00
Darrick J. Wong 130d7f0d1e reflink: test reflink+cow+enospc all at the same time
Set up an impossibly small filesystem and try to reflink and rewrite a
file on it to see what happens when we ENOSPC.  Basically
generic/16[67] but with a constrained fs size.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00
Darrick J. Wong 3c95f55047 reflink: test aio copy on write
Make sure that copy on write works with the AIO path.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00
Darrick J. Wong aad7738cda reflink: test quota accounting
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00
Darrick J. Wong 2fcbba4ceb reflink: high offset reflink and dedupe tests
Ensure that we can pass absurdly enormous offsets and lengths to
reflink/dedupe and it'll survive.

v2: Ask for dedupe in the dedupe test.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
[hch@lst.de: call _require_test_dedupe]
Signed-off-by: Christoph Hellwig <hch@lst.de>
2016-02-12 09:39:05 -08:00
Darrick J. Wong 9184ca155d xfs: test fragmentation characteristics of copy-on-write
Perform copy-on-writes at random offsets to stress the CoW allocation
system.  Assess the effectiveness of the extent size hint at
combatting fragmentation via unshare, a rewrite, and no-op after the
random writes.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
2016-02-12 09:39:05 -08:00