generic/223: make sure all files get created on the data device
[xfstests-dev.git] / tests / generic / 300
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 300
6 #
7 # AIO/DIO stress test
8 # Run random AIO/DIO activity and fallocate/punch_hole simultaneously
9 # Test will operate on huge sparsed file so ENOSPC is expected.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 fio_config=$tmp.fio
18 fio_out=$tmp.fio.out
19 status=1        # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.*
26 }
27
28 # get standard environment, filters and checks
29 . ./common/rc
30 . ./common/filter
31
32 # real QA test starts here
33 _supported_fs generic
34 _require_scratch
35 _require_odirect
36 _require_aio
37 _require_block_device $SCRATCH_DEV
38
39 # xfs_io is not required for this test, but it's the best way to verify
40 # the test system supports fallocate() for allocation and hole punching
41 _require_xfs_io_command "falloc"
42 _require_xfs_io_command "fpunch"
43
44 rm -f $seqres.full
45
46 NUM_JOBS=$((4*LOAD_FACTOR))
47 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
48 if [ $((BLK_DEV_SIZE)) -gt 1048576 ]; then
49         BLK_DEV_SIZE=1048576
50 fi
51 FS_SIZE=$((BLK_DEV_SIZE * 512))
52
53 cat >$fio_config <<EOF
54 ###########
55 # $seq test fio activity
56 # Run DIO, fallocate and punch_hole threads on a single in parallel
57 #
58 # If race exist old dio request may rewrite punched block after it was
59 # allocated to another file, we will catch that by verifying blocks content
60 #
61 [global]
62 directory=${SCRATCH_MNT}
63 filesize=${FS_SIZE}
64 size=999G
65 continue_on_error=write
66 ignore_error=,ENOSPC
67 error_dump=0
68
69 create_on_open=1
70 fallocate=none
71 exitall=1
72
73 ## Perform direct aio, to files which may be truncated
74 ## by external task
75 [direct_aio_raicer]
76 ioengine=libaio
77 iodepth=128*${LOAD_FACTOR}
78 bs=128k
79 direct=1
80 numjobs=${NUM_JOBS}
81 rw=randwrite
82 runtime=100*${TIME_FACTOR}
83 time_based
84 filename=racer
85
86 # Run falloc and punch_hole threads in parallel
87 # After activity file will be highly fragmented
88 [falloc_raicer]
89 ioengine=falloc
90 runtime=100*${TIME_FACTOR}
91 iodepth=1
92 bssplit=128k/80:512k/10:32k/10
93 rw=randwrite
94 numjobs=1
95 filename=racer
96
97 [punch_hole_raicer]
98 ioengine=falloc
99 runtime=100*${TIME_FACTOR}
100 bs=4k
101 time_based=10
102 rw=randtrim
103 numjobs=2
104 filename=racer
105 time_based
106
107 # Verifier thread continiously write to newly allcated blocks
108 # and veryfy written content
109 [aio-dio-verifier]
110 ioengine=libaio
111 iodepth=128*${LOAD_FACTOR}
112 numjobs=1
113 verify=crc32c-intel
114 verify_fatal=1
115 verify_dump=1
116 verify_backlog=1024
117 verify_async=4
118 verifysort=1
119 direct=1
120 bs=4k
121 rw=randwrite
122 filename=aio-dio-verifier
123 EOF
124
125 _require_fio $fio_config
126
127 _scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
128 _scratch_mount
129
130 echo ""
131 echo "Run fio with random aio-dio pattern"
132 echo ""
133 cat $fio_config >>  $seqres.full
134 $FIO_PROG $fio_config --output=$fio_out
135 cat $fio_out >> $seqres.full
136
137 status=0
138 exit