Add comments, diganostics, pass back some errors from funcs.
[xfstests-dev.git] / 068
1 #! /bin/sh
2 # FSQA Test No. 068
3 #
4 # Test case to reproduce xfs_freeze hang under filsystem load.
5 # The fail case for this test is a hang on an xfs_freeze.
6 #
7 #-----------------------------------------------------------------------
8 #  Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
9 #  This program is free software; you can redistribute it and/or modify
10 #  it under the terms of the GNU General Public License as published by
11 #  the Free Software Foundation; either version 2 of the License, or
12 #  (at your option) any later version.
13 #
14 #  This program is distributed in the hope that it will be useful,
15 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 #  GNU General Public License for more details.
18 #
19 #  You should have received a copy of the GNU General Public License
20 #  along with this program; if not, write to the Free Software
21 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
22 #  USA
23 #
24 #  Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
25 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
26 #-----------------------------------------------------------------------
27 #
28 # creator
29 owner=ajones@sgi.com
30
31 seq=`basename $0`
32 echo "QA output created by $seq"
33
34 here=`pwd`
35 tmp=/tmp/$$
36 status=0        # success is the default!
37
38 ITERATIONS=10
39
40 _cleanup()
41 {
42     cd /
43     _cleanup_testdir
44
45     trap 0 1 2 3 15
46     exit $status
47 }
48
49 trap "_cleanup" 0 1 2 3 15
50
51
52 # get standard environment, filters and checks
53 . ./common.rc
54 . ./common.filter
55
56 # real QA test starts here
57 _supported_fs xfs
58 _supported_os Linux IRIX
59
60 _require_scratch
61
62 echo "*** init FS"
63
64 rm -f $seq.full
65 umount $SCRATCH_DEV >/dev/null 2>&1
66 echo "*** MKFS ***"                         >>$seq.full
67 echo ""                                     >>$seq.full
68 _scratch_mkfs_xfs                           >>$seq.full 2>&1 \
69     || _fail "mkfs failed"
70 _scratch_mount                              >>$seq.full 2>&1 \
71     || _fail "mount failed"
72
73 touch $tmp.running
74
75
76 # start fsstress loop in a background block
77 {
78     STRESS_DIR="$SCRATCH_MNT/fsstress_test_dir"
79     mkdir "$STRESS_DIR"
80
81     procs=2
82     nops=200
83     while [ -f "$tmp.running" ]
84       do
85       # -w ensures that the only ops are ones which cause write I/O
86       ltp/fsstress -d $STRESS_DIR -w -p $procs -n $nops $FSSTRESS_AVOID \
87           > /dev/null 2>&1
88     done
89
90     rm -r $STRESS_DIR/*
91     rmdir $STRESS_DIR
92 } &
93
94 i=0
95 ITERATIONS=`expr $ITERATIONS - 1`
96
97 echo | tee -a $seq.full
98 while [ $i -le $ITERATIONS ]
99 do
100         echo "*** iteration: $i" | tee -a $seq.full
101         echo "*** freezing \$SCRATCH_MNT" | tee -a $seq.full
102         xfs_freeze -f "$SCRATCH_MNT" | tee -a $seq.full
103         [ $? != 0 ] && echo xfs_freeze -f "$SCRATCH_MNT" failed | \
104             tee -a $seq.full
105         sleep 2
106
107         echo "*** thawing  \$SCRATCH_MNT" | tee -a $seq.full
108         xfs_freeze -u "$SCRATCH_MNT" | tee -a $seq.full
109         [ $? != 0 ] && echo xfs_freeze -u "$SCRATCH_MNT" failed | \
110             tee -a $seq.full
111         sleep 2
112
113         echo  | tee -a $seq.full
114         i=`expr $i + 1`
115 done
116
117 # stop fsstress iterations
118 rm $tmp.running
119
120 # wait for fsstresses to finish
121 wait
122
123 _check_scratch_fs
124
125 exit 1