reflink: ensure that we can handle reflinking a lot of extents
[xfstests-dev.git] / tests / generic / 200
1 #! /bin/bash
2 # FS QA Test No. 200
3 #
4 # Ensuring that copy on write in buffered mode works when the CoW
5 # range originally covers multiple extents, some unwritten, some not.
6 #   - Create a file with the following repeating sequence of blocks:
7 #     1. reflinked
8 #     2. unwritten
9 #     3. hole
10 #     4. regular block
11 #     5. delalloc
12 #   - CoW across the halfway mark, starting with the unwritten extent.
13 #   - Check that the files are now different where we say they're different.
14 #
15 #-----------------------------------------------------------------------
16 # Copyright (c) 2015, Oracle and/or its affiliates.  All Rights Reserved.
17 #
18 # This program is free software; you can redistribute it and/or
19 # modify it under the terms of the GNU General Public License as
20 # published by the Free Software Foundation.
21 #
22 # This program is distributed in the hope that it would be useful,
23 # but WITHOUT ANY WARRANTY; without even the implied warranty of
24 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25 # GNU General Public License for more details.
26 #
27 # You should have received a copy of the GNU General Public License
28 # along with this program; if not, write the Free Software Foundation,
29 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30 #-----------------------------------------------------------------------
31
32 seq=`basename $0`
33 seqres=$RESULT_DIR/$seq
34 echo "QA output created by $seq"
35
36 here=`pwd`
37 tmp=/tmp/$$
38 status=1    # failure is the default!
39 trap "_cleanup; exit \$status" 0 1 2 3 15
40
41 _cleanup()
42 {
43     cd /
44     rm -rf $tmp.* $testdir
45 }
46
47 # get standard environment, filters and checks
48 . ./common/rc
49 . ./common/filter
50 . ./common/reflink
51
52 # real QA test starts here
53 _supported_os Linux
54 _require_scratch_reflink
55 _require_xfs_io_command "falloc"
56 _require_xfs_io_command "fpunch"
57 _require_cp_reflink
58 _require_odirect
59
60 rm -f $seqres.full
61
62 echo "Format and mount"
63 _scratch_mkfs > $seqres.full 2>&1
64 _scratch_mount >> $seqres.full 2>&1
65
66 testdir=$SCRATCH_MNT/test-$seq
67 mkdir $testdir
68
69 echo "Create the original files"
70 blksz=65536
71 nr=64
72 filesize=$((blksz * nr))
73 _weave_reflink_rainbow $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
74 _scratch_remount
75
76 echo "Compare files"
77 md5sum $testdir/file1 | _filter_scratch
78 md5sum $testdir/file3 | _filter_scratch
79 md5sum $testdir/file3.chk | _filter_scratch
80
81 echo "directio CoW across the transition"
82 cowoff=$((filesize / 4))
83 cowsz=$((filesize / 2))
84 _weave_reflink_rainbow_delalloc $blksz $nr $testdir/file3 >> $seqres.full
85 # now cow
86 $XFS_IO_PROG -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file3 >> $seqres.full
87 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file3.chk >> $seqres.full
88 _scratch_remount
89
90 echo "Compare files"
91 md5sum $testdir/file1 | _filter_scratch
92 md5sum $testdir/file3 | _filter_scratch
93 md5sum $testdir/file3.chk | _filter_scratch
94
95 # success, all done
96 status=0
97 exit