Update QA tests and host configs.
[xfstests-dev.git] / 071
1 #! /bin/sh
2 # FS QA Test No. 071
3 #
4 # Exercise IO at large file offsets.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003 Silicon Graphics, Inc.  All Rights Reserved.
8
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write the Free Software Foundation, Inc., 59
26 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
27
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA  94043, or:
30
31 # http://www.sgi.com 
32
33 # For further information regarding this notice, see: 
34
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
37 #
38 # creator
39 owner=nathans@sgi.com
40
41 seq=`basename $0`
42 echo "QA output created by $seq"
43 rm -f $seq.full
44
45 here=`pwd`
46 tmp=/tmp/$$
47 status=1        # failure is the default!
48
49 _cleanup()
50 {
51     cd /
52     rm -f $tmp.*
53     umount $SCRATCH_DEV 2>/dev/null
54 }
55 trap "_cleanup; exit \$status" 0 1 2 3 15
56
57 # get standard environment, filters and checks
58 . ./common.rc
59 . ./common.filter
60
61 _filter_io()
62 {
63     sed -e "s/$dbsize/1FSB/g" -e '/.* ops; /d'
64 }
65
66 _filter_off()
67 {
68     sed -e "s/$1/<OFFSET>/g" | _filter_io
69 }
70
71 _filter_xfs_io()
72 {
73     sed -e "s/[0-9/.]* bytes, [0-9] ops\; [0-9/.]* sec ([0-9/.]* [MKiBbytes]*\/sec and [0-9/.]* ops\/sec)/XXX bytes, X ops\; XXX sec (X YYY\/sec and XXX ops\/sec/"
74 }
75
76 write_block()
77 {
78     location=$1
79     words=$2
80     offset=$3
81     bytes=$4
82     direct=$5
83
84     [ `$direct` ] && flags=-d
85
86     echo "Writing $bytes bytes, offset is $words (direct=$direct)" | _filter_io
87     echo "Writing $bytes bytes at $location $words (direct=$direct)" >>$seq.full
88     xfs_io -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq \
89         2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
90     xfs_bmap -v $SCRATCH_MNT/$seq >>$seq.full
91
92     echo "Reading $bytes bytes (direct=$direct)" | _filter_io
93     echo "Reading $bytes bytes at $location (direct=$direct)" >>$seq.full
94     xfs_io -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq \
95         2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
96
97     xfs_io -c "pread -v $offset $bytes" $flags $SCRATCH_MNT/$seq >>$seq.full
98
99     echo | tee -a $seq.full
100 }
101
102 # real QA test starts here
103 _supported_fs xfs
104 _supported_os IRIX Linux
105
106 [ -x /usr/sbin/xfs_io ] || _notrun "xfs_io executable not found"
107
108 _require_scratch
109 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
110 . $tmp.mkfs
111 echo
112 _scratch_mount
113
114 # Okay... filesize limit depends on blocksize, bits per long and
115 # also if large block device patch is enabled (can't dynamically
116 # check that, so use env var USE_LBD_PATCH to override default).
117
118 # Note:
119 # We check from 1Tb below our guessed limit to 1Tb above it, and
120 # see what happens for each 1Tb increment along the way (first
121 # half should succeed, second half should fail to create a file).
122 # So, number calculated here is not the actual limit, its a ways
123 # above that, hopefully.
124
125 bitsperlong=`src/feature -w`
126 if [ "$bitsperlong" -eq 32 ]; then
127     upperbound=`expr $dbsize / 512`
128     # which is 8(TB) for 4K, 4(TB) for 2k, ... etc.
129     [ "$USE_LBD_PATCH" = yes ] && upperbound=16
130     # limited by page cache index when LBD patch onboard.
131 else
132     upperbound=`echo 8 \* 1024 \* 1024 | bc` 
133     # 8 exabytes (working in TBs below)
134 fi
135
136 # Step from (upperbound-1)(Tb) through (upperbound+1(Tb), &
137 # seeks/writes/reads on each boundary (using holey files) -
138 # 1byte back from the boundary, and 1FSB back from the same
139 # boundary (and stash xfs_bmap output), before moving onto
140 # each new test point.
141
142 xfs_io -c "truncate 0" -f $SCRATCH_MNT/$seq
143
144 oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
145 count=`expr $upperbound - 1`
146 upperbound=`expr $upperbound + 1`
147
148 while [ $count -le $upperbound ]
149 do
150     # buffered IO
151     offset=`echo $oneTB \* $count | bc`
152     write_block $count "+0" $offset 512 false
153     offset=`echo $oneTB \* $count \- 1 | bc`
154     write_block $count "minus 1 byte" $offset 512 false
155     offset=`echo $oneTB \* $count \- $dbsize | bc`
156     write_block $count "minus 1FSB" $offset 512 false
157     write_block $count "minus 1FSB" $offset 1 false
158
159     # direct IO
160     offset=`echo $oneTB \* $count | bc`
161     write_block $count "+0" $offset $dbsize true
162     offset=`echo $oneTB \* $count \- 1 | bc`
163     write_block $count "minus 1FSB" $offset $dbsize true
164
165     echo === Iterating, `expr $upperbound - $count` remains
166     echo
167     echo
168     count=`expr $count + 1`
169 done
170
171 # success, all done
172 status=0
173 exit