679b1774d7d0343351dbb0dd40ea7ee350185048
[xfstests-dev.git] / tests / xfs / 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
28 seq=`basename $0`
29 seqres=$RESULT_DIR/$seq
30 seqres=$RESULT_DIR/$seq
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=1        # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
38
39 _cleanup()
40 {
41     cd /
42     rm -f $tmp.*
43 }
44
45 _filter_io()
46 {
47     tee -a $seqres.full | _filter_xfs_io
48 }
49
50 #
51 # <    1: [8..79]:         6552..6623        0 (6552..6623)        72
52 # >    1: [8..79]:         202544..202615    0 (202544..202615)    72
53 #
54 #
55 _filter_bmap()
56 {
57     awk '$3 ~ /hole/ { print $1, $2, $3; next }
58          {print $1, $2}' >> $seqres.full
59 }
60
61 # get standard environment, filters and checks
62 . ./common/rc
63 . ./common/filter
64
65 # real QA test starts here
66
67 # Modify as appropriate.
68 _supported_fs xfs
69 _supported_os IRIX Linux
70
71 # io tests 
72 testfile=$TEST_DIR/file.$seq
73 rm -f $testfile
74 rm -f $seqres.full
75 len=4
76 end=`expr 10 \* $len`
77
78 # Other test...
79 #$XFS_IO_PROG -f -c "resvsp ${off}k ${end}k" $testfile
80
81 # write the initial file
82 $XFS_IO_PROG -f -c "pwrite 0  ${end}k" $testfile | _filter_io
83
84
85 off=0
86 while [ $off -le $end ]
87 do
88         offset=${off}k
89         length=${len}k
90
91         $XFS_IO_PROG -c "unresvsp $offset $length" -c "bmap -vp" $testfile | _filter_bmap
92
93         let off=$off+$len # skip over 1
94         let off=$off+$len
95 done
96
97 off=0
98 while [ $off -le $end ]
99 do
100         offset=${off}k
101         length=${len}k
102         bufsize=${len}k
103         echo ""
104         echo "*** offset = $offset ***"
105         echo ""
106
107         # prealloc and write
108         $XFS_IO_PROG -d -c "resvsp $offset $length" -c "pwrite -b $bufsize $offset $length" $testfile | _filter_io
109
110         # Other tests...
111         #$XFS_IO_PROG -c "resvsp $offset $length" $testfile
112         #xfs_bmap -v -p $testfile
113         #$XFS_IO_PROG -d -c "pwrite -b $bufsize $offset $length" $testfile
114         #xfs_bmap -v -p $testfile
115
116         $XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile >$tmp.$off &
117
118         # Other tests...
119         #$XFS_IO_PROG -r -c "pread -v -b $bufsize $offset $length" $testfile
120         #sleep 5
121
122         let off=$off+$len # skip over 1
123         let off=$off+$len
124 done
125
126 wait
127 cat $tmp.* | _filter_io
128
129 # success, all done
130 status=0
131 exit