4 # Test for incorrect exclusive reference count after cloning file
7 #-----------------------------------------------------------------------
8 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
10 # This program is free software; you can redistribute it and/or
11 # modify it under the terms of the GNU General Public License as
12 # published by the Free Software Foundation.
14 # This program is distributed in the hope that it would be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program; if not, write the Free Software Foundation,
21 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=1 # failure is the default!
32 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
44 # real QA test starts here
54 # use largest node/leaf size (64K) to allow the test to be run on arch with
57 SUPPORT_NOINODE_CACHE="yes"
59 run_check _scratch_mkfs "--nodesize $NODESIZE"
61 # inode cache will also take space in fs tree, disable them to get consistent
63 # discard error output since we will check return value manually.
64 _scratch_mount "-o noinode_cache" 2> /dev/null
66 # Check for old kernel which doesn't support 'noinode_cache' mount option
68 support_noinode_cache="no"
69 run_check _scratch_mount
72 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv1
73 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv2
74 _run_btrfs_util_prog subvolume create $SCRATCH_MNT/subv3
76 _run_btrfs_util_prog quota enable $SCRATCH_MNT
77 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
79 # if we don't support noinode_cache mount option, then we should double check
80 # whether inode cache is enabled before executing the real test payload.
81 if [ $SUPPORT_NOINODE_CACHE == "no" ]; then
82 EMPTY_SIZE=`$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | \
83 $SED_PROG -n '/[0-9]/p' | $AWK_PROG '{print $2}' | head -n1`
84 if [ $EMPTY_SIZE != $NODESIZE ]; then
85 _notrun "Kernel doesn't support to disable inode cache"
89 $XFS_IO_PROG -f -c "pwrite 0 256K" $SCRATCH_MNT/subv1/file1 | _filter_xfs_io
90 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv2/file1
91 cp --reflink $SCRATCH_MNT/subv1/file1 $SCRATCH_MNT/subv3/file1
93 # Current btrfs use tree search ioctl to show quota, which will only show info
94 # in commit tree. So need to sync to update the qgroup commit tree.
97 units=`_btrfs_qgroup_units`
98 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' | \
99 $AWK_PROG '{print $2" "$3}'