4 # test end of log overwrite bug #796141
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2003 Silicon Graphics, Inc. All Rights Reserved.
8 #-----------------------------------------------------------------------
16 # create a new FS, mostly fill the log. Then wrap the log back to the
17 # start bit by bit to force wiping of stale blocks near the end of the
18 # log. Check the block after the log ends to check for corruption
21 # - given we're only touching a single inode, the block after the
22 # log which is in the middle ag should never be touched.
23 # if it changes, we assume the log is writing over it
27 echo "QA output created by $seq"
33 trap "_cleanup; exit \$status" 0 1 2 3 15
40 umount $SCRATCH_MNT 2>/dev/null
45 sed -e 's/[0-9][0-9]*\.\.[0-9][0-9]*/BLOCKRANGE/g'
50 echo "*** reset partition"
51 $here/src/devzero -b 2048 -n 50 -v 198 $SCRATCH_DEV
53 force_opts="-dsize=50m -lsize=2097152"
54 echo mkfs_xfs $force_opts $SCRATCH_DEV >>$seq.full
55 _scratch_mkfs_xfs $force_opts >$tmp.mkfs0 2>&1
57 _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified"
58 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
65 echo "*** generate log traffic"
67 out=$SCRATCH_MNT/$$.tmp
72 echo "failed to mount $SCRATCH_DEV"
76 # having any quota enabled (acct/enfd) means extra log traffic - evil!
77 $here/src/feature -U $SCRATCH_DEV && \
78 _notrun "Quota are enabled, test needs controlled log traffic"
79 $here/src/feature -G $SCRATCH_DEV && \
80 _notrun "Quota are enabled, test needs controlled log traffic"
83 while [ $count -ge 0 ]
87 let "count = count - 1"
91 if ! umount $SCRATCH_DEV
93 echo "failed to unmount $SCRATCH_DEV"
100 _scratch_xfs_logprint -tb | $AWK_PROG '
101 /log file: / || /log device: / { print $7}
107 _scratch_xfs_logprint -tb | $AWK_PROG '
112 # Get log stripe unit for v2 logs; if none specified,
113 # (or v1 log) just return "1" block
117 if [ ${lsunit:-0} -eq 0 ]; then
120 expr $lsunit \* $dbsize
126 xfs_db -r $1 -c "sb" -c "print" | $AWK_PROG '
127 /logstart/ { logstart = $3 }
128 /logblocks/ { logblocks = $3 }
130 print logstart + logblocks
138 echo "*** check for corruption"
139 echo "expect $f..." >>$seq.full
140 xfs_db -r -c "fsblock $2" -c "print" $1 | head | tee -a $seq.full | \
141 grep -q -v "$f $f $f $f $f $f $f $f" && \
142 _fail "!!! block $2 corrupted!"
145 # get standard environment, filters and checks
149 # real QA test starts here
158 block=`_after_log $SCRATCH_DEV`
159 echo "fsblock after log = $block" >>$seq.full
160 _check_corrupt $SCRATCH_DEV $block
163 echo "log size = $size BB" >>$seq.full
165 echo "log position = $head" >>$seq.full
167 echo "log sunit = $lsunit" >>$seq.full
169 [ $size -eq 4096 ] || \
170 _fail "!!! unexpected log size $size"
171 [ $head -eq 2 -o $head -eq $((lsunit/512)) ] || \
172 _fail "!!! unexpected initial log position $head vs. $((lsunit/512))"
174 echo " lots of traffic" >>$seq.full
177 echo "log position = $head" >>$seq.full
179 [ $head -gt 3850 -a $head -lt 4050 ] || \
180 _fail "!!! unexpected log position $head"
182 for c in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
184 echo " little traffic" >>$seq.full
187 echo "log position = $head" >>$seq.full
188 _check_corrupt $SCRATCH_DEV $block
191 [ $head -lt 1000 ] || \
192 _fail "!!! unexpected log position $head"