summaryrefslogtreecommitdiff
path: root/tests/btrfs/230
blob: 2daacfbeebb63d769f56cfc3f7b20bb92cca80eb (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2020 SUSE Linux Products GmbH. All Rights Reserved.
#
# FS QA Test 230
#
# Test if btrfs qgroup would crash if we're modifying the fs
# after exceeding the limit
#
. ./common/preamble
_begin_fstest auto quick qgroup limit

# Import common functions.
. ./common/filter

# real QA test starts here

_supported_fs btrfs

# Need at least 2GiB
_require_scratch_size $((2 * 1024 * 1024))
_scratch_mkfs > /dev/null 2>&1
_scratch_mount

_pwrite_byte 0xcd 0 1G $SCRATCH_MNT/file >> $seqres.full
# Make sure the data reach disk so later qgroup scan can see it
sync

$BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
$BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full

# Set the limit to just 512MiB, which is way below the existing usage
$BTRFS_UTIL_PROG qgroup limit  512M 0/5 $SCRATCH_MNT

# Touch above file, if kernel not patched, it will trigger an ASSERT()
#
# Even for patched kernel, we will still get EDQUOT error, but that
# is expected behavior.
touch $SCRATCH_MNT/file 2>&1 | _filter_scratch

# success, all done
status=0
exit