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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
28 # remove previous $seqres.full before test
31 # real QA test starts here
34 _require_test_program "feature"
35 _require_aiodio aio-dio-cycle-write
36 _require_command "$TIMEOUT_PROG" timeout
38 TESTFILE=$TEST_DIR/tst-aio-dio-cycle-write.$seq
41 # More read processes can help to reproduce the bug easier, so run
42 # 2 ~ 20 readers according to the number of CPUs
43 nr_cpu=`$here/src/feature -o`
45 if [ $loops -lt 2 ]; then
47 elif [ $loops -gt 20 ]; then
51 keep_reading=$tmp.reading
53 # buffered reads the file frequently
54 for ((i=0; i<loops; i++)); do
55 while [ -e $keep_reading ]; do
56 $XFS_IO_PROG -f -c "pread 0 $FSIZE" $TESTFILE >/dev/null 2>&1
58 reader_pid="$reader_pid $!"
61 # start an aio writer, which does writing loops internally and check
63 # For reproduce the original bug, keep testing about 30s will be better,
64 # So let the AIO_TEST run as many loops as it can, then kill it in 30s.
65 $TIMEOUT_PROG -s TERM 30s $AIO_TEST -c 999999 -b $FSIZE $TESTFILE >/dev/null
67 # Remove $keep_reading file to stop the reader cycle
71 echo "Silence is golden"