btrfs/139: creation/deletion within qgroup limits
[xfstests-dev.git] / tests / btrfs / 139
1 #! /bin/bash
2 # FS QA Test 139
3 #
4 # Check if btrfs quota limits are not reached when you constantly
5 # create and delete files within the exclusive qgroup limits.
6 #
7 # Finally we create files to exceed the quota.
8 #
9 #-----------------------------------------------------------------------
10 # Copyright (c) 2017 SUSE. All Rights Reserved.
11 #
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This program is distributed in the hope that it would be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write the Free Software Foundation,
23 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
24 #-----------------------------------------------------------------------
25 #
26
27 seq=`basename $0`
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
35
36 _cleanup()
37 {
38         cd /
39         rm -f $tmp.*
40 }
41
42 # get standard environment, filters and checks
43 . ./common/rc
44 . ./common/filter
45
46 # remove previous $seqres.full before test
47 rm -f $seqres.full
48
49 _supported_fs btrfs
50 _supported_os Linux
51 _require_scratch
52
53 _scratch_mkfs > /dev/null 2>&1
54 _scratch_mount
55
56 SUBVOL=$SCRATCH_MNT/subvol
57
58 _run_btrfs_util_prog subvolume create $SUBVOL
59 _run_btrfs_util_prog quota enable $SCRATCH_MNT
60 _run_btrfs_util_prog quota rescan -w $SCRATCH_MNT
61 _run_btrfs_util_prog qgroup limit -e 1G $SUBVOL
62
63
64 # Write and delete files within 1G limits, multiple times
65 for i in $(seq 1 5); do
66         for j in $(seq 1 240); do
67                 $XFS_IO_PROG -f -c "pwrite 0 4m" $SUBVOL/file_$j > /dev/null
68         done
69         rm -f $SUBVOL/file*
70 done
71
72 # Exceed the limits here
73 for j in $(seq 1 8); do
74         $XFS_IO_PROG -f -c "pwrite 0 128m" $SUBVOL/file_$j 2>&1 | _filter_xfs_io | _filter_xfs_io_error
75 done
76
77 # success, all done
78 status=0
79 exit