xfstests: introduce a common directory
[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 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
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 NUM_JOBS=$((4*LOAD_FACTOR))
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 >$tmp-$seq.fio <<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 group_reporting
65
66 #################################
67 # Test1
68 # Defragment file while other task does direct io
69
70 # Continious sequential defrag activity
71 [defrag-4k]
72 ioengine=e4defrag
73 iodepth=1
74 bs=128k
75 donorname=test1.def
76 filename=test1
77 inplace=0
78 rw=write
79 numjobs=${NUM_JOBS}
80 runtime=30*${TIME_FACTOR}
81 time_based
82
83 # Verifier
84 [aio-dio-verifier]
85 ioengine=libaio
86 iodepth=128*${LOAD_FACTOR}
87 numjobs=1
88 verify=crc32c-intel
89 verify_fatal=1
90 verify_dump=1
91 verify_backlog=1024
92 verify_async=1
93 verifysort=1
94 direct=1
95 bs=64k
96 rw=randwrite
97 filename=test1
98 runtime=30*${TIME_FACTOR}
99 time_based
100 EOF
101
102 _workout()
103 {
104         echo ""
105         echo " Start defragment activity"
106         echo ""
107         cat $tmp-$seq.fio >>  $seqres.full
108         run_check $FIO_PROG $tmp-$seq.fio
109 }
110
111 _require_fio $tmp-$seq.fio
112
113 _scratch_mkfs  >> $seqres.full 2>&1
114 _scratch_mount
115
116 if ! _workout; then
117         umount $SCRATCH_DEV 2>/dev/null
118         exit
119 fi
120
121 if ! _scratch_unmount; then
122         echo "failed to umount"
123         status=1
124         exit
125 fi
126 _check_scratch_fs
127 status=$?