Handle EBUSY errors from the optional-extra advisory file locking.
[xfstests-dev.git] / 087
1 #! /bin/sh
2 # XFS 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 modify it
12 # under the terms of version 2 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, but
16 # WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
19 # Further, this software is distributed without any warranty that it is
20 # free of the rightful claim of any third person regarding infringement
21 # or the like.  Any license provided herein, whether implied or
22 # otherwise, applies only to this software file.  Patent licenses, if
23 # any, provided herein do not apply to combinations of this program with
24 # other software, or any other product whatsoever.
25
26 # You should have received a copy of the GNU General Public License along
27 # with this program; if not, write the Free Software Foundation, Inc., 59
28 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
29
30 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
31 # Mountain View, CA  94043, or:
32
33 # http://www.sgi.com 
34
35 # For further information regarding this notice, see: 
36
37 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
38 #-----------------------------------------------------------------------
39 #
40 # creator
41 owner=tes@melbourne.sgi.com
42
43 seq=`basename $0`
44 echo "QA output created by $seq"
45
46 here=`pwd`
47 tmp=/tmp/$$
48 status=1        # failure is the default!
49 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
50
51 # get standard environment, filters and checks
52 . ./common.rc
53 . ./common.filter
54 . ./common.log
55
56 _do_meta()
57 {
58     out=$SCRATCH_MNT/fsstress
59     count=10000
60     param="-p 4 -z -f rmdir=10 -f link=10 -f creat=10 -f mkdir=10 \
61            -f rename=30 -f stat=30 -f unlink=30 -f truncate=20"
62     _echofull "calling fsstress $param -m8 -n $count"
63     if ! time $here/ltp/fsstress $param $FSSTRESS_AVOID -m 8 -n $count -d $out >>$seq.full 2>&1
64     then
65         _echofull "fsstress failed"
66     fi
67 }
68
69 # real QA test starts here
70 rm -f $seq.full $tmp.*
71 _require_scratch
72
73 echo "*** init FS"
74 umount $SCRATCH_DEV >/dev/null 2>&1
75
76 cat >$tmp.seq.params <<EOF
77 # mkfs-opt             mount-opt
78   -lversion=2          -ologbsize=32k
79   -lversion=2,su=4096  -ologbsize=32k
80   -lversion=2,su=32768 -ologbsize=32k
81   -lversion=2          -ologbsize=64k
82 EOF
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 ---"
92     export MOUNT_OPTIONS=$mnt
93     export MKFS_OPTIONS=$mkfs
94
95     # mkfs the FS
96     _echofull "mkfs"
97     if ! _mkfs_log; then
98         _echofull "mkfs failed: $MKFS_OPTIONS"
99         continue
100     fi
101
102     # mount the FS
103     _echofull "mount"
104     if ! _scratch_mount >>$seq.full 2>&1; then
105         _echofull "mount failed: $MOUNT_OPTIONS"
106         continue
107     fi
108
109     # create the metadata
110     _do_meta
111
112     # check before on what FS should look like
113     _echofull "ls -RF SCRATCH_MNT"
114     ls -RF $SCRATCH_MNT >$tmp.ls1
115
116     _echofull "godown"
117     src/godown -v -f $SCRATCH_MNT >> $seq.full
118
119     _echofull "unmount"
120     umount $SCRATCH_DEV >>$seq.full 2>&1 \
121         || _fail "umount failed"
122
123     _echofull "logprint after going down..."
124     _print_logstate
125
126     _full "logprint headers"
127     _scratch_xfs_logprint -n >>$seq.full 2>&1
128
129     _echofull "mount with replay"
130     _scratch_mount >>$seq.full 2>&1 \
131         || _fail "mount failed: $MOUNT_OPTIONS"
132
133     # check on what FS looks like after log recovery
134     _echofull "ls -RF SCRATCH_MNT"
135     ls -RF $SCRATCH_MNT >$tmp.ls2
136
137     _echofull "diff ls before and after"
138     diff -us $tmp.ls1 $tmp.ls2 | sed "s#$tmp#TMP#g"
139
140     _echofull "unmount"
141     umount $SCRATCH_MNT
142
143     _echofull "logprint after mount and replay..."
144     _print_logstate
145
146     if _check_scratch_fs; then
147         _echofull "filesystem is checked ok"
148     else
149         _echofull "filesystem is NOT ok"
150     fi
151 done
152
153 status=0 
154 exit