#
# FSQA Test No. 061
#
-# Test ro/rw fd data inconsistecies
+# Test memory mapped data inconsistencies
#
# 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
+# - process A created shared ro mmap on file F
+# - process B created shared rw mmap on file F
+# - process B writes new data to shared mmap
+# - process A reads old data from shared mmap
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
_scratch_mount
+filter_xfs_io_mmap()
+{
+ # filter out these lines:
+ # [000] 0x7f3d9aece000 - 0x7f3d9aece010 r-- SCRATCH_MNT/foo (0 : 16)
+ grep -Fv '[00'
+}
+
#
# mmap MAP_SHARED|PROT_READ of rofd
-# write to rwfd
-# read from mapped memory
+# mmap MAP_SHARED|PROT_WRITE of rwfd
+# write to rw mmap
+# read from ro mmap
#
$XFS_IO_PROG -r $SCRATCH_MNT/foo \
-C "mmap -r 0 16" \
+ -C "close" \
-C "open $SCRATCH_MNT/foo" \
- -C "pwrite -S 0x61 0 16" \
+ -C "mmap -w 0 16" \
+ -C "close" \
+ -C "mwrite -S 0x61 0 16" \
+ -C "munmap" \
+ -C "mread -v 0 16" \
+| _filter_xfs_io | _filter_scratch | filter_xfs_io_mmap
+
+_scratch_cycle_mount
+
+# Verify mmap write after close has persisted through mount cycle
+echo "After mount cycle:"
+$XFS_IO_PROG -r $SCRATCH_MNT/foo \
+ -C "mmap -r 0 16" \
-C "mread -v 0 16" \
| _filter_xfs_io | _filter_scratch
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
+After mount cycle:
00000000: 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 61 aaaaaaaaaaaaaaaa