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
39 testdir=$TEST_DIR/test-$seq
43 echo "Create the original file blocks"
44 blksz="$(_get_block_size $testdir)"
49 filesize=$((blksz * nr))
50 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
52 free_blocks0=$(stat -f $testdir -c '%f')
54 echo "Create the reflink copies"
55 for i in `seq 2 $nr`; do
56 _cp_reflink $testdir/file1 $testdir/file.$i
59 free_blocks1=$(stat -f $testdir -c '%f')
61 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v