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 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # real QA test starts here
38 # use largest node/leaf size (64K) to allow the test to be run on arch with
41 SUPPORT_NOINODE_CACHE="yes"
43 run_check _scratch_mkfs "--nodesize $NODESIZE"
45 # inode cache will also take space in fs tree, disable them to get consistent
47 # discard error output since we will check return value manually.
48 # also disable all compression, or output will mismatch with golden output
49 _try_scratch_mount "-o noinode_cache,compress=no,compress-force=no" 2> /dev/null
51 # Check for old kernel which doesn't support 'noinode_cache' mount option
53 support_noinode_cache="no"
57 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
58 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2
59 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3
61 _run_btrfs_util_prog quota enable $SCRATCH_MNT
62 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
64 # if we don't support noinode_cache mount option, then we should double check
65 # whether inode cache is enabled before executing the real test payload.
66 if [ $SUPPORT_NOINODE_CACHE == "no" ]; then
67 EMPTY_SIZE=`$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | \
68 $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2}' | head -n1`
69 if [ $EMPTY_SIZE != $NODESIZE ]; then
70 _notrun "Kernel doesn't support to disable inode cache"
74 $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io
75 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
76 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv3/file1
78 # Current btrfs use tree search ioctl to show quota, which will only show info
79 # in commit tree. So need to sync to update the qgroup commit tree.
82 units=`_btrfs_qgroup_units`
83 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | \
84 $AWK_PROG '{print $2" "$3}'