8375e574db24ca0c97b2124538c52f0e8c262c18
[xfstests-dev.git] / tests / generic / 054
1 #! /bin/bash
2 # FS QA Test No. 054
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
12 # modify it under the terms 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,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common/rc
38 . ./common/filter
39 . ./common/log
40
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os IRIX Linux
44
45 rm -f $seqres.full $tmp.*
46 _require_scratch
47 _require_scratch_shutdown
48 _require_logstate
49
50 echo "*** init FS"
51 _scratch_unmount >/dev/null 2>&1
52
53 _get_log_configs > $tmp.seq.params
54
55 # Do the work for various log params which
56 # should not effect the data content of the log
57 # Try with and without sync'ing - sync'ing will mean that
58 # the log will be written out unfilled and thus the log
59 # stripe can have an effect.
60 #
61 for s in sync nosync ; do
62     cat $tmp.seq.params \
63     | while read mkfs mnt restofline
64     do
65         if [ "$mkfs" = "#" ]; then
66             continue
67         fi
68
69         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---" >>$seqres.full
70         export MKFS_OPTIONS="-l $mkfs"
71         export MOUNT_OPTIONS="-o $mnt"
72
73         # mkfs the FS
74         _echofull "mkfs"
75         _scratch_mkfs >>$seqres.full 2>&1
76         if [ $? -ne 0 ] ; then
77             _echofull "mkfs failed: $MKFS_OPTIONS"
78             continue
79         fi
80
81         # mount the FS
82         _echofull "mount"
83         if ! _scratch_mount >>$seqres.full 2>&1; then
84             _echofull "mount failed: $MOUNT_OPTIONS"
85             continue
86         fi
87
88         # create the metadata
89         if [ $s = "sync" ]; then
90             # generate some log traffic - but not too much
91             # add some syncs to get the log flushed to disk
92             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
93                 touch $file
94                 sync
95             done
96         else
97             # generate some log traffic - but not too much - life gets a little
98             # more complicated if the log wraps around. This traffic is
99             # pretty much arbitary, but could probably be made better than this.
100             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
101         fi
102
103         # check before on what FS should look like
104         _echofull "ls SCRATCH_MNT"
105         ls $SCRATCH_MNT | _filter_lostfound
106
107         _echofull "godown"
108         src/godown -v -f $SCRATCH_MNT >> $seqres.full
109
110         _echofull "unmount"
111         _scratch_unmount >>$seqres.full 2>&1 \
112             || _fail "umount failed"
113
114         _echofull "logprint after going down..."
115         _print_logstate
116
117         _echofull "mount with replay"
118         _scratch_mount >>$seqres.full 2>&1 \
119             || _fail "mount failed: $MOUNT_OPTIONS"
120
121         # check on what FS looks like after log recovery
122         _echofull "ls SCRATCH_MNT"
123         ls $SCRATCH_MNT | _filter_lostfound
124
125         _echofull "unmount"
126         _scratch_unmount
127
128         _echofull "logprint after mount and replay..."
129         _print_logstate
130
131         if _check_scratch_fs; then
132             _echofull "filesystem is checked ok"
133         else
134             _echofull "filesystem is NOT ok"
135         fi
136     done
137 done
138
139 status=0
140 exit