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;
174 /override tail/s/[0-9][0-9]*/<TAIL_BLK>/;
189 _full "clean_log : xfs_logprint"
190 _scratch_xfs_logprint -t | tee -a $seq.full \
191 | head | grep -q "<CLEAN>" || _fail "DIRTY LOG"
196 raw=$seq.op.mnt$mnt.mkfs$mkfs.raw
197 filtered=$seq.op.mnt$mnt.mkfs$mkfs.filtered
199 echo "### xfs_logprint output ###" | tee $raw >$filtered
200 _scratch_xfs_logprint -c 2>&1 \
207 # start at rec#2 "-s 2" so we skip over UMOUNT record which will always
208 # be a 512b single header at mkfs time
209 # and may not match with the FS mounted at a different LR size
210 # => xlog_do_recovery_pass() can not handle the different hdr sizes
211 # it assumes them all to be the same between the start..finish
212 # NB: On IRIX there is no UMOUNT record and so we could start from -s 0.
214 _print_transaction_inode()
217 raw=$seq.trans_inode.mnt$mnt.mkfs$mkfs.raw
218 filtered=$seq.trans_inode.mnt$mnt.mkfs$mkfs.filtered
220 echo "### xfs_logprint -t -i -s START output ###" | tee $raw >$filtered
221 _scratch_xfs_logprint -t -i -s $_start 2>&1 \
227 _print_transaction_buf()
230 raw=$seq.trans_buf.mnt$mnt.mkfs$mkfs.raw
231 filtered=$seq.trans_buf.mnt$mnt.mkfs$mkfs.filtered
233 echo "### xfs_logprint -t -b -s START output ###" | tee $raw >$filtered
234 _scratch_xfs_logprint -t -b -s $_start 2>&1 \
242 # will be run with different MKFS and MOUNT options
251 extra_ops="-lsize=2000b $_mkfs_opts"
252 _scratch_mkfs_xfs $extra_ops >$tmp.mkfs0 2>&1
254 _notrun "Cannot mkfs for this test using MKFS_OPTIONS specified: $MKFS_OPTIONS $extra_ops"
256 # check the mkfs settings
257 _filter_mkfs <$tmp.mkfs0 2>$tmp.mkfs
259 [ $dbsize -eq 4096 ] \
260 || _notrun "Logprint test, tailored to 4K blocks ($dbsize in use)"
262 || _notrun "Logprint test, tailored to 256b inodes ($isize in use)"
266 _scratch_mount $_mnt_opts >>$seq.full 2>&1 \
267 || _fail "mount failed: $_mnt_opts $MOUNT_OPTIONS"
269 # generate some log traffic - but not too much - life gets a little
270 # more complicated if the log wraps around. This traffic is
271 # pretty much arbitary, but could probably be made better than this.
272 touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
276 umount $SCRATCH_DEV >>$seq.full 2>&1 \
277 || _fail "umount failed"
283 echo "*** compare logprint: $1 with $2"
284 if ! diff $1 $2 >/dev/null; then
285 echo "FAILED: logprint output $1 differs to $2"
293 # - remove the log options in mkfs
294 # - remove the log options in mount
295 # - remove the quota options in mount
296 # leave any other options given
297 MKFS_OPTIONS=`echo $MKFS_OPTIONS | sed -e 's/-l[ ]*[^ $]*//g'`
298 MOUNT_OPTIONS=`echo $MOUNT_OPTIONS |\
299 sed -e 's/logbsize=[^ ,]*,*//g' \
300 -e 's/usrquota,*//g' \
301 -e 's/grpquota,*//g' \
303 -e 's/uqnoenforce,*//g' \
304 -e 's/gqnoenforce,*//g' \
315 # Op data of different Log Record sizes will mean that data is
316 # split at different points and in op printing it will not
317 # try and decode the data which has been split up.
318 # So we do a special diff processing to complain of differences
319 # if no split is involved.
321 # Example diff with forms of:
322 # "Left over region from split log item"
323 # "Not printing rest of data"
326 # < Left over region from split log item
330 # < INODE: #regs: 3 Not printing rest of data
332 # > INODE: #regs: 3 ino: 0x80 flags: 0x5 dsize: 16
333 # > blkno: <BLKNO> len:<LEN> boff: <BOFF>
338 BEGIN { num_splits = 1 }
341 # ensure cmd is a change op
343 gsub(/[0-9][0-9]*/,"", cmd)
346 print "bad diff cmd: ", $0
350 # ensure a split happened in previous difference
351 if (num_splits != 1 && num_splits != 2) {
352 print num_splits, " split(s) found prior to diff cmd: ", $0
353 num_splits = 1 # shut-up end condition
360 /Left over region/ || /Not printing rest/ {
366 if (num_splits != 1 && num_splits != 2) {
367 print num_splits, " split(s) found prior to diff end"
377 echo "*** compare logprint: $1 with $2"
379 diff $1 $2 >$filtered.diff
380 if ! _process_op_diff $filtered.diff
382 echo "FAILED: logprint output $1 differs to $2 considering splits"
388 # real QA test starts here
391 rm -f $seq.full $tmp.*
395 umount $SCRATCH_DEV >/dev/null 2>&1
397 cat >$tmp.seq.params <<EOF
398 # mkfs-opt mount-opt start-blk
399 -lversion=1 -ologbsize=32k 2
400 -lversion=2 -ologbsize=32k 2
401 -lversion=2 -ologbsize=64k 2
402 -lversion=2 -ologbsize=128k 2
403 -lversion=2 -ologbsize=256k 2
404 # NB: Stripe only affects LRs which weren't full when written out
405 # So if we wrote out 32K LR then the stripe has no effect
406 # In our case, it is likely that the LRs will be full but
407 # it may no be the case in all QA environments where the LR
408 # may be forced out early.
409 -lversion=2,su=4096 -ologbsize=32k 8
412 # do the work for various log params which
413 # should not effect the data content of the log
414 cat $tmp.seq.params \
415 | while read mkfs mnt start
417 if [ "$mkfs" != "#" ]; then
418 _mkfs_create_log $mkfs $mnt
422 _cmp_op_output $seq.noquota.op $filtered
424 _print_transaction_inode $start
425 _cmp_output $seq.noquota.trans_inode $filtered
427 _print_transaction_buf $start
428 _cmp_output $seq.noquota.trans_buf $filtered
432 # do a simple quota test to ensure DQUOT data is happening
434 mnt="-ousrquota,grpquota"
435 _mkfs_create_log $mkfs $mnt
437 _print_transaction_inode 2
438 _cmp_output $seq.ugquota.trans_inode $filtered
440 # got thru it all so we may have success
441 if [ ! -e $tmp.error ]; then