e3dceb8d331e32e993a181b0f251c1ce85a11385
[xfstests-dev.git] / 302
1 #! /bin/bash
2 # FSQA Test No. 302
3 #
4 # Ext4 defragmentation stress test
5 # Perform defragmentation on file under buffered io
6 # while third task does direct io to donor file
7 #-----------------------------------------------------------------------
8 # (c) 2013 Dmitry Monakhov
9 #
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
13 #
14 # This program is distributed in the hope that it would 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 the Free Software Foundation,
21 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22 #
23 #-----------------------------------------------------------------------
24 #
25 # creator
26 owner=dmonakhov@openvz.org
27
28 seq=`basename $0`
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common.rc
38 . ./common.filter
39 . ./common.defrag
40
41 # real QA test starts here
42 _supported_os Linux
43 _supported_fs ext4
44 _need_to_be_root
45 _require_scratch
46 _require_defrag
47
48 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
49 # We need space for 2 files (test file, and donor one)
50 # reserve 30% in order to avoid ENOSPC
51 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (2 + 1))))
52
53 cat >$tmp-$seq.fio <<EOF
54 # Common e4defrag regression tests
55 [global]
56 ioengine=ioe_e4defrag
57 iodepth=1
58 directory=${SCRATCH_MNT}
59 filesize=${FILE_SIZE}
60 size=999G
61 buffered=0
62 fadvise_hint=0
63 group_reporting
64
65 ##########################################
66 # Test2
67 # Perform defragmentation on file under buffered io
68 # while third task does direct io to donor file
69 #
70 # Continuous sequential defrag activity
71 [defrag-4k]
72 stonewall
73 ioengine=e4defrag
74 iodepth=1
75 bs=128k
76 donorname=test2.def
77 filename=test2
78 inplace=0
79 rw=write
80 numjobs=${LOAD_FACTOR}
81 runtime=30*${TIME_FACTOR}
82 time_based
83
84 # Run DIO/AIO for donor file
85 [donor-file-fuzzer]
86 ioengine=libaio
87 iodepth=128*${LOAD_FACTOR}
88 numjobs=${LOAD_FACTOR}
89 verify=0
90 direct=1
91 bs=64k
92 rw=randwrite
93 filename=test2.def
94 runtime=30*${TIME_FACTOR}
95 time_based
96
97 # Verifier thread
98 [aio-dio-verifier]
99 ioengine=libaio
100 iodepth=128*${LOAD_FACTOR}
101 numjobs=1
102 verify=crc32c-intel
103 verify_fatal=1
104 verify_dump=1
105 verify_backlog=1024
106 verify_async=1
107 verifysort=1
108 buffered=1
109 bs=64k
110 rw=randrw
111 filename=test2
112 runtime=30*${TIME_FACTOR}
113 time_based
114
115 EOF
116
117 _workout()
118 {
119         echo ""
120         echo " Start defragment activity"
121         echo ""
122         cat $tmp-$seq.fio >>  $seq.full
123         run_check $FIO_PROG $tmp-$seq.fio
124 }
125
126 _require_fio $tmp-$seq.fio
127
128 _scratch_mkfs  >> $seq.full 2>&1
129 _scratch_mount
130
131 if ! _workout; then
132         umount $SCRATCH_DEV 2>/dev/null
133         exit
134 fi
135
136 if ! _scratch_unmount; then
137         echo "failed to umount"
138         status=1
139         exit
140 fi
141 _check_scratch_fs
142 status=$?
143 exit