2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
7 # Test for incorrect exclusive reference count after cloning file
11 _begin_fstest auto quick qgroup
13 # Import common functions.
17 # real QA test starts here
23 # use largest node/leaf size (64K) to allow the test to be run on arch with
27 run_check _scratch_mkfs "--nodesize $NODESIZE"
29 # discard error output since we will check return value manually.
30 # also disable all compression, or output will mismatch with golden output
31 _try_scratch_mount "-o compress=no,compress-force=no" 2> /dev/null
33 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
34 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2
35 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3
37 _run_btrfs_util_prog quota enable $SCRATCH_MNT
38 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
40 $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io
41 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
42 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv3/file1
44 # Current btrfs use tree search ioctl to show quota, which will only show info
45 # in commit tree. So need to sync to update the qgroup commit tree.
48 units=`_btrfs_qgroup_units`
49 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | \
50 $AWK_PROG '{print $2" "$3}'