4 # Ensure that we can create enough distinct reflink entries to force creation
5 # of a multi-level refcount btree by reflinking a file a number of times and
6 # truncating the copies at successively lower sizes. Delete and recreate a few
7 # times to exercise the refcount btree grow/shrink functions.
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 umount $SCRATCH_MNT > /dev/null 2>&1
42 # get standard environment, filters and checks
47 # real QA test starts here
50 _require_scratch_reflink
55 _scratch_mkfs >/dev/null 2>&1
58 testdir=$SCRATCH_MNT/test-$seq
61 echo "Create the original file blocks"
62 blksz="$(_get_block_size $testdir)"
63 nr_blks=$((2 * blksz / 12))
66 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
68 echo "$i: Reflink a bunch of times"
69 seq 1 $nr_blks | while read nr; do
70 _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
74 echo "$i: Truncate files"
75 seq 1 $nr_blks | while read nr; do
76 truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
83 test $i = "x" && break
85 echo "$i: Delete both files"