4 # Make sure that reflink deals with extents going beyond EOF.
5 # - fallocate 256k in file1
6 # - pwrite 252-257k to cause it to speculatively prealloc file1
7 # - reflink file1 to file2
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
51 _require_xfs_io_command "falloc"
52 _require_xfs_io_command "bmap" "-c"
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 the original files"
65 $XFS_IO_PROG -f -c "falloc 0 256k" -c "pwrite 252k 6k" $testdir/file1 >> $seqres.full
67 _cp_reflink $testdir/file1 $testdir/file2 >> $seqres.full
70 md5sum $testdir/file1 | _filter_scratch
71 md5sum $testdir/file2 | _filter_scratch
73 echo "Unwritten data extents"
74 test $(_xfs_bmapx_find data $testdir/file1 '10000$') -gt 0 || \
75 echo "Expected to find an unwritten file1 extent"
76 echo "Shared data extents"
77 test $(_xfs_bmapx_find data $testdir/file1 '100000$') -gt 0 || \
78 echo "Expected to find a shared data extent"
80 echo "Hole data extents"
81 test $(_xfs_bmapx_find data $testdir/file2 'hole') -gt 0 || \
82 echo "Expected to find a hole data extent"
83 echo "Shared data extents"
84 test $(_xfs_bmapx_find data $testdir/file2 '100000$') -gt 0 || \
85 echo "Expected to find a shared data extent"
87 echo "Hole cow extents"
88 test $(_xfs_bmapx_find cow $testdir/file1 'hole') -gt 0 || \
89 echo "Expected to find a hole cow extent"
90 echo "Hole cow extents"
91 test $(_xfs_bmapx_find cow $testdir/file2 'hole') -gt 0 || \
92 echo "Expected to find a hole cow extent"