xfstests: move generic tests out of top level dir
[xfstests-dev.git] / 086
1 #! /bin/bash
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
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 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common.rc
37 . ./common.filter
38 . ./common.log
39
40 # real QA test starts here
41 _supported_fs xfs
42 _supported_os IRIX Linux
43
44 rm -f $seq.full $tmp.*
45 _require_scratch
46 _require_v2log
47
48 echo "*** init FS"
49 umount $SCRATCH_DEV >/dev/null 2>&1
50
51 cat >$tmp.seq.params <<EOF
52 # mkfs-opt             mount-opt
53 # ------------------------------
54   version=2            logbsize=32k
55   version=2,su=4096    logbsize=32k
56   version=2,su=32768   logbsize=32k
57   version=2,su=32768   logbsize=64k
58   version=2            logbsize=64k
59   version=2,su=64k     logbsize=64k
60   version=2            logbsize=128k
61   version=2,su=128k    logbsize=128k
62   version=2            logbsize=256k
63   version=2,su=256k    logbsize=256k
64 EOF
65
66 # Do the work for various log params which
67 # should not effect the data content of the log
68 # Try with and without sync'ing - sync'ing will mean that
69 # the log will be written out unfilled and thus the log 
70 # stripe can have an effect.
71 #
72 for s in sync nosync ; do
73     cat $tmp.seq.params \
74     | while read mkfs mnt restofline
75     do
76         if [ "$mkfs" = "#" ]; then 
77             continue
78         fi
79
80         echo "--- mkfs=$mkfs, mnt=$mnt, sync=$s ---"
81         export MKFS_OPTIONS="-l $mkfs"
82         export MOUNT_OPTIONS="-o $mnt"
83
84         # mkfs the FS
85         _echofull "mkfs"
86         _scratch_mkfs_xfs >>$seq.full 2>&1
87         if [ $? -ne 0 ] ; then 
88             _echofull "mkfs failed: $MKFS_OPTIONS"
89             continue
90         fi
91
92         # mount the FS
93         _echofull "mount"
94         if ! _scratch_mount >>$seq.full 2>&1; then
95             _echofull "mount failed: $MOUNT_OPTIONS"
96             continue
97         fi
98
99         # create the metadata
100         if [ $s = "sync" ]; then
101             # generate some log traffic - but not too much
102             # add some syncs to get the log flushed to disk 
103             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
104                 touch $file
105                 sync
106             done
107         else
108             # generate some log traffic - but not too much - life gets a little
109             # more complicated if the log wraps around. This traffic is
110             # pretty much arbitary, but could probably be made better than this.
111             touch $SCRATCH_MNT/{0,1,2,3,4,5,6,7,8,9}{0,1,2,3,4,5,6,7,8,9}
112         fi
113
114         # check before on what FS should look like
115         _echofull "ls SCRATCH_MNT"
116         ls $SCRATCH_MNT
117
118         _echofull "godown"
119         src/godown -v -f $SCRATCH_MNT >> $seq.full
120
121         _echofull "unmount"
122         umount $SCRATCH_DEV >>$seq.full 2>&1 \
123             || _fail "umount failed"
124
125         _echofull "logprint after going down..."
126         _print_logstate
127
128         _echofull "mount with replay"
129         _scratch_mount >>$seq.full 2>&1 \
130             || _fail "mount failed: $MOUNT_OPTIONS"
131
132         # check on what FS looks like after log recovery
133         _echofull "ls SCRATCH_MNT"
134         ls $SCRATCH_MNT
135
136         _echofull "unmount"
137         umount $SCRATCH_MNT
138
139         _echofull "logprint after mount and replay..."
140         _print_logstate
141
142         if _check_scratch_fs; then
143             _echofull "filesystem is checked ok"
144         else
145             _echofull "filesystem is NOT ok"
146         fi
147     done
148 done
149
150 status=0 
151 exit