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
26 SUPPORT_NOINODE_CACHE="yes"
28 run_check _scratch_mkfs "--nodesize $NODESIZE"
30 # inode cache will also take space in fs tree, disable them to get consistent
32 # discard error output since we will check return value manually.
33 # also disable all compression, or output will mismatch with golden output
34 _try_scratch_mount "-o noinode_cache,compress=no,compress-force=no" 2> /dev/null
36 # Check for old kernel which doesn't support 'noinode_cache' mount option
38 support_noinode_cache="no"
42 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
43 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2
44 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3
46 _run_btrfs_util_prog quota enable $SCRATCH_MNT
47 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
49 # if we don't support noinode_cache mount option, then we should double check
50 # whether inode cache is enabled before executing the real test payload.
51 if [ $SUPPORT_NOINODE_CACHE == "no" ]; then
52 EMPTY_SIZE=`$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | \
53 $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2}' | head -n1`
54 if [ $EMPTY_SIZE != $NODESIZE ]; then
55 _notrun "Kernel doesn't support to disable inode cache"
59 $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io
60 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
61 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv3/file1
63 # Current btrfs use tree search ioctl to show quota, which will only show info
64 # in commit tree. So need to sync to update the qgroup commit tree.
67 units=`_btrfs_qgroup_units`
68 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | \
69 $AWK_PROG '{print $2" "$3}'