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