Commit Graph

113 Commits

Author SHA1 Message Date
Qu Wenruo 842c5a5941 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>
2015-05-04 22:56:11 +10:00
Filipe Manana 1a9dfb77f1 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>
2015-05-04 22:55:21 +10:00
Filipe Manana 2fbdbfb48d 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>
2015-05-04 22:55:19 +10:00
Filipe Manana 9edaf22811 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>
2015-04-01 11:39:24 +11:00
Jeff Mahoney dd26ee398f 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>
2015-04-01 11:35:44 +11:00
Filipe Manana 40851f9917 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>
2015-04-01 11:32:01 +11:00
Filipe Manana a752266d74 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>
2015-04-01 11:31:24 +11:00
Xing Gu 5e8b9e64ec btrfs: add regression test for remount with thread_pool resized
Regression test for a btrfs issue of resizing 'thread_pool' when
remount the fs.

This regression was introduced by the following linux kernel commit:
    btrfs: Added btrfs_workqueue_struct implemented ordered
    execution based on kernel workqueue
    08a9ff3264181986d1d692a4e6fce3669700c9f8
And it was fixed by the following linux kernel commit:
    btrfs: fix crash in remount(thread_pool=) case
    800ee2247f483b6d05ed47ef3bbc90b56451746c

Signed-off-by: Xing Gu <gux.fnst@cn.fujitsu.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2015-02-12 14:14:00 +11:00
Liu Bo e4aa15bc59 btrfs: add test case for qgroup account on shared extents
This is a regression test of
'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
it's used to verify that removing shared extents can end up incorrect
qgroup accounting.

It can produce qgroup related warnings.

The fix is https://patchwork.kernel.org/patch/5499981/
"Btrfs: fix a warning of qgroup account on shared extents"

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Tested-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-12-24 14:48:23 +11:00
Filipe Manana 22fc64ea50 btrfs: add regression test for clone ioctl
Regression test for a btrfs clone ioctl issue where races between
a clone operation and concurrent target file reads would result in
leaving stale data in the page cache. After the clone operation
finished, reading from the clone target file would return the old
and no longer valid data. This affected only buffered reads (i.e.
didn't affect direct IO reads).

This issue was fixed by the following linux kernel patch:

    Btrfs: ensure readers see new data after a clone operation
    (commit c125b8bff1d9f6c8c91ce4eb8bd5616058c7d510)

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-12-16 10:53:42 +11:00
Filipe Manana 0cfb617c51 fstests: btrfs, add test for snapshoting after file write + truncate
Regression test for a btrfs issue where if right after the snapshot
creation ioctl started, a file write followed by a file truncate
happened, with both operations increasing the file's size, the created
snapshot would capture an inconsistent state of the file system tree.
That state reflected the file truncation but it didn't reflect the
write operation, and left a gap between two file extent items (and
that gap corresponded to the total or a partial area of the write
operation's range).

This issue was fixed by the following linux kernel patch:

    Btrfs: fix snapshot inconsistency after a file write followed by truncate

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-12-16 10:50:56 +11:00
Eryu Guan 6a923ff03d btrfs: add groups for btrfs tests
Some new btrfs groups have been added in the btrfs stress patchset, add
other tests to proper groups too.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-12-16 10:48:35 +11:00
Eryu Guan 8d03c12def btrfs/017: remove duplicate test
btrfs/017 is same as btrfs/015, remove it.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-12-12 11:26:31 +11:00
Qu Wenruo 027bcfa64e btrfs: regression test for btrfs extent merge
The following kernel commit introduced the bug:
51f395ad btrfs: Use right extent length when inserting overlap extent map.

When btrfs commit race with btrfs_get_extent(), merge_extent_mapping()
may build up a new extent which length overflows and cause extent map
insert fail, causing the caller get a -EEXIST error.

This regression is fixed by the following patches:
btrfs: Fix and enhance merge_extent_mapping() to insert best fitted extent map
btrfs: Fix the wrong condition judgment about subset extent map

Cc: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-11-10 13:04:00 +11:00
Filipe Manana 8c7c07e79b btrfs: regression test for ro snapshot creation
Regression test for a btrfs issue where creation of readonly snapshots caused
the filesystem to get into an inconsistent state.

This regression was introduced in the 3.17 kernel and fixed by reverting the
following linux kernel commit:

     Btrfs: race free update of commit root for ro snapshots
     9c3b306e1c9e6be4be09e99a8fe2227d1005effc

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-11-10 13:03:43 +11:00
Filipe Manana edaea8a075 btrfs: regression test for btrfs incremental send
This is a regression test for a btrfs incremental send issue.
If between two snapshots we rename an existing directory named X to Y and
make it a child (direct or not) of a new inode named X, we were delaying
the move/rename of the former directory unnecessarily, which would result
in attempting to rename the new directory from its orphan name to name X
prematurely. This made btrfs receive fail with an error message like the
following:

   rename o261-7-0 -> merlin/RC/OSD failed

This issue was a regression in the 3.16 kernel and got fixed by the
following linux kernel btrfs patch:

   Btrfs: send, don't delay dir move if there's a new parent inode

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:39 +11:00
Wang Shilong 562af5d343 btrfs: add regression for inode bad compression ratio detection
This test add a regression test to make sure btrfs dosen't set
inode NOCOMPRESS flag when a small write(<=blocksize) happens.

Signed-off-by: Wang Shilong <wangshilong1991@gmail.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan b675ef7265 btrfs: test mount btrfs subvolume with selinux context
If one subvolume was mounted with selinux context, other subvolumes
should be able to be mounted with the same selinux context too.

Signed-off-by: Eryu Guan <eguan@redhat.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan a1a9f6ebbb btrfs: new case to run defrag and remount with different compress algorithms simultaneously
Run btrfs defrag operations and remount with different compress
algorithms simultaneously with fsstress running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 5398fca4b3 btrfs: new case to run btrfs scrub and remount with different compress algorithms simultaneously
Run btrfs scrub and remount with different compress algorithms
simultaneously with fsstress running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 1e18397f57 btrfs: new case to run btrfs scrub and defrag operations simultaneously
Run btrfs scrub and defrag operations simultaneously with fsstress
running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 5160c146b4 btrfs: new case to run device replace and remount with different compress algorithms simultaneously
Run btrfs replace operations and remount with different compress
algorithms simultaneously with fsstress running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 87c32f62a5 btrfs: new case to run device replace and defrag operations simultaneously
Run btrfs replace operations and defrag simultaneously with fsstress
running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 8dc3354fee btrfs: new case to run device replace and scrub operations simultaneously
Run btrfs replace operations and scrub simultaneously with fsstress
running in background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00
Eryu Guan 067578b6c7 btrfs: new case to run subvolume create/delete and remount with defferent compress algorithms
Run btrfs subvolume create/mount/umount/delete and remount with
different compress algorithms simultaneously, with fsstress running in
background.

Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
2014-10-14 22:59:38 +11:00