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
23 fulldir=$seqres.fulldir
28 if [ $status -eq 0 ]; then
29 # don't keep these files around unless something went wrong
36 echo "" >>$seqres.full
37 echo "*** $* ***" >>$seqres.full
38 echo "" >>$seqres.full
43 echo "" | tee -a $seqres.full
44 echo "*** $* ***" | tee -a $seqres.full
45 echo "" | tee -a $seqres.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 */
111 s/ver:[0-9]/ver:<VERS>/;
112 s/version [0-9] format [0-9]/version <VERS> format <FORMAT>/;
113 s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
114 s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
115 s/log file: \".*\"/log device: <DEVICE>/;
116 s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
117 s/length: [0-9][0-9]*/length: <LENGTH>/;
118 s/length: [0-9][0-9]*/length: <LENGTH>/;
119 s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
120 s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
121 s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
122 s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
123 s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
124 s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
125 s/blkno: *[0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
126 s/blkno: *[0-9][0-9]*/blkno: <BLKNO>/g;
127 s/boff: [0-9][0-9]*/boff: <BOFF>/g;
128 s/len: *[0-9][0-9]*/len:<LEN>/g;
129 /BUF:/s/[ ]*flags:.*$//;
130 /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
132 /log tail/s/[0-9][0-9]*/<COUNT>/g;
133 s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
134 s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
135 s/block [0-9][0-9]*/block <BLOCK>/;
136 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>/;
137 s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
138 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>/;
139 s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
141 /version:/,/h_size:/d;
142 /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
148 /DATA FORK EXTENTS/d;
149 s/BUF: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/BUF: cnt:C total:T/;
150 s/INO: cnt:[1-9][0-9]* total:[1-9][0-9]*.*/INO: cnt:C total:T/;
151 s/#regs: *[1-9][0-9]*/#regs:R/;
152 /INODE:/s/flags:0x5/flags:0x1/g;
153 s/Oper ([0-9][0-9]*)/Oper (OPNUM)/;
157 s/newino: 0x[0-9a-f]*$/newino: <INO>/g
158 s/newino:0x[0-9a-f]*$/newino:<INO>/g
159 s/ino: 0x[0-9a-f]* flags:/ino: <INO> flags:/g
160 s/ino:0x[0-9a-f]* flags:/ino:<INO> flags:/g
161 s/onlink:[0-9][0-9]*/onlink:<ONLINK>/;
162 s/gen:-*[0-9][0-9]*/gen:<GEN>/;
163 s/gen 0x[0-9a-f][0-9a-f]*/gen <GEN>/;
166 # collapse BUF DATA group into 1 line
167 # for Oper data this can be over separate operations...ughh
169 if (!buf_data) { # 1st one
177 oper = 0 # wont need it now
181 # store it as we dont know if 2nd BUF DATA is to follow
188 /^TRANS/ && dummy_rec == 1 {
189 # start printing again - dummy transaction over
193 # filter out dummy transactions
202 if (oper) { # now we can print out oper
213 _full "clean_log : xfs_logprint"
214 _scratch_xfs_logprint -t | tee -a $seqres.full \
215 | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
218 _scratch_xfs_logstate()
220 _scratch_xfs_logprint -t | tee -a $seqres.full | grep -q "<CLEAN>"
224 _scratch_f2fs_logstate()
226 $DUMP_F2FS_PROG $SCRATCH_DEV | tee -a $seqres.full | grep -q "unmount"
230 _scratch_ext4_logstate()
232 $DUMPE2FS_PROG -h $SCRATCH_DEV 2> /dev/null | tee -a $seqres.full | \
233 grep "^Filesystem features" | grep -q needs_recovery
242 _scratch_xfs_logprint
245 $DUMP_F2FS_PROG $SCRATCH_DEV
248 $DUMPE2FS_PROG -h $SCRATCH_DEV
262 $DUMP_F2FS_PROG $TEST_DEV
265 $DUMPE2FS_PROG -h $TEST_DEV
276 dirty=$(_scratch_xfs_logstate)
279 dirty=$(_scratch_f2fs_logstate)
282 dirty=$(_scratch_ext4_logstate)
288 if [ $dirty -ne 0 ]; then
297 mkdir $fulldir >/dev/null 2>&1
298 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
299 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
300 raw=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
301 filtered=$fulldir/op.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
303 echo "### xfs_logprint output ###" | tee $raw >$filtered
304 _scratch_xfs_logprint -c 2>&1 \
311 # start at rec#2 "-s 2" so we skip over UMOUNT record which will always
312 # be a 512b single header at mkfs time
313 # and may not match with the FS mounted at a different LR size
314 # => xlog_do_recovery_pass() can not handle the different hdr sizes
315 # it assumes them all to be the same between the start..finish
317 _print_transaction_inode()
320 mkdir $fulldir >/dev/null 2>&1
321 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
322 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
323 raw=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
324 filtered=$fulldir/trans_inode.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
326 echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
327 _scratch_xfs_logprint -t -i -s $_start 2>&1 \
333 _print_transaction_buf()
336 mkdir $fulldir >/dev/null 2>&1
337 mntopt=`echo $MOUNT_OPTIONS | sed 's/ //g'`
338 mkfsopt=`echo $MKFS_OPTIONS | sed 's/ //g'`
339 raw=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.raw
340 filtered=$fulldir/trans_buf.mnt$mntopt.mkfs$mkfsopt$sync_suffix.filtered
342 echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
343 _scratch_xfs_logprint -t -b -s $_start 2>&1 \
352 # mkfs options to append to log size otion can be specified ($*)
353 export MKFS_OPTIONS="-l size=2000b -l lazy-count=1 $*"
355 _scratch_mkfs_xfs >>$seqres.full 2>&1
356 if [ $? -ne 0 ] ; then
357 _echofull "Cannot mkfs for this test using option specified: $MKFS_OPTIONS"
366 # mount fs and create some log traffic
372 _try_scratch_mount >>$seqres.full 2>&1
373 if [ $? -ne 0 ] ; then
374 _echofull "mount failed: $MOUNT_OPTIONS"
378 # generate some log traffic - but not too much - life gets a little
379 # more complicated if the log wraps around. This traffic is
380 # pretty much arbitary, but could probably be made better than this.
381 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
385 _scratch_unmount >>$seqres.full 2>&1
386 if [ $? -ne 0 ] ; then
387 _echofull "umount failed"
395 # mount fs and create some log traffic with sync'ing
401 _try_scratch_mount >>$seqres.full 2>&1
402 if [ $? -ne 0 ] ; then
403 _echofull "mount failed: $MOUNT_OPTIONS"
407 # generate some log traffic - but not too much
408 # add some syncs to get the log flushed to disk
409 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
416 _scratch_unmount >>$seqres.full 2>&1
417 if [ $? -ne 0 ] ; then
418 _echofull "umount failed"
425 echo "*** compare logprint: $1 with $2"
426 if ! diff $1 $2 >/dev/null; then
427 _fail "logprint output $1 differs to $2"
432 # Op data of different Log Record sizes will mean that data is
433 # split at different points and in op printing it will not
434 # try and decode the data which has been split up.
435 # So we do a special diff processing to complain of differences
436 # if no split is involved.
438 # Example diff with forms of:
439 # "Left over region from split log item"
440 # "Not printing rest of data"
443 # < Left over region from split log item
447 # < INODE: #regs: 3 Not printing rest of data
449 # > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
450 # > blkno: <BLKNO> len:<LEN> boff: <BOFF>
455 BEGIN { num_splits = 1; max_splits = 50 }
458 # ensure a split happened in previous difference
459 if (num_splits < 1 || num_splits > max_splits) {
460 print num_splits, " split(s) found prior to diff cmd: ", $0
461 num_splits = 1 # shut-up end condition
468 /Left over region/ || /Not printing rest/ {
474 if (num_splits < 1 || num_splits > max_splits) {
475 print num_splits, " split(s) found prior to diff end"
485 echo "*** compare logprint: $1 with $2"
487 diff $1 $2 >$filtered.diff
488 if ! _process_op_diff $filtered.diff
490 _fail "logprint output $1 differs to $2 considering splits"
494 # return xfs log version of device
496 # _log_version /dev/dsk/dks0d1s4
501 vers=`xfs_db -c 'sb 0' -c 'p versionnum' -r $_dev | $AWK_PROG '{print $3}'`
502 logver=`echo $vers | sed -e 's/0x[0-9a-f]\([0-9a-f]\)[0-9a-f][0-9a-f]/\1/'`
503 if [ $logver = 4 -o $logver = 5 -o $logver = 6 -o $logver = 7 -o \
504 $logver = c -o $logver = d -o $logver = e -o $logver = f ]; then
513 # test out mkfs to see if it supports "-l version=2"
514 export MKFS_OPTIONS="-l version=2"
515 if ! _scratch_mkfs_xfs >>$seqres.full 2>&1; then
516 _notrun "mkfs does not support v2 logs"
519 # test out mount to see if it mounts a v2 log fs
520 export MOUNT_OPTIONS="-o logbsize=32k"
521 if ! _try_scratch_mount >>$seqres.full 2>&1; then
522 _notrun "mount/kernel does not support v2 logs"
525 # check after unmount to see if it is clean
526 # i.e. it is not a 6.5.25 buggy version checking kernel
527 touch $SCRATCH_MNT/file
528 _scratch_unmount >>$seqres.full 2>&1
529 if _scratch_xfs_logprint -t | tee -a $seqres.full \
530 | head | grep -q "<DIRTY>"; then
531 _notrun "kernel does not support v2 logs"
534 # otherwise presume it does support v2 logs...:)
541 if [ -z "$XFS_LOGPRINT_PROG" ]; then
542 _notrun "This test requires xfs_logprint utility."
546 if [ -z "$DUMP_F2FS_PROG" ]; then
547 _notrun "This test requires dump.f2fs utility."
551 if [ -z "$DUMPE2FS_PROG" ]; then
552 _notrun "This test requires dumpe2fs utility."
556 _notrun "$FSTYP does not support log state probing."
563 echo "# mkfs-opt mount-opt"
564 echo "# ------------------------------"
565 echo " version=2 logbsize=32k"
566 echo " version=2,su=4096 logbsize=32k"
567 echo " version=2,su=32768 logbsize=32k"
568 echo " version=2,su=32768 logbsize=64k"
569 echo " version=2 logbsize=64k"
570 echo " version=2,su=64k logbsize=64k"
571 echo " version=2 logbsize=128k"
572 echo " version=2,su=128k logbsize=128k"
573 echo " version=2 logbsize=256k"
574 echo " version=2,su=256k logbsize=256k"
579 echo "# mkfs-opt mount-opt"
580 echo "# ------------------------------"
581 echo " test1 active_logs=6,background_gc=off"
582 echo " test2 active_logs=6,background_gc=off,inline_data"
583 echo " test3 active_logs=6,background_gc=off,inline_dentry"
584 echo " test4 active_logs=6,background_gc=off,inline_data,inline_dentry"
585 echo " test5 active_logs=6,background_gc=off,disable_roll_forward"
586 echo " test6 active_logs=6,background_gc=off,discard,inline_data,inline_dentry"
587 echo " test7 active_logs=6,background_gc=on"
588 echo " test8 active_logs=6,background_gc=on,inline_data"
589 echo " test9 active_logs=6,background_gc=on,inline_data,inline_dentry"
590 echo " test10 active_logs=6,background_gc=on,discard,inline_data,inline_dentry"
595 echo "# mkfs-opt mount-opt"
596 echo "# ------------------------------"
597 echo " /dev/null data=writeback"
598 echo " /dev/null data=ordered"
599 echo " /dev/null data=journal"
600 echo " /dev/null data=ordered,data_err=abort"
601 echo " /dev/null data=writeback,nojournal_checksum"
602 echo " /dev/null data=ordered,nojournal_checksum"
603 echo " /dev/null data=journal,nojournal_checksum"
604 echo " /dev/null data=ordered,data_err=abort,nojournal_checksum"
605 echo " /dev/null data=writeback,journal_checksum"
606 echo " /dev/null data=ordered,journal_checksum"
622 _notrun "$FSTYP does not support log configs."
627 # make sure this script returns success