generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 055
1 #! /bin/bash
2 # FS QA Test No. 055
3 #
4 # * like 054 but want to create more/different kinds of metadata
5 #   and so will use fsstress
6 # * also can interrupt metadata with godown
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 . ./common/quota
41
42 _do_meta()
43 {
44     out=$SCRATCH_MNT/fsstress
45     count=10000
46     param="-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
47            -f rename=30 -f stat=30 -f unlink=30 -f truncate=20"
48     _echofull "calling fsstress $param -m8 -n $count"
49     FSSTRESS_ARGS=`_scale_fsstress_args $param $FSSTRESS_AVOID -m 8 -n $count -d $out`
50     if ! $FSSTRESS_PROG $FSSTRESS_ARGS >>$seqres.full 2>&1
51     then
52         _echofull "fsstress failed"
53     fi
54 }
55
56 _get_quota_option()
57 {
58     case $FSTYP in
59     xfs)
60         _require_xfs_quota
61         echo "-o uquota"
62         ;;
63     *)
64         ;;
65     esac
66 }
67
68 # real QA test starts here
69 _supported_fs generic
70 _supported_os IRIX Linux
71
72 rm -f $seqres.full $tmp.*
73 _require_scratch
74 _require_scratch_shutdown
75 _require_logstate
76
77 QUOTA_OPTION=`_get_quota_option`
78
79 echo "*** init FS"
80 _scratch_unmount >/dev/null 2>&1
81
82 _get_log_configs > $tmp.seq.params
83
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 ---" >> $seqres.full
92     export MKFS_OPTIONS="-l $mkfs"
93     export MOUNT_OPTIONS="-o $mnt"
94
95     # mkfs the FS
96     _echofull "mkfs"
97     _scratch_mkfs >>$seqres.full 2>&1
98     if [ $? -ne 0 ] ; then
99         _echofull "mkfs failed: $MKFS_OPTIONS"
100         continue
101     fi
102
103     # mount the FS
104     _echofull "mount"
105     if ! _scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1; then
106         _echofull "mount failed: $MOUNT_OPTIONS"
107         continue
108     fi
109
110     # create the metadata
111     _do_meta
112
113     # check before on what FS should look like
114     _echofull "ls -RF SCRATCH_MNT"
115     ls -RF $SCRATCH_MNT >$tmp.ls1
116
117     _echofull "godown"
118     src/godown -v -f $SCRATCH_MNT >> $seqres.full
119
120     _echofull "unmount"
121     _scratch_unmount >>$seqres.full 2>&1 \
122         || _fail "umount failed"
123
124     _echofull "logprint after going down..."
125     _print_logstate
126
127     _full "logprint headers"
128     _scratch_xfs_logprint -n >>$seqres.full 2>&1
129
130     _echofull "mount with replay"
131     _scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1 \
132         || _fail "mount failed: $MOUNT_OPTIONS"
133
134     # check on what FS looks like after log recovery
135     _echofull "ls -RF SCRATCH_MNT"
136     ls -RF $SCRATCH_MNT >$tmp.ls2
137
138     _echofull "diff ls before and after"
139     diff -us $tmp.ls1 $tmp.ls2 | sed "s#$tmp#TMP#g"
140
141     _echofull "unmount"
142     _scratch_unmount
143
144     _echofull "logprint after mount and replay..."
145     _print_logstate
146
147     if _check_scratch_fs; then
148         _echofull "filesystem is checked ok"
149     else
150         _echofull "filesystem is NOT ok"
151     fi
152 done
153
154 status=0
155 exit