btrfs: check qgroup doesn't crash when beyond limit
[xfstests-dev.git] / tests / btrfs / 182
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2019 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 182
6 #
7 # Test if balance will report false ENOSPC error
8 #
9 # This is a long existing bug, caused by over-estimated metadata
10 # space_info::bytes_may_use.
11 #
12 # There is one proposed patch for btrfs-progs to fix it, titled:
13 # "btrfs-progs: balance: Sync the fs before balancing metadata chunks"
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs btrfs
41 _require_scratch
42
43 nr_files=1024
44
45 _scratch_mkfs > /dev/null
46 _scratch_mount
47
48 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/subvol" > /dev/null
49
50 # Create some small files to take up enough metadata reserved space
51 for ((i = 0; i < $nr_files; i++)) do
52         _pwrite_byte 0xcd 0 1K "$SCRATCH_MNT/subvol/file_$i" > /dev/null
53 done
54
55 _run_btrfs_balance_start -m $SCRATCH_MNT >> $seqres.full
56
57 # success, all done
58 echo "Silence is golden"
59 status=0
60 exit