xfs/{263,106}: erase max warnings printout
[xfstests-dev.git] / tests / generic / 030
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/030
6 #
7 # Test mapped writes against remap+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 _supported_os Linux
35 _require_scratch
36 _require_xfs_io_command "mremap"
37
38 testfile=$SCRATCH_MNT/testfile
39
40 _scratch_mkfs > /dev/null 2>&1
41 _scratch_mount
42
43 # first case is just truncate down/truncate up to check that the mapped
44 # write after the truncate up is correctly handled.
45 $XFS_IO_PROG -t -f \
46 -c "truncate 5017k"             `# truncate     |       |` \
47 -c "pwrite -S 0x58 0 5017k"     `# write        |X...XXX|` \
48 -c "mmap -rw 0 5017k"           `# mmap         |       |` \
49 -c "truncate 5020k"             `# truncate up  |                        |` \
50 -c "mremap -m 5020k"            `# mremap up    |                        |` \
51 -c "mwrite -S 0x57 5017k 3k"    `# mwrite       |        WWWWWWWWWWWWWWWW|` \
52 -c "mremap 5017k "              `# mremap dn    |       |` \
53 -c "truncate 5017k"             `# mremap dn    |       |` \
54 -c "truncate 5020k"             `# truncate up  |                        |` \
55 -c "mremap -m 5020k"            `# mremap up    |                        |` \
56 -c "mwrite -S 0x59 5017k 3k"    `# mwrite       |        YYYYYYYYYYYYYYYY|` \
57 -c "close"      \
58 $testfile | _filter_xfs_io
59
60 echo "==== Pre-Remount ==="
61 hexdump -C $testfile
62 _scratch_cycle_mount
63 echo "==== Post-Remount =="
64 hexdump -C $testfile
65
66 rm -f $testfile
67 sync
68
69 # second case is to do a mwrite between the truncate to a block on the
70 # same page we are truncating within the EOF. This checks that a mapped
71 # write between truncate down and truncate up a further mapped
72 # write to the same page into the new space doesn't result in data being lost.
73 $XFS_IO_PROG -t -f \
74 -c "truncate 5017k"             `# truncate     |       |` \
75 -c "pwrite -S 0x58 0 5017k"     `# write        |X...XXX|` \
76 -c "mmap -rw 0 5017k"           `# mmap         |       |` \
77 -c "truncate 5020k"             `# truncate up  |                        |` \
78 -c "mremap -m 5020k"            `# mremap up    |                        |` \
79 -c "mwrite -S 0x57 5017k 3k"    `# mwrite       |        WWWWWWWWWWWWWWWW|` \
80 -c "mremap 5017k "              `# mremap dn    |       |` \
81 -c "truncate 5017k"             `# mremap dn    |       |` \
82 -c "mwrite -S 0x5a 5016k 1k"    `# mwrite       |    ZZZ                 |` \
83 -c "truncate 5020k"             `# truncate up  |                        |` \
84 -c "mremap -m 5020k"            `# mremap up    |                        |` \
85 -c "mwrite -S 0x59 5017k 3k"    `# mwrite       |        YYYYYYYYYYYYYYYY|` \
86 -c "close"      \
87 $testfile | _filter_xfs_io
88
89 echo "==== Pre-Remount ==="
90 hexdump -C $testfile
91 _scratch_cycle_mount
92 echo "==== Post-Remount =="
93 hexdump -C $testfile
94
95 # third case is the same as the first, but this time on unaligned byte
96 # boundaries rather than block boundaries. This mimics the exact mmap write
97 # patterns of the application that exposed the bug in the first place, and
98 # so is somewhat more complex and has repeated operations in it. 
99 $XFS_IO_PROG -t -f \
100 -c "truncate 5136912" \
101 -c "pwrite -S 0x58 0 5136912" \
102 -c "mmap -rw 0 5136912" \
103 -c "mremap 5136912" \
104 -c "truncate 5136912" \
105 -c "truncate 5139720" \
106 -c "mremap -m 5139720" \
107 -c "mwrite -S 0 5136912 2808" \
108 -c "mwrite -S 0 5136912 2808" \
109 -c "mwrite -S 0 5136912 2808" \
110 -c "mremap 5136912 " \
111 -c "truncate 5136912" \
112 -c "truncate 5139720" \
113 -c "mremap -m 5139720" \
114 -c "mwrite -S 0 5136912 2808" \
115 -c "mwrite -S 0 5136912 2808" \
116 -c "mwrite -S 0x59 5136912 2808" \
117 -c "truncate 5140480" \
118 -c "mremap 5140480" \
119 -c "msync -s 0 5140480" \
120 -c "mremap 5139720" \
121 -c "munmap" \
122 -c "close" \
123 $testfile | _filter_xfs_io
124
125 echo "==== Pre-Remount ==="
126 hexdump -C $testfile
127 _scratch_cycle_mount
128 echo "==== Post-Remount =="
129 hexdump -C $testfile
130
131 status=0
132 exit
133