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