generic: test for file fsync after moving it to a new parent directory
[xfstests-dev.git] / tests / generic / 300
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3
4 #
5 # FSQA Test No. 300
6 #
7 # AIO/DIO stress test
8 # Run random AIO/DIO activity and fallocate/punch_hole simultaneously
9 # Test will operate on huge sparsed file 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 _supported_os Linux
28 _require_scratch
29 _require_odirect
30 _require_block_device $SCRATCH_DEV
31
32 # xfs_io is not required for this test, but it's the best way to verify
33 # the test system supports fallocate() for allocation and hole punching
34 _require_xfs_io_command "falloc"
35 _require_xfs_io_command "fpunch"
36
37 rm -f $seqres.full
38
39 NUM_JOBS=$((4*LOAD_FACTOR))
40 BLK_DEV_SIZE=`blockdev --getsz $SCRATCH_DEV`
41 if [ $((BLK_DEV_SIZE)) -gt 1048576 ]
42 then
43     BLK_DEV_SIZE=1048576
44 fi
45 FS_SIZE=$((BLK_DEV_SIZE * 512))
46
47 cat >$fio_config <<EOF
48 ###########
49 # $seq test fio activity
50 # Run DIO, fallocate and punch_hole threads on a single in parallel
51 #
52 # If race exist old dio request may rewrite punched block after it was
53 # allocated to another file, we will catch that by verifying blocks content
54 #
55 [global]
56 directory=${SCRATCH_MNT}
57 filesize=${FS_SIZE}
58 size=999G
59 continue_on_error=write
60 ignore_error=,ENOSPC
61 error_dump=0
62
63 create_on_open=1
64 fallocate=none
65 exitall=1
66
67 ## Perform direct aio, to files which may be truncated
68 ## by external task
69 [direct_aio_raicer]
70 ioengine=libaio
71 iodepth=128*${LOAD_FACTOR}
72 bs=128k
73 direct=1
74 numjobs=${NUM_JOBS}
75 rw=randwrite
76 runtime=100*${TIME_FACTOR}
77 time_based
78 filename=racer
79
80 # Run falloc and punch_hole threads in parallel
81 # After activity file will be highly fragmented
82 [falloc_raicer]
83 ioengine=falloc
84 runtime=100*${TIME_FACTOR}
85 iodepth=1
86 bssplit=128k/80:512k/10:32k/10
87 rw=randwrite
88 numjobs=1
89 filename=racer
90
91 [punch_hole_raicer]
92 ioengine=falloc
93 runtime=100*${TIME_FACTOR}
94 bs=4k
95 time_based=10
96 rw=randtrim
97 numjobs=2
98 filename=racer
99 time_based
100
101 # Verifier thread continiously write to newly allcated blocks
102 # and veryfy written content
103 [aio-dio-verifier]
104 ioengine=libaio
105 iodepth=128*${LOAD_FACTOR}
106 numjobs=1
107 verify=crc32c-intel
108 verify_fatal=1
109 verify_dump=1
110 verify_backlog=1024
111 verify_async=4
112 verifysort=1
113 direct=1
114 bs=4k
115 rw=randwrite
116 filename=aio-dio-verifier
117 EOF
118
119 _workout()
120 {
121         echo ""
122         echo "Run fio with random aio-dio pattern"
123         echo ""
124         cat $fio_config >>  $seqres.full
125         run_check $FIO_PROG $fio_config
126 }
127
128 _require_fio $fio_config
129
130 _scratch_mkfs_sized $FS_SIZE >> $seqres.full 2>&1
131 _scratch_mount
132
133 if ! _workout; then
134         _scratch_unmount 2>/dev/null
135         exit
136 fi
137
138 if ! _scratch_unmount; then
139         echo "failed to umount"
140         status=1
141         exit
142 fi
143 status=0
144 exit