common/fuzzy: try to clear blocking flags first in _scratch_fuzz_modify
[xfstests-dev.git] / tests / generic / 578
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0-or-newer
3 # Copyright (c) 2019, Oracle and/or its affiliates.  All Rights Reserved.
4 #
5 # FS QA Test No. 578
6 #
7 # Make sure that we can handle multiple mmap writers to the same file.
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 15
17
18 _cleanup()
19 {
20         cd /
21         rm -rf $tmp.* $testdir
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30 _supported_os Linux
31 _supported_fs generic
32 _require_test_program "mmap-write-concurrent"
33 _require_command "$FILEFRAG_PROG" filefrag
34 _require_test_reflink
35 _require_cp_reflink
36
37 rm -f $seqres.full
38
39 compare() {
40         for i in $(seq 1 8); do
41                 md5sum $testdir/file$i | _filter_test_dir
42                 echo $testdir/file$i >> $seqres.full
43                 od -tx1 -Ad -c $testdir/file$i >> $seqres.full
44         done
45 }
46
47 testdir=$TEST_DIR/test-$seq
48 rm -rf $testdir
49 mkdir $testdir
50
51 echo "Create the original files"
52 blksz=65536
53 filesz=$((blksz * 4))
54 _pwrite_byte 0x61 0 $filesz $testdir/file1 >> $seqres.full
55 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
56 _cp_reflink $testdir/file1 $testdir/file3 >> $seqres.full
57 _cp_reflink $testdir/file1 $testdir/file4 >> $seqres.full
58 _reflink_range $testdir/file1 0 $testdir/file5 $blksz $filesz >> $seqres.full
59 _reflink_range $testdir/file1 0 $testdir/file6 $((blksz * 2)) $filesz >> $seqres.full
60 _reflink_range $testdir/file1 0 $testdir/file7 $((blksz * 3)) $filesz >> $seqres.full
61 _reflink_range $testdir/file1 0 $testdir/file8 $((blksz * 4)) $filesz >> $seqres.full
62 _test_cycle_mount
63
64 echo "Compare files before cow" | tee -a $seqres.full
65 compare
66
67 echo "mwrite all copies" | tee -a $seqres.full
68 off=$(( (filesz / 2) - 168 ))
69 len=337
70 $here/src/mmap-write-concurrent $len \
71                 $off $testdir/file1 \
72                 $off $testdir/file2 \
73                 $off $testdir/file3 \
74                 $off $testdir/file4 \
75                 $((off + blksz)) $testdir/file5 \
76                 $((off + (blksz * 2))) $testdir/file6 \
77                 $((off + (blksz * 3))) $testdir/file7 \
78                 $((off + (blksz * 4))) $testdir/file8 \
79                 168 $testdir/file1 \
80                 $((blksz - 168)) $testdir/file2 \
81                 $((filesz - 777)) $testdir/file3 \
82                 $(((blksz * 3) - 168)) $testdir/file4 \
83
84
85 echo "Compare files before remount" | tee -a $seqres.full
86 compare
87 _test_cycle_mount
88
89 echo "Compare files after remount" | tee -a $seqres.full
90 compare
91
92 echo "Check for non-shared extents" | tee -a $seqres.full
93 $FILEFRAG_PROG -v $testdir/file1 $testdir/file2 $testdir/file3 $testdir/file4 \
94                   $testdir/file5 $testdir/file6 $testdir/file7 $testdir/file8 \
95                   | grep '^[[:space:]]*[0-9]*:' > $testdir/fiemap
96 cat $testdir/fiemap >> $seqres.full
97 grep -q 'shared' $testdir/fiemap || \
98                 echo "Expected to find shared extents"
99
100 grep -q -v 'shared' $testdir/fiemap || \
101                 echo "Expected to find non-shared extents"
102
103 # success, all done
104 status=0
105 exit