aed3b28c3ceb2de6cc60c63f6bd50ab212c2fcba
[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 _scratch_mkfs >/dev/null 2>&1
83 _require_metadata_journaling $SCRATCH_DEV
84
85 _get_log_configs > $tmp.seq.params
86
87 cat $tmp.seq.params \
88 | while read mkfs mnt restofline
89 do
90     if [ "$mkfs" = "#" ]; then
91         continue
92     fi
93
94     echo "--- mkfs=$mkfs, mnt=$mnt ---" >> $seqres.full
95     export MKFS_OPTIONS="-l $mkfs"
96     export MOUNT_OPTIONS="-o $mnt"
97
98     # mkfs the FS
99     _echofull "mkfs"
100     _scratch_mkfs >>$seqres.full 2>&1
101     if [ $? -ne 0 ] ; then
102         _echofull "mkfs failed: $MKFS_OPTIONS"
103         continue
104     fi
105
106     # mount the FS
107     _echofull "mount"
108     if ! _scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1; then
109         _echofull "mount failed: $MOUNT_OPTIONS"
110         continue
111     fi
112
113     # create the metadata
114     _do_meta
115
116     # check before on what FS should look like
117     _echofull "ls -RF SCRATCH_MNT"
118     ls -RF $SCRATCH_MNT >$tmp.ls1
119
120     _echofull "godown"
121     src/godown -v -f $SCRATCH_MNT >> $seqres.full
122
123     _echofull "unmount"
124     _scratch_unmount >>$seqres.full 2>&1 \
125         || _fail "umount failed"
126
127     _echofull "logprint after going down..."
128     _print_logstate
129
130     _full "logprint headers"
131     _scratch_xfs_logprint -n >>$seqres.full 2>&1
132
133     _echofull "mount with replay"
134     _scratch_mount $QUOTA_OPTION >>$seqres.full 2>&1 \
135         || _fail "mount failed: $MOUNT_OPTIONS"
136
137     # check on what FS looks like after log recovery
138     _echofull "ls -RF SCRATCH_MNT"
139     ls -RF $SCRATCH_MNT >$tmp.ls2
140
141     _echofull "diff ls before and after"
142     diff -us $tmp.ls1 $tmp.ls2 | sed "s#$tmp#TMP#g"
143
144     _echofull "unmount"
145     _scratch_unmount
146
147     _echofull "logprint after mount and replay..."
148     _print_logstate
149
150     if _check_scratch_fs; then
151         _echofull "filesystem is checked ok"
152     else
153         _echofull "filesystem is NOT ok"
154     fi
155 done
156
157 status=0
158 exit