2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc. All Rights Reserved.
7 # Test data integrity when mixing buffered reads and asynchronous
8 # direct writes a file.
11 _begin_fstest auto quick rw aio
13 # Import common functions.
15 # real QA test starts here
18 _require_test_program "feature"
19 _require_aiodio aio-dio-cycle-write
20 _require_command "$TIMEOUT_PROG" timeout
22 TESTFILE=$TEST_DIR/tst-aio-dio-cycle-write.$seq
25 # More read processes can help to reproduce the bug easier, so run
26 # 2 ~ 20 readers according to the number of CPUs
27 nr_cpu=`$here/src/feature -o`
29 if [ $loops -lt 2 ]; then
31 elif [ $loops -gt 20 ]; then
35 keep_reading=$tmp.reading
37 # buffered reads the file frequently
38 for ((i=0; i<loops; i++)); do
39 while [ -e $keep_reading ]; do
40 $XFS_IO_PROG -f -c "pread 0 $FSIZE" $TESTFILE >/dev/null 2>&1
42 reader_pid="$reader_pid $!"
45 # start an aio writer, which does writing loops internally and check
47 # For reproduce the original bug, keep testing about 30s will be better,
48 # So let the AIO_TEST run as many loops as it can, then kill it in 30s.
49 $TIMEOUT_PROG -s TERM 30s $AIO_TEST -c 999999 -b $FSIZE $TESTFILE >/dev/null
51 # Remove $keep_reading file to stop the reader cycle
55 echo "Silence is golden"