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
36 _require_scratch_reflink
41 _scratch_mkfs >/dev/null 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
47 echo "Create the original file blocks"
48 blksz="$(_get_block_size $testdir)"
49 nr_blks=$((2 * blksz / 12))
52 _pwrite_byte 0x61 0 $((blksz * nr_blks)) $testdir/file1 >> $seqres.full
54 echo "$i: Reflink a bunch of times"
55 seq 1 $nr_blks | while read nr; do
56 _cp_reflink $testdir/file1 $testdir/file1.$nr >> $seqres.full
60 echo "$i: Truncate files"
61 seq 1 $nr_blks | while read nr; do
62 truncate -s $((blksz * (nr_blks - nr))) $testdir/file1.$nr >> $seqres.full
69 test $i = "x" && break
71 echo "$i: Delete both files"