dc19c3a4c033a66a4d2bc93b73ca084c48f05682
[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 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36 . ./common.defrag
37
38 # real QA test starts here
39 _supported_os Linux
40 _supported_fs ext4
41 _need_to_be_root
42 _require_scratch
43 _require_defrag
44
45 NUM_JOBS=$((4*LOAD_FACTOR))
46 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
47 # We need space for 2 files (test file, and donor one)
48 # reserve 30% in order to avoid ENOSPC
49 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (2 + 1))))
50
51 cat >$tmp-$seq.fio <<EOF
52 # Common e4defrag regression tests
53 [global]
54 ioengine=ioe_e4defrag
55 iodepth=1
56 directory=${SCRATCH_MNT}
57 filesize=${FILE_SIZE}
58 size=999G
59 buffered=0
60 fadvise_hint=0
61 group_reporting
62
63 #################################
64 # Test1
65 # Defragment file while other task does direct io
66
67 # Continious sequential defrag activity
68 [defrag-4k]
69 ioengine=e4defrag
70 iodepth=1
71 bs=128k
72 donorname=test1.def
73 filename=test1
74 inplace=0
75 rw=write
76 numjobs=${NUM_JOBS}
77 runtime=30*${TIME_FACTOR}
78 time_based
79
80 # Verifier
81 [aio-dio-verifier]
82 ioengine=libaio
83 iodepth=128*${LOAD_FACTOR}
84 numjobs=1
85 verify=crc32c-intel
86 verify_fatal=1
87 verify_dump=1
88 verify_backlog=1024
89 verify_async=1
90 verifysort=1
91 direct=1
92 bs=64k
93 rw=randwrite
94 filename=test1
95 runtime=30*${TIME_FACTOR}
96 time_based
97 EOF
98
99 _workout()
100 {
101         echo ""
102         echo " Start defragment activity"
103         echo ""
104         cat $tmp-$seq.fio >>  $seq.full
105         run_check $FIO_PROG $tmp-$seq.fio
106 }
107
108 _require_fio $tmp-$seq.fio
109
110 _scratch_mkfs  >> $seq.full 2>&1
111 _scratch_mount
112
113 if ! _workout; then
114         umount $SCRATCH_DEV 2>/dev/null
115         exit
116 fi
117
118 if ! _scratch_unmount; then
119         echo "failed to umount"
120         status=1
121         exit
122 fi
123 _check_scratch_fs
124 status=$?