xfs/007: check correct quota inodes
[xfstests-dev.git] / tests / xfs / 007
1 #! /bin/bash
2 # FS QA Test No. xfs/007
3 #
4 # Test to verify Q_XQUOTARM functionality.
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2014 Red Hat, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #-----------------------------------------------------------------------
22 #
23
24 seq=`basename $0`
25 seqres=$RESULT_DIR/$seq
26 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "_cleanup; exit \$status" 0 1 2 3 15
32
33 _cleanup()
34 {
35     cd /
36     rm -f $tmp.*
37 }
38
39 # get standard environment, filters and checks
40 . ./common/rc
41 . ./common/filter
42 . ./common/quota
43
44 # Modify as appropriate.
45 _supported_fs xfs
46 _supported_os Linux Irix
47
48 _require_scratch
49 _require_xfs_quota
50
51 rm -f $seqres.full
52
53 _scratch_mkfs_xfs >/dev/null 2>&1
54
55 do_test()
56 {
57         qino_1=$1
58         qino_2=$2
59         off_opts=$3
60
61         echo "*** umount"
62         umount $SCRATCH_MNT
63
64         QINO_1=`xfs_db -c "sb 0" -c "p" $SCRATCH_DEV | \
65                         grep $qino_1 | awk '{print $NF}'`
66         QINO_2=`xfs_db -c "sb 0" -c "p" $SCRATCH_DEV | \
67                         grep $qino_2 | awk '{print $NF}'`
68
69         echo "*** Usage before quotarm ***"
70         xfs_db -c "inode $QINO_1" -c "p core.nblocks" $SCRATCH_DEV
71         xfs_db -c "inode $QINO_2" -c "p core.nblocks" $SCRATCH_DEV
72
73         _qmount
74         echo "*** turn off $off_opts quotas"
75         xfs_quota -x -c "off -$off_opts" $SCRATCH_MNT
76         xfs_quota -x -c "remove -$off_opts" $SCRATCH_MNT
77         echo "*** umount"
78         umount $SCRATCH_MNT
79
80         echo "*** Usage after quotarm ***"
81         xfs_db -c "inode $QINO_1" -c "p core.nblocks" $SCRATCH_DEV
82         xfs_db -c "inode $QINO_2" -c "p core.nblocks" $SCRATCH_DEV
83 }
84
85
86 # Test user and group first
87 _qmount_option "uquota,gquota"
88 _qmount
89 do_test uquotino gquotino ug
90
91 # Test user and project
92 _qmount_option "uquota,pquota"
93 _qmount
94 _require_prjquota $SCRATCH_DEV
95 do_test uquotino pquotino up
96
97 # success, all done
98 status=0
99 exit