2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu. All Rights Reserved.
7 # Test the basic functionality of Quota groups
10 _begin_fstest auto quick qgroup limit
12 # Import common functions.
17 _require_btrfs_qgroup_report
19 run_check _scratch_mkfs
22 LIMIT_SIZE=$((10 * 1024 * 1024))
24 _run_btrfs_util_prog quota enable $SCRATCH_MNT
25 _run_btrfs_util_prog qgroup create 1/1 $SCRATCH_MNT
26 _run_btrfs_util_prog qgroup limit $LIMIT_SIZE 1/1 $SCRATCH_MNT
28 for i in `seq 10 -1 1`; do
29 #add newly created subvolume qgroup to it's parent qgroup
30 _run_btrfs_util_prog subvolume create -i 1/1 \
34 #try to write data into every subvolume
35 for i in `seq 10 -1 1`; do
36 $XFS_IO_PROG -f -d -c 'pwrite -b 4k 0 10m' $SCRATCH_MNT/subv_$i/data \
41 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT \
45 #calculate every subvolume's data.
46 for i in `seq 10 -1 1`; do
47 #we may fail to create the file, skip this subvolume
48 test -f $SCRATCH_MNT/subv_$i || continue
50 filesize=`du -b $SCRATCH_MNT/subv_$i/data | $AWK_PROG '{print $1}'`
51 if [ $filesize -gt $LIMIT_SIZE ];then
52 _fail "subv_$i/data size should be less than $LIMIT_SIZE"
54 total_written=$(($total_written+$filesize))
57 #check if total written exceeds limit
58 if [ $total_written -gt $LIMIT_SIZE ];then
59 _fail "total written should be less than $LIMIT_SIZE"
63 echo "Silence is golden"