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
37 # use largest node/leaf size (64K) to allow the test to be run on arch with
40 SUPPORT_NOINODE_CACHE="yes"
42 run_check _scratch_mkfs "--nodesize $NODESIZE"
44 # inode cache will also take space in fs tree, disable them to get consistent
46 # discard error output since we will check return value manually.
47 # also disable all compression, or output will mismatch with golden output
48 _try_scratch_mount "-o noinode_cache,compress=no,compress-force=no" 2> /dev/null
50 # Check for old kernel which doesn't support 'noinode_cache' mount option
52 support_noinode_cache="no"
56 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
57 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2
58 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3
60 _run_btrfs_util_prog quota enable $SCRATCH_MNT
61 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
63 # if we don't support noinode_cache mount option, then we should double check
64 # whether inode cache is enabled before executing the real test payload.
65 if [ $SUPPORT_NOINODE_CACHE == "no" ]; then
66 EMPTY_SIZE=`$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | \
67 $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2}' | head -n1`
68 if [ $EMPTY_SIZE != $NODESIZE ]; then
69 _notrun "Kernel doesn't support to disable inode cache"
73 $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io
74 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
75 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv3/file1
77 # Current btrfs use tree search ioctl to show quota, which will only show info
78 # in commit tree. So need to sync to update the qgroup commit tree.
81 units=`_btrfs_qgroup_units`
82 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | \
83 $AWK_PROG '{print $2" "$3}'