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 _begin_fstest auto quick clone
15 # Override the default cleanup function.
19 rm -rf $tmp.* $testdir
22 # Import common functions.
26 # real QA test starts here
30 testdir=$TEST_DIR/test-$seq
34 echo "Create the original file blocks"
35 blksz="$(_get_block_size $testdir)"
40 filesize=$((blksz * nr))
41 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
43 free_blocks0=$(stat -f $testdir -c '%f')
45 echo "Create the reflink copies"
46 for i in `seq 2 $nr`; do
47 _cp_reflink $testdir/file1 $testdir/file.$i
50 free_blocks1=$(stat -f $testdir -c '%f')
52 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v