2 # SPDX-License-Identifier: GPL-2.0
8 # Run random AIO/DIO activity and fallocate/truncate simultaneously
9 # Test will operate on huge sparsed files so ENOSPC is expected.
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # real QA test starts here
38 _require_block_device $SCRATCH_DEV
40 NUM_JOBS=$((4*LOAD_FACTOR))
41 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
42 FILE_SIZE=$((BLK_DEV_SIZE * 512))
44 max_file_size=$(_get_max_file_size)
45 if [ $max_file_size -lt $FILE_SIZE ]; then
46 FILE_SIZE=$max_file_size
49 cat >$fio_config <<EOF
51 # $seq test fio activity
52 # Filenames derived from jobsname and jobid like follows:
53 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
57 directory=${SCRATCH_MNT}
60 iodepth=128*${LOAD_FACTOR}
61 continue_on_error=write
68 ## Perform direct aio, to files which may be truncated
75 runtime=100*${TIME_FACTOR}
78 # Perform direct aio and verify data
79 # This test case should check use-after-free issues
91 filename=aio-dio-verifier
93 # Perform buffered aio and verify data
94 # This test case should check use-after-free issues
95 [buffered-aio-verifier]
107 filename=buffered-aio-verifier
112 _require_fio $fio_config
113 _require_xfs_io_command "falloc"
115 _scratch_mkfs >> $seqres.full 2>&1
119 echo "Run fio with random aio-dio pattern"
121 cat $fio_config >> $seqres.full
122 $FIO_PROG $fio_config --output=$fio_out &
124 echo "Start fallocate/truncate loop"
126 for ((i=0; ; i++)); do
127 for ((k=1; k <= NUM_JOBS; k++)); do
128 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
129 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
131 for ((k=1; k <= NUM_JOBS; k++)); do
132 $XFS_IO_PROG -c "truncate 0" \
133 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
135 # Following like will check that pid is still run.
136 # Once fio exit we can stop fallocate/truncate loop
137 pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
140 cat $fio_out >> $seqres.full