common: kill _supported_os
[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 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21     rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/reflink
28
29 # real QA test starts here
30
31 _supported_fs btrfs
32 _require_scratch
33 _require_cp_reflink
34
35 rm -f $seqres.full
36
37 # use largest node/leaf size (64K) to allow the test to be run on arch with
38 # page size > 4k.
39 NODESIZE=65536
40 SUPPORT_NOINODE_CACHE="yes"
41
42 run_check _scratch_mkfs "--nodesize $NODESIZE"
43
44 # inode cache will also take space in fs tree, disable them to get consistent
45 # result.
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
49
50 # Check for old kernel which doesn't support 'noinode_cache' mount option
51 if [ $? -ne 0 ]; then
52         support_noinode_cache="no"
53         _scratch_mount
54 fi
55
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
59
60 _run_btrfs_util_prog quota enable $SCRATCH_MNT
61 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
62
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"
70         fi
71 fi
72
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
76
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.
79 sync
80
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}'
84
85 # success, all done
86 status=0
87 exit