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 _begin_fstest auto aio enospc rw stress
17 # Import common functions.
20 # real QA test starts here
26 _require_block_device $SCRATCH_DEV
28 NUM_JOBS=$((4*LOAD_FACTOR))
29 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
30 FILE_SIZE=$((BLK_DEV_SIZE * 512))
32 max_file_size=$(_get_max_file_size)
33 if [ $max_file_size -lt $FILE_SIZE ]; then
34 FILE_SIZE=$max_file_size
37 cat >$fio_config <<EOF
39 # $seq test fio activity
40 # Filenames derived from jobsname and jobid like follows:
41 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
45 directory=${SCRATCH_MNT}
48 iodepth=128*${LOAD_FACTOR}
49 continue_on_error=write
56 ## Perform direct aio, to files which may be truncated
63 runtime=100*${TIME_FACTOR}
66 # Perform direct aio and verify data
67 # This test case should check use-after-free issues
79 filename=aio-dio-verifier
81 # Perform buffered aio and verify data
82 # This test case should check use-after-free issues
83 [buffered-aio-verifier]
95 filename=buffered-aio-verifier
98 _require_fio $fio_config
99 _require_xfs_io_command "falloc"
101 _scratch_mkfs >> $seqres.full 2>&1
105 echo "Run fio with random aio-dio pattern"
107 cat $fio_config >> $seqres.full
108 $FIO_PROG $fio_config --output=$fio_out &
110 echo "Start fallocate/truncate loop"
112 for ((i=0; ; i++)); do
113 for ((k=1; k <= NUM_JOBS; k++)); do
114 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
115 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
117 for ((k=1; k <= NUM_JOBS; k++)); do
118 $XFS_IO_PROG -c "truncate 0" \
119 $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
121 # Following like will check that pid is still run.
122 # Once fio exit we can stop fallocate/truncate loop
123 pgrep -f "$FIO_PROG" > /dev/null 2>&1 || break
126 cat $fio_out >> $seqres.full