btrfs: exercise transaction abort on device with discard support
authorFilipe Manana <fdmanana@suse.com>
Mon, 4 May 2015 12:55:21 +0000 (22:55 +1000)
committerDave Chinner <david@fromorbit.com>
Mon, 4 May 2015 12:55:21 +0000 (22:55 +1000)
commit1a9dfb77f19dfd3a7df8140e3bf0bf71818b8323
treefab9ac5356ccb4da7176e659932c54f6e1372161
parent2fbdbfb48d741517ec13f71967a3d407150ecf8c
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>
tests/btrfs/088 [new file with mode: 0755]
tests/btrfs/088.out [new file with mode: 0644]
tests/btrfs/group