generic/611: Use _getfattr instead of GETFATTR_PROG
[xfstests-dev.git] / tests / generic / 451
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 451
6 #
7 # Test data integrity when mixing buffered reads and asynchronous
8 # direct writes a file.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27
28 # remove previous $seqres.full before test
29 rm -f $seqres.full
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_test
34 _require_test_program "feature"
35 _require_aiodio aio-dio-cycle-write
36 _require_command "$TIMEOUT_PROG" timeout
37
38 TESTFILE=$TEST_DIR/tst-aio-dio-cycle-write.$seq
39 FSIZE=655360    # bytes
40
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`
44 loops=$((nr_cpu / 2))
45 if [ $loops -lt 2 ]; then
46         loops=2
47 elif [ $loops -gt 20 ]; then
48         loops=20
49 fi
50
51 keep_reading=$tmp.reading
52 touch $keep_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
57         done &
58         reader_pid="$reader_pid $!"
59 done
60
61 # start an aio writer, which does writing loops internally and check
62 # data integrality.
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
66
67 # Remove $keep_reading file to stop the reader cycle
68 rm -f $keep_reading
69 wait $reader_pid
70
71 echo "Silence is golden"
72
73 status=0
74 exit