5 # - extended to test for various log version 2 scenarios
6 # - tests 1 case of user/group quotas
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
11 # This program is free software; you can redistribute it and/or modify it
12 # under the terms of version 2 of the GNU General Public License as
13 # published by the Free Software Foundation.
15 # This program is distributed in the hope that it would be useful, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like. Any license provided herein, whether implied or
22 # otherwise, applies only to this software file. Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA 94043, or:
35 # For further information regarding this notice, see:
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
44 echo "QA output created by $seq"
48 status=1 # failure is the default!
50 # get standard environment, filters and checks
57 if [ $status -eq 0 ]; then
58 # don't keep these files around unless something went wrong
59 rm -f $seq.trans* $seq.op* $seq.full
62 umount $SCRATCH_MNT 2>/dev/null
64 trap "_cleanup; exit \$status" 0 1 2 3 15
69 echo "*** $* ***" >>$seq.full
73 # Handle the operations which get split over Log Record
75 # Oper (379)..... flags: CONTINUE
77 # Oper (0)....... flags: WAS_CONT END
81 # Oper (379)..... flags: none
83 # Oper (0)....... flags: none
88 function extract_opnum(str) {
89 # e.g. "(379):" => "379"
98 printf "line = %s\n", $0
103 opnum = extract_opnum($2)
105 /^Oper/ && /flags: CONTINUE/ {
106 $9 = "none" # overwrite CONTINUE flags
107 $2 = sprintf("(%d):", remember+opnum)
112 /^Oper/ && /flags: WAS_CONT END/ {
113 # skip over was-continued op
114 # we assume there can be only 1
119 # skip over any continued op stuff
122 /^Oper/ && /UNMOUNT/ {
128 /^Oper/ && (opnum == 0) {
129 # have operation 0 with NO continued op
130 remember += (prev_opnum+1)
132 /^Oper/ && debug { printf "line2 = %s, remember = %d, prev_opnum = %d\n", $0, remember, prev_opnum}
133 /^Oper/ && (remember > 0) {
134 # add in opnum accumulation from previous LRs
135 $2 = sprintf("(%d):", remember+opnum)
146 s/data device: 0x[0-9a-f][0-9a-f]*/data device: <DEVICE>/;
147 s/log device: 0x[0-9a-f][0-9a-f]*/log device: <DEVICE>/;
148 s/log file: \".*\"/log device: <DEVICE>/;
149 s/daddr: [0-9][0-9]*/daddr: <DADDR>/;
150 s/length: [0-9][0-9]*/length: <LENGTH>/;
151 s/length: [0-9][0-9]*/length: <LENGTH>/;
152 s/^cycle num overwrites: .*$/cycle num overwrites: <TIDS>/;
153 s/tid: [0-9a-f][0-9a-f]*/tid: <TID>/;
154 s/tid:0x[0-9a-f][0-9a-f]*/tid:<TID>/;
155 s/q:0x[0-9a-f][0-9a-f]*/q:<Q>/;
156 s/a:0x[0-9a-f][0-9a-f]*/a:<A>/g;
157 s/blkno:0x[0-9a-f][0-9a-f]*/blkno:<BLKNO>/g;
158 s/blkno: [0-9][0-9]* (0x[0-9a-f]*)/blkno: <BLKNO> (<BLKNO>)/g;
159 s/blkno: [0-9][0-9]*/blkno: <BLKNO>/g;
160 s/boff: [0-9][0-9]*/boff: <BOFF>/g;
161 s/len: *[0-9][0-9]*/len:<LEN>/g;
162 /zeroed blocks/s/[0-9][0-9]*/<COUNT>/g;
163 /cleared blocks/s/[0-9][0-9]*/<COUNT>/g;
164 /log tail/s/[0-9][0-9]*/<COUNT>/g;
165 s/atime:[0-9a-fx]* *mtime:[0-9a-fx]* *ctime:[0-9a-fx]*/atime:<TIME> mtime:<TIME> ctime:<TIME>/;
166 s/atime 0x[0-9a-f]* mtime 0x[0-9a-f]* ctime 0x[0-9a-f]*/atime <TIME> mtime <TIME> ctime <TIME>/;
167 s/block [0-9][0-9]*/block <BLOCK>/;
168 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>/;
169 s/sunit: *[0-9][0-9]* *swidth: *[0-9][0-9]*/sunit:<SUNIT> swidth:<SWIDTH>/;
170 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>/;
171 s/^uuid: *[0-9a-f-][0-9a-f-]* *format: *.*$/uuid: <UUID> format: <FORMAT>/;
173 /version:/,/h_size:/d;
188 _full "clean_log : xfs_logprint"
189 _scratch_xfs_logprint -t | tee -a $seq.full \
190 | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
195 raw=$seq.op.mnt$mnt.mkfs$mkfs.raw
196 filtered=$seq.op.mnt$mnt.mkfs$mkfs.filtered
198 echo "### xfs_logprint output ###" | tee $raw >$filtered
199 _scratch_xfs_logprint -c 2>&1 \
206 # start at rec#2 "-s 2" so we skip over UMOUNT record which will always
207 # be a 512b single header at mkfs time
208 # and may not match with the FS mounted at a different LR size
209 # => xlog_do_recovery_pass() can not handle the different hdr sizes
210 # it assumes them all to be the same between the start..finish
211 # NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
213 _print_transaction_inode()
215 raw=$seq.trans_inode.mnt$mnt.mkfs$mkfs.raw
216 filtered=$seq.trans_inode.mnt$mnt.mkfs$mkfs.filtered
218 echo "### xfs_logprint -t -i -s 2 output ###" | tee $raw >$filtered
219 _scratch_xfs_logprint -t -i -s 2 2>&1 \
225 _print_transaction_buf()
227 raw=$seq.trans_buf.mnt$mnt.mkfs$mkfs.raw
228 filtered=$seq.trans_buf.mnt$mnt.mkfs$mkfs.filtered
230 echo "### xfs_logprint -t -b -s 2 output ###" | tee $raw >$filtered
231 _scratch_xfs_logprint -t -b -s 2 2>&1 \
239 # will be run with different MKFS and MOUNT options
248 extra_ops="-lsize=2000b $_mkfs_opts"
249 _scratch_mkfs_xfs $extra_ops >$tmp.mkfs0 2>&1
251 _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified: $MKFS_OPTIONS $extra_ops"
253 # check the mkfs settings
254 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs
256 [ $dbsize -eq 4096 ] \
257 || _notrun "Logprint test, tailored to 4K blocks ($dbsize in use)"
259 || _notrun "Logprint test, tailored to 256b inodes ($isize in use)"
263 _scratch_mount $_mnt_opts >>$seq.full 2>&1 \
264 || _fail "mount failed: $_mnt_opts $MOUNT_OPTIONS"
266 # generate some log traffic - but not too much - life gets a little
267 # more complicated if the log wraps around. This traffic is
268 # pretty much arbitary, but could probably be made better than this.
269 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
273 umount $SCRATCH_DEV >>$seq.full 2>&1 \
274 || _fail "umount failed"
280 echo "*** compare logprint: $1 with $2"
281 if ! diff $1 $2 >/dev/null; then
282 echo "FAILED: logprint output $1 differs to $2"
290 # - remove the log options in mkfs
291 # - remove the log options in mount
292 # - remove the quota options in mount
293 # leave any other options given
294 MKFS_OPTIONS=`echo $MKFS_OPTIONS | sed -e 's/-l[ ]*[^ $]*//g'`
295 MOUNT_OPTIONS=`echo $MOUNT_OPTIONS |\
296 sed -e 's/logbsize=[^ ,]*,*//g' \
297 -e 's/usrquota,*//g' \
298 -e 's/grpquota,*//g' \
300 -e 's/uqnoenforce,*//g' \
301 -e 's/gqnoenforce,*//g' \
312 # Op data of different Log Record sizes will mean that data is
313 # split at different points and in op printing it will not
314 # try and decode the data which has been split up.
315 # So we do a special diff processing to complain of differences
316 # if no split is involved.
318 # Example diff with forms of:
319 # "Left over region from split log item"
320 # "Not printing rest of data"
323 # < Left over region from split log item
327 # < INODE: #regs: 3 Not printing rest of data
329 # > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
330 # > blkno: <BLKNO> len:<LEN> boff: <BOFF>
335 BEGIN { num_splits = 1 }
338 # ensure cmd is a change op
340 gsub(/[0-9][0-9]*/,"", cmd)
343 print "bad diff cmd: ", $0
347 # ensure a split happened in previous difference
348 if (num_splits != 1 && num_splits != 2) {
349 print num_splits, " split(s) found prior to diff cmd: ", $0
350 num_splits = 1 # shut-up end condition
357 /Left over region/ || /Not printing rest/ {
363 if (num_splits != 1 && num_splits != 2) {
364 print num_splits, " split(s) found prior to diff end"
374 echo "*** compare logprint: $1 with $2"
376 diff $1 $2 >$filtered.diff
377 if ! _process_op_diff $filtered.diff
379 echo "FAILED: logprint output $1 differs to $2 considering splits"
385 # real QA test starts here
388 rm -f $seq.full $tmp.*
392 umount $SCRATCH_DEV >/dev/null 2>&1
394 cat >$tmp.seq.params <<EOF
396 -lversion=1 -ologbsize=32k
397 -lversion=2 -ologbsize=32k
398 -lversion=2 -ologbsize=64k
399 -lversion=2 -ologbsize=128k
400 -lversion=2 -ologbsize=256k
401 # NB: Stripe only affects LRs which weren't full when written out
402 # So if we wrote out 32K LR then the stripe has no effect
403 # In our case, it is likely that the LRs will be full but
404 # it may no be the case in all QA environments where the LR
405 # may be forced out early.
406 # -lversion=2,su=4096 -ologbsize=32k
409 # do the work for various log params which
410 # should not effect the data content of the log
411 cat $tmp.seq.params \
412 | while read mkfs mnt
414 if [ "$mkfs" != "#" ]; then
415 _mkfs_create_log $mkfs $mnt
419 _cmp_op_output $seq.noquota.op $filtered
421 _print_transaction_inode
422 _cmp_output $seq.noquota.trans_inode $filtered
424 _print_transaction_buf
425 _cmp_output $seq.noquota.trans_buf $filtered
429 # do a simple quota test to ensure DQUOT data is happening
431 mnt="-ousrquota,grpquota"
432 _mkfs_create_log $mkfs $mnt
434 _print_transaction_inode
435 _cmp_output $seq.ugquota.trans_inode $filtered
437 # got thru it all so we may have success
438 if [ ! -e $tmp.error ]; then