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
10 # This tests excercises the problem fixed in kernel with commit
11 # "ext4: Fix data corruption caused by unwritten and delayed extents"
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2015 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
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.
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.
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 #-----------------------------------------------------------------------
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
37 status=1 # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
46 # get standard environment, filters and checks
50 # real QA test starts here
52 # Modify as appropriate.
54 _supported_os IRIX Linux
56 _require_xfs_io_command "falloc"
58 test_file=${TEST_DIR}/testfile-$seq
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
71 # Drop the caches to evict dirty buffers from memory
72 echo 3 > /proc/sys/vm/drop_caches
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
80 # On a faulty ext4 oxbb data will be missing, overwritten by zeroes.