4 # Make sure that the reference counting mechanism can handle the case
5 # where we share the first 1/4 of an extent with a file, share the
6 # last 1/4 of the extent with a second file, share the first half of
7 # the extent with N files, and share the second half of the extent
8 # with a different set of N files. The key point here is to test that
9 # we handle the case where a refcount extent record doesn't coincide
10 # exactly with the block mapping records.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2016 Oracle, Inc. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 7 15
46 # get standard environment, filters and checks
51 # real QA test starts here
53 _require_scratch_reflink
55 echo "Format and mount"
56 _scratch_mkfs > $seqres.full 2>&1
57 _scratch_mount >> $seqres.full 2>&1
59 testdir=$SCRATCH_MNT/test-$seq
65 halfway=$((blocks / 2 * blksz))
66 quarter=$((blocks / 4 * blksz))
68 echo "Initialize file"
69 _pwrite_byte 0x61 0 $((blocks * blksz)) $testdir/file >> $seqres.full
71 echo "Share the first half of the extent"
72 seq 1 $nr | while read nr; do
73 _reflink_range $testdir/file 0 $testdir/file$nr.0 0 $halfway >> $seqres.full
76 echo "Share the last half of the extent"
77 seq 1 $nr | while read nr; do
78 _reflink_range $testdir/file $halfway $testdir/file$nr.1 0 $halfway >> $seqres.full
81 echo "Share the first quarter of the extent"
82 _reflink_range $testdir/file 0 $testdir/file.2 0 $quarter >> $seqres.full
84 echo "Share the last quarter of the extent"
85 _reflink_range $testdir/file $((quarter * 3)) $testdir/file.3 0 $quarter >> $seqres.full
90 md5sum $testdir/file $testdir/file* | _filter_scratch