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
35 _require_test_program "feature"
36 _require_aiodio aio-dio-cycle-write
37 _require_command "$TIMEOUT_PROG" timeout
39 TESTFILE=$TEST_DIR/tst-aio-dio-cycle-write.$seq
42 # More read processes can help to reproduce the bug easier, so run
43 # 2 ~ 20 readers according to the number of CPUs
44 nr_cpu=`$here/src/feature -o`
46 if [ $loops -lt 2 ]; then
48 elif [ $loops -gt 20 ]; then
52 keep_reading=$tmp.reading
54 # buffered reads the file frequently
55 for ((i=0; i<loops; i++)); do
56 while [ -e $keep_reading ]; do
57 $XFS_IO_PROG -f -c "pread 0 $FSIZE" $TESTFILE >/dev/null 2>&1
59 reader_pid="$reader_pid $!"
62 # start an aio writer, which does writing loops internally and check
64 # For reproduce the original bug, keep testing about 30s will be better,
65 # So let the AIO_TEST run as many loops as it can, then kill it in 30s.
66 $TIMEOUT_PROG -s TERM 30s $AIO_TEST -c 999999 -b $FSIZE $TESTFILE >/dev/null
68 # Remove $keep_reading file to stop the reader cycle
72 echo "Silence is golden"