Fixed merge issue with TIMESTAMP string printing twice.
[xfstests-dev.git] / 086
1 #! /bin/sh
2 # FS QA Test No. 086
3 #
4 # To test log replay with version 2 logs
5 # Initially keep this simple with just creates.
6 # In another qa test we can do more e.g. use fsstress.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
10
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.
14
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.
18
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.
25
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.
29
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA  94043, or:
32
33 # http://www.sgi.com 
34
35 # For further information regarding this notice, see: 
36
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
39 #
40 # creator
41 owner=root@icy.melbourne.sgi.com
42
43 seq=`basename $0`
44 echo "QA output created by $seq"
45
46 here=`pwd`
47 tmp=/tmp/$$
48 status=1        # failure is the default!
49 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.filter
54 . ./common.log
55
56 # real QA test starts here
57 _supported_fs xfs
58 _supported_os IRIX Linux
59
60 rm -f $seq.full $tmp.*
61 _require_scratch
62
63 echo "*** init FS"
64 umount $SCRATCH_DEV >/dev/null 2>&1
65
66 cat >$tmp.seq.params <<EOF
67 # mkfs-opt             mount-opt
68   -lversion=2          -ologbsize=32k
69   -lversion=2,su=4096  -ologbsize=32k
70   -lversion=2,su=32768 -ologbsize=32k
71   -lversion=2,su=32768 -ologbsize=64k
72   -lversion=2          -ologbsize=64k
73   -lversion=2          -ologbsize=128k
74   -lversion=2          -ologbsize=256k
75 EOF
76
77 # Do the work for various log params which
78 # should not effect the data content of the log
79 # Try with and without sync'ing - sync'ing will mean that
80 # the log will be written out unfilled and thus the log 
81 # stripe can have an effect.
82 #
83 for s in sync nosync ; do
84     cat $tmp.seq.params \
85     | while read mkfs mnt restofline
86     do
87         if [ "$mkfs" = "#" ]; then 
88             continue
89         fi
90
91         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---"
92         export MOUNT_OPTIONS=$mnt
93         export MKFS_OPTIONS=$mkfs
94
95         # mkfs the FS
96         _echofull "mkfs"
97         if ! _mkfs_log; then
98             _echofull "mkfs failed: $MKFS_OPTIONS"
99             continue
100         fi
101
102         # mount the FS
103         _echofull "mount"
104         if ! _scratch_mount >>$seq.full 2>&1; then
105             _echofull "mount failed: $MOUNT_OPTIONS"
106             continue
107         fi
108
109         # create the metadata
110         if [ $s = "sync" ]; then
111             # generate some log traffic - but not too much
112             # add some syncs to get the log flushed to disk 
113             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
114                 touch $file
115                 sync
116             done
117         else
118             # generate some log traffic - but not too much - life gets a little
119             # more complicated if the log wraps around. This traffic is
120             # pretty much arbitary, but could probably be made better than this.
121             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
122         fi
123
124         # check before on what FS should look like
125         _echofull "ls SCRATCH_MNT"
126         ls $SCRATCH_MNT
127
128         _echofull "godown"
129         src/godown -v -f $SCRATCH_MNT >> $seq.full
130
131         _echofull "unmount"
132         umount $SCRATCH_DEV >>$seq.full 2>&1 \
133             || _fail "umount failed"
134
135         _echofull "logprint after going down..."
136         _print_logstate
137
138         _echofull "mount with replay"
139         _scratch_mount >>$seq.full 2>&1 \
140             || _fail "mount failed: $MOUNT_OPTIONS"
141
142         # check on what FS looks like after log recovery
143         _echofull "ls SCRATCH_MNT"
144         ls $SCRATCH_MNT
145
146         _echofull "unmount"
147         umount $SCRATCH_MNT
148
149         _echofull "logprint after mount and replay..."
150         _print_logstate
151
152         if _check_scratch_fs; then
153             _echofull "filesystem is checked ok"
154         else
155             _echofull "filesystem is NOT ok"
156         fi
157     done
158 done
159
160 status=0 
161 exit