common: Check the file system consistency on SCRATCH_DEV
[xfstests-dev.git] / tests / ext4 / 303
1 #! /bin/bash
2 # FSQA Test No. 303
3 #
4 # Ext4 defragmentation stress test
5 # Two defrag tasks use common donor file
6 #
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
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 fio_config=$tmp.fio
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 3 files (one donor file and two test files)
50 # Reserve space for 4 files in order to avoid ENOSPC
51 FILE_SIZE=$((BLK_DEV_SIZE * (512 / (3+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 # Test3
66 # Two defrag tasks use common donor file
67 [defrag-1]
68 ioengine=e4defrag
69 iodepth=1
70 bs=128k
71 donorname=test3.def
72 filename=test31
73 inplace=0
74 rw=write
75 numjobs=${LOAD_FACTOR}
76 runtime=30*${TIME_FACTOR}
77 time_based
78
79 [defrag-2]
80 ioengine=e4defrag
81 iodepth=1
82 bs=128k
83 donorname=test3.def
84 filename=test32
85 inplace=0
86 rw=write
87 numjobs=${LOAD_FACTOR}
88 runtime=30*${TIME_FACTOR}
89 time_based
90
91 [aio-dio-verifier-1]
92 ioengine=libaio
93 iodepth=128*${LOAD_FACTOR}
94 numjobs=1
95 verify=crc32c-intel
96 verify_fatal=1
97 verify_dump=1
98 verify_backlog=1024
99 verify_async=1
100 verifysort=1
101 direct=1
102 bs=64k
103 rw=write
104 filename=test31
105 runtime=30*${TIME_FACTOR}
106 time_based
107
108 [aio-buffer-verifier-2]
109 ioengine=libaio
110 numjobs=1
111 verify=crc32c-intel
112 verify_fatal=1
113 verify_dump=1
114 verify_backlog=1024
115 verify_async=1
116 verifysort=1
117 buffered=1
118 bs=64k
119 rw=randrw
120 filename=test32
121 runtime=30*${TIME_FACTOR}
122 time_based
123
124 EOF
125
126 _workout()
127 {
128         echo ""
129         echo " Start defragment activity"
130         echo ""
131         cat $fio_config >>  $seqres.full
132         run_check $FIO_PROG $fio_config
133 }
134
135 _require_fio $fio_config
136
137 _scratch_mkfs  >> $seqres.full 2>&1
138 _scratch_mount
139
140 if ! _workout; then
141         umount $SCRATCH_DEV 2>/dev/null
142         exit
143 fi
144
145 if ! _scratch_unmount; then
146         echo "failed to umount"
147         status=1
148         exit
149 fi
150 status=0
151 exit