2 # FS QA Test No. generic/029
4 # Test mapped writes against truncate down/up to ensure we get the data
5 # correctly written. This can expose data corruption bugs on filesystems where
6 # the block size is smaller than the page size.
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
45 # real QA test starts here
47 # Modify as appropriate.
49 _supported_os IRIX Linux
52 testfile=$SCRATCH_MNT/testfile
54 _scratch_mkfs > /dev/null 2>&1
57 # first case is just truncate down/truncate up to check that the mapped
58 # write after the truncate up is correctly handled.
60 -c "truncate 5120" `# truncate | |` \
61 -c "pwrite -S 0x58 0 5120" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
62 -c "mmap -rw 0 5120" `# mmap | |` \
63 -c "mwrite -S 0x5a 2048 3072" `# mwrite | ZZZZZZZZZZZZZZ|` \
64 -c "truncate 2048" `# truncate dn | |` \
65 -c "truncate 5120" `# truncate up | |` \
66 -c "mwrite -S 0x59 2048 3072" `# mwrite | YYYYYYYYYYYYYY|` \
68 $testfile | _filter_xfs_io
70 echo "==== Pre-Remount ==="
73 echo "==== Post-Remount =="
79 # second case is to do a mwrite between the truncate to a block on the
80 # same page we are truncating within the EOF. This checks that a mapped
81 # write between truncate down and truncate up a further mapped
82 # write to the same page into the new space doesn't result in data being lost.
84 -c "truncate 5120" `# truncate | |` \
85 -c "pwrite -S 0x58 0 5120" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
86 -c "mmap -rw 0 5120" `# mmap | |` \
87 -c "mwrite -S 0x5a 2048 3072" `# mwrite | ZZZZZZZZZZZZZZ|` \
88 -c "truncate 2048" `# truncate dn | |` \
89 -c "mwrite -S 0x57 1024 1024" `# mwrite | WWWWW |` \
90 -c "truncate 5120" `# truncate up | |` \
91 -c "mwrite -S 0x59 2048 3072" `# mwrite | YYYYYYYYYYYYYY|` \
93 $testfile | _filter_xfs_io
95 echo "==== Pre-Remount ==="
98 echo "==== Post-Remount =="
101 # third case is the same as second case, just with non-1k aligned offsets and
104 -c "truncate 5121" `# truncate | |` \
105 -c "pwrite -S 0x58 0 5121" `# write |XXXXXXXXXXXXXXXXXXXXXXXX|` \
106 -c "mmap -rw 0 5121" `# mmap | |` \
107 -c "mwrite -S 0x5a 2047 3071" `# mwrite | ZZZZZZZZZZZZZZ|` \
108 -c "truncate 2047" `# truncate dn | |` \
109 -c "mwrite -S 0x57 513 1025" `# mwrite | WWWWW |` \
110 -c "truncate 5121" `# truncate up | |` \
111 -c "mwrite -S 0x59 2047 3071" `# mwrite | YYYYYYYYYYYYYY|` \
113 $testfile | _filter_xfs_io
115 echo "==== Pre-Remount ==="
118 echo "==== Post-Remount =="