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.
35 _require_scratch_reflink
37 #btrfs needs 256mb to create default blockgroup fs
38 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
41 testfile=$SCRATCH_MNT/testfile
42 dummyfile=$SCRATCH_MNT/dummyfile
43 blocksize=$((128 * 1024))
45 # create a dummy file, which is used to occupy some fs space first.
46 _pwrite_byte 0xcdcdcdcd 0 $((1 * 1024 * 1024)) $dummyfile > /dev/null
47 _pwrite_byte 0xcdcdcdcd 0 $blocksize $testfile > /dev/null
49 echo "Silence is golden"
50 for ((i = 0; i < 16384; i++)); do
51 _reflink_range $testfile 0 $testfile $(($i * $blocksize)) \
52 $blocksize > /dev/null 2>&1
55 # consume all remaining free space
56 dd if=/dev/zero of=$SCRATCH_MNT/space >/dev/null 2>&1
59 # fs is full now and fs internal operations may need some free space, for
60 # example, in btrfs, transaction will need to reserve space first, so here free
63 $XFS_IO_PROG -f -c "truncate 0" $testfile