5287ab5d1ed5fcfb8b0f7a326d67d8c202e40699
[xfstests-dev.git] / tests / ext4 / 304
1 #! /bin/bash
2 # FSQA Test No. 304
3 #
4 # Ext4 defragmentation stress test
5 # Several threads perform defragmentation at random position
6 # using 'inplace' mode (allocate and free blocks inside defrag event)
7 # which significantly improve load pressure on block allocator.
8 #-----------------------------------------------------------------------
9 # (c) 2013 Dmitry Monakhov
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
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 fio_config=$tmp.fio
34 status=1        # failure is the default!
35 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
36
37 # get standard environment, filters and checks
38 . ./common/rc
39 . ./common/filter
40 . ./common/defrag
41
42 # real QA test starts here
43 _supported_os Linux
44 _supported_fs ext4
45 _require_scratch
46 _require_defrag
47 _require_odirect
48
49 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
50 # We need space for 2 files (test file, and donor one)
51 # reserve 30% in order to avoid ENOSPC
52 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (2 + 1))))
53
54 cat >$fio_config <<EOF
55 # Common e4defrag regression tests
56 [global]
57 ioengine=ioe_e4defrag
58 iodepth=1
59 directory=${SCRATCH_MNT}
60 filesize=${FILE_SIZE}
61 size=999G
62 buffered=0
63 fadvise_hint=0
64 continue_on_error=write
65 ignore_error=,EINVAL:61
66
67 #################################
68 # Test4
69 # Stress test defragmentation engine
70 # Several threads perform defragmentation at random position
71 # use inplace=1 will allocate and free blocks inside defrag event
72 # which highly increase defragmentation
73 [defrag-fuzzer]
74 ioengine=e4defrag
75 iodepth=1
76 bs=8k
77 donorname=test4.def
78 filename=test4
79 inplace=1
80 rw=randwrite
81 numjobs=4*${LOAD_FACTOR}
82 runtime=30*${TIME_FACTOR}
83 time_based
84
85 [aio-dio-verifier]
86 ioengine=libaio
87 iodepth=128
88 iomem_align=4k
89 numjobs=1
90 verify=crc32c-intel
91 verify_fatal=1
92 verify_dump=1
93 verify_backlog=1024
94 verify_async=1
95 verifysort=1
96 direct=1
97 bs=64k
98 rw=write
99 filename=test4
100 runtime=30*${TIME_FACTOR}
101 time_based
102
103 EOF
104
105 _workout()
106 {
107         echo ""
108         echo " Start defragment activity"
109         echo ""
110         cat $fio_config >>  $seqres.full
111         run_check $FIO_PROG $fio_config
112 }
113
114 _require_fio $fio_config
115
116 rm -f $seqres.full
117 _scratch_mkfs  >> $seqres.full 2>&1
118 _scratch_mount
119
120 if ! _workout; then
121         _scratch_unmount 2>/dev/null
122         exit
123 fi
124
125 if ! _scratch_unmount; then
126         echo "failed to umount"
127         status=1
128         exit
129 fi
130 status=0
131 exit