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
31 _require_block_device $SCRATCH_DEV
33 NUM_JOBS=$((4*LOAD_FACTOR))
34 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
35 FILE_SIZE=$((BLK_DEV_SIZE * 512))
37 max_file_size=$(_get_max_file_size)
38 if [ $max_file_size -lt $FILE_SIZE ]; then
39 FILE_SIZE=$max_file_size
42 cat >$fio_config <<EOF
44 # $seq test fio activity
45 # Filenames derived from jobsname and jobid like follows:
46 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
50 directory=${SCRATCH_MNT}
53 iodepth=128*${LOAD_FACTOR}
54 continue_on_error=write
61 ## Perform direct aio, to files which may be truncated
68 runtime=100*${TIME_FACTOR}
71 # Perform direct aio and verify data
72 # This test case should check use-after-free issues
84 filename=aio-dio-verifier
86 # Perform buffered aio and verify data
87 # This test case should check use-after-free issues
88 [buffered-aio-verifier]
100 filename=buffered-aio-verifier
105 _require_fio $fio_config
106 _require_xfs_io_command "falloc"
111 echo "Run fio with random aio-dio pattern"
113 cat $fio_config >> $seqres.full
114 run_check $FIO_PROG $fio_config &
116 echo "Start fallocate/truncate loop"
120 for ((k=1; k <= NUM_JOBS; k++))
122 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
123 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
125 for ((k=1; k <= NUM_JOBS; k++))
127 $XFS_IO_PROG -c "truncate 0" \
128 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
130 # Following like will check that pid is still run.
131 # Once fio exit we can stop fallocate/truncate loop
132 pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
137 _scratch_mkfs >> $seqres.full 2>&1
141 _scratch_unmount 2>/dev/null
145 if ! _scratch_unmount; then
146 echo "failed to umount"