xfstests: move xfs specific tests out of top directory
[xfstests-dev.git] / tests / xfs / 297
1 #! /bin/bash
2 # FS QA Test No. 297
3 #
4 # Test freeze/unfreeze file system randomly under fsstress
5 # Regression test for commit:
6 # 437a255 xfs: fix direct IO nested transaction deadlock.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 Red Hat, 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 seq=`basename $0`
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 status=1        # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
33
34 _cleanup()
35 {
36     cd /
37     rm -f $tmp.*
38 }
39
40 # get standard environment, filters and checks
41 . ./common.rc
42 . ./common.filter
43
44 # real QA test starts here
45 _supported_fs xfs
46 _supported_os IRIX Linux
47
48 _require_scratch
49 _require_freeze
50
51 rm -f $seq.full
52 _scratch_mkfs_xfs -d agcount=16,su=256k,sw=12 -l su=256k,size=2560b >/dev/null 2>&1
53 _scratch_mount >/dev/null 2>&1
54
55 STRESS_DIR="$SCRATCH_MNT/testdir"
56 mkdir -p $STRESS_DIR
57
58 $FSSTRESS_PROG -d $STRESS_DIR -n 100 -p 1000 $FSSTRESS_AVOID >/dev/null 2>&1 &
59
60 # Freeze/unfreeze file system randomly
61 echo "Start freeze/unfreeze randomly" | tee -a $seq.full
62 LOOP=10
63 while [ $LOOP -gt 0 ];do
64         TIMEOUT=`expr $RANDOM % 5`
65         sleep $TIMEOUT
66         echo "* Freeze file system after sleeping $TIMEOUT seconds" >>$seq.full
67         xfs_freeze -f $SCRATCH_MNT
68         if [ $? -ne 0 ];then
69                 echo " - Error: freeze filesystem failed" | tee -a $seq.full
70         fi
71         TIMEOUT=`expr $RANDOM % 3`
72         sleep $TIMEOUT
73         echo "* Unfreeze file system after sleeping $TIMEOUT seconds" >>$seq.full
74         xfs_freeze -u $SCRATCH_MNT
75         if [ $? -ne 0 ];then
76                 echo " - Error: unfreeze filesystem failed" | tee -a $seq.full
77         fi
78         let LOOP=$LOOP-1
79 done
80 echo "Test done" | tee -a $seq.full
81 killall -q $FSSTRESS_PROG
82 wait
83
84 _check_scratch_fs
85 status=0
86 exit