4d4be59ba7018ffbf021ab11a194f6cb92997f88
[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 _scratch_mkfs >/dev/null 2>&1
54 _require_metadata_journaling $SCRATCH_DEV
55
56 _get_log_configs > $tmp.seq.params
57
58 # Do the work for various log params which
59 # should not effect the data content of the log
60 # Try with and without sync'ing - sync'ing will mean that
61 # the log will be written out unfilled and thus the log
62 # stripe can have an effect.
63 #
64 for s in sync nosync ; do
65     cat $tmp.seq.params \
66     | while read mkfs mnt restofline
67     do
68         if [ "$mkfs" = "#" ]; then
69             continue
70         fi
71
72         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---" >>$seqres.full
73         export MKFS_OPTIONS="-l $mkfs"
74         export MOUNT_OPTIONS="-o $mnt"
75
76         # mkfs the FS
77         _echofull "mkfs"
78         _scratch_mkfs >>$seqres.full 2>&1
79         if [ $? -ne 0 ] ; then
80             _echofull "mkfs failed: $MKFS_OPTIONS"
81             continue
82         fi
83
84         # mount the FS
85         _echofull "mount"
86         if ! _scratch_mount >>$seqres.full 2>&1; then
87             _echofull "mount failed: $MOUNT_OPTIONS"
88             continue
89         fi
90
91         # create the metadata
92         if [ $s = "sync" ]; then
93             # generate some log traffic - but not too much
94             # add some syncs to get the log flushed to disk
95             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
96                 touch $file
97                 sync
98             done
99         else
100             # generate some log traffic - but not too much - life gets a little
101             # more complicated if the log wraps around. This traffic is
102             # pretty much arbitary, but could probably be made better than this.
103             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
104         fi
105
106         # check before on what FS should look like
107         _echofull "ls SCRATCH_MNT"
108         ls $SCRATCH_MNT | _filter_lostfound
109
110         _echofull "godown"
111         src/godown -v -f $SCRATCH_MNT >> $seqres.full
112
113         _echofull "unmount"
114         _scratch_unmount >>$seqres.full 2>&1 \
115             || _fail "umount failed"
116
117         _echofull "logprint after going down..."
118         _print_logstate
119
120         _echofull "mount with replay"
121         _scratch_mount >>$seqres.full 2>&1 \
122             || _fail "mount failed: $MOUNT_OPTIONS"
123
124         # check on what FS looks like after log recovery
125         _echofull "ls SCRATCH_MNT"
126         ls $SCRATCH_MNT | _filter_lostfound
127
128         _echofull "unmount"
129         _scratch_unmount
130
131         _echofull "logprint after mount and replay..."
132         _print_logstate
133
134         if _check_scratch_fs; then
135             _echofull "filesystem is checked ok"
136         else
137             _echofull "filesystem is NOT ok"
138         fi
139     done
140 done
141
142 status=0
143 exit