fstests: convert remaining tests to SPDX license tags
[xfstests-dev.git] / tests / generic / 247
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2010 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 247
6 #
7 # Test for race between direct I/O and mmap
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 7 15
17
18 _cleanup()
19 {
20     cd /
21     rm -f $tmp.* $testfile
22     wait
23 }
24
25 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30
31 # Modify as appropriate.
32 _supported_fs generic
33 _supported_os Linux
34 _require_test
35
36 # this test leaves a 512MB file around if we abort the test during the run via a
37 # reboot or kernel panic. Hence just name the file $seq so that we can always
38 # clean up on the next run and not leave large stale files around on the testdir
39 # that can lead to ENOSPC issues over time.
40 testfile=$TEST_DIR/$seq
41 rm -f $testfile
42
43 loops=500
44 iosize=1048576
45
46 # Initialise file
47 dd if=/dev/zero of=$testfile bs=$iosize count=$loops &> /dev/null
48 [ $? -ne 0 ] && exit
49 sync
50         
51 # Direct I/O overwriter
52 dd if=/dev/zero of=$testfile oflag=direct bs=$iosize count=$loops conv=notrunc &> /dev/null &
53 [ $? -ne 0 ] && exit
54
55 # Mmap writer
56 start=`expr $loops - 1`
57 for i in `seq $start -1 0`
58 do
59         offset=`expr $i \* $iosize`
60         $XFS_IO_PROG -f -c "mmap -w $offset $iosize" -c "mwrite $offset $iosize" $testfile
61         [ $? -ne 0 ] && exit
62 done
63
64 wait
65
66 echo "Silence is golden."
67
68 # unmount and check dmesg, filtering out expected warnings about mixed
69 # mmap/dio
70 _test_unmount
71 _check_dmesg _filter_aiodio_dmesg
72
73 status=$?
74 exit