generic: add _require_odirect to generic/113 and generic/214
[xfstests-dev.git] / tests / generic / 304
1 #! /bin/bash
2 # FS QA Test No. 304
3 #
4 # Check that high-offset dedupes work.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016, Oracle and/or its affiliates.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22
23 seq=`basename $0`
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
26
27 here=`pwd`
28 tmp=/tmp/$$
29 status=1    # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
31
32 _cleanup()
33 {
34     cd /
35     rm -rf $tmp.* $testdir
36 }
37
38 # get standard environment, filters and checks
39 . ./common/rc
40 . ./common/filter
41 . ./common/attr
42 . ./common/reflink
43
44 # real QA test starts here
45 _supported_os Linux
46 _require_test_dedupe
47 _require_cp_reflink
48
49 rm -f $seqres.full
50
51 echo "Format and mount"
52 testdir=$TEST_DIR/test-$seq
53 mkdir $testdir
54
55 echo "Create the original files"
56 bigoff=9223372036854775806
57 len=9223372036854775807
58 bigoff_64k=9223372036854710272  # bigoff rounded down to 64k
59 $XFS_IO_PROG -f -c "truncate $len" $testdir/file0 >> $seqres.full
60 test -s $testdir/file0 || _notrun "High offset ftruncate failed"
61 _pwrite_byte 0x61 $bigoff 1 $testdir/file1 >> $seqres.full
62 _pwrite_byte 0x61 $bigoff 1 $testdir/file3 >> $seqres.full
63 _pwrite_byte 0x61 1048575 1 $testdir/file2 >> $seqres.full
64
65 echo "Dedupe large single byte file"
66 _dedupe_range $testdir/file1 0 $testdir/file3 0 $len >> $seqres.full
67
68 echo "Dedupe large empty file"
69 _dedupe_range $testdir/file0 0 $testdir/file4 0 $len >> $seqres.full
70
71 echo "Dedupe past maximum file size in dest file (should fail)"
72 _dedupe_range $testdir/file1 0 $testdir/file5 4611686018427322368 $len >> $seqres.full
73
74 echo "Dedupe high offset to low offset"
75 _dedupe_range $testdir/file1 $bigoff_64k $testdir/file6 1048576 65535 >> $seqres.full
76
77 echo "Dedupe past source file EOF (should fail)"
78 _dedupe_range $testdir/file2 524288 $testdir/file7 0 1048576 >> $seqres.full
79
80 echo "Dedupe max size at nonzero offset (should fail)"
81 _dedupe_range $testdir/file2 524288 $testdir/file8 0 $len >> $seqres.full
82
83 echo "Dedupe with huge off/len (should fail)"
84 _dedupe_range $testdir/file2 $bigoff_64k $testdir/file9 0 $bigoff_64k >> $seqres.full
85
86 echo "Check file creation"
87 _test_remount
88 echo "file3"
89 $XFS_IO_PROG -c "pread -v -q $bigoff 1" $testdir/file3
90 echo "file4"
91 $XFS_IO_PROG -c "pread -v -q $bigoff 1" $testdir/file4
92 # file5 should fail above
93 echo "file6"
94 $XFS_IO_PROG -c "pread -v -q 1114110 1" $testdir/file6
95 # file7 should fail above
96
97 # success, all done
98 status=0
99 exit