generic: test MADV_POPULATE_READ with IO errors
[xfstests-dev.git] / tests / btrfs / 042
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Fujitsu.  All Rights Reserved.
4 #
5 # FS QA Test No. 042
6 #
7 # Test the basic functionality of Quota groups
8 #
9 . ./common/preamble
10 _begin_fstest auto quick qgroup limit
11
12 # Import common functions.
13 . ./common/filter
14
15 _supported_fs btrfs
16 _require_scratch
17 _require_btrfs_qgroup_report
18
19 run_check _scratch_mkfs
20 _scratch_mount
21
22 LIMIT_SIZE=$((10 * 1024 * 1024))
23
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
27
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 \
31                 $SCRATCH_MNT/subv_$i
32 done
33
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 \
37                 >> /dev/null 2>&1 &
38 done
39
40 wait
41 _run_btrfs_util_prog filesystem sync $SCRATCH_MNT \
42         >>$seqres.full 2>&1
43
44 total_written=0
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
49
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"
53         fi
54         total_written=$(($total_written+$filesize))
55 done
56
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"
60 fi
61
62 # success, all done
63 echo "Silence is golden"
64 status=0
65 exit