4 # test end of log overwrite bug #796141
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 #-----------------------------------------------------------------------
44 # create a new FS, mostly fill the log. Then wrap the log back to the
45 # start bit by bit to force wiping of stale blocks near the end of the
46 # log. Check the block after the log ends to check for corruption
49 # - given we're only touching a single inode, the block after the
50 # log which is in the middle ag should never be touched.
51 # if it changes, we assume the log is writing over it
55 echo "QA output created by $seq"
61 trap "_cleanup; exit \$status" 0 1 2 3 15
67 umount $SCRATCH_MNT 2>/dev/null
72 sed -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g'
77 echo "*** reset partition"
78 $here/src/devzero -b 2048 -n 50 -v 198 $SCRATCH_DEV
80 force_opts="-dsize=50m -lsize=2097152"
81 echo mkfs_xfs $force_opts $SCRATCH_DEV >>$seq.full
82 _scratch_mkfs_xfs $force_opts >$tmp.mkfs0 2>&1
84 _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
85 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
92 echo "*** generate log traffic"
94 out=$SCRATCH_MNT/$$.tmp
99 echo "failed to mount $SCRATCH_DEV"
103 # having any quota enabled (acct/enfd) means extra log traffic - evil!
104 $here/src/feature -U $SCRATCH_DEV && \
105 _notrun "Quota are enabled, test needs controlled log traffic"
106 $here/src/feature -G $SCRATCH_DEV && \
107 _notrun "Quota are enabled, test needs controlled log traffic"
110 while [ $count -ge 0 ]
114 let "count = count - 1"
118 if ! umount $SCRATCH_DEV
120 echo "failed to unmount $SCRATCH_DEV"
127 _scratch_xfs_logprint -tb | $AWK_PROG '
128 /log file: / || /log device: / { print $7}
134 _scratch_xfs_logprint -tb | $AWK_PROG '
139 # Get log stripe unit for v2 logs; if none specified,
140 # (or v1 log) just return "1" block
144 if [ ${lsunit:-0} -eq 0 ]; then
147 expr $lsunit \* $dbsize
153 xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
154 /logstart/ { logstart = $3 }
155 /logblocks/ { logblocks = $3 }
157 print logstart + logblocks
165 echo "*** check for corruption"
166 echo "expect $f..." >>$seq.full
167 xfs_db -r $1 -c "fsblock $2" -c "print" | head | tee -a $seq.full | \
168 grep -q -v "$f $f $f $f $f $f $f $f" && \
169 _fail "!!! block $2 corrupted!"
172 # get standard environment, filters and checks
176 # real QA test starts here
183 block=`_after_log $SCRATCH_DEV`
184 echo "fsblock after log = $block" >>$seq.full
185 _check_corrupt $SCRATCH_DEV $block
188 echo "log size = $size BB" >>$seq.full
190 echo "log position = $head" >>$seq.full
192 echo "log sunit = $lsunit" >>$seq.full
194 [ $size -eq 4096 ] || \
195 _fail "!!! unexpected log size $size"
196 [ $head -eq 2 -o $head -eq $((lsunit/512)) ] || \
197 _fail "!!! unexpected initial log position $head vs. $((lsunit/512))"
199 echo " lots of traffic" >>$seq.full
202 echo "log position = $head" >>$seq.full
204 [ $head -gt 3850 -a $head -lt 4050 ] || \
205 _fail "!!! unexpected log position $head"
207 for c in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
209 echo " little traffic" >>$seq.full
212 echo "log position = $head" >>$seq.full
213 _check_corrupt $SCRATCH_DEV $block
216 [ $head -lt 1000 ] || \
217 _fail "!!! unexpected log position $head"