xfs: make some xfs project quota tests generic

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>
This commit is contained in:
Eric Sandeen
2016-09-22 17:51:03 -05:00
committed by Eryu Guan
parent fe901ccaa7
commit 7369e9c7f9
7 changed files with 74 additions and 41 deletions
+28 -5
View 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/\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
}
+5
View File
@@ -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 --" || \
+11 -7
View File
@@ -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
+3 -3
View 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 [--------]
+10 -16
View File
@@ -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
_scratch_mkfs >/dev/null 2>&1
_scratch_enable_pquota
#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
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()
{
+8 -5
View File
@@ -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
+7 -3
View File
@@ -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"
}
@@ -125,9 +126,12 @@ echo $proj_name:$proj_num > "$my_projid"
echo $proj_num:$proj_dir > "$my_projects"
_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