5 # test end of log overwrite bug #796141
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or modify it
11 # under the terms of version 2 of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 # Further, this software is distributed without any warranty that it is
19 # free of the rightful claim of any third person regarding infringement
20 # or the like. Any license provided herein, whether implied or
21 # otherwise, applies only to this software file. Patent licenses, if
22 # any, provided herein do not apply to combinations of this program with
23 # other software, or any other product whatsoever.
25 # You should have received a copy of the GNU General Public License along
26 # with this program; if not, write the Free Software Foundation, Inc., 59
27 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
29 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
30 # Mountain View, CA 94043, or:
34 # For further information regarding this notice, see:
36 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
37 #-----------------------------------------------------------------------
45 # create a new FS, mostly fill the log. Then wrap the log back to the
46 # start bit by bit to force wiping of stale blocks near the end of the
47 # log. Check the block after the log ends to check for corruption
50 # - given we're only touching a single inode, the block after the
51 # log which is in the middle ag should never be touched.
52 # if it changes, we assume the log is writing over it
56 echo "QA output created by $seq"
62 trap "_cleanup; exit \$status" 0 1 2 3 15
68 umount $SCRATCH_MNT 2>/dev/null
73 sed -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g'
78 echo "*** reset partition"
79 $here/src/devzero -b 2048 -n 50 -v 198 $SCRATCH_DEV
83 echo mkfs_xfs -dsize=$dsize -lsize=$lsize $SCRATCH_DEV >>$seq.full
84 if ! mkfs_xfs -dsize=$dsize -lsize=$lsize $SCRATCH_DEV >>$seq.full 2>&1
86 echo "failed to mkfs $SCRATCH_DEV" >>$seq.full
87 _notrun "mkfs cannot create scratch fs, probably too small log"
95 echo "*** generate log traffic"
97 out=$SCRATCH_MNT/$$.tmp
100 if ! mount -t xfs $SCRATCH_DEV $SCRATCH_MNT
102 echo "failed to mount $SCRATCH_DEV"
106 # having any quota enabled (acct/enfd) means extra log traffic - evil!
107 $here/src/feature -U $SCRATCH_DEV && \
108 _notrun "Quota are enabled, test needs controlled log traffic"
109 $here/src/feature -G $SCRATCH_DEV && \
110 _notrun "Quota are enabled, test needs controlled log traffic"
113 while [ $count -ge 0 ]
117 let "count = count - 1"
121 if ! umount $SCRATCH_DEV
123 echo "failed to unmount $SCRATCH_DEV"
130 xfs_logprint -tb $SCRATCH_DEV | $AWK_PROG '
131 /log device/ { print $7}
137 xfs_logprint -tb $SCRATCH_DEV | $AWK_PROG '
142 # Get log stripe unit for v2 logs; if none specified,
143 # (or v1 log) just return "1"
147 echo $MKFS_OPTIONS | (grep sunit || echo "sunit=1") \
148 | sed "s/.*sunit=\(.*\).*/\1/"
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"
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"