xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / overlay / 061
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2018 CTERA Networks. All Rights Reserved.
4 #
5 # FSQA Test No. 061
6 #
7 # Test memory mapped data inconsistencies
8 #
9 # This is a variant of test overlay/016 with mread instead of pread.
10 #
11 # This simple test demonstrates a known issue with overlayfs:
12 # - process A created shared ro mmap on file F
13 # - process B created shared rw mmap on file F
14 # - process B writes new data to shared mmap
15 # - process A reads old data from shared mmap
16 #
17 seq=`basename $0`
18 seqres=$RESULT_DIR/$seq
19 echo "QA output created by $seq"
20
21 tmp=/tmp/$$
22 status=1        # failure is the default!
23 trap "_cleanup; exit \$status" 0 1 2 3 15
24
25 _cleanup()
26 {
27         cd /
28         rm -f $tmp.*
29 }
30
31 # get standard environment, filters and checks
32 . ./common/rc
33 . ./common/filter
34
35 # real QA test starts here
36 _supported_fs overlay
37 _require_scratch
38 _require_xfs_io_command "open"
39
40 rm -f $seqres.full
41
42 _scratch_mkfs >>$seqres.full 2>&1
43
44 # Create our test files.
45 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
46 mkdir -p $lowerdir
47 echo "This is old news" > $lowerdir/foo
48
49 _scratch_mount
50
51
52 filter_xfs_io_mmap()
53 {
54         # filter out these lines:
55         # [000] 0x7f3d9aece000 - 0x7f3d9aece010 r--  SCRATCH_MNT/foo (0 : 16)
56         grep -Fv '[00'
57 }
58
59 #
60 # mmap MAP_SHARED|PROT_READ of rofd
61 # mmap MAP_SHARED|PROT_WRITE of rwfd
62 # write to rw mmap
63 # read from ro mmap
64 #
65 $XFS_IO_PROG -r $SCRATCH_MNT/foo \
66         -C "mmap -r 0 16" \
67         -C "close" \
68         -C "open $SCRATCH_MNT/foo" \
69         -C "mmap -w 0 16" \
70         -C "close" \
71         -C "mwrite -S 0x61 0 16" \
72         -C "munmap" \
73         -C "mread -v 0 16" \
74 | _filter_xfs_io | _filter_scratch | filter_xfs_io_mmap
75
76 _scratch_cycle_mount
77
78 # Verify mmap write after close has persisted through mount cycle
79 echo "After mount cycle:"
80 $XFS_IO_PROG -r $SCRATCH_MNT/foo \
81         -C "mmap -r 0 16" \
82         -C "mread -v 0 16" \
83 | _filter_xfs_io | _filter_scratch
84
85 status=0
86 exit