generic: convert tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 299
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 299
6 #
7 # AIO/DIO stress test
8 # Run random AIO/DIO activity and fallocate/truncate simultaneously
9 # Test will operate on huge sparsed files 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 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24
25 # real QA test starts here
26 _supported_fs generic
27 _supported_os Linux
28 _require_scratch
29 _require_odirect
30 _require_block_device $SCRATCH_DEV
31
32 NUM_JOBS=$((4*LOAD_FACTOR))
33 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
34 FILE_SIZE=$((BLK_DEV_SIZE * 512))
35
36 cat >$fio_config <<EOF
37 ###########
38 # $seq test fio activity
39 # Filenames derived from jobsname and jobid like follows:
40 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
41 [global]
42 ioengine=libaio
43 bs=128k
44 directory=${SCRATCH_MNT}
45 filesize=${FILE_SIZE}
46 size=999G
47 iodepth=128*${LOAD_FACTOR}
48 continue_on_error=write
49 ignore_error=,ENOSPC
50 error_dump=0
51 create_on_open=1
52 fallocate=none
53 exitall=1
54
55 ## Perform direct aio, to files which may be truncated
56 ## by external task
57 [direct_aio]
58 direct=1
59 buffered=0
60 numjobs=${NUM_JOBS}
61 rw=randwrite
62 runtime=100*${TIME_FACTOR}
63 time_based
64
65 # Perform direct aio and verify data
66 # This test case should check use-after-free issues
67 [aio-dio-verifier]
68 numjobs=1
69 verify=crc32c-intel
70 verify_fatal=1
71 verify_dump=1
72 verify_backlog=1024
73 verify_async=4
74 verifysort=1
75 direct=1
76 bs=4k
77 rw=randrw
78 filename=aio-dio-verifier
79
80 # Perform buffered aio and verify data
81 # This test case should check use-after-free issues
82 [buffered-aio-verifier]
83 numjobs=1
84 verify=crc32c-intel
85 verify_fatal=1
86 verify_dump=1
87 verify_backlog=1024
88 verify_async=4
89 verifysort=1
90 direct=0
91 buffered=1
92 bs=4k
93 rw=randrw
94 filename=buffered-aio-verifier
95 EOF
96
97 rm -f $seqres.full
98
99 _require_fio $fio_config
100 _require_xfs_io_command "falloc"
101
102 _workout()
103 {
104         echo ""
105         echo "Run fio with random aio-dio pattern"
106         echo ""
107         cat $fio_config >>  $seqres.full
108         run_check $FIO_PROG $fio_config &
109         pid=$!
110         echo "Start fallocate/truncate loop"
111
112         for ((i=0; ; i++))
113         do
114             for ((k=1; k <= NUM_JOBS; k++))
115             do
116                 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
117                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
118             done
119             for ((k=1; k <= NUM_JOBS; k++))
120             do
121                 $XFS_IO_PROG -c "truncate  0" \
122                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
123             done
124             # Following like will check that pid is still run.
125             # Once fio exit we can stop fallocate/truncate loop
126             pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
127         done
128         wait $pid
129 }
130
131 _scratch_mkfs >> $seqres.full 2>&1
132 _scratch_mount
133
134 if ! _workout; then
135         _scratch_unmount 2>/dev/null
136         exit
137 fi
138
139 if ! _scratch_unmount; then
140         echo "failed to umount"
141         status=1
142         exit
143 fi
144 status=0
145 exit