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
+29 -6
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/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
}