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