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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # Modify as appropriate.
36 _require_scratch_reflink
38 #btrfs needs 256mb to create default blockgroup fs
39 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
42 testfile=$SCRATCH_MNT/testfile
43 dummyfile=$SCRATCH_MNT/dummyfile
44 blocksize=$((128 * 1024))
46 # create a dummy file, which is used to occupy some fs space first.
47 _pwrite_byte 0xcdcdcdcd 0 $((1 * 1024 * 1024)) $dummyfile > /dev/null
48 _pwrite_byte 0xcdcdcdcd 0 $blocksize $testfile > /dev/null
50 echo "Silence is golden"
51 for ((i = 0; i < 16384; i++)); do
52 _reflink_range $testfile 0 $testfile $(($i * $blocksize)) \
53 $blocksize > /dev/null 2>&1
56 # consume all remaining free space
57 dd if=/dev/zero of=$SCRATCH_MNT/space >/dev/null 2>&1
60 # fs is full now and fs internal operations may need some free space, for
61 # example, in btrfs, transaction will need to reserve space first, so here free
64 $XFS_IO_PROG -f -c "truncate 0" $testfile