generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 086
1 #! /bin/bash
2 # FS QA Test 086
3 #
4 # This test excercises the problem with unwritten and delayed extents
5 # in ext4 extent status tree where we might in some cases lose a block
6 # worth of data. Even though this was a ext4 specific problem the
7 # reproducer can be easily tun on any file system so let's do that just
8 # in case.
9 #
10 # This tests excercises the problem fixed in kernel with commit
11 # "ext4: Fix data corruption caused by unwritten and delayed extents"
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2015 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51
52 # Modify as appropriate.
53 _supported_fs generic
54 _supported_os IRIX Linux
55 _require_test
56 _require_xfs_io_command "falloc"
57
58 test_file=${TEST_DIR}/testfile-$seq
59
60 rm -f $test_file
61
62 # The first write creates a delayed extent, fallocate creates
63 # unwritten extent which will be marked as delayed in ext4
64 # extent status tree. Second write will convert unwritten/delayed
65 # block into written/delayed.
66 $XFS_IO_PROG -f -c "pwrite -S 0xaa 4096 2048" \
67                 -c "falloc 0 131072" \
68                 -c "pwrite -S 0xbb 65536 2048" \
69                 -c "fsync"  $test_file > $seqres.full 2>&1
70
71 # Drop the caches to evict dirty buffers from memory
72 echo 3 > /proc/sys/vm/drop_caches
73
74 # Write into the second part of the block with 0xbb write from before
75 # will create new empty! buffer because the block is still marked as
76 # delayed even though it's already written - resulting in
77 # overwriting previous data.
78 $XFS_IO_PROG -c "pwrite -S 0xdd 67584 2048" $test_file >> $seqres.full 2>&1
79
80 # On a faulty ext4 oxbb data will be missing, overwritten by zeroes.
81 hexdump -C $test_file
82
83 # success, all done
84 status=0
85 exit