generic/554: hide permision warning on exfat
[xfstests-dev.git] / tests / generic / 612
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2020 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test 612
6 #
7 # Regression test for reflink corruption present as of:
8 # 78f0cc9d55cb "xfs: don't use delalloc extents for COW on files with extsize hints"
9 # and (inadvertently) fixed as of:
10 # 36adcbace24e "xfs: fill out the srcmap in iomap_begin"
11 # upstream, and in the 5.4 stable tree with:
12 # aee38af574a1 "xfs: trim IO to found COW extent limit"
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32 . ./common/reflink
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs generic
41 _require_test
42 _require_test_reflink
43
44 DIR=$TEST_DIR/dir.$seq
45 mkdir -p $DIR
46 rm -f $DIR/a $DIR/b
47
48 # This test essentially creates an existing COW extent which
49 # covers the first 1M, and then does another IO that overlaps it,
50 # but extends beyond it.  The bug was that we did not trim the
51 # new IO to the end of the existing COW extent, and so the IO
52 # extended past the COW blocks and corrupted the reflinked files(s).
53
54 # Make all files w/ 1m hints; create original 2m file
55 $XFS_IO_PROG -c "extsize 1048576" $DIR >/dev/null 2>&1
56 $XFS_IO_PROG -c "cowextsize 1048576" $DIR >/dev/null 2>&1
57
58 echo "Create file b"
59 $XFS_IO_PROG -f -c "pwrite -S 0x0 0 2m" -c fsync $DIR/b | _filter_xfs_io
60
61 # Make a reflinked copy
62 echo "Reflink copy from b to a"
63 cp --reflink=always $DIR/b $DIR/a
64
65 echo "Contents of b"
66 hexdump -C $DIR/b
67
68 # Cycle mount to get stuff out of cache
69 _test_cycle_mount
70
71 # Create a 1m-hinted IO at offset 0, then
72 # do another IO that overlaps but extends past the 1m hint
73 echo "Write to a"
74 $XFS_IO_PROG -c "pwrite -S 0xa 0k -b 4k 4k" \
75        -c "pwrite -S 0xa 4k -b 1m 1m" \
76        $DIR/a | _filter_xfs_io
77
78 $XFS_IO_PROG -c fsync $DIR/a
79
80 echo "Contents of b now:"
81 hexdump -C $DIR/b
82
83 # success, all done
84 status=0
85 exit