3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # common routines for log testing
20 # Created by dxm@sgi.com & tes@sgi.com
28 if [ $status -eq 0 ]; then
29 # don't keep these files around unless something went wrong
37 echo "*** $* ***" >>$seq.full
43 echo "" | tee -a $seq.full
44 echo "*** $* ***" | tee -a $seq.full
45 echo "" | tee -a $seq.full
48 # Handle the operations which get split over Log Record
50 # Oper (379)..... flags: CONTINUE
52 # Oper (0)....... flags: WAS_CONT END
56 # Oper (379)..... flags: none
58 # Oper (0)....... flags: none
67 printf "line = %s\n", $0
72 /^Oper/ && /flags: CONTINUE/ {
73 # this will be the first op of split region
74 $9 = "none" # overwrite CONTINUE flags
76 print "Not printing rest"
80 /^Oper/ && /flags: WAS_CONT END/ {
81 # this will be the last op of split region
82 # skip over was-continued op
83 # we assume there can be only 1
88 # skip over any continued op stuff
96 # Filter out things that can change
97 # We have complexities which change when log is sync'ed at different
99 # Example1: DATA FORK EXTENTS
100 # These will not show up if inode is sync'ed sooner
101 # /DATA FORK EXTENTS/d;
102 # /INODE:/s/flags:0x5/flags:0x1/g;
103 # define XFS_ILOG_CORE 0x001 /* log standard inode fields */
104 # define XFS_ILOG_DEXT 0x004 /* log i_df.if_extents */
112 s/ver:[0-9]/ver:<VERS>/;
113 s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
114 s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
115 s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
116 s/log file: \".*\"/log device: <DEVICE>/;
117 s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
118 s/length: [0-9][0-9]*/length: <LENGTH>/;
119 s/length: [0-9][0-9]*/length: <LENGTH>/;
120 s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
121 s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
122 s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
123 s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
124 s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
125 s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
126 s/blkno: *[0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
127 s/blkno: *[0-9][0-9]*/blkno: <BLKNO>/g;
128 s/boff: [0-9][0-9]*/boff: <BOFF>/g;
129 s/len: *[0-9][0-9]*/len:<LEN>/g;
130 /BUF:/s/[ ]*flags:.*$//;
131 /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
133 /log tail/s/[0-9][0-9]*/<COUNT>/g;
134 s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
135 s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
136 s/block [0-9][0-9]*/block <BLOCK>/;
137 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>/;
138 s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
139 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>/;
140 s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
142 /version:/,/h_size:/d;
143 /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
149 /DATA FORK EXTENTS/d;
150 s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
151 s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
152 s/#regs: *[1-9][0-9]*/#regs:R/;
153 /INODE:/s/flags:0x5/flags:0x1/g;
154 s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
158 s/newino: 0x[0-9a-f]*$/newino: <INO>/g
159 s/newino:0x[0-9a-f]*$/newino:<INO>/g
160 s/ino: 0x[0-9a-f]* flags:/ino: <INO> flags:/g
161 s/ino:0x[0-9a-f]* flags:/ino:<INO> flags:/g
162 s/onlink:[0-9][0-9]*/onlink:<ONLINK>/;
163 s/gen:-*[0-9][0-9]*/gen:<GEN>/;
164 s/gen 0x[0-9a-f][0-9a-f]*/gen <GEN>/;
167 # collapse BUF DATA group into 1 line
168 # for Oper data this can be over separate operations...ughh
170 if (!buf_data) { # 1st one
178 oper = 0 # wont need it now
182 # store it as we dont know if 2nd BUF DATA is to follow
189 /^TRANS/ && dummy_rec == 1 {
190 # start printing again - dummy transaction over
194 # filter out dummy transactions
203 if (oper) { # now we can print out oper
214 _full "clean_log : xfs_logprint"
215 _scratch_xfs_logprint -t | tee -a $seq.full \
216 | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
221 _scratch_xfs_logprint -t | tee -a $seq.full >$tmp.logprint
222 if grep -q "<DIRTY>" $tmp.logprint; then
225 if grep -q "<CLEAN>" $tmp.logprint; then
232 mkdir $fulldir >/dev/null 2>&1
233 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
234 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
235 raw=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
236 filtered=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
238 echo "### xfs_logprint output ###" | tee $raw >$filtered
239 _scratch_xfs_logprint -c 2>&1 \
246 # start at rec#2 "-s 2" so we skip over UMOUNT record which will always
247 # be a 512b single header at mkfs time
248 # and may not match with the FS mounted at a different LR size
249 # => xlog_do_recovery_pass() can not handle the different hdr sizes
250 # it assumes them all to be the same between the start..finish
251 # NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
253 _print_transaction_inode()
256 mkdir $fulldir >/dev/null 2>&1
257 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
258 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
259 raw=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
260 filtered=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
262 echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
263 _scratch_xfs_logprint -t -i -s $_start 2>&1 \
269 _print_transaction_buf()
272 mkdir $fulldir >/dev/null 2>&1
273 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
274 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
275 raw=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
276 filtered=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
278 echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
279 _scratch_xfs_logprint -t -b -s $_start 2>&1 \
288 # mkfs options to append to log size otion can be specified ($*)
289 export MKFS_OPTIONS="-l size=2000b -l lazy-count=1 $*"
291 _scratch_mkfs_xfs >>$seq.full 2>&1
292 if [ $? -ne 0 ] ; then
293 _echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS"
302 # mount fs and create some log traffic
308 _scratch_mount >>$seq.full 2>&1
309 if [ $? -ne 0 ] ; then
310 _echofull "mount failed: $MOUNT_OPTIONS"
314 # generate some log traffic - but not too much - life gets a little
315 # more complicated if the log wraps around. This traffic is
316 # pretty much arbitary, but could probably be made better than this.
317 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
321 umount $SCRATCH_DEV >>$seq.full 2>&1
322 if [ $? -ne 0 ] ; then
323 _echofull "umount failed"
331 # mount fs and create some log traffic with sync'ing
337 _scratch_mount >>$seq.full 2>&1
338 if [ $? -ne 0 ] ; then
339 _echofull "mount failed: $MOUNT_OPTIONS"
343 # generate some log traffic - but not too much
344 # add some syncs to get the log flushed to disk
345 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
352 umount $SCRATCH_DEV >>$seq.full 2>&1
353 if [ $? -ne 0 ] ; then
354 _echofull "umount failed"
361 echo "*** compare logprint: $1 with $2"
362 if ! diff $1 $2 >/dev/null; then
363 _fail "logprint output $1 differs to $2"
368 # Op data of different Log Record sizes will mean that data is
369 # split at different points and in op printing it will not
370 # try and decode the data which has been split up.
371 # So we do a special diff processing to complain of differences
372 # if no split is involved.
374 # Example diff with forms of:
375 # "Left over region from split log item"
376 # "Not printing rest of data"
379 # < Left over region from split log item
383 # < INODE: #regs: 3 Not printing rest of data
385 # > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
386 # > blkno: <BLKNO> len:<LEN> boff: <BOFF>
391 BEGIN { num_splits = 1; max_splits = 50 }
394 # ensure a split happened in previous difference
395 if (num_splits < 1 || num_splits > max_splits) {
396 print num_splits, " split(s) found prior to diff cmd: ", $0
397 num_splits = 1 # shut-up end condition
404 /Left over region/ || /Not printing rest/ {
410 if (num_splits < 1 || num_splits > max_splits) {
411 print num_splits, " split(s) found prior to diff end"
421 echo "*** compare logprint: $1 with $2"
423 diff $1 $2 >$filtered.diff
424 if ! _process_op_diff $filtered.diff
426 _fail "logprint output $1 differs to $2 considering splits"
430 # return xfs log version of device
432 # _log_version /dev/dsk/dks0d1s4
437 vers=`xfs_db -c 'sb 0' -c 'p versionnum' -r $_dev | $AWK_PROG '{print $3}'`
438 logver=`echo $vers | sed -e 's/0x[0-9a-f]\([0-9a-f]\)[0-9a-f][0-9a-f]/\1/'`
439 if [ $logver = 4 -o $logver = 5 -o $logver = 6 -o $logver = 7 -o \
440 $logver = c -o $logver = d -o $logver = e -o $logver = f ]; then
449 # test out mkfs to see if it supports "-l version=2"
450 export MKFS_OPTIONS="-l version=2"
451 if ! _scratch_mkfs_xfs >>$seq.full 2>&1; then
452 _notrun "mkfs does not support v2 logs"
455 # test out mount to see if it mounts a v2 log fs
456 export MOUNT_OPTIONS="-o logbsize=32k"
457 if ! _scratch_mount >>$seq.full 2>&1; then
458 _notrun "mount/kernel does not support v2 logs"
461 # check after unmount to see if it is clean
462 # i.e. it is not a 6.5.25 buggy version checking kernel
463 touch $SCRATCH_MNT/file
464 umount $SCRATCH_DEV >>$seq.full 2>&1
465 if _scratch_xfs_logprint -t | tee -a $seq.full \
466 | head | grep -q "<DIRTY>"; then
467 _notrun "kernel does not support v2 logs"
470 # otherwise presume it does support v2 logs...:)
474 # make sure this script returns success