#! /bin/sh
# XFS QA Test No. 071
-# $Id: 071,v 1.1 2003/07/07 03:34:36 fsgqa Exp $
#
-# Exercise IO at large file offsets (just terabytes for now).
+# Exercise IO at large file offsets.
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
. ./common.rc
. ./common.filter
+_filter_io()
+{
+ sed -e "s/$dbsize/1FSB/g"
+}
+
+_filter_off()
+{
+ sed -e "s/$1/<OFFSET>/g" | _filter_io
+}
+
write_block()
{
location=$1
- offset=$2
- bytes=$3
- direct=$4
+ words=$2
+ offset=$3
+ bytes=$4
+ direct=$5
[ `$direct` ] && flags=-d
- echo "Writing $bytes bytes at $location (direct=$direct)" | tee -a $seq.full
- xfs_io -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq
-
- echo "Saving block map to $seq.full" | tee -a $seq.full
+ echo "Writing $bytes bytes, offset is $words (direct=$direct)" | _filter_io
+ echo "Writing $bytes bytes at $location $words (direct=$direct)" >>$seq.full
+ xfs_io -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq \
+ 2>&1 | _filter_off $offset | tee -a $seq.full
xfs_bmap -v $SCRATCH_MNT/$seq >>$seq.full
- echo "Reading $bytes bytes at $location (direct=$direct)" | tee -a $seq.full
- xfs_io -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq
+ echo "Reading $bytes bytes (direct=$direct)" | _filter_io
+ echo "Reading $bytes bytes at $location (direct=$direct)" >>$seq.full
+ xfs_io -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq \
+ 2>&1 | _filter_off $offset | tee -a $seq.full
+
xfs_io -c "pread -v $offset $bytes" $flags $SCRATCH_MNT/$seq >>$seq.full
echo | tee -a $seq.full
echo
_scratch_mount
-oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
-
-# Step from 1Tb through 16Tb, doing seek/writes/reads on each
-# boundary (using holey files), 1byte back from the boundary,
-# and 1FSB back from the boundary (and xfs_bmaps all the way).
+# Okay... filesize limit depends on blocksize, bits per long and
+# also if large block device patch is enabled (can't dynamically
+# check that, so use env var USE_LBD_PATCH to override default).
+#
+# Note:
+# We check from 1Tb below our guessed limit to 1Tb above it, and
+# see what happens for each 1Tb increment along the way (first
+# half should succeed, second half should fail to create a file).
+# So, number calculated here is not the actual limit, its a ways
+# above that, hopefully.
+
+bitsperlong=`src/feature -w`
+if [ "$bitsperlong" -eq 32 ]; then
+ upperbound=`expr $dbsize / 512`
+ # which is 8(TB) for 4K, 4(TB) for 2k, ... etc.
+ [ "$USE_LBD_PATCH" = yes ] && upperbound=16
+ # limited by page cache index when LBD patch onboard.
+else
+ upperbound=`echo 16 \* 1024 \* 1024 | bc`
+ # 16 exabytes (working in TBs below)
+fi
+
+# Step from (upperbound-1)(Tb) through (upperbound+1(Tb), &
+# seeks/writes/reads on each boundary (using holey files) -
+# 1byte back from the boundary, and 1FSB back from the same
+# boundary (and stash xfs_bmap output), before moving onto
+# each new test point.
xfs_io -c "truncate 0" -f $SCRATCH_MNT/$seq
-count=1
-while [ $count -le 16 ]
+oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
+count=`expr $upperbound - 1`
+upperbound=`expr $upperbound + 1`
+
+while [ $count -le $upperbound ]
do
# buffered IO
offset=`echo $oneTB \* $count | bc`
- write_block "$count Tb" $offset 512 false
+ write_block $count "+0" $offset 512 false
offset=`echo $oneTB \* $count \- 1 | bc`
- write_block "$count Tb minus 1 byte" $offset 512 false
+ write_block $count "minus 1 byte" $offset 512 false
offset=`echo $oneTB \* $count \- $dbsize | bc`
- write_block "$count Tb minus 1 FSB" $offset 512 false
+ write_block $count "minus 1FSB" $offset 512 false
+ write_block $count "minus 1FSB" $offset 1 false
# direct IO
offset=`echo $oneTB \* $count | bc`
- write_block "$count Tb" $offset $dbsize true
+ write_block $count "+0" $offset $dbsize true
offset=`echo $oneTB \* $count \- 1 | bc`
- write_block "$count Tb minus 1 FSB" $offset $dbsize true
+ write_block $count "minus 1FSB" $offset $dbsize true
+ echo === Iterating, `expr $upperbound - $count` remains
+ echo
+ echo
count=`expr $count + 1`
done