fstests: move test group info to test files
[xfstests-dev.git] / tests / btrfs / 091
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
4 #
5 # FS QA Test No. 091
6 #
7 # Test for incorrect exclusive reference count after cloning file
8 # between subvolumes.
9 #
10 . ./common/preamble
11 _begin_fstest auto quick qgroup
12
13 # Import common functions.
14 . ./common/filter
15 . ./common/reflink
16
17 # real QA test starts here
18
19 _supported_fs btrfs
20 _require_scratch
21 _require_cp_reflink
22
23 # use largest node/leaf size (64K) to allow the test to be run on arch with
24 # page size > 4k.
25 NODESIZE=65536
26 SUPPORT_NOINODE_CACHE="yes"
27
28 run_check _scratch_mkfs "--nodesize $NODESIZE"
29
30 # inode cache will also take space in fs tree, disable them to get consistent
31 # result.
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
35
36 # Check for old kernel which doesn't support 'noinode_cache' mount option
37 if [ $? -ne 0 ]; then
38         support_noinode_cache="no"
39         _scratch_mount
40 fi
41
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
45
46 _run_btrfs_util_prog quota enable $SCRATCH_MNT
47 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
48
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"
56         fi
57 fi
58
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
62
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.
65 sync
66
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}'
70
71 # success, all done
72 status=0
73 exit