xfs: new test default user/group quota
authorZorro Lang <zlang@redhat.com>
Thu, 18 Feb 2016 23:49:54 +0000 (10:49 +1100)
committerDave Chinner <david@fromorbit.com>
Thu, 18 Feb 2016 23:49:54 +0000 (10:49 +1100)
When default quota is set, all different quota types inherits the
same default value, include group quota. So if a user quota limit
larger than the default user quota value, it will still be limited
by the group default quota value.

An upstream patch for this bug:

  xfs: Split default quota limits by quota type

Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
tests/xfs/260 [new file with mode: 0755]
tests/xfs/260.out [new file with mode: 0644]
tests/xfs/group

diff --git a/tests/xfs/260 b/tests/xfs/260
new file mode 100755 (executable)
index 0000000..70486ac
--- /dev/null
@@ -0,0 +1,119 @@
+#! /bin/bash
+# FS QA Test 260
+#
+# When default quota is set, all different quota types inherits the
+# same default value, include group quota. So if a user quota limit
+# larger than the default user quota value, it will still be limited
+# by the group default quota value.
+#
+# There's a patch from Upstream can fix this bug:
+#
+#    [PATCH] xfs: Split default quota limits by quota type V4
+#
+#-----------------------------------------------------------------------
+# Copyright (c) 2016 Red Hat, Inc.  All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it would be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write the Free Software Foundation,
+# Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+#-----------------------------------------------------------------------
+#
+
+seq=`basename $0`
+seqres=$RESULT_DIR/$seq
+echo "QA output created by $seq"
+
+here=`pwd`
+tmp=/tmp/$$
+status=1       # failure is the default!
+trap "_cleanup; exit \$status" 0 1 2 3 15
+
+_cleanup()
+{
+       cd /
+       rm -f $tmp.*
+}
+
+# get standard environment, filters and checks
+. ./common/rc
+. ./common/filter
+. ./common/quota
+
+# remove previous $seqres.full before test
+rm -f $seqres.full
+
+# real QA test starts here
+_supported_fs xfs
+_supported_os Linux
+_require_scratch
+_require_quota
+_require_user
+_require_group
+
+do_test()
+{
+       local qname=$1
+       local type
+
+       if [ "$qname" = "user" ];then
+               type="-u"
+               echo "=== user quota test ==="
+       elif [ "$qname" = "group" ];then
+               type="-g"
+               echo "=== group quota test ==="
+       else
+               echo "wrong quota type name - $qname"
+               return 1
+       fi
+
+       $XFS_QUOTA_PROG -x -c "limit bsoft=20M bhard=20M isoft=20 ihard=20 $type -d" $SCRATCH_MNT
+       $XFS_QUOTA_PROG -x -c "limit bsoft=40M bhard=40M isoft=40 ihard=40 $type fsgqa" $SCRATCH_MNT
+       echo "$qname blocks and inode limit"
+       $XFS_QUOTA_PROG -x -c "report $type -N -bi" $SCRATCH_MNT | _filter_spaces
+
+       ## blocks default quota test ##
+       _user_do "$XFS_IO_PROG -f -c \"pwrite 0 30M\" -c \"fsync\" $SCRATCH_MNT/data" | _filter_xfs_io
+       echo "$qname blocks quota after write 30M data"
+       $XFS_QUOTA_PROG -x -c "report $type -N -b" $SCRATCH_MNT | _filter_spaces
+
+       rm -f ${SCRATCH_MNT}/* >/dev/null 2>&1
+
+       ## inode default quota test ##
+       for ((i=0; i<30; i++));do
+               _user_do "echo -n > ${SCRATCH_MNT}/file${i}"
+       done
+       sync
+
+       echo "$qname inode quota after create 300 inodes"
+       $XFS_QUOTA_PROG -x -c "report $type -N -i" $SCRATCH_MNT | _filter_spaces
+
+       rm -f ${SCRATCH_MNT}/* >/dev/null 2>&1
+}
+
+### user default quota test ###
+_scratch_mkfs_xfs >/dev/null 2>&1
+_qmount_option "uquota,gquota"
+_qmount
+
+do_test user
+
+### group default quota test ###
+_scratch_unmount
+_scratch_mkfs_xfs >/dev/null 2>&1
+_qmount_option "gquota,uquota"
+_qmount
+
+do_test group
+
+# success, all done
+status=0
+exit
diff --git a/tests/xfs/260.out b/tests/xfs/260.out
new file mode 100644 (file)
index 0000000..4965eeb
--- /dev/null
@@ -0,0 +1,31 @@
+QA output created by 260
+=== user quota test ===
+user blocks and inode limit
+root 0 20480 20480 00 [--------] 3 20 20 00 [--------]
+fsgqa 0 40960 40960 00 [--------] 0 40 40 00 [--------]
+
+wrote 31457280/31457280 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+user blocks quota after write 30M data
+root 0 20480 20480 00 [--------]
+fsgqa 30720 40960 40960 00 [--------]
+
+user inode quota after create 300 inodes
+root 3 20 20 00 [--------]
+fsgqa 30 40 40 00 [--------]
+
+=== group quota test ===
+group blocks and inode limit
+root 0 20480 20480 00 [--------] 3 20 20 00 [--------]
+fsgqa 0 40960 40960 00 [--------] 0 40 40 00 [--------]
+
+wrote 31457280/31457280 bytes at offset 0
+XXX Bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
+group blocks quota after write 30M data
+root 0 20480 20480 00 [--------]
+fsgqa 30720 40960 40960 00 [--------]
+
+group inode quota after create 300 inodes
+root 3 20 20 00 [--------]
+fsgqa 30 40 40 00 [--------]
+
index eadc212b12fde9234a6f2e8b5f14cf858afcaa09..e0c4553f8d4309d50f98c98ca90f1fcd12cb56b9 100644 (file)
 257 auto quick clone
 258 auto quick clone
 259 auto quick
+260 auto quick quota
 261 auto quick quota
 262 auto quick quota
 266 dump ioctl auto quick