2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
7 # Create a heavily reflinked file, then check whether we can truncate
11 _begin_fstest auto clone
13 # Import common functions.
17 # Modify as appropriate.
19 _require_scratch_reflink
21 #btrfs needs 256mb to create default blockgroup fs
22 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
25 testfile=$SCRATCH_MNT/testfile
26 dummyfile=$SCRATCH_MNT/dummyfile
27 blocksize=$((128 * 1024))
29 # create a dummy file, which is used to occupy some fs space first.
30 _pwrite_byte 0xcdcdcdcd 0 $((1 * 1024 * 1024)) $dummyfile > /dev/null
31 _pwrite_byte 0xcdcdcdcd 0 $blocksize $testfile > /dev/null
33 echo "Silence is golden"
34 for ((i = 0; i < 16384; i++)); do
35 _reflink_range $testfile 0 $testfile $(($i * $blocksize)) \
36 $blocksize > /dev/null 2>&1
39 # consume all remaining free space
40 dd if=/dev/zero of=$SCRATCH_MNT/space >/dev/null 2>&1
43 # fs is full now and fs internal operations may need some free space, for
44 # example, in btrfs, transaction will need to reserve space first, so here free
47 $XFS_IO_PROG -f -c "truncate 0" $testfile