2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
7 # Test if btrfs leaks qgroup numbers for data extents
9 # Due to balance code is doing trick tree block swap, which doing
10 # non-standard extent reference update, qgroup can't handle it correctly,
11 # and leads to corrupted qgroup numbers.
14 _begin_fstest auto quick qgroup balance
16 # Import common functions.
19 # real QA test starts here
21 # Modify as appropriate.
24 _require_btrfs_qgroup_report
26 _scratch_mkfs >/dev/null
27 # Need to use inline extents to fill metadata rapidly
28 _scratch_mount "-o max_inline=2048"
30 # create 64K inlined metadata, which will ensure there is a 2-level
31 # metadata. Even for maximum nodesize(64K)
32 for i in $(seq 32); do
33 _pwrite_byte 0xcdcdcdcd 0 2k $SCRATCH_MNT/small_$i | _filter_xfs_io
36 # then a large data write to make the quota corruption obvious enough
37 _pwrite_byte 0xcdcdcdcd 0 32m $SCRATCH_MNT/large | _filter_xfs_io
40 # enable quota and rescan to get correct number
41 _run_btrfs_util_prog quota enable $SCRATCH_MNT
42 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
44 # now balance data block groups to corrupt qgroup
45 _run_btrfs_balance_start -d $SCRATCH_MNT >> $seqres.full
48 # qgroup will be check at _check_scratch_fs() by fstest