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