2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
7 # Ensure that reflinking a file N times doesn't eat a lot of blocks
8 # - Create a file and record fs block usage
9 # - Create some reflink copies
10 # - Compare fs block usage to before
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 rm -rf $tmp.* $testdir
27 # get standard environment, filters and checks
32 # real QA test starts here
38 testdir=$TEST_DIR/test-$seq
42 echo "Create the original file blocks"
43 blksz="$(_get_block_size $testdir)"
48 filesize=$((blksz * nr))
49 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
51 free_blocks0=$(stat -f $testdir -c '%f')
53 echo "Create the reflink copies"
54 for i in `seq 2 $nr`; do
55 _cp_reflink $testdir/file1 $testdir/file.$i
58 free_blocks1=$(stat -f $testdir -c '%f')
60 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v