generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / generic / 086
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Red Hat, Inc., Lukas Czerner <lczerner@redhat.com>
4 #
5 # FS QA Test 086
6 #
7 # This test excercises the problem with unwritten and delayed extents
8 # in ext4 extent status tree where we might in some cases lose a block
9 # worth of data. Even though this was a ext4 specific problem the
10 # reproducer can be easily tun on any file system so let's do that just
11 # in case.
12 #
13 # This tests excercises the problem fixed in kernel with commit
14 # "ext4: Fix data corruption caused by unwritten and delayed extents"
15 #
16 . ./common/preamble
17 _begin_fstest auto prealloc preallocrw quick
18
19 # Import common functions.
20 . ./common/filter
21
22 # real QA test starts here
23
24 # Modify as appropriate.
25 _supported_fs generic
26 _require_test
27 _require_xfs_io_command "falloc"
28
29 test_file=${TEST_DIR}/testfile-$seq
30
31 rm -f $test_file
32
33 # The first write creates a delayed extent, fallocate creates
34 # unwritten extent which will be marked as delayed in ext4
35 # extent status tree. Second write will convert unwritten/delayed
36 # block into written/delayed.
37 $XFS_IO_PROG -f -c "pwrite -S 0xaa 4096 2048" \
38                 -c "falloc 0 131072" \
39                 -c "pwrite -S 0xbb 65536 2048" \
40                 -c "fsync"  $test_file > $seqres.full 2>&1
41
42 # Drop the caches to evict dirty buffers from memory
43 echo 3 > /proc/sys/vm/drop_caches
44
45 # Write into the second part of the block with 0xbb write from before
46 # will create new empty! buffer because the block is still marked as
47 # delayed even though it's already written - resulting in
48 # overwriting previous data.
49 $XFS_IO_PROG -c "pwrite -S 0xdd 67584 2048" $test_file >> $seqres.full 2>&1
50
51 # On a faulty ext4 oxbb data will be missing, overwritten by zeroes.
52 hexdump -C $test_file
53
54 # success, all done
55 status=0
56 exit