summaryrefslogtreecommitdiff
path: root/tests/btrfs/193
blob: bf9e92b4aaf91afdfd3f67ed63bad6359cbca608 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test btrfs/193
#
# Test if btrfs is going to leak qgroup reserved data space when
# falloc on multiple holes fails.
# The fix is titled:
# "btrfs: qgroup: Fix the wrong target io_tree when freeing reserved data space"
#
. ./common/preamble
_begin_fstest auto quick qgroup enospc limit prealloc

. ./common/filter

_supported_fs btrfs
_require_scratch
_require_xfs_io_command falloc

_scratch_mkfs > /dev/null
_scratch_mount

$BTRFS_UTIL_PROG quota enable "$SCRATCH_MNT" > /dev/null
_qgroup_rescan "$SCRATCH_MNT" > /dev/null
$BTRFS_UTIL_PROG qgroup limit -e 256M "$SCRATCH_MNT"

# Create a file with the following layout:
# 0         128M      256M      384M
# |  Hole   |4K| Hole |4K| Hole |
# The total hole size will be 384M - 8k
truncate -s 384m "$SCRATCH_MNT/file"
$XFS_IO_PROG -c "pwrite 128m 4k" -c "pwrite 256m 4k" \
	"$SCRATCH_MNT/file" | _filter_xfs_io

# Falloc 0~384M range, it's going to fail due to the qgroup limit
$XFS_IO_PROG -c "falloc 0 384m" "$SCRATCH_MNT/file" | _filter_xfs_io_error
rm -f "$SCRATCH_MNT/file"

# Ensure above delete reaches disk and free some space
sync

# We should be able to write at least 3/4 of the limit
$XFS_IO_PROG -f -c "pwrite 0 192m" "$SCRATCH_MNT/file" | _filter_xfs_io

# success, all done
status=0
exit