generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / generic / 320
1 #! /bin/bash
2 # FS QA Test No. generic/320
3 #
4 # heavy rm workload
5 #
6 # Regression test for commit:
7 # 9a3a5da xfs: check for stale inode before acquiring iflock on push
8 #
9 # Based on generic/273
10 #
11 #-----------------------------------------------------------------------
12 # Copyright (c) 2011-2012 Fujitsu, Inc.  All Rights Reserved.
13 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
14 #
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
18 #
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22 # GNU General Public License for more details.
23 #
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
27 #
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -rf $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49
50 # real QA test starts here
51 _supported_fs generic
52 _supported_os IRIX Linux
53 _require_scratch
54
55 threads=100
56 count=2
57 fs_size=$((2 * 1024 * 1024 * 1024))
58 ORIGIN=$SCRATCH_MNT/origin
59
60 threads_set()
61 {
62         threads=$((LOAD_FACTOR * 100))
63         if [ $threads -gt 200 ]
64         then
65                 threads=200
66         fi
67 }
68
69 file_create()
70 {
71         i=0
72         mkdir $ORIGIN
73
74         disksize=$(($fs_size / 3))
75         num=$(($disksize / $count / $threads / 4096))
76         while [ $i -lt $num ]; do
77                 $XFS_IO_PROG -f -c "pwrite 0 $((4096*count))" \
78                         $ORIGIN/file_$i >>$seqres.full 2>&1
79                 i=$(($i + 1))
80         done
81 }
82
83 worker()
84 {
85         suffix=$1
86
87         mkdir $SCRATCH_MNT/sub_$suffix
88
89         cp -r $ORIGIN/* $SCRATCH_MNT/sub_$suffix >>$seqres.full 2>&1
90         rm -rf $SCRATCH_MNT/sub_$suffix
91 }
92
93 do_workload()
94 {
95         pids=""
96         loop=1
97
98         threads_set
99         file_create
100
101         while [ $loop -lt $threads ]; do
102                 worker $loop &
103                 pids="$pids $!"
104                 loop=$(($loop + 1))
105         done
106
107         wait $pids
108 }
109
110 echo "Silence is golden"
111
112 rm -f $seqres.full
113
114 _scratch_mkfs_sized $fs_size >>$seqres.full 2>&1
115 _scratch_mount >>$seqres.full 2>&1
116
117 do_workload
118
119 status=0
120 exit