lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
mkdir -p $lowerdir
echo "This is old news" > $lowerdir/foo
-echo "This is old news" > $lowerdir/bar
_scratch_mount
#
-# case #1:
# open file for read (rofd)
# open file for write (rwfd)
# write to rwfd
-C "pread -v 0 16" \
| _filter_xfs_io | _filter_scratch
-#
-# case #2:
-# mmap MAP_SHARED|PROT_READ of rofd
-# write to rwfd
-# read from mapped memory
-#
-$XFS_IO_PROG -r $SCRATCH_MNT/bar \
- -C "mmap -r 0 16" \
- -C "open $SCRATCH_MNT/bar" \
- -C "pwrite -S 0x61 0 16" \
- -C "mread -v 0 16" \
-| _filter_xfs_io | _filter_scratch
-
status=0
exit
00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
read 16/16 bytes at offset 0
XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-wrote 16/16 bytes at offset 0
-XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
-00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa
--- /dev/null
+#! /bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2018 CTERA Networks. All Rights Reserved.
+#
+# FSQA Test No. 061
+#
+# Test ro/rw fd data inconsistecies
+#
+# This is a variant of test overlay/016 with mread instead of pread.
+#
+# This simple test demonstrates a known issue with overlayfs:
+# - process A opens file F for read + mmap
+# - process B writes new data to file F
+# - process A reads old data from mapped memory
+#
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+tmp=/tmp/$$
+status=1 # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+ cd /
+ rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+
+# real QA test starts here
+_supported_fs overlay
+_supported_os Linux
+_require_scratch
+_require_xfs_io_command "open"
+
+rm -f $seqres.full
+
+_scratch_mkfs >>$seqres.full 2>&1
+
+# Create our test files.
+lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
+mkdir -p $lowerdir
+echo "This is old news" > $lowerdir/foo
+
+_scratch_mount
+
+
+#
+# mmap MAP_SHARED|PROT_READ of rofd
+# write to rwfd
+# read from mapped memory
+#
+$XFS_IO_PROG -r $SCRATCH_MNT/foo \
+ -C "mmap -r 0 16" \
+ -C "open $SCRATCH_MNT/foo" \
+ -C "pwrite -S 0x61 0 16" \
+ -C "mread -v 0 16" \
+| _filter_xfs_io | _filter_scratch
+
+status=0
+exit
--- /dev/null
+QA output created by 061
+wrote 16/16 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa