]> www.infradead.org Git - users/hch/xfstests-dev.git/commitdiff
xfs: make some xfs project quota tests generic
authorEric Sandeen <sandeen@redhat.com>
Thu, 22 Sep 2016 22:51:03 +0000 (17:51 -0500)
committerEryu Guan <eguan@redhat.com>
Fri, 23 Sep 2016 04:30:04 +0000 (12:30 +0800)
This patch makes some xfs project quota tests generic,
so that there is at least some coverage on ext4 for this
(semi-)new feature.

It requires bleeding edge xfsprogs, so that xfs_quota and
xfs_io's chproj command can operate on "foreign" filesystems,
and requires relatively new e2fsprogs to enable the project
quota feature on-disk.

The mechanism for enabling project quota on ext4 is a bit
arcane, but hopefully I've encapsulated it reasonably well here.

Changes:

* look for "project" feature in _require_prjquota
* look for accounting not enforcement (-P) in _require_prjquota
* add a _scratch_enable_pquota to turn on project quota feature
* s/pquota/quota/ in _qmount_option for ext4
* add helper to test for xfs_io chproj on foreign filesystems
* switch from block to inode quota in xfs/133 because empty
  ext4 dirs consume one block
* cosmetic/generic changes for mkfs, require tests, etc.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
common/quota
common/rc
tests/xfs/133
tests/xfs/133.out
tests/xfs/134
tests/xfs/196
tests/xfs/262

index ce6940071e3d678b936946c005cc4f950d1277ec..fb2b2a041cd20a8cff9359ad75bcb8434c744971 100644 (file)
@@ -92,18 +92,32 @@ _require_xfs_quota_foreign()
 }
 
 #
-# checks that the XFS project quota support in the kernel is enabled.
+# checks that the project quota support in the kernel is enabled.
 #
 _require_prjquota()
 {
     [ -n "$1" ] && _dev="$1" || _dev="$TEST_DEV"
-    src/feature -p $_dev
+    if [ "$FSTYP" == "ext4" ]; then
+       dumpe2fs -h $_dev 2>&1 | grep -qw project || \
+               _notrun "Project quota not available on this ext4"
+    fi
+    src/feature -P $_dev
     [ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
     if [ "$USE_EXTERNAL" = yes -a ! -z "$_dev" ]; then
        _notrun "Project quotas not supported on realtime filesystem"
     fi
 }
 
+#
+# ext4 (for now) is unique in that we must enable the project quota feature
+# prior to mount.  This is a relatively new feature ...
+_scratch_enable_pquota()
+{
+       [ "$FSTYP" != "ext4" ] && return
+
+       tune2fs -O quota,project $SCRATCH_DEV >>$seqres.full 2>&1
+}
+
 #
 # checks for user nobody in /etc/passwd and /etc/group.
 #
@@ -197,6 +211,8 @@ _qmount()
 #
 _qmount_option()
 {
+       OPTS=$1
+
        # Replace any user defined quota options
        # with the quota option that we want.
        # Simplest to do this rather than delete existing ones first because
@@ -209,17 +225,24 @@ _qmount_option()
                -e 's/usrquota/QUOTA/g'    \
                -e 's/gquota/QUOTA/g'      \
                -e 's/grpquota/QUOTA/g'    \
-               -e 's/pquota/QUOTA/g'      \
-               -e 's/prjquota/QUOTA/g'      \
+               -e 's/\bpquota/QUOTA/g'    \
+               -e 's/prjquota/QUOTA/g'    \
                -e 's/quota/QUOTA/g'       \
                -e 's/uqnoenforce/QUOTA/g' \
                -e 's/gqnoenforce/QUOTA/g' \
                -e 's/pqnoenforce/QUOTA/g' \
                -e 's/qnoenforce/QUOTA/g'  \
-               -e "s/QUOTA/$1/g"`
+               -e "s/QUOTA/$OPTS/g"`
 
+       # ext4 doesn't _do_ "-o pquota/prjquota" because reasons
+       # Switch it to "quota" to enable mkfs-time pquota
+       if [ "$FSTYP" == "ext4" ]; then
+               OPTS=`echo $OPTS \
+               | sed   -e 's/\bpquota/quota/g' \
+                       -e 's/prjquota/quota/g'`
+       fi
        # Ensure we have the given quota option - duplicates are fine
-       export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $1"
+       export MOUNT_OPTIONS="$MOUNT_OPTIONS -o $OPTS"
        echo "MOUNT_OPTIONS = $MOUNT_OPTIONS" >>$seqres.full
 }
 
index 8a393d9de888909d4dd3b935a13905f54af475d7..73387790b3dae2e62d3d8a804e964bd51bc9008b 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -2031,6 +2031,9 @@ _require_xfs_io_command()
 
        testfile=$TEST_DIR/$$.xfs_io
        case $command in
+       "chproj")
+               testio=`$XFS_IO_PROG -F -f -c "chproj 0" $testfile 2>&1`
+               ;;
        "falloc" )
                testio=`$XFS_IO_PROG -F -f -c "falloc 0 1m" $testfile 2>&1`
                ;;
@@ -2062,6 +2065,8 @@ _require_xfs_io_command()
                _notrun "xfs_io $command support is missing"
        echo $testio | grep -q "Operation not supported" && \
                _notrun "xfs_io $command failed (old kernel/wrong fs?)"
+       echo $testio | grep -q "foreign file active" && \
+               _notrun "xfs_io $command not supported on $FSTYP"
 
        test -z "$param" && return
        $XFS_IO_PROG -c "help $command" | grep -q "^ $param --" || \
index f77bc794cac33cb39ea88ea7d7979c7dd93b4a3d..be5b19b75703eb767855fa84eb3eb3398a3d7268 100755 (executable)
@@ -46,12 +46,14 @@ _cleanup()
 rm -f $seqres.full
 
 # real QA test starts here
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux
 _require_scratch
-_require_xfs_quota
+_require_quota
+_require_xfs_quota_foreign
 
-_scratch_mkfs_xfs >/dev/null 2>&1
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
 
 do_project_test()
 {
@@ -72,20 +74,22 @@ EOF
        $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
                -c "project -s $qa_project" $SCRATCH_MNT > /dev/null
 
+       # We set & test inodes, because xfs vs ext4 consume differing
+       # amounts of space for an empty dir, but an inode is an inode...
        $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-               -c "limit -p bsoft=100m bhard=200m $qa_project" $SCRATCH_MNT
+               -c "limit -p isoft=100 ihard=200 $qa_project" $SCRATCH_MNT
 
        echo "=== quota command output ==="
        $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid \
-               -c "quota -p -v -b $qa_project" $SCRATCH_MNT | _filter_quota
+               -c "quota -p -v -i $qa_project" $SCRATCH_MNT | _filter_quota
 
        echo "=== report command output ==="
        $XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid -x \
-               -c "report -p -N -b" $SCRATCH_MNT | _filter_project_quota
+               -c "report -p -N -i" $SCRATCH_MNT | _filter_project_quota
 }
 
 # Test project
-_qmount_option "uquota,pquota"
+_qmount_option "usrquota,prjquota"
 _qmount
 _require_prjquota $SCRATCH_DEV
 do_project_test
index 21cfd0db68128244dd54f0cd8ae0ccfe9816ecfe..3accee64925c58ef9e35e59e4a05f063aa0c3c3a 100644 (file)
@@ -1,8 +1,8 @@
 QA output created by 133
 === quota command output ===
 Disk quotas for Project 123456-project (10)
-Filesystem Blocks Quota Limit Warn/Time Mounted on
-SCRATCH_DEV 0 102400 204800 00 [--------] SCRATCH_MNT
+Filesystem Files Quota Limit Warn/Time Mounted on
+SCRATCH_DEV 1 100 200 00 [--------] SCRATCH_MNT
 === report command output ===
-123456-project 0 102400 204800 00 [--------]
+123456-project 1 100 200 00 [--------]
 
index 21fe1edd988920be87af3fe7ed43d449fdb4bc02..58acc3b3b5fcaa15cd5b32325816ec5fb39856e5 100755 (executable)
@@ -45,11 +45,14 @@ _cleanup()
 trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # real QA test starts here
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux IRIX
 
 _require_test
-_require_xfs_quota
+_require_quota
+_require_xfs_quota_foreign
+_require_xfs_io_command "chproj"
+
 # we can't run with group quotas
 _exclude_scratch_mount_option "gquota" "grpquota"
 
@@ -68,21 +71,12 @@ cp /dev/null $seqres.full
 chmod a+rwx $seqres.full       # arbitrary users will write here
 
 _require_scratch
-_scratch_mkfs_xfs >/dev/null 2>&1
-
-#if pquota's already in mount options then we dont need to enable
-
-EXTRA_MOUNT_OPTIONS="-o pquota"
-
-if ! _scratch_mount "$EXTRA_MOUNT_OPTIONS" >$tmp.out 2>&1
-then
-    cat $tmp.out
-    echo "!!! mount failed"
-    exit
-fi
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
 
-src/feature -p $SCRATCH_DEV
-[ $? -ne 0 ] && _notrun "Installed kernel does not support project quotas"
+_qmount_option "prjquota"
+_qmount
+_require_prjquota $SCRATCH_DEV
 
 report_quota()
 {
index 3bff8f62291ede09f657918f5afc6c5b0bba878e..f185c81044b240a0fcd91015fb1664f97184a9e2 100755 (executable)
@@ -46,11 +46,12 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common/quota
 
 # real QA test starts here
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux
 
 _require_scratch
-_require_xfs_quota
+_require_quota
+_require_xfs_quota_foreign
 
 #
 # Setup temporary replacements for /etc/projects and /etc/projid
@@ -66,11 +67,13 @@ EOF
 #
 # And make sure we always use our replacements
 #
-quota_cmd="xfs_quota -D $tmp.projects -P $tmp.projid"
+quota_cmd="$XFS_QUOTA_PROG -D $tmp.projects -P $tmp.projid"
 
-_scratch_mkfs_xfs >/dev/null 2>&1
-_qmount_option "pquota"
+_scratch_mkfs >/dev/null 2>&1
+_scratch_enable_pquota
+_qmount_option "prjquota"
 _qmount
+_require_prjquota $SCRATCH_DEV
 
 #
 # Create the project root
index 9d8b8389c1d3aaa6eb555e068b60636199c269bf..3c2c34ecba1a2704951f97e5d1643eeabc1caaa2 100755 (executable)
@@ -63,10 +63,11 @@ echo "Silence is golden."
 proj_dir="$SCRATCH_MNT/test"
 
 # Modify as appropriate.
-_supported_fs xfs
+_supported_fs generic
 _supported_os Linux
 
 _require_quota
+_require_xfs_quota_foreign
 _require_scratch
 
 # Make sure the hard limits reported are what was set.
@@ -115,7 +116,7 @@ _filter_quota_rpt() {
 }
 
 _quota_cmd() {
-       xfs_quota -P "$my_projid" -D "$my_projects" -x \
+       $XFS_QUOTA_PROG -P "$my_projid" -D "$my_projects" -x \
                -c "$@" "$SCRATCH_MNT"
 }
 
@@ -124,10 +125,13 @@ _quota_cmd() {
 echo $proj_name:$proj_num > "$my_projid"
 echo $proj_num:$proj_dir > "$my_projects"
 
-_scratch_mkfs                                          >> "$seqres.full" 2>&1
+_scratch_mkfs                                  >> "$seqres.full" 2>&1
+_scratch_enable_pquota
 
-export MOUNT_OPTIONS="-opquota"
+_qmount_option "prjquota"
 _qmount
+_require_prjquota $SCRATCH_DEV
+
 mkdir -p "${proj_dir}"
 
 # Setup the project quota directory