btrfs/057: Update test case to keep subvolume in any kernel version
[xfstests-dev.git] / tests / btrfs / 057
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2014 Fujitsu.  All rights reserved.
4 #
5 # FSQA Test No. btrfs/057
6 #
7 # Quota rescan stress test, we run fsstress and quota rescan concurrently
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1
16
17 _cleanup()
18 {
19         cd /
20         rm -f $tmp.*
21 }
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 # real QA test starts here
29 _supported_fs btrfs
30 _supported_os Linux
31 _require_scratch
32
33 rm -f $seqres.full
34
35 # use small leaf size to get higher btree height.
36 run_check _scratch_mkfs "-b 1g --nodesize 4096"
37
38 # inode cache is saved in the FS tree itself for every
39 # individual FS tree,that affects the sizes reported by qgroup show
40 # so we need to explicitly turn it off to get consistent values.
41 _scratch_mount "-o noinode_cache"
42
43 # -w ensures that the only ops are ones which cause write I/O
44 run_check $FSSTRESS_PROG -d $SCRATCH_MNT -w -p 5 -n 1000 \
45                 $FSSTRESS_AVOID >&/dev/null
46
47 _run_btrfs_util_prog subvolume snapshot $SCRATCH_MNT \
48         $SCRATCH_MNT/snap1
49
50 run_check $FSSTRESS_PROG -d $SCRATCH_MNT/snap1 -w -p 5 -n 1000 \
51        $FSSTRESS_AVOID >&/dev/null
52
53 _run_btrfs_util_prog quota enable $SCRATCH_MNT
54 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
55
56 # remove all file/dir other than subvolume
57 rm -rf $SCRATCH_MNT/snap1/* >& /dev/null
58 rm -rf $SCRATCH_MNT/p* >& /dev/null
59
60 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT
61 units=`_btrfs_qgroup_units`
62 $BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | $SED_PROG -n '/[0-9]/p' \
63         | $AWK_PROG '{print $2" "$3}'
64
65 status=0
66 exit