4 # Test if btrfs leaks qgroup numbers for data extents
6 # Due to balance code is doing trick tree block swap, which doing
7 # non-standard extent reference update, qgroup can't handle it correctly,
8 # and leads to corrupted qgroup numbers.
10 #-----------------------------------------------------------------------
11 # Copyright (c) 2016 Fujitsu. All Rights Reserved.
13 # This program is free software; you can redistribute it and/or
14 # modify it under the terms of the GNU General Public License as
15 # published by the Free Software Foundation.
17 # This program is distributed in the hope that it would be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with this program; if not, write the Free Software Foundation,
24 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #-----------------------------------------------------------------------
29 seqres=$RESULT_DIR/$seq
30 echo "QA output created by $seq"
34 status=1 # failure is the default!
35 trap "_cleanup; exit \$status" 0 1 2 3 15
43 # get standard environment, filters and checks
47 # remove previous $seqres.full before test
50 # real QA test starts here
52 # Modify as appropriate.
56 _require_btrfs_qgroup_report
58 _scratch_mkfs >/dev/null
59 # Need to use inline extents to fill metadata rapidly
60 _scratch_mount "-o max_inline=2048"
62 # create 64K inlined metadata, which will ensure there is a 2-level
63 # metadata. Even for maximum nodesize(64K)
64 for i in $(seq 32); do
65 _pwrite_byte 0xcdcdcdcd 0 2k $SCRATCH_MNT/small_$i | _filter_xfs_io
68 # then a large data write to make the quota corruption obvious enough
69 _pwrite_byte 0xcdcdcdcd 0 32m $SCRATCH_MNT/large | _filter_xfs_io
72 # enable quota and rescan to get correct number
73 _run_btrfs_util_prog quota enable $SCRATCH_MNT
74 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
76 # now balance data block groups to corrupt qgroup
77 _run_btrfs_util_prog balance start -d $SCRATCH_MNT
80 # qgroup will be check at _check_scratch_fs() by fstest