generic: shutdown fs after log recovery
[xfstests-dev.git] / tests / generic / 382
1 #! /bin/bash
2 # FS QA Test 260
3 #
4 # When default quota is set, all different quota types inherits the
5 # same default value, include group quota. So if a user quota limit
6 # larger than the default user quota value, it will still be limited
7 # by the group default quota value.
8 #
9 # There's a patch from Upstream can fix this bug:
10 #
11 #    [PATCH] xfs: Split default quota limits by quota type V4
12 #
13 #-----------------------------------------------------------------------
14 # Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
15 #
16 # This program is free software; you can redistribute it and/or
17 # modify it under the terms of the GNU General Public License as
18 # published by the Free Software Foundation.
19 #
20 # This program is distributed in the hope that it would be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23 # GNU General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with this program; if not, write the Free Software Foundation,
27 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
28 #-----------------------------------------------------------------------
29 #
30
31 seq=`basename $0`
32 seqres=$RESULT_DIR/$seq
33 echo "QA output created by $seq"
34
35 here=`pwd`
36 tmp=/tmp/$$
37 status=1        # failure is the default!
38 trap "_cleanup; exit \$status" 0 1 2 3 15
39
40 _cleanup()
41 {
42         cd /
43         rm -f $tmp.*
44 }
45
46 # get standard environment, filters and checks
47 . ./common/rc
48 . ./common/filter
49 . ./common/quota
50
51 # remove previous $seqres.full before test
52 rm -f $seqres.full
53
54 # real QA test starts here
55 _supported_fs generic
56 _supported_os Linux
57 _require_scratch
58 _require_quota
59 _require_xfs_quota_foreign
60 _require_user
61 _require_group
62
63 do_test()
64 {
65         local qname=$1
66         local type
67
68         if [ "$qname" = "user" ];then
69                 type="-u"
70                 echo "=== user quota test ==="
71         elif [ "$qname" = "group" ];then
72                 type="-g"
73                 echo "=== group quota test ==="
74         else
75                 echo "wrong quota type name - $qname"
76                 return 1
77         fi
78
79         $XFS_QUOTA_PROG -x -c "limit bsoft=20M bhard=20M isoft=20 ihard=20 $type -d" $SCRATCH_MNT
80         $XFS_QUOTA_PROG -x -c "limit bsoft=40M bhard=40M isoft=40 ihard=40 $type fsgqa" $SCRATCH_MNT
81         echo "$qname blocks and inode limit"
82         $XFS_QUOTA_PROG -x -c "report $type -N -bi" $SCRATCH_MNT | grep -v ^root | _filter_spaces
83
84         ## blocks default quota test ##
85         _user_do "$XFS_IO_PROG -f -c \"pwrite 0 30M\" -c \"fsync\" $SCRATCH_MNT/data" | _filter_xfs_io
86         echo "$qname blocks quota after write 30M data"
87         $XFS_QUOTA_PROG -x -c "report $type -N -b" $SCRATCH_MNT | grep -v ^root | _filter_spaces
88
89         rm -f ${SCRATCH_MNT}/* >/dev/null 2>&1
90
91         ## inode default quota test ##
92         for ((i=0; i<30; i++));do
93                 _user_do "echo -n > ${SCRATCH_MNT}/file${i}"
94         done
95         sync
96
97         echo "$qname inode quota after creating 30 inodes"
98         $XFS_QUOTA_PROG -x -c "report $type -N -i" $SCRATCH_MNT | grep -v ^root | _filter_spaces
99
100         rm -f ${SCRATCH_MNT}/* >/dev/null 2>&1
101 }
102
103 ### user default quota test ###
104 _scratch_mkfs >/dev/null 2>&1
105 _qmount_option "usrquota,grpquota"
106 _qmount
107
108 do_test user
109
110 ### group default quota test ###
111 _scratch_unmount
112 _scratch_mkfs >/dev/null 2>&1
113 _qmount_option "grpquota,usrquota"
114 _qmount
115
116 do_test group
117
118 # success, all done
119 status=0
120 exit