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 seqres=$RESULT_DIR/$seq
15 echo "QA output created by $seq"
19 status=1 # failure is the default!
20 trap "_cleanup; exit \$status" 0 1 2 3 15
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
35 # real QA test starts here
37 # Modify as appropriate.
40 _require_btrfs_qgroup_report
42 _scratch_mkfs >/dev/null
43 # Need to use inline extents to fill metadata rapidly
44 _scratch_mount "-o max_inline=2048"
46 # create 64K inlined metadata, which will ensure there is a 2-level
47 # metadata. Even for maximum nodesize(64K)
48 for i in $(seq 32); do
49 _pwrite_byte 0xcdcdcdcd 0 2k $SCRATCH_MNT/small_$i | _filter_xfs_io
52 # then a large data write to make the quota corruption obvious enough
53 _pwrite_byte 0xcdcdcdcd 0 32m $SCRATCH_MNT/large | _filter_xfs_io
56 # enable quota and rescan to get correct number
57 _run_btrfs_util_prog quota enable $SCRATCH_MNT
58 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
60 # now balance data block groups to corrupt qgroup
61 _run_btrfs_balance_start -d $SCRATCH_MNT >> $seqres.full
64 # qgroup will be check at _check_scratch_fs() by fstest