blob: afed43b503e5c10860da1f785fded0ae5101059f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Facebook. All Rights Reserved.
#
# FS QA Test No. 320
#
# Test qgroups to validate the creation works, the counters are sane, rescan
# works, and we do not get failures when we write less than the limit amount.
#
. ./common/preamble
_begin_fstest auto qgroup limit
. ./common/filter
_supported_fs btrfs
_require_scratch
_require_qgroup_rescan
_require_btrfs_qgroup_report
_require_scratch_qgroup
# Test to make sure we can actually turn it on and it makes sense
_basic_test()
{
echo "=== basic test ===" >> $seqres.full
_btrfs subvolume create $SCRATCH_MNT/a
_btrfs quota enable $SCRATCH_MNT/a
_qgroup_rescan $SCRATCH_MNT
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep $subvolid >> \
$seqres.full 2>&1
[ $? -eq 0 ] || _fail "couldn't find our subvols quota group"
run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
$FSSTRESS_AVOID
_btrfs subvolume snapshot $SCRATCH_MNT/a \
$SCRATCH_MNT/b
# the shared values of both the original subvol and snapshot should
# match
a_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
a_shared=$(echo $a_shared | $AWK_PROG '{ print $2 }')
echo "subvol a id=$subvolid" >> $seqres.full
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT b)
echo "subvol b id=$subvolid" >> $seqres.full
b_shared=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
b_shared=$(echo $b_shared | $AWK_PROG '{ print $2 }')
$BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT >> $seqres.full
[ $b_shared -eq $a_shared ] || _fail "shared values don't match"
}
#enable quotas, do some work, check our values and then rescan and make sure we
#come up with the same answer
_rescan_test()
{
echo "=== rescan test ===" >> $seqres.full
# first with a blank subvol
_btrfs subvolume create $SCRATCH_MNT/a
_btrfs quota enable $SCRATCH_MNT/a
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
run_check $FSSTRESS_PROG -d $SCRATCH_MNT/a -w -p 1 -n 2000 \
$FSSTRESS_AVOID
sync
output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
echo "qgroup values before rescan: $output" >> $seqres.full
refer=$(echo $output | $AWK_PROG '{ print $2 }')
excl=$(echo $output | $AWK_PROG '{ print $3 }')
_qgroup_rescan $SCRATCH_MNT
output=$($BTRFS_UTIL_PROG qgroup show $units $SCRATCH_MNT | grep "0/$subvolid")
echo "qgroup values after rescan: $output" >> $seqres.full
[ $refer -eq $(echo $output | $AWK_PROG '{ print $2 }') ] || \
_fail "reference values don't match after rescan"
[ $excl -eq $(echo $output | $AWK_PROG '{ print $3 }') ] || \
_fail "exclusive values don't match after rescan"
}
#basic noexceed limit testing
_limit_test_noexceed()
{
echo "=== limit not exceed test ===" >> $seqres.full
_btrfs subvolume create $SCRATCH_MNT/a
_btrfs quota enable $SCRATCH_MNT
subvolid=$(_btrfs_get_subvolid $SCRATCH_MNT a)
_btrfs qgroup limit 5M 0/$subvolid $SCRATCH_MNT
_ddt of=$SCRATCH_MNT/a/file bs=4M count=1 >> $seqres.full 2>&1
[ $? -eq 0 ] || _fail "should have been allowed to write"
}
units=`_btrfs_qgroup_units`
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_basic_test
_scratch_unmount
_check_scratch_fs
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_rescan_test
_scratch_unmount
_check_scratch_fs
_scratch_mkfs > /dev/null 2>&1
_scratch_mount
_limit_test_noexceed
# success, all done
echo "Silence is golden"
status=0
exit
|