2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that we can create enough distinct reflink entries to force creation
8 # of a multi-level refcount btree by reflinking a file a number of times and
9 # truncating the copies at successively lower sizes. Delete and recreate a few
10 # times to exercise the refcount btree grow/shrink functions.
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
24 _scratch_unmount > /dev/null 2>&1
28 # get standard environment, filters and checks
33 # real QA test starts here
35 _require_scratch_reflink
40 _scratch_mkfs >/dev/null 2>&1
43 testdir=$SCRATCH_MNT/test-$seq
46 echo "Create the original file blocks"
47 blksz="$(_get_block_size $testdir)"
48 nr_blks=$((2 * blksz / 12))
51 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
53 echo "$i: Reflink a bunch of times"
54 seq 1 $nr_blks | while read nr; do
55 _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
59 echo "$i: Truncate files"
60 seq 1 $nr_blks | while read nr; do
61 truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
68 test $i = "x" && break
70 echo "$i: Delete both files"