4 # Ensure that reflinking a file N times doesn't eat a lot of blocks
5 # - Create a file and record fs block usage
6 # - Create some reflink copies
7 # - Compare fs block usage to before
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2015, Oracle and/or its affiliates. All Rights Reserved.
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #-----------------------------------------------------------------------
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
38 rm -rf $tmp.* $testdir
41 # get standard environment, filters and checks
46 # real QA test starts here
53 testdir=$TEST_DIR/test-$seq
57 echo "Create the original file blocks"
58 blksz="$(_get_block_size $testdir)"
63 filesize=$((blksz * nr))
64 _pwrite_byte 0x61 0 $sz $testdir/file1 >> $seqres.full
66 free_blocks0=$(stat -f $testdir -c '%f')
68 echo "Create the reflink copies"
69 for i in `seq 2 $nr`; do
70 _cp_reflink $testdir/file1 $testdir/file.$i
73 free_blocks1=$(stat -f $testdir -c '%f')
75 _within_tolerance "free blocks after reflink" $free_blocks1 $free_blocks0 $margin -v