generic: add _require_odirect to generic/113 and generic/214
[xfstests-dev.git] / tests / generic / 290
1 #! /bin/bash
2 # FS QA Test No. 290
3 #
4 # Ensuring that copy on write in directio mode to the source file when the
5 # CoW range covers unwritten and regular shared blocks.
6 #   - Create two files.
7 #   - fallocate 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 #   - DIO 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 _require_odirect
56
57 rm -f $seqres.full
58
59 echo "Format and mount"
60 _scratch_mkfs > $seqres.full 2>&1
61 _scratch_mount >> $seqres.full 2>&1
62
63 testdir=$SCRATCH_MNT/test-$seq
64 mkdir $testdir
65
66 echo "Create the original files"
67 blksz=65536
68 nr=64
69 filesize=$((blksz * nr))
70 _sweave_reflink_unwritten $blksz $nr $testdir/file1 $testdir/file3 >> $seqres.full
71 _scratch_remount
72
73 echo "Compare files"
74 md5sum $testdir/file1 | _filter_scratch
75 md5sum $testdir/file3 | _filter_scratch
76 md5sum $testdir/file1.chk | _filter_scratch
77
78 echo "CoW across the transition"
79 cowoff=$((filesize / 4))
80 cowsz=$((filesize / 2))
81 $XFS_IO_PROG -d -f -c "pwrite -S 0x63 -b $cowsz $cowoff $cowsz" $testdir/file1 >> $seqres.full
82 _pwrite_byte 0x63 $cowoff $cowsz $testdir/file1.chk >> $seqres.full
83 _scratch_remount
84
85 echo "Compare files"
86 md5sum $testdir/file1 | _filter_scratch
87 md5sum $testdir/file3 | _filter_scratch
88 md5sum $testdir/file1.chk | _filter_scratch
89
90 # success, all done
91 status=0
92 exit