xfstests: randholes: only allocate write buffer when needed
[xfstests-dev.git] / 165
1 #! /bin/bash
2 # FS QA Test No. 165
3 #
4 # Test out prealloc, direct writes and buffered read
5 # Some experimentation when looking at 
6 #   pv#962014 - DMF 3.7 reading incorrect data 
7 # Doesn't actually reproduce the problem but it tried to :-)
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2007 Silicon Graphics, Inc.  All Rights Reserved.
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 #
27 # creator
28 owner=tes@puffy.melbourne.sgi.com
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "_cleanup; exit \$status" 0 1 2 3 15
37
38 _cleanup()
39 {
40     cd /
41     rm -f $tmp.*
42 }
43
44 #
45 # Filter out these lines partially
46 # From:
47 #   40 KiB, 10 ops; 0.0000 sec (4.070 MiB/sec and 1041.9923 ops/sec)
48 # To:
49 #   40 KiB, 10 ops
50 #
51 _filter_io()
52 {
53     tee -a $seq.full | sed 's/ops;.*/ops/'
54 }
55
56 #
57 # <    1: [8..79]:         6552..6623        0 (6552..6623)        72
58 # >    1: [8..79]:         202544..202615    0 (202544..202615)    72
59 #
60 #
61 _filter_bmap()
62 {
63     awk '$3 ~ /hole/ { print $1, $2, $3; next }
64          {print $1, $2}' >> $seq.full
65 }
66
67 # get standard environment, filters and checks
68 . ./common.rc
69 . ./common.filter
70
71 # real QA test starts here
72
73 # Modify as appropriate.
74 _supported_fs xfs
75 _supported_os IRIX Linux
76
77 # io tests 
78 testfile=$TEST_DIR/file.$seq
79 rm -f $testfile
80 rm -f $seq.full
81 len=4
82 end=`expr 10 \* $len`
83
84 # Other test...
85 #$XFS_IO_PROG -f -c "resvsp ${off}k ${end}k" $testfile
86
87 # write the initial file
88 $XFS_IO_PROG -f -c "pwrite 0  ${end}k" $testfile | _filter_io
89
90
91 off=0
92 while [ $off -le $end ]
93 do
94         offset=${off}k
95         length=${len}k
96
97         $XFS_IO_PROG -c "unresvsp $offset $length" -c "bmap -vp" $testfile | _filter_bmap
98
99         let off=$off+$len # skip over 1
100         let off=$off+$len
101 done
102
103 off=0
104 while [ $off -le $end ]
105 do
106         offset=${off}k
107         length=${len}k
108         bufsize=${len}k
109         echo ""
110         echo "*** offset = $offset ***"
111         echo ""
112
113         # prealloc and write
114         $XFS_IO_PROG -d -c "resvsp $offset $length" -c "pwrite -b $bufsize $offset $length" $testfile | _filter_io
115
116         # Other tests...
117         #$XFS_IO_PROG -c "resvsp $offset $length" $testfile
118         #xfs_bmap -v -p $testfile
119         #$XFS_IO_PROG -d -c "pwrite -b $bufsize $offset $length" $testfile
120         #xfs_bmap -v -p $testfile
121
122         $XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile >$tmp.$off &
123
124         # Other tests...
125         #$XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile
126         #sleep 5
127
128         let off=$off+$len # skip over 1
129         let off=$off+$len
130 done
131
132 wait
133 cat $tmp.* | _filter_io
134
135 # success, all done
136 status=0
137 exit