generic: test for file loss after mix of rename, fsync and inode eviction
[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 . ./common/preamble
12 _begin_fstest auto aio enospc rw stress
13
14 fio_config=$tmp.fio
15 fio_out=$tmp.fio.out
16
17 # Import common functions.
18 . ./common/filter
19
20 # real QA test starts here
21 _supported_fs generic
22 _require_test
23 _require_scratch
24 _require_odirect
25 _require_aio
26 _require_block_device $SCRATCH_DEV
27
28 NUM_JOBS=$((4*LOAD_FACTOR))
29 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
30 FILE_SIZE=$((BLK_DEV_SIZE * 512))
31
32 max_file_size=$(_get_max_file_size)
33 if [ $max_file_size -lt $FILE_SIZE ]; then
34         FILE_SIZE=$max_file_size
35 fi
36
37 cat >$fio_config <<EOF
38 ###########
39 # $seq test fio activity
40 # Filenames derived from jobsname and jobid like follows:
41 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
42 [global]
43 ioengine=libaio
44 bs=128k
45 directory=${SCRATCH_MNT}
46 filesize=${FILE_SIZE}
47 size=999G
48 iodepth=128*${LOAD_FACTOR}
49 continue_on_error=write
50 ignore_error=,ENOSPC
51 error_dump=0
52 create_on_open=1
53 fallocate=none
54 exitall=1
55
56 ## Perform direct aio, to files which may be truncated
57 ## by external task
58 [direct_aio]
59 direct=1
60 buffered=0
61 numjobs=${NUM_JOBS}
62 rw=randwrite
63 runtime=100*${TIME_FACTOR}
64 time_based
65
66 # Perform direct aio and verify data
67 # This test case should check use-after-free issues
68 [aio-dio-verifier]
69 numjobs=1
70 verify=crc32c-intel
71 verify_fatal=1
72 verify_dump=1
73 verify_backlog=1024
74 verify_async=4
75 verifysort=1
76 direct=1
77 bs=4k
78 rw=randrw
79 filename=aio-dio-verifier
80
81 # Perform buffered aio and verify data
82 # This test case should check use-after-free issues
83 [buffered-aio-verifier]
84 numjobs=1
85 verify=crc32c-intel
86 verify_fatal=1
87 verify_dump=1
88 verify_backlog=1024
89 verify_async=4
90 verifysort=1
91 direct=0
92 buffered=1
93 bs=4k
94 rw=randrw
95 filename=buffered-aio-verifier
96 EOF
97
98 _require_fio $fio_config
99 _require_xfs_io_command "falloc"
100
101 _scratch_mkfs >> $seqres.full 2>&1
102 _scratch_mount
103
104 echo ""
105 echo "Run fio with random aio-dio pattern"
106 echo ""
107 cat $fio_config >>  $seqres.full
108 $FIO_PROG $fio_config --output=$fio_out &
109 pid=$!
110 echo "Start fallocate/truncate loop"
111
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
116         done
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
120         done
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
124 done
125 wait $pid
126 cat $fio_out >> $seqres.full
127
128 status=0
129 exit