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
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
81 force_opts="-dsize=50m -lsize=2097152"
82 echo mkfs_xfs $force_opts $SCRATCH_DEV >>$seq.full
83 _scratch_mkfs_xfs $force_opts >$tmp.mkfs0 2>&1
85 _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
86 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
93 echo "*** generate log traffic"
95 out=$SCRATCH_MNT/$$.tmp
100 echo "failed to mount $SCRATCH_DEV"
104 # having any quota enabled (acct/enfd) means extra log traffic - evil!
105 $here/src/feature -U $SCRATCH_DEV && \
106 _notrun "Quota are enabled, test needs controlled log traffic"
107 $here/src/feature -G $SCRATCH_DEV && \
108 _notrun "Quota are enabled, test needs controlled log traffic"
111 while [ $count -ge 0 ]
115 let "count = count - 1"
119 if ! umount $SCRATCH_DEV
121 echo "failed to unmount $SCRATCH_DEV"
128 _scratch_xfs_logprint -tb | $AWK_PROG '
129 /log file: / || /log device: / { print $7}
135 _scratch_xfs_logprint -tb | $AWK_PROG '
140 # Get log stripe unit for v2 logs; if none specified,
141 # (or v1 log) just return "1" block
145 if [ ${lsunit:-0} -eq 0 ]; then
148 expr $lsunit \* $dbsize
154 xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
155 /logstart/ { logstart = $3 }
156 /logblocks/ { logblocks = $3 }
158 print logstart + logblocks
166 echo "*** check for corruption"
167 echo "expect $f..." >>$seq.full
168 xfs_db -r -c "fsblock $2" -c "print" $1 | head | tee -a $seq.full | \
169 grep -q -v "$f $f $f $f $f $f $f $f" && \
170 _fail "!!! block $2 corrupted!"
173 # get standard environment, filters and checks
177 # real QA test starts here
186 block=`_after_log $SCRATCH_DEV`
187 echo "fsblock after log = $block" >>$seq.full
188 _check_corrupt $SCRATCH_DEV $block
191 echo "log size = $size BB" >>$seq.full
193 echo "log position = $head" >>$seq.full
195 echo "log sunit = $lsunit" >>$seq.full
197 [ $size -eq 4096 ] || \
198 _fail "!!! unexpected log size $size"
199 [ $head -eq 2 -o $head -eq $((lsunit/512)) ] || \
200 _fail "!!! unexpected initial log position $head vs. $((lsunit/512))"
202 echo " lots of traffic" >>$seq.full
205 echo "log position = $head" >>$seq.full
207 [ $head -gt 3850 -a $head -lt 4050 ] || \
208 _fail "!!! unexpected log position $head"
210 for c in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
212 echo " little traffic" >>$seq.full
215 echo "log position = $head" >>$seq.full
216 _check_corrupt $SCRATCH_DEV $block
219 [ $head -lt 1000 ] || \
220 _fail "!!! unexpected log position $head"