4 # Exercise IO at large file offsets.
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
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.
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.
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.
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.
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA 94043, or:
33 # For further information regarding this notice, see:
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
42 echo "QA output created by $seq"
47 status=1 # failure is the default!
52 umount $SCRATCH_DEV 2>/dev/null
54 trap "_cleanup; exit \$status" 0 1 2 3 15
56 # get standard environment, filters and checks
62 sed -e "s/$dbsize/1FSB/g" -e '/.* ops; /d'
67 sed -e "s/$1/<OFFSET>/g" | _filter_io
78 [ `$direct` ] && flags=-d
80 echo "Writing $bytes bytes, offset is $words (direct=$direct)" | _filter_io
81 echo "Writing $bytes bytes at $location $words (direct=$direct)" >>$seq.full
82 xfs_io -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq \
83 2>&1 | _filter_off $offset | tee -a $seq.full
84 xfs_bmap -v $SCRATCH_MNT/$seq >>$seq.full
86 echo "Reading $bytes bytes (direct=$direct)" | _filter_io
87 echo "Reading $bytes bytes at $location (direct=$direct)" >>$seq.full
88 xfs_io -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq \
89 2>&1 | _filter_off $offset | tee -a $seq.full
91 xfs_io -c "pread -v $offset $bytes" $flags $SCRATCH_MNT/$seq >>$seq.full
93 echo | tee -a $seq.full
96 # real QA test starts here
98 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
103 # Okay... filesize limit depends on blocksize, bits per long and
104 # also if large block device patch is enabled (can't dynamically
105 # check that, so use env var USE_LBD_PATCH to override default).
108 # We check from 1Tb below our guessed limit to 1Tb above it, and
109 # see what happens for each 1Tb increment along the way (first
110 # half should succeed, second half should fail to create a file).
111 # So, number calculated here is not the actual limit, its a ways
112 # above that, hopefully.
114 bitsperlong=`src/feature -w`
115 if [ "$bitsperlong" -eq 32 ]; then
116 upperbound=`expr $dbsize / 512`
117 # which is 8(TB) for 4K, 4(TB) for 2k, ... etc.
118 [ "$USE_LBD_PATCH" = yes ] && upperbound=16
119 # limited by page cache index when LBD patch onboard.
121 upperbound=`echo 8 \* 1024 \* 1024 | bc`
122 # 8 exabytes (working in TBs below)
125 # Step from (upperbound-1)(Tb) through (upperbound+1(Tb), &
126 # seeks/writes/reads on each boundary (using holey files) -
127 # 1byte back from the boundary, and 1FSB back from the same
128 # boundary (and stash xfs_bmap output), before moving onto
129 # each new test point.
131 xfs_io -c "truncate 0" -f $SCRATCH_MNT/$seq
133 oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
134 count=`expr $upperbound - 1`
135 upperbound=`expr $upperbound + 1`
137 while [ $count -le $upperbound ]
140 offset=`echo $oneTB \* $count | bc`
141 write_block $count "+0" $offset 512 false
142 offset=`echo $oneTB \* $count \- 1 | bc`
143 write_block $count "minus 1 byte" $offset 512 false
144 offset=`echo $oneTB \* $count \- $dbsize | bc`
145 write_block $count "minus 1FSB" $offset 512 false
146 write_block $count "minus 1FSB" $offset 1 false
149 offset=`echo $oneTB \* $count | bc`
150 write_block $count "+0" $offset $dbsize true
151 offset=`echo $oneTB \* $count \- 1 | bc`
152 write_block $count "minus 1FSB" $offset $dbsize true
154 echo === Iterating, `expr $upperbound - $count` remains
157 count=`expr $count + 1`