2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu. All Rights Reserved.
7 # Test the basic functionality of Quota groups
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
30 _require_btrfs_qgroup_report
34 run_check _scratch_mkfs
37 LIMIT_SIZE=$((10 * 1024 * 1024))
39 _run_btrfs_util_prog quota enable $SCRATCH_MNT
40 _run_btrfs_util_prog qgroup create 1/1 $SCRATCH_MNT
41 _run_btrfs_util_prog qgroup limit $LIMIT_SIZE 1/1 $SCRATCH_MNT
43 for i in `seq 10 -1 1`; do
44 #add newly created subvolume qgroup to it's parent qgroup
45 _run_btrfs_util_prog subvolume create -i 1/1 \
49 #try to write data into every subvolume
50 for i in `seq 10 -1 1`; do
51 $XFS_IO_PROG -f -d -c 'pwrite -b 4k 0 10m' $SCRATCH_MNT/subv_$i/data \
56 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT \
60 #calculate every subvolume's data.
61 for i in `seq 10 -1 1`; do
62 #we may fail to create the file, skip this subvolume
63 test -f $SCRATCH_MNT/subv_$i || continue
65 filesize=`du -b $SCRATCH_MNT/subv_$i/data | $AWK_PROG '{print $1}'`
66 if [ $filesize -gt $LIMIT_SIZE ];then
67 _fail "subv_$i/data size should be less than $LIMIT_SIZE"
69 total_written=$(($total_written+$filesize))
72 #check if total written exceeds limit
73 if [ $total_written -gt $LIMIT_SIZE ];then
74 _fail "total written should be less than $LIMIT_SIZE"
78 echo "Silence is golden"