generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 090
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2015 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test No. 090
6 #
7 # Test that after syncing the filesystem, adding a hard link to a file,
8 # syncing the filesystem again, doing a write to the file that increases
9 # its size and then doing a fsync against that file, durably persists the
10 # data written to the file. That is, after log/journal replay, the data
11 # is available.
12 #
13 # This test is motivated by a bug found in btrfs.
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22
23 _cleanup()
24 {
25         _cleanup_flakey
26         rm -f $tmp.*
27 }
28 trap "_cleanup; exit \$status" 0 1 2 3 15
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33 . ./common/dmflakey
34
35 # real QA test starts here
36 _supported_fs generic
37 _require_scratch
38 _require_hardlinks
39 _require_dm_target flakey
40
41 rm -f $seqres.full
42
43 _scratch_mkfs >> $seqres.full 2>&1
44 _require_metadata_journaling $SCRATCH_DEV
45 _init_flakey
46 _mount_flakey
47
48 # Create the test file with some initial data and then fsync it.
49 # The fsync here is only needed to trigger the issue in btrfs, as it causes the
50 # the flag BTRFS_INODE_NEEDS_FULL_SYNC to be removed from the btrfs inode.
51 $XFS_IO_PROG -f -c "pwrite -S 0xaa 0 32k" \
52                 -c "fsync" \
53                 $SCRATCH_MNT/foo | _filter_xfs_io
54 sync
55
56 # Add a hard link to our file.
57 # On btrfs this sets the flag BTRFS_INODE_COPY_EVERYTHING on the btrfs inode,
58 # which is a necessary condition to trigger the issue.
59 ln $SCRATCH_MNT/foo $SCRATCH_MNT/bar
60
61 # Sync the filesystem to force a commit of the current btrfs transaction, this
62 # is a necessary condition to trigger the bug on btrfs.
63 sync
64
65 # Now append more data to our file, increasing its size, and fsync the file.
66 # In btrfs because the inode flag BTRFS_INODE_COPY_EVERYTHING was set and the
67 # write path did not update the inode item in the btree nor the delayed inode
68 # item (in memory structure) in the current transaction (created by the fsync
69 # handler), the fsync did not record the inode's new i_size in the fsync
70 # log/journal. This made the data unavailable after the fsync log/journal is
71 # replayed.
72 $XFS_IO_PROG -c "pwrite -S 0xbb 32K 32K" \
73                 -c "fsync" \
74                 $SCRATCH_MNT/foo | _filter_xfs_io
75
76 echo "File content after fsync and before crash:"
77 od -t x1 $SCRATCH_MNT/foo
78
79 _flakey_drop_and_remount
80
81 echo "File content after crash and log replay:"
82 od -t x1 $SCRATCH_MNT/foo
83
84 status=0
85 exit