2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Liu Bo. All Rights Reserved.
7 # Verify that removing shared extents can end up incorrect qgroup accounting.
9 # Regression of 'commit fcebe4562dec ("Btrfs: rework qgroup accounting")',
10 # this will throw a warning into dmesg.
12 # The issue is fixed by https://patchwork.kernel.org/patch/5499981/
13 # "Btrfs: fix a warning of qgroup account on shared extents"
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
34 # real QA test starts here
42 # Currently in btrfs the node/leaf size can not be smaller than the page
43 # size (but it can be greater than the page size). So use the largest
44 # supported node/leaf size (64Kb) so that the test can run on any platform
45 # that Linux supports.
46 _scratch_mkfs "--nodesize 65536" >>$seqres.full 2>&1
49 BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
50 EXTENT_SIZE=$((2 * $BLOCK_SIZE))
52 $XFS_IO_PROG -f -d -c "pwrite 0 $EXTENT_SIZE" $SCRATCH_MNT/foo \
53 | _filter_xfs_io_blocks_modified
55 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT $SCRATCH_MNT/snap
57 $CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo $SCRATCH_MNT/foo-reflink
59 $CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo \
60 $SCRATCH_MNT/snap/foo-reflink
62 $CLONER_PROG -s 0 -d 0 -l $EXTENT_SIZE $SCRATCH_MNT/foo \
63 $SCRATCH_MNT/snap/foo-reflink2
65 _run_btrfs_util_prog quota enable $SCRATCH_MNT
66 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
68 rm -fr $SCRATCH_MNT/foo*
69 rm -fr $SCRATCH_MNT/snap/foo*
73 units=`_btrfs_qgroup_units`
74 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $AWK_PROG '/[0-9]/ {print $2" "$3}'