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 _begin_fstest auto quick qgroup enospc limit prealloc
15 # Import common functions.
18 # real QA test starts here
20 # Modify as appropriate.
23 _require_xfs_io_command falloc
25 _scratch_mkfs > /dev/null
28 $BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
29 _qgroup_rescan "$SCRATCH_MNT" > /dev/null
30 $BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT"
32 # Create a file with the following layout:
34 # | Hole |4K| Hole |4K| Hole |
35 # The total hole size will be 384M - 8k
36 truncate -s 384m "$SCRATCH_MNT/file"
37 $XFS_IO_PROG -c "pwrite 128m 4k" -c "pwrite 256m 4k" \
38 "$SCRATCH_MNT/file" | _filter_xfs_io
40 # Falloc 0~384M range, it's going to fail due to the qgroup limit
41 $XFS_IO_PROG -c "falloc 0 384m" "$SCRATCH_MNT/file" | _filter_xfs_io_error
42 rm -f "$SCRATCH_MNT/file"
44 # Ensure above delete reaches disk and free some space
47 # We should be able to write at least 3/4 of the limit
48 $XFS_IO_PROG -f -c "pwrite 0 192m" "$SCRATCH_MNT/file" | _filter_xfs_io