2 # SPDX-License-Identifier: GPL-2.0-or-newer
3 # Copyright (c) 2019, Oracle and/or its affiliates. All Rights Reserved.
7 # Make sure that we can handle multiple mmap writers to the same file.
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
21 rm -rf $tmp.* $testdir
24 # get standard environment, filters and checks
29 # real QA test starts here
31 _require_test_program "mmap-write-concurrent"
32 _require_command "$FILEFRAG_PROG" filefrag
39 for i in $(seq 1 8); do
40 md5sum $testdir/file$i | _filter_test_dir
41 echo $testdir/file$i >> $seqres.full
42 od -tx1 -Ad -c $testdir/file$i >> $seqres.full
46 testdir=$TEST_DIR/test-$seq
50 echo "Create the original files"
53 _pwrite_byte 0x61 0 $filesz $testdir/file1 >> $seqres.full
54 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
56 _cp_reflink $testdir/file1 $testdir/file4 >> $seqres.full
57 _reflink_range $testdir/file1 0 $testdir/file5 $blksz $filesz >> $seqres.full
58 _reflink_range $testdir/file1 0 $testdir/file6 $((blksz * 2)) $filesz >> $seqres.full
59 _reflink_range $testdir/file1 0 $testdir/file7 $((blksz * 3)) $filesz >> $seqres.full
60 _reflink_range $testdir/file1 0 $testdir/file8 $((blksz * 4)) $filesz >> $seqres.full
63 echo "Compare files before cow" | tee -a $seqres.full
66 echo "mwrite all copies" | tee -a $seqres.full
67 off=$(( (filesz / 2) - 168 ))
69 $here/src/mmap-write-concurrent $len \
74 $((off + blksz)) $testdir/file5 \
75 $((off + (blksz * 2))) $testdir/file6 \
76 $((off + (blksz * 3))) $testdir/file7 \
77 $((off + (blksz * 4))) $testdir/file8 \
79 $((blksz - 168)) $testdir/file2 \
80 $((filesz - 777)) $testdir/file3 \
81 $(((blksz * 3) - 168)) $testdir/file4 \
84 echo "Compare files before remount" | tee -a $seqres.full
88 echo "Compare files after remount" | tee -a $seqres.full
91 echo "Check for non-shared extents" | tee -a $seqres.full
92 $FILEFRAG_PROG -v $testdir/file1 $testdir/file2 $testdir/file3 $testdir/file4 \
93 $testdir/file5 $testdir/file6 $testdir/file7 $testdir/file8 \
94 | grep '^[[:space:]]*[0-9]*:' > $testdir/fiemap
95 cat $testdir/fiemap >> $seqres.full
96 grep -q 'shared' $testdir/fiemap || \
97 echo "Expected to find shared extents"
99 grep -q -v 'shared' $testdir/fiemap || \
100 echo "Expected to find non-shared extents"