d6547c579436ef565a5ea851bc6b341cb3aaa5d5
[xfstests-dev.git] / tests / ext4 / 301
1 #! /bin/bash
2 # FSQA Test No. 301
3 #
4 # Ext4 defragmentation stress test
5 # Defragment file while other task does direct io
6 #-----------------------------------------------------------------------
7 # (c) 2013 Dmitry Monakhov
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
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
28
29 here=`pwd`
30 tmp=/tmp/$$
31 fio_config=$tmp.fio
32 status=1        # failure is the default!
33 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
34
35 # get standard environment, filters and checks
36 . ./common/rc
37 . ./common/filter
38 . ./common/defrag
39
40 # real QA test starts here
41 _supported_os Linux
42 _supported_fs ext4
43 _need_to_be_root
44 _require_scratch
45 _require_defrag
46
47 NUM_JOBS=$((4*LOAD_FACTOR))
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 >$fio_config <<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
64 #################################
65 # Test1
66 # Defragment file while other task does direct io
67
68 # Continious sequential defrag activity
69 [defrag-4k]
70 ioengine=e4defrag
71 iodepth=1
72 bs=128k
73 donorname=test1.def
74 filename=test1
75 inplace=0
76 rw=write
77 numjobs=${NUM_JOBS}
78 runtime=30*${TIME_FACTOR}
79 time_based
80
81 # Verifier
82 [aio-dio-verifier]
83 ioengine=libaio
84 iodepth=128*${LOAD_FACTOR}
85 numjobs=1
86 verify=crc32c-intel
87 verify_fatal=1
88 verify_dump=1
89 verify_backlog=1024
90 verify_async=1
91 verifysort=1
92 direct=1
93 bs=64k
94 rw=randwrite
95 filename=test1
96 runtime=30*${TIME_FACTOR}
97 time_based
98 EOF
99
100 _workout()
101 {
102         echo ""
103         echo " Start defragment activity"
104         echo ""
105         cat $fio_config >>  $seqres.full
106         run_check $FIO_PROG $fio_config
107 }
108
109 _require_fio $fio_config
110
111 _scratch_mkfs  >> $seqres.full 2>&1
112 _scratch_mount
113
114 if ! _workout; then
115         _scratch_unmount 2>/dev/null
116         exit
117 fi
118
119 if ! _scratch_unmount; then
120         echo "failed to umount"
121         status=1
122         exit
123 fi
124 status=0