common/rc: Add _require_{chown,chmod}()
[xfstests-dev.git] / tests / generic / 627
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 627
6 #
7 # AIO/DIO stress test
8 # Run random AIO/DIO activity on an file system with unwritten regions
9 #
10 # This test verifies that the an unwritten extent is properly marked
11 # as written after writing into it.
12 #
13 # There was a hard-to-hit bug which would occasionally trigger with
14 # ext4 for which this test was a reproducer.  This has been fixed
15 # after moving ext4 to use iomap for Direct I/O's, although as of this
16 # writing, there are still some occasional failures on ext4 when block
17 # size < page size.
18 #
19 seq=`basename $0`
20 seqres=$RESULT_DIR/$seq
21 echo "QA output created by $seq"
22
23 here=`pwd`
24 tmp=/tmp/$$
25 fio_config=$tmp.fio
26 fio_out=$tmp.fio.out
27 status=1        # failure is the default!
28 trap "_cleanup; exit \$status" 0 1 2 3 15
29
30 _cleanup()
31 {
32         cd /
33         rm -f $tmp.*
34 }
35
36 # get standard environment, filters and checks
37 . ./common/rc
38 . ./common/filter
39
40 # real QA test starts here
41 _supported_fs generic
42 _require_test
43 _require_scratch
44 _require_odirect
45 _require_aio
46 _require_block_device $SCRATCH_DEV
47
48 NUM_JOBS=$((4*LOAD_FACTOR))
49 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
50 FILE_SIZE=$(((BLK_DEV_SIZE * 512) * 3 / 4))
51
52 max_file_size=$((5 * 1024 * 1024 * 1024))
53 if [ $max_file_size -lt $FILE_SIZE ]; then
54         FILE_SIZE=$max_file_size
55 fi
56 SIZE=$((FILE_SIZE / 2))
57
58 cat >$fio_config <<EOF
59 ###########
60 # $seq test fio activity
61 # Filenames derived from jobsname and jobid like follows:
62 # ${JOB_NAME}.${JOB_ID}.${ITERATION_ID}
63 [global]
64 ioengine=libaio
65 bs=128k
66 directory=${SCRATCH_MNT}
67 filesize=${FILE_SIZE}
68 size=${FILE_SIZE}
69 io_size=${SIZE}
70 iodepth=$((128*$LOAD_FACTOR))
71 fallocate=native
72
73 # Perform direct aio and verify data
74 # This test case should check use-after-free issues
75 [aio-dio-verifier]
76 numjobs=1
77 verify=crc32c-intel
78 verify_fatal=1
79 verify_dump=1
80 verify_backlog=1024
81 verify_async=4
82 direct=1
83 random_generator=lfsr
84 blocksize_range=4k-8200k
85 rw=randwrite
86 filename=test-file
87
88 EOF
89
90 rm -f $seqres.full
91
92 _require_fio $fio_config
93 _require_xfs_io_command "falloc"
94
95 _scratch_mkfs >> $seqres.full 2>&1
96 _scratch_mount
97
98 echo ""
99 echo "Run fio with random aio-dio pattern"
100 echo ""
101 cat $fio_config >> $seqres.full
102 $FIO_PROG $fio_config --output=$fio_out
103 cat $fio_out >> $seqres.full
104
105 status=0
106 exit