fstests: use _require_symlinks on all necessary tests
[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 seq=`basename $0`
17 seqres=$RESULT_DIR/$seq
18 echo "QA output created by $seq"
19
20 here=`pwd`
21 tmp=/tmp/$$
22 status=1        # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # real QA test starts here
36
37 # Modify as appropriate.
38 _supported_fs generic
39 _supported_os Linux
40 _require_test
41 _require_xfs_io_command "falloc"
42
43 test_file=${TEST_DIR}/testfile-$seq
44
45 rm -f $test_file
46
47 # The first write creates a delayed extent, fallocate creates
48 # unwritten extent which will be marked as delayed in ext4
49 # extent status tree. Second write will convert unwritten/delayed
50 # block into written/delayed.
51 $XFS_IO_PROG -f -c "pwrite -S 0xaa 4096 2048" \
52                 -c "falloc 0 131072" \
53                 -c "pwrite -S 0xbb 65536 2048" \
54                 -c "fsync"  $test_file > $seqres.full 2>&1
55
56 # Drop the caches to evict dirty buffers from memory
57 echo 3 > /proc/sys/vm/drop_caches
58
59 # Write into the second part of the block with 0xbb write from before
60 # will create new empty! buffer because the block is still marked as
61 # delayed even though it's already written - resulting in
62 # overwriting previous data.
63 $XFS_IO_PROG -c "pwrite -S 0xdd 67584 2048" $test_file >> $seqres.full 2>&1
64
65 # On a faulty ext4 oxbb data will be missing, overwritten by zeroes.
66 hexdump -C $test_file
67
68 # success, all done
69 status=0
70 exit