xfstests: randholes: only allocate write buffer when needed
[xfstests-dev.git] / 201
1 #! /bin/bash
2 # FS QA Test No. 201
3 #
4 # Test out the infamous xfs_btree_delrec corruption.
5 #
6 # Only happens on 32-bit kernels without CONFIG_LBD, but it should be harmless
7 # to run this everywhere.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2009 Christoph Hellwig.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26 # creator
27 owner=hch@lst.de
28
29 seq=`basename $0`
30 echo "QA output created by $seq"
31
32 here=`pwd`
33 tmp=/tmp/$$
34 status=1        # failure is the default!
35
36 do_pwrite()
37 {
38         offset=`expr $1 \* 512`
39         end=`expr $2 \* 512`
40         length=`expr $end - $offset`
41
42         xfs_io -d -f $file -c "pwrite $offset $length" >/dev/null
43 }
44
45
46
47 _cleanup()
48 {
49         umount $SCRATCH_MNT
50 }
51 trap "_cleanup; exit \$status" 0 1 2 3 15
52
53 # get standard environment, filters and checks
54 . ./common.rc
55 . ./common.filter
56
57 # real QA test starts here
58 _supported_fs xfs
59 _supported_os Linux
60
61 file=$SCRATCH_MNT/f
62
63 _require_scratch
64
65 _scratch_mkfs_xfs >/dev/null 2>&1
66 _scratch_mount
67
68 # Create a fragmented file
69 do_pwrite 30792 31039
70 do_pwrite 30320 30791
71 do_pwrite 29688 30319
72 do_pwrite 29536 29687
73 do_pwrite 27216 29535
74 do_pwrite 24368 27215
75 do_pwrite 21616 24367
76 do_pwrite 20608 21615
77 do_pwrite 19680 20607
78 do_pwrite 19232 19679
79 do_pwrite 17840 19231
80 do_pwrite 16928 17839
81 do_pwrite 15168 16927
82 do_pwrite 14048 15167
83 do_pwrite 12152 14047
84 do_pwrite 11344 12151
85 do_pwrite 8792 11343
86 do_pwrite 6456 8791
87 do_pwrite 5000 6455
88 do_pwrite 1728 4999
89 do_pwrite 0 1727
90
91 sync
92 sync
93
94 # and truncate it again
95 > $SCRATCH_MNT/bigfile
96
97 # success, all done
98 echo "*** done"
99 rm -f $seq.full
100 status=0