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