reflink: ensure that we can handle reflinking a lot of extents
[xfstests-dev.git] / tests / generic / 300
1 #! /bin/bash
2 # FSQA Test No. 300
3 #
4 # AIO/DIO stress test
5 # Run random AIO/DIO activity and fallocate/punch_hole simultaneously
6 # Test will operate on huge sparsed file so ENOSPC is expected.
7 #
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
41 # real QA test starts here
42 _supported_fs generic
43 _supported_os Linux
44 _need_to_be_root
45 _require_scratch
46 _require_odirect
47
48 # xfs_io is not required for this test, but it's the best way to verify
49 # the test system supports fallocate() for allocation and hole punching
50 _require_xfs_io_command "falloc"
51 _require_xfs_io_command "fpunch"
52
53 rm -f $seqres.full
54
55 NUM_JOBS=$((4*LOAD_FACTOR))
56 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
57 if [ $((BLK_DEV_SIZE)) -gt 1048576 ]
58 then
59     BLK_DEV_SIZE=1048576
60 fi
61 FS_SIZE=$((BLK_DEV_SIZE * 512))
62
63 cat >$fio_config <<EOF
64 ###########
65 # $seq test fio activity
66 # Run DIO, fallocate and punch_hole threads on a single in parallel
67 #
68 # If race exist old dio request may rewrite punched block after it was
69 # allocated to another file, we will catch that by verifying blocks content
70 #
71 [global]
72 directory=${SCRATCH_MNT}
73 filesize=${FS_SIZE}
74 size=999G
75 continue_on_error=write
76 ignore_error=,ENOSPC
77 error_dump=0
78
79 create_on_open=1
80 fallocate=none
81 exitall=1
82
83 ## Perform direct aio, to files which may be truncated
84 ## by external task
85 [direct_aio_raicer]
86 ioengine=libaio
87 iodepth=128*${LOAD_FACTOR}
88 bs=128k
89 direct=1
90 numjobs=${NUM_JOBS}
91 rw=randwrite
92 runtime=100*${TIME_FACTOR}
93 time_based
94 filename=racer
95
96 # Run falloc and punch_hole threads in parallel
97 # After activity file will be highly fragmented
98 [falloc_raicer]
99 ioengine=falloc
100 runtime=100*${TIME_FACTOR}
101 iodepth=1
102 bssplit=128k/80:512k/10:32k/10
103 rw=randwrite
104 numjobs=1
105 filename=racer
106
107 [punch_hole_raicer]
108 ioengine=falloc
109 runtime=100*${TIME_FACTOR}
110 bs=4k
111 time_based=10
112 rw=randtrim
113 numjobs=2
114 filename=racer
115 time_based
116
117 # Verifier thread continiously write to newly allcated blocks
118 # and veryfy written content
119 [aio-dio-verifier]
120 ioengine=libaio
121 iodepth=128*${LOAD_FACTOR}
122 numjobs=1
123 verify=crc32c-intel
124 verify_fatal=1
125 verify_dump=1
126 verify_backlog=1024
127 verify_async=4
128 verifysort=1
129 direct=1
130 bs=4k
131 rw=randwrite
132 filename=aio-dio-verifier
133 EOF
134
135 _workout()
136 {
137         echo ""
138         echo "Run fio with random aio-dio pattern"
139         echo ""
140         cat $fio_config >>  $seqres.full
141         run_check $FIO_PROG $fio_config
142 }
143
144 _require_fio $fio_config
145
146 _scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
147 _scratch_mount
148
149 if ! _workout; then
150         _scratch_unmount 2>/dev/null
151         exit
152 fi
153
154 if ! _scratch_unmount; then
155         echo "failed to umount"
156         status=1
157         exit
158 fi
159 status=0
160 exit