use _filter_repair when running xfs_repair. This stops timestamp mismatches from...
[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 #
10 # creator
11 owner=nathans@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15 rm -f $seq.full
16
17 here=`pwd`
18 tmp=/tmp/$$
19 status=1        # failure is the default!
20
21 _cleanup()
22 {
23     cd /
24     rm -f $tmp.*
25     umount $SCRATCH_DEV 2>/dev/null
26 }
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 # get standard environment, filters and checks
30 . ./common.rc
31 . ./common.filter
32
33 _filter_io()
34 {
35     sed -e "s/$dbsize/1FSB/g" -e '/.* ops; /d'
36 }
37
38 _filter_off()
39 {
40     sed -e "s/$1/<OFFSET>/g" | _filter_io
41 }
42
43 _filter_xfs_io()
44 {
45     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/"
46 }
47
48 write_block()
49 {
50     location=$1
51     words=$2
52     offset=$3
53     bytes=$4
54     direct=$5
55
56     [ `$direct` ] && flags=-d
57
58     echo "Writing $bytes bytes, offset is $words (direct=$direct)" | _filter_io
59     echo "Writing $bytes bytes at $location $words (direct=$direct)" >>$seq.full
60     $XFS_IO_PROG -c "pwrite $offset 512" $flags $SCRATCH_MNT/$seq \
61         2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
62     xfs_bmap -v $SCRATCH_MNT/$seq >>$seq.full
63
64     echo "Reading $bytes bytes (direct=$direct)" | _filter_io
65     echo "Reading $bytes bytes at $location (direct=$direct)" >>$seq.full
66     $XFS_IO_PROG -c "pread $offset $bytes" $flags $SCRATCH_MNT/$seq \
67         2>&1 | _filter_off $offset | _filter_xfs_io | tee -a $seq.full
68
69     $XFS_IO_PROG -c "pread -v $offset $bytes" $flags $SCRATCH_MNT/$seq >>$seq.full
70
71     echo | tee -a $seq.full
72 }
73
74 # real QA test starts here
75 _supported_fs xfs
76 _supported_os IRIX Linux
77
78 [ -n "$XFS_IO_PROG" ] || _notrun "xfs_io executable not found"
79
80 _require_scratch
81 _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
82 . $tmp.mkfs
83 echo
84 _scratch_mount
85
86 # Okay... filesize limit depends on blocksize, bits per long and
87 # also if large block device patch is enabled (can't dynamically
88 # check that, so use env var USE_LBD_PATCH to override default).
89
90 # Note:
91 # We check from 1Tb below our guessed limit to 1Tb above it, and
92 # see what happens for each 1Tb increment along the way (first
93 # half should succeed, second half should fail to create a file).
94 # So, number calculated here is not the actual limit, its a ways
95 # above that, hopefully.
96
97 bitsperlong=`src/feature -w`
98 if [ "$bitsperlong" -eq 32 ]; then
99     upperbound=`expr $dbsize / 512`
100     # which is 8(TB) for 4K, 4(TB) for 2k, ... etc.
101     [ "$USE_LBD_PATCH" = yes ] && upperbound=16
102     # limited by page cache index when LBD patch onboard.
103 else
104     upperbound=`echo 8 \* 1024 \* 1024 | bc` 
105     # 8 exabytes (working in TBs below)
106 fi
107
108 # Step from (upperbound-1)(Tb) through (upperbound+1(Tb), &
109 # seeks/writes/reads on each boundary (using holey files) -
110 # 1byte back from the boundary, and 1FSB back from the same
111 # boundary (and stash xfs_bmap output), before moving onto
112 # each new test point.
113
114 $XFS_IO_PROG -c "truncate 0" -f $SCRATCH_MNT/$seq
115
116 oneTB=`echo 1024 \* 1024 \* 1024 \* 1024 | bc`
117 count=`expr $upperbound - 1`
118 upperbound=`expr $upperbound + 1`
119
120 while [ $count -le $upperbound ]
121 do
122     # buffered IO
123     offset=`echo $oneTB \* $count | bc`
124     write_block $count "+0" $offset 512 false
125     offset=`echo $oneTB \* $count \- 1 | bc`
126     write_block $count "minus 1 byte" $offset 512 false
127     offset=`echo $oneTB \* $count \- $dbsize | bc`
128     write_block $count "minus 1FSB" $offset 512 false
129     write_block $count "minus 1FSB" $offset 1 false
130
131     # direct IO
132     offset=`echo $oneTB \* $count | bc`
133     write_block $count "+0" $offset $dbsize true
134     offset=`echo $oneTB \* $count \- 1 | bc`
135     write_block $count "minus 1FSB" $offset $dbsize true
136
137     echo === Iterating, `expr $upperbound - $count` remains
138     echo
139     echo
140     count=`expr $count + 1`
141 done
142
143 # success, all done
144 status=0
145 exit