4 # Exercise IO at large file offsets.
5 #-----------------------------------------------------------------------
6 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it would be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write the Free Software Foundation,
19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
27 echo "QA output created by $seq"
32 status=1 # failure is the default!
38 umount $SCRATCH_DEV 2>/dev/null
40 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
48 sed -e "s/$dbsize/1FSB/g" -e '/.* ops; /d'
53 sed -e "s/$1/<OFFSET>/g" | _filter_io
58 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/"
69 [ `$direct` ] && flags=-d
71 echo "Writing $bytes bytes, offset is $words (direct=$direct)" | _filter_io
72 echo "Writing $bytes bytes at $location $words (direct=$direct)" >>$seq.full
73 $XFS_IO_PROG -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq \
74 2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
75 xfs_bmap -v $SCRATCH_MNT/$seq >>$seq.full
77 echo "Reading $bytes bytes (direct=$direct)" | _filter_io
78 echo "Reading $bytes bytes at $location (direct=$direct)" >>$seq.full
79 $XFS_IO_PROG -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq \
80 2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
82 $XFS_IO_PROG -c "pread -v $offset $bytes" $flags $SCRATCH_MNT/$seq >>$seq.full
84 echo | tee -a $seq.full
87 # real QA test starts here
89 _supported_os IRIX Linux
91 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
94 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
99 # Okay... filesize limit depends on blocksize, bits per long and
100 # also if large block device patch is enabled (can't dynamically
101 # check that, so use env var USE_LBD_PATCH to override default).
104 # We check from 1Tb below our guessed limit to 1Tb above it, and
105 # see what happens for each 1Tb increment along the way (first
106 # half should succeed, second half should fail to create a file).
107 # So, number calculated here is not the actual limit, its a ways
108 # above that, hopefully.
110 bitsperlong=`src/feature -w`
111 if [ "$bitsperlong" -eq 32 ]; then
112 upperbound=`expr $dbsize / 512`
113 # which is 8(TB) for 4K, 4(TB) for 2k, ... etc.
114 [ "$USE_LBD_PATCH" = yes ] && upperbound=16
115 # limited by page cache index when LBD patch onboard.
117 upperbound=`echo 8 \* 1024 \* 1024 | bc`
118 # 8 exabytes (working in TBs below)
121 # Step from (upperbound-1)(Tb) through (upperbound+1(Tb), &
122 # seeks/writes/reads on each boundary (using holey files) -
123 # 1byte back from the boundary, and 1FSB back from the same
124 # boundary (and stash xfs_bmap output), before moving onto
125 # each new test point.
127 $XFS_IO_PROG -c "truncate 0" -f $SCRATCH_MNT/$seq
129 oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
130 count=`expr $upperbound - 1`
131 upperbound=`expr $upperbound + 1`
133 while [ $count -le $upperbound ]
136 offset=`echo $oneTB \* $count | bc`
137 write_block $count "+0" $offset 512 false
138 offset=`echo $oneTB \* $count \- 1 | bc`
139 write_block $count "minus 1 byte" $offset 512 false
140 offset=`echo $oneTB \* $count \- $dbsize | bc`
141 write_block $count "minus 1FSB" $offset 512 false
142 write_block $count "minus 1FSB" $offset 1 false
145 offset=`echo $oneTB \* $count | bc`
146 write_block $count "+0" $offset $dbsize true
147 offset=`echo $oneTB \* $count \- 1 | bc`
148 write_block $count "minus 1FSB" $offset $dbsize true
150 echo === Iterating, `expr $upperbound - $count` remains