}
#
-# 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.
#
#
_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
-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
}
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`
;;
_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 --" || \
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()
{
$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
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 [--------]
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"
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()
{
. ./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
#
# 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
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.
}
_quota_cmd() {
- xfs_quota -P "$my_projid" -D "$my_projects" -x \
+ $XFS_QUOTA_PROG -P "$my_projid" -D "$my_projects" -x \
-c "$@" "$SCRATCH_MNT"
}
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