generic: test for creating duplicate filenames in encrypted dir
[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 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 fio_config=$tmp.fio
18 status=1        # failure is the default!
19 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20
21 # get standard environment, filters and checks
22 . ./common/rc
23 . ./common/filter
24
25 # real QA test starts here
26 _supported_fs generic
27 _require_test
28 _require_scratch
29 _require_odirect
30 _require_block_device $SCRATCH_DEV
31
32 NUM_JOBS=$((4*LOAD_FACTOR))
33 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
34 FILE_SIZE=$((BLK_DEV_SIZE * 512))
35
36 max_file_size=$(_get_max_file_size)
37 if [ $max_file_size -lt $FILE_SIZE ]; then
38         FILE_SIZE=$max_file_size
39 fi
40
41 cat >$fio_config <<EOF
42 ###########
43 # $seq test fio activity
44 # Filenames derived from jobsname and jobid like follows:
45 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
46 [global]
47 ioengine=libaio
48 bs=128k
49 directory=${SCRATCH_MNT}
50 filesize=${FILE_SIZE}
51 size=999G
52 iodepth=128*${LOAD_FACTOR}
53 continue_on_error=write
54 ignore_error=,ENOSPC
55 error_dump=0
56 create_on_open=1
57 fallocate=none
58 exitall=1
59
60 ## Perform direct aio, to files which may be truncated
61 ## by external task
62 [direct_aio]
63 direct=1
64 buffered=0
65 numjobs=${NUM_JOBS}
66 rw=randwrite
67 runtime=100*${TIME_FACTOR}
68 time_based
69
70 # Perform direct aio and verify data
71 # This test case should check use-after-free issues
72 [aio-dio-verifier]
73 numjobs=1
74 verify=crc32c-intel
75 verify_fatal=1
76 verify_dump=1
77 verify_backlog=1024
78 verify_async=4
79 verifysort=1
80 direct=1
81 bs=4k
82 rw=randrw
83 filename=aio-dio-verifier
84
85 # Perform buffered aio and verify data
86 # This test case should check use-after-free issues
87 [buffered-aio-verifier]
88 numjobs=1
89 verify=crc32c-intel
90 verify_fatal=1
91 verify_dump=1
92 verify_backlog=1024
93 verify_async=4
94 verifysort=1
95 direct=0
96 buffered=1
97 bs=4k
98 rw=randrw
99 filename=buffered-aio-verifier
100 EOF
101
102 rm -f $seqres.full
103
104 _require_fio $fio_config
105 _require_xfs_io_command "falloc"
106
107 _workout()
108 {
109         echo ""
110         echo "Run fio with random aio-dio pattern"
111         echo ""
112         cat $fio_config >>  $seqres.full
113         run_check $FIO_PROG $fio_config &
114         pid=$!
115         echo "Start fallocate/truncate loop"
116
117         for ((i=0; ; i++))
118         do
119             for ((k=1; k <= NUM_JOBS; k++))
120             do
121                 $XFS_IO_PROG -f -c "falloc 0 $FILE_SIZE" \
122                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
123             done
124             for ((k=1; k <= NUM_JOBS; k++))
125             do
126                 $XFS_IO_PROG -c "truncate  0" \
127                         $SCRATCH_MNT/direct_aio.$k.0 >> $seqres.full 2>&1
128             done
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
132         done
133         wait $pid
134 }
135
136 _scratch_mkfs >> $seqres.full 2>&1
137 _scratch_mount
138
139 if ! _workout; then
140         _scratch_unmount 2>/dev/null
141         exit
142 fi
143
144 if ! _scratch_unmount; then
145         echo "failed to umount"
146         status=1
147         exit
148 fi
149 status=0
150 exit