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"
18 status=1 # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
21 # get standard environment, filters and checks
25 # real QA test starts here
30 _require_block_device $SCRATCH_DEV
32 NUM_JOBS=$((4*LOAD_FACTOR))
33 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
34 FILE_SIZE=$((BLK_DEV_SIZE * 512))
36 max_file_size=$(_get_max_file_size)
37 if [ $max_file_size -lt $FILE_SIZE ]; then
38 FILE_SIZE=$max_file_size
41 cat >$fio_config <<EOF
43 # $seq test fio activity
44 # Filenames derived from jobsname and jobid like follows:
45 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
49 directory=${SCRATCH_MNT}
52 iodepth=128*${LOAD_FACTOR}
53 continue_on_error=write
60 ## Perform direct aio, to files which may be truncated
67 runtime=100*${TIME_FACTOR}
70 # Perform direct aio and verify data
71 # This test case should check use-after-free issues
83 filename=aio-dio-verifier
85 # Perform buffered aio and verify data
86 # This test case should check use-after-free issues
87 [buffered-aio-verifier]
99 filename=buffered-aio-verifier
104 _require_fio $fio_config
105 _require_xfs_io_command "falloc"
110 echo "Run fio with random aio-dio pattern"
112 cat $fio_config >> $seqres.full
113 run_check $FIO_PROG $fio_config &
115 echo "Start fallocate/truncate loop"
119 for ((k=1; k <= NUM_JOBS; k++))
121 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
122 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
124 for ((k=1; k <= NUM_JOBS; k++))
126 $XFS_IO_PROG -c "truncate 0" \
127 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
129 # Following like will check that pid is still run.
130 # Once fio exit we can stop fallocate/truncate loop
131 pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
136 _scratch_mkfs >> $seqres.full 2>&1
140 _scratch_unmount 2>/dev/null
144 if ! _scratch_unmount; then
145 echo "failed to umount"