2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
7 # Test if btrfs is going to leak qgroup reserved data space when
8 # falloc on multiple holes fails.
10 # "btrfs: qgroup: Fix the wrong target io_tree when freeing reserved data space"
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
27 # get standard environment, filters and checks
31 # remove previous $seqres.full before test
34 # real QA test starts here
36 # Modify as appropriate.
39 _require_xfs_io_command falloc
41 _scratch_mkfs > /dev/null
44 $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
45 $BTRFS_UTIL_PROG quota rescan -w "$SCRATCH_MNT" > /dev/null
46 $BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT"
48 # Create a file with the following layout:
50 # | Hole |4K| Hole |4K| Hole |
51 # The total hole size will be 384M - 8k
52 truncate -s 384m "$SCRATCH_MNT/file"
53 $XFS_IO_PROG -c "pwrite 128m 4k" -c "pwrite 256m 4k" \
54 "$SCRATCH_MNT/file" | _filter_xfs_io
56 # Falloc 0~384M range, it's going to fail due to the qgroup limit
57 $XFS_IO_PROG -c "falloc 0 384m" "$SCRATCH_MNT/file" | _filter_xfs_io_error
58 rm -f "$SCRATCH_MNT/file"
60 # Ensure above delete reaches disk and free some space
63 # We should be able to write at least 3/4 of the limit
64 $XFS_IO_PROG -f -c "pwrite 0 192m" "$SCRATCH_MNT/file" | _filter_xfs_io