generic/395: remove workarounds for wrong error codes
[xfstests-dev.git] / tests / generic / 029
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. generic/029
6 #
7 # Test mapped writes against truncate down/up to ensure we get the data
8 # correctly written. This can expose data corruption bugs on filesystems where
9 # the block size is smaller than the page size.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31
32 # Modify as appropriate.
33 _supported_fs generic
34 _require_scratch
35
36 testfile=$SCRATCH_MNT/testfile
37
38 _scratch_mkfs > /dev/null 2>&1
39 _scratch_mount
40
41 # first case is just truncate down/truncate up to check that the mapped
42 # write after the truncate up is correctly handled.
43 $XFS_IO_PROG -t -f \
44 -c "truncate 5120"              `# truncate     |                        |` \
45 -c "pwrite -S 0x58 0 5120"      `# write        |XXXXXXXXXXXXXXXXXXXXXXXX|` \
46 -c "mmap -rw 0 5120"            `# mmap         |                        |` \
47 -c "mwrite -S 0x5a 2048 3072"   `# mwrite       |          ZZZZZZZZZZZZZZ|` \
48 -c "truncate 2048"              `# truncate dn  |         |` \
49 -c "truncate 5120"              `# truncate up  |                        |` \
50 -c "mwrite -S 0x59 2048 3072"   `# mwrite       |          YYYYYYYYYYYYYY|` \
51 -c "close"      \
52 $testfile | _filter_xfs_io
53
54 echo "==== Pre-Remount ==="
55 hexdump -C $testfile
56 _scratch_cycle_mount
57 echo "==== Post-Remount =="
58 hexdump -C $testfile
59
60 rm -f $testfile
61 sync
62
63 # second case is to do a mwrite between the truncate to a block on the
64 # same page we are truncating within the EOF. This checks that a mapped
65 # write between truncate down and truncate up a further mapped
66 # write to the same page into the new space doesn't result in data being lost.
67 $XFS_IO_PROG -t -f \
68 -c "truncate 5120"              `# truncate     |                        |` \
69 -c "pwrite -S 0x58 0 5120"      `# write        |XXXXXXXXXXXXXXXXXXXXXXXX|` \
70 -c "mmap -rw 0 5120"            `# mmap         |                        |` \
71 -c "mwrite -S 0x5a 2048 3072"   `# mwrite       |          ZZZZZZZZZZZZZZ|` \
72 -c "truncate 2048"              `# truncate dn  |         |` \
73 -c "mwrite -S 0x57 1024 1024"   `# mwrite       |     WWWWW              |` \
74 -c "truncate 5120"              `# truncate up  |                        |` \
75 -c "mwrite -S 0x59 2048 3072"   `# mwrite       |          YYYYYYYYYYYYYY|` \
76 -c "close"      \
77 $testfile | _filter_xfs_io
78  
79 echo "==== Pre-Remount ==="
80 hexdump -C $testfile
81 _scratch_cycle_mount
82 echo "==== Post-Remount =="
83 hexdump -C $testfile
84
85 # third case is the same as second case, just with non-1k aligned offsets and
86 # sizes.
87 $XFS_IO_PROG -t -f \
88 -c "truncate 5121"              `# truncate     |                        |` \
89 -c "pwrite -S 0x58 0 5121"      `# write        |XXXXXXXXXXXXXXXXXXXXXXXX|` \
90 -c "mmap -rw 0 5121"            `# mmap         |                        |` \
91 -c "mwrite -S 0x5a 2047 3071"   `# mwrite       |          ZZZZZZZZZZZZZZ|` \
92 -c "truncate 2047"              `# truncate dn  |         |` \
93 -c "mwrite -S 0x57 513 1025"    `# mwrite       |  WWWWW                 |` \
94 -c "truncate 5121"              `# truncate up  |                        |` \
95 -c "mwrite -S 0x59 2047 3071"   `# mwrite       |          YYYYYYYYYYYYYY|` \
96 -c "close"      \
97 $testfile | _filter_xfs_io
98  
99 echo "==== Pre-Remount ==="
100 hexdump -C $testfile
101 _scratch_cycle_mount
102 echo "==== Post-Remount =="
103 hexdump -C $testfile
104
105 status=0
106 exit
107