4 # Test the basic functionality of Quota groups
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2014 Fujitsu. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
30 status=1 # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
39 # get standard environment, filters and checks
46 _require_btrfs_qgroup_report
50 run_check _scratch_mkfs
53 LIMIT_SIZE=$((10 * 1024 * 1024))
55 _run_btrfs_util_prog quota enable $SCRATCH_MNT
56 _run_btrfs_util_prog qgroup create 1/1 $SCRATCH_MNT
57 _run_btrfs_util_prog qgroup limit $LIMIT_SIZE 1/1 $SCRATCH_MNT
59 for i in `seq 10 -1 1`; do
60 #add newly created subvolume qgroup to it's parent qgroup
61 _run_btrfs_util_prog subvolume create -i 1/1 \
65 #try to write data into every subvolume
66 for i in `seq 10 -1 1`; do
67 $XFS_IO_PROG -f -d -c 'pwrite -b 4k 0 10m' $SCRATCH_MNT/subv_$i/data \
72 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT \
76 #calculate every subvolume's data.
77 for i in `seq 10 -1 1`; do
78 #we may fail to create the file, skip this subvolume
79 test -f $SCRATCH_MNT/subv_$i || continue
81 filesize=`du -b $SCRATCH_MNT/subv_$i/data | $AWK_PROG '{print $1}'`
82 if [ $filesize -gt $LIMIT_SIZE ];then
83 _fail "subv_$i/data size should be less than $LIMIT_SIZE"
85 total_written=$(($total_written+$filesize))
88 #check if total written exceeds limit
89 if [ $total_written -gt $LIMIT_SIZE ];then
90 _fail "total written should be less than $LIMIT_SIZE"
94 echo "Silence is golden"