xfstests: introduce 285 for SEEK_DATA/SEEK_HOLE sanity test
[xfstests-dev.git] / 273
1 #! /bin/bash
2 # FS QA Test No. 273
3 #
4 # reservation test with heavy cp workload
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2011-2012 Fujitsu, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24 #creator
25 owner=wu.bo@cn.fujitsu.com
26
27 seq=`basename $0`
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=0        # success is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37         cd /
38         rm -rf $SCRATCH_MNT/* $tmp.*
39         _scratch_unmount
40 }
41
42 . ./common.rc
43 . ./common.filter
44
45 threads=50
46 count=1
47
48 _threads_set()
49 {
50         _cpu_num=`cat /proc/cpuinfo | grep "processor" | wc -l`
51         threads=$(($_cpu_num * 50))
52         if [ $threads -gt 200 ]
53         then
54                 threads=200
55         fi
56 }
57
58 _file_create()
59 {
60         _i=0
61
62         if ! mkdir $SCRATCH_MNT/origin
63         then
64                 echo "mkdir origin err"
65                 status=1
66                 exit
67         fi
68
69         cd $SCRATCH_MNT/origin
70
71         _disksize=`df --block-size=1 | grep $SCRATCH_DEV | awk '{print $2}'`
72         _disksize=$(($_disksize / 3))
73         _num=$(($_disksize / $count / $threads / 4096))
74         _count=$count
75         while [ $_i -lt $_num ]
76         do
77                 dd if=/dev/zero of=file_$_i bs=4096 count=$_count >/dev/null 2>&1
78                 _i=$(($_i + 1))
79         done
80
81         cd $here
82 }
83
84 _porter()
85 {
86         _suffix=$1
87
88         if ! mkdir $SCRATCH_MNT/sub_$_suffix
89         then
90                 echo "mkdir sub_xxx err"
91                 status=1
92                 exit
93         fi
94
95         cp -r $SCRATCH_MNT/origin $SCRATCH_MNT/sub_$_suffix >$seq.full 2>&1
96         if [ $? -ne 0 ]
97         then
98                 echo "_porter $_suffix not complete"
99         fi
100         
101         sync
102 }
103
104 _do_workload()
105 {
106         _pids=""
107         _pid=1
108         
109         rm -rf $SCRATCH_MNT/*
110
111         _threads_set
112         _file_create
113
114         _threads=$threads
115
116         while [ $_pid -lt $_threads ]
117         do
118                 _porter $_pid &
119                 _pids="$_pids $!"
120                 _pid=$(($_pid + 1))
121         done
122
123         wait $_pids
124 }
125
126 # real QA test starts here
127 _supported_fs generic
128 _supported_os IRIX Linux
129 _require_scratch
130
131 echo "------------------------------"
132 echo "start the workload"
133 echo "------------------------------"
134
135 rm -f $seq.full
136
137 umount $SCRATCH_DEV 2>/dev/null
138 _scratch_mkfs_sized $((2 * 1024 * 1024 * 1024)) >>$seq.full 2>&1
139 _scratch_mount
140
141 _do_workload
142
143 _check_scratch_fs
144 status=$?
145 exit