Add a test for ENOSPC when fallocating.
[xfstests-dev.git] / 087
1 #! /bin/sh
2 # FS QA Test No. 087
3 #
4 # * like 086 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 # creator
27 owner=tes@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 _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     if ! $FSSTRESS_PROG $param $FSSTRESS_AVOID -m 8 -n $count -d $out >>$seq.full 2>&1
50     then
51         _echofull "fsstress failed"
52     fi
53 }
54
55 # real QA test starts here
56 _supported_fs xfs
57 _supported_os IRIX Linux
58
59 rm -f $seq.full $tmp.*
60 _require_scratch
61 _require_v2log 
62
63 echo "*** init FS"
64 umount $SCRATCH_DEV >/dev/null 2>&1
65
66 cat >$tmp.seq.params <<EOF
67 # mkfs-opt             mount-opt
68 # ------------------------------
69   version=2            logbsize=32k
70   version=2,su=4096    logbsize=32k
71   version=2,su=32768   logbsize=32k
72   version=2            logbsize=64k
73   version=2,su=64k     logbsize=64k
74   version=2            logbsize=128k
75   version=2,su=128k    logbsize=128k
76   version=2            logbsize=256k
77   version=2,su=256k    logbsize=256k
78 EOF
79
80 cat $tmp.seq.params \
81 | while read mkfs mnt restofline
82 do
83     if [ "$mkfs" = "#" ]; then 
84         continue
85     fi
86
87     echo "--- mkfs=$mkfs, mnt=$mnt ---"
88     export MKFS_OPTIONS="-l $mkfs"
89     export MOUNT_OPTIONS="-o $mnt"
90
91     # mkfs the FS
92     _echofull "mkfs"
93     _scratch_mkfs_xfs >>$seq.full 2>&1
94     if [ $? -ne 0 ] ; then 
95         _echofull "mkfs failed: $MKFS_OPTIONS"
96         continue
97     fi
98
99     # mount the FS
100     _echofull "mount"
101     if ! _scratch_mount >>$seq.full 2>&1; then
102         _echofull "mount failed: $MOUNT_OPTIONS"
103         continue
104     fi
105
106     # create the metadata
107     _do_meta
108
109     # check before on what FS should look like
110     _echofull "ls -RF SCRATCH_MNT"
111     ls -RF $SCRATCH_MNT >$tmp.ls1
112
113     _echofull "godown"
114     src/godown -v -f $SCRATCH_MNT >> $seq.full
115
116     _echofull "unmount"
117     umount $SCRATCH_DEV >>$seq.full 2>&1 \
118         || _fail "umount failed"
119
120     _echofull "logprint after going down..."
121     _print_logstate
122
123     _full "logprint headers"
124     _scratch_xfs_logprint -n >>$seq.full 2>&1
125
126     _echofull "mount with replay"
127     _scratch_mount >>$seq.full 2>&1 \
128         || _fail "mount failed: $MOUNT_OPTIONS"
129
130     # check on what FS looks like after log recovery
131     _echofull "ls -RF SCRATCH_MNT"
132     ls -RF $SCRATCH_MNT >$tmp.ls2
133
134     _echofull "diff ls before and after"
135     diff -us $tmp.ls1 $tmp.ls2 | sed "s#$tmp#TMP#g"
136
137     _echofull "unmount"
138     umount $SCRATCH_MNT
139
140     _echofull "logprint after mount and replay..."
141     _print_logstate
142
143     if _check_scratch_fs; then
144         _echofull "filesystem is checked ok"
145     else
146         _echofull "filesystem is NOT ok"
147     fi
148 done
149
150 status=0 
151 exit