4 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of version 2 of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 # Further, this software is distributed without any warranty that it is
15 # free of the rightful claim of any third person regarding infringement
16 # or the like. Any license provided herein, whether implied or
17 # otherwise, applies only to this software file. Patent licenses, if
18 # any, provided herein do not apply to combinations of this program with
19 # other software, or any other product whatsoever.
21 # You should have received a copy of the GNU General Public License along
22 # with this program; if not, write the Free Software Foundation, Inc., 59
23 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
25 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
26 # Mountain View, CA 94043, or:
30 # For further information regarding this notice, see:
32 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 # common routines for log testing
37 # Created by dxm@sgi.com & tes@sgi.com
45 if [ $status -eq 0 ]; then
46 # don't keep these files around unless something went wrong
54 echo "*** $* ***" >>$seq.full
60 echo "" | tee -a $seq.full
61 echo "*** $* ***" | tee -a $seq.full
62 echo "" | tee -a $seq.full
65 # Handle the operations which get split over Log Record
67 # Oper (379)..... flags: CONTINUE
69 # Oper (0)....... flags: WAS_CONT END
73 # Oper (379)..... flags: none
75 # Oper (0)....... flags: none
84 printf "line = %s\n", $0
89 /^Oper/ && /flags: CONTINUE/ {
90 # this will be the first op of split region
91 $9 = "none" # overwrite CONTINUE flags
93 print "Not printing rest"
97 /^Oper/ && /flags: WAS_CONT END/ {
98 # this will be the last op of split region
99 # skip over was-continued op
100 # we assume there can be only 1
105 # skip over any continued op stuff
113 # Filter out things that can change
114 # We have complexities which change when log is sync'ed at different
116 # Example1: DATA FORK EXTENTS
117 # These will not show up if inode is sync'ed sooner
118 # /DATA FORK EXTENTS/d;
119 # /INODE:/s/flags:0x5/flags:0x1/g;
120 # define XFS_ILOG_CORE 0x001 /* log standard inode fields */
121 # define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
129 s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
130 s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
131 s/log file: \".*\"/log device: <DEVICE>/;
132 s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
133 s/length: [0-9][0-9]*/length: <LENGTH>/;
134 s/length: [0-9][0-9]*/length: <LENGTH>/;
135 s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
136 s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
137 s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
138 s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
139 s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
140 s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
141 s/blkno: [0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
142 s/blkno: [0-9][0-9]*/blkno: <BLKNO>/g;
143 s/boff: [0-9][0-9]*/boff: <BOFF>/g;
144 s/len: *[0-9][0-9]*/len:<LEN>/g;
145 /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
147 /log tail/s/[0-9][0-9]*/<COUNT>/g;
148 s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
149 s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
150 s/block [0-9][0-9]*/block <BLOCK>/;
151 s/icount: *[0-9][0-9]* *ifree: *[0-9][0-9]* *fdblks: *[0-9][0-9]* *frext: *[0-9][0-9]*/icount:<COUNT> ifree:<FREE> fdblks:<BLOCKS> frext:<COUNT>/;
152 s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
153 s/1st: *[0-9][0-9]* *last: *[0-9][0-9]* *cnt: *[0-9][0-9]* *freeblks: *[0-9][0-9]* *longest: *[0-9][0-9]*/1st:<NUM> last:<NUM> cnt:<COUNT> freeblks:<COUNT> longest:<NUM>/;
154 s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
156 /version:/,/h_size:/d;
157 /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
163 /DATA FORK EXTENTS/d;
164 s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
165 s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
166 s/#regs: *[1-9][0-9]*/#regs:R/;
167 /INODE:/s/flags:0x5/flags:0x1/g;
168 s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
174 # collapse BUF DATA group into 1 line
175 # for Oper data this can be over separate operations...ughh
177 if (!buf_data) { # 1st one
185 oper = 0 # wont need it now
189 # store it as we dont know if 2nd BUF DATA is to follow
198 if (oper) { # now we can print out oper
209 _full "clean_log : xfs_logprint"
210 _scratch_xfs_logprint -t | tee -a $seq.full \
211 | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
216 _scratch_xfs_logprint -t | tee -a $seq.full >$tmp.logprint
217 if grep -q "<DIRTY>" $tmp.logprint; then
220 if grep -q "<CLEAN>" $tmp.logprint; then
227 mkdir $fulldir >/dev/null 2>&1
228 raw=$fulldir/op.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.raw
229 filtered=$fulldir/op.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.filtered
231 echo "### xfs_logprint output ###" | tee $raw >$filtered
232 _scratch_xfs_logprint -c 2>&1 \
239 # start at rec#2 "-s 2" so we skip over UMOUNT record which will always
240 # be a 512b single header at mkfs time
241 # and may not match with the FS mounted at a different LR size
242 # => xlog_do_recovery_pass() can not handle the different hdr sizes
243 # it assumes them all to be the same between the start..finish
244 # NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
246 _print_transaction_inode()
249 mkdir $fulldir >/dev/null 2>&1
250 raw=$fulldir/trans_inode.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.raw
251 filtered=$fulldir/trans_inode.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.filtered
253 echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
254 _scratch_xfs_logprint -t -i -s $_start 2>&1 \
260 _print_transaction_buf()
263 mkdir $fulldir >/dev/null 2>&1
264 raw=$fulldir/trans_buf.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.raw
265 filtered=$fulldir/trans_buf.mnt$MOUNT_OPTIONS.mkfs$MKFS_OPTIONS$sync_suffix.filtered
267 echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
268 _scratch_xfs_logprint -t -b -s $_start 2>&1 \
278 extra_ops="-lsize=2000b"
279 _scratch_mkfs_xfs $extra_ops >>$seq.full 2>&1
280 if [ $? -ne 0 ] ; then
281 _echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS $extra_ops"
290 # mount fs and create some log traffic
296 _scratch_mount >>$seq.full 2>&1
297 if [ $? -ne 0 ] ; then
298 _echofull "mount failed: $MOUNT_OPTIONS"
302 # generate some log traffic - but not too much - life gets a little
303 # more complicated if the log wraps around. This traffic is
304 # pretty much arbitary, but could probably be made better than this.
305 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
309 umount $SCRATCH_DEV >>$seq.full 2>&1
310 if [ $? -ne 0 ] ; then
311 _echofull "umount failed"
319 # mount fs and create some log traffic with sync'ing
325 _scratch_mount >>$seq.full 2>&1
326 if [ $? -ne 0 ] ; then
327 _echofull "mount failed: $MOUNT_OPTIONS"
331 # generate some log traffic - but not too much
332 # add some syncs to get the log flushed to disk
333 for file in $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}; do
340 umount $SCRATCH_DEV >>$seq.full 2>&1
341 if [ $? -ne 0 ] ; then
342 _echofull "umount failed"
350 echo "*** compare logprint: $1 with $2"
351 if ! diff $1 $2 >/dev/null; then
352 _fail "logprint output $1 differs to $2"
357 # Op data of different Log Record sizes will mean that data is
358 # split at different points and in op printing it will not
359 # try and decode the data which has been split up.
360 # So we do a special diff processing to complain of differences
361 # if no split is involved.
363 # Example diff with forms of:
364 # "Left over region from split log item"
365 # "Not printing rest of data"
368 # < Left over region from split log item
372 # < INODE: #regs: 3 Not printing rest of data
374 # > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
375 # > blkno: <BLKNO> len:<LEN> boff: <BOFF>
380 BEGIN { num_splits = 1 }
383 # ensure a split happened in previous difference
384 if (num_splits < 1 || num_splits > 3) {
385 print num_splits, " split(s) found prior to diff cmd: ", $0
386 num_splits = 1 # shut-up end condition
393 /Left over region/ || /Not printing rest/ {
399 if (num_splits < 1 || num_splits > 3) {
400 print num_splits, " split(s) found prior to diff end"
410 echo "*** compare logprint: $1 with $2"
412 diff $1 $2 >$filtered.diff
413 if ! _process_op_diff $filtered.diff
415 _fail "logprint output $1 differs to $2 considering splits"
420 # make sure this script returns success