4 # During reflink, XFS should carry the cowextsz setting to the destination file
5 # if the destination file size is less than the size of the source file, the
6 # length is the size of the source file, both offsets are zero, and the
7 # destination does not already have a cowextsz setting. It should not do so
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
42 # get standard environment, filters and checks
47 # real QA test starts here
50 _require_scratch_reflink
52 _require_xfs_io_command "fiemap"
53 _require_xfs_io_command "cowextsize"
57 echo "Format and mount"
58 _scratch_mkfs > $seqres.full 2>&1
59 _scratch_mount >> $seqres.full 2>&1
61 testdir=$SCRATCH_MNT/test-$seq
64 echo "Create initial file"
65 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 131072" $testdir/file1 >> $seqres.full
66 $XFS_IO_PROG -c "cowextsize 1048576" $testdir/file1 >> $seqres.full
67 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 1" $testdir/file4 >> $seqres.full
68 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file7 >> $seqres.full
69 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file9 >> $seqres.full
70 $XFS_IO_PROG -f -c "pwrite -S 0x61 0 262144" $testdir/file10 >> $seqres.full
72 echo "Reflink to an empty file"
73 _reflink_range $testdir/file1 0 $testdir/file2 0 0 >> $seqres.full
75 echo "Reflink to an empty file that already has cowextsz"
76 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file3 >> $seqres.full
77 _reflink_range $testdir/file1 0 $testdir/file3 0 0 >> $seqres.full
79 echo "Reflink to a small file"
80 _reflink_range $testdir/file1 0 $testdir/file4 0 0 >> $seqres.full
82 echo "Reflink to a nonzero offset"
83 _reflink_range $testdir/file1 0 $testdir/file5 65536 0 >> $seqres.full
85 echo "Reflink from a nonzero offset"
86 _reflink_range $testdir/file1 65536 $testdir/file6 0 0 >> $seqres.full
88 echo "Reflink to a larger file"
89 _reflink_range $testdir/file1 0 $testdir/file7 0 0 >> $seqres.full
91 echo "Reflink less than the whole source file"
92 _reflink_range $testdir/file1 0 $testdir/file8 0 65536 >> $seqres.full
94 echo "cp reflink to a larger file"
95 _cp_reflink $testdir/file1 $testdir/file9 >> $seqres.full
97 echo "cp reflink to a larger file with cowextsize"
98 $XFS_IO_PROG -f -c "cowextsize 524288" $testdir/file10 >> $seqres.full
99 _cp_reflink $testdir/file1 $testdir/file10 >> $seqres.full
101 echo "Check cowextsz"
102 for i in `seq 1 10`; do
103 $XFS_IO_PROG -c "cowextsize" $testdir/file$i | _filter_scratch