fi
}
+# Reconfigure the mounted fs as needed so that we can test the VFS quota
+# utilities. They do not support realtime block limits or reporting, so
+# we forcibly inhibit rtinherit on XFS filesystems.
+_force_vfs_quota_testing()
+{
+ local mount="${1:-$TEST_DIR}"
+
+ test "$FSTYP" = "xfs" && _xfs_force_bdev data "$mount"
+}
+
+# Does the mounted scratch filesystem have a realtime volume where quota works?
+# Returns nonzero if any of the above are false.
+_scratch_supports_rtquota()
+{
+ case "$FSTYP" in
+ "xfs")
+ if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ]; then
+ _xfs_scratch_supports_rtquota
+ return
+ fi
+ esac
+
+ return 1
+}
+
# make sure this script returns success
/bin/true
_scratch_unmount 2>/dev/null
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount "-o usrquota,grpquota"
+_force_vfs_quota_testing $SCRATCH_MNT
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
quotaon $SCRATCH_MNT 2>/dev/null
_scratch_unmount
_scratch_mkfs >> $seqres.full 2>&1
_scratch_mount "-o usrquota,grpquota"
+_force_vfs_quota_testing $SCRATCH_MNT
BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
quotaon $SCRATCH_MNT 2>/dev/null
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
dir="$SCRATCH_MNT/dummy"
mkdir -p $dir
chown $qa_user $dir
-$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $qa_user" $SCRATCH_MNT
+_scratch_supports_rtquota && \
+ extra_limits="rtbsoft=100k rtbhard=100k"
+$XFS_QUOTA_PROG -x -c "limit -g bsoft=100k bhard=100k $extra_limits $qa_user" $SCRATCH_MNT
$XFS_IO_PROG -f -c 'pwrite -S 0x58 0 1m' $dir/foo >> $seqres.full
chown $qa_user "${dir}/foo"
# This test must have user quota enabled
_qmount_option usrquota
_qmount >> $seqres.full
+_force_vfs_quota_testing $SCRATCH_MNT
testfile=$SCRATCH_MNT/test-$seq
touch $testfile
_scratch_enable_pquota
_qmount_option "usrquota,grpquota,prjquota"
_qmount
+_force_vfs_quota_testing $SCRATCH_MNT
_require_prjquota $SCRATCH_DEV
BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
rm -rf $SCRATCH_MNT/t
_scratch_enable_pquota
_qmount_option "prjquota"
_qmount
+_force_vfs_quota_testing $SCRATCH_MNT
_require_prjquota $SCRATCH_DEV
filter_quota()
_scratch_enable_pquota
fi
_qmount
+ _force_vfs_quota_testing $SCRATCH_MNT
if [ "$type" = "P" ];then
_create_project_quota $SCRATCH_MNT/t 100 $qa_user
file=$SCRATCH_MNT/t/testfile
chown nobody $SCRATCH_MNT/b
# Set up a quota limit
-$XFS_QUOTA_PROG -x -c "limit -u bhard=70k nobody" $SCRATCH_MNT
+_scratch_supports_rtquota && \
+ extra_limits="rtbhard=70k"
+$XFS_QUOTA_PROG -x -c "limit -u bhard=70k $extra_limits nobody" $SCRATCH_MNT
echo before exchangerange >> $seqres.full
$XFS_QUOTA_PROG -x -c 'report -a' $SCRATCH_MNT >> $seqres.full
orig_mntopts="$MOUNT_OPTIONS"
_qmount_option "uquota"
_scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
bsize=$(_get_file_block_size $SCRATCH_MNT)
# needs quota enabled to compute the number of metadata dir files
HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
. $tmp.mkfs
_qmount
+ _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
# Figure out whether we're doing large allocations
# (bail out if they're so large they stuff the test up)
_require_xfs_quota
_require_xfs_nocrc
+if [ "$USE_EXTERNAL" = yes ] && [ -n "$SCRATCH_RTDEV" ]; then
+ _notrun "Realtime quotas not supported on V4 filesystems"
+fi
+
function option_string()
{
VAL=$1
{
_qmount_option $1
_qmount
+ _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
if [ $type == "p" ]; then
_require_prjquota $SCRATCH_DEV
export MOUNT_OPTIONS="-opquota"
_scratch_mkfs_xfs >> $seqres.full
_qmount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
_require_prjquota $SCRATCH_DEV
rm -f $tmp.projects $seqres.full
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
cat $tmp.mkfs >>$seqres.full
_scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
uid=1
gid=2
{
wipe_mounts
_try_scratch_mount || _fail "qmount failed"
+ _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
mkdir -p "${SCRATCH_MNT}/unmapped"
mkdir -p "${SCRATCH_MNT}/idmapped"
orig_mntopts="$MOUNT_OPTIONS"
_qmount_option "uquota"
_scratch_mount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
bsize=$(_get_file_block_size $SCRATCH_MNT)
# needs quota enabled to compute the number of metadata dir files
HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
. $tmp.mkfs
_qmount
+ _force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
# Figure out whether we're doing large allocations
# (bail out if they're so large they stuff the test up)
_scratch_xfs_db -c 'version' -c 'sb 0' -c 'p' >> $seqres.full
_scratch_mount >> $seqres.full
+_xfs_force_bdev data $SCRATCH_MNT
min_blksz=65536
file_blksz=$(_get_file_block_size "$SCRATCH_MNT")
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT # repquota
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
_scratch_mkfs > $seqres.full 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT # repquota
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
# mount with quotas enabled
_scratch_mount -o uquota
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
# turn off quota
$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
# mount with quotas enabled
_scratch_mount -o uquota
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
# turn off quota accounting...
$XFS_QUOTA_PROG -x -c off $SCRATCH_DEV
echo "*** user, group, and project"
_qmount_option "uquota,gquota,pquota"
_qmount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
bsize=$(_get_file_block_size $SCRATCH_MNT)
HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
echo "*** uqnoenforce, gqnoenforce, and pqnoenforce"
_qmount_option "uqnoenforce,gqnoenforce,pqnoenforce"
_qmount
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
_exercise uno
_exercise gno
_exercise pno
_scratch_mkfs > "$seqres.full" 2>&1
export MOUNT_OPTIONS="-o usrquota,grpquota $MOUNT_OPTIONS"
_scratch_mount >> "$seqres.full" 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT # golden output encodes block usage
HIDDEN_QUOTA_FILES=$(_xfs_calc_hidden_quota_files $SCRATCH_MNT)
quotacheck -u -g $SCRATCH_MNT 2> /dev/null
quotaon $SCRATCH_MNT 2> /dev/null
testdir="$SCRATCH_MNT/test-$seq"
blksz=65536
+_require_congruent_file_oplen $SCRATCH_MNT $blksz
blks=3
mkdir "$testdir"
testdir="$SCRATCH_MNT/test-$seq"
blksz=65536
+_require_congruent_file_oplen $SCRATCH_MNT $blksz
blks=3
mkdir "$testdir"
_scratch_mkfs > "$seqres.full" 2>&1
_scratch_mount "-o usrquota,grpquota" >> "$seqres.full" 2>&1
+# Make sure all our files are on the data device
+_xfs_force_bdev data $SCRATCH_MNT
+
echo "Create files"
$XFS_IO_PROG -c "cowextsize 1m" $SCRATCH_MNT
touch $SCRATCH_MNT/a $SCRATCH_MNT/force_fsgqa
echo "Format and mount (noquota)"
_scratch_mkfs > "$seqres.full" 2>&1
_scratch_mount "-o noquota" >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT # _check_quota_usage uses repquota
echo "Create files"
_pwrite_byte 0x58 0 1m $SCRATCH_MNT/a >> $seqres.full
# tests now have separate faster-running regression tests.
_scratch_mkfs_sized $((1600 * 1048576)) > $seqres.full 2>&1
_scratch_mount >> $seqres.full 2>&1
+_force_vfs_quota_testing $SCRATCH_MNT # _check_quota_usage uses repquota
nr_cpus=$((LOAD_FACTOR * 4))
nr_ops=$((25000 * nr_cpus * TIME_FACTOR))
mkdir $SCRATCH_MNT/dir
$QUOTA_CMD -x -c 'project -s test' $SCRATCH_MNT >>$seqres.full 2>&1
$QUOTA_CMD -x -c 'limit -p bsoft=1m bhard=2m test' $SCRATCH_MNT
+_scratch_supports_rtquota && \
+ $QUOTA_CMD -x -c 'limit -p rtbsoft=1m rtbhard=2m test' $SCRATCH_MNT
# test the Project inheritance bit is a directory only flag, and it's set on
# directory by default. Expect no complain about "project inheritance flag is
quota_cmd="$XFS_QUOTA_PROG -x"
$quota_cmd -c "project -s -p $SCRATCH_MNT/t 42" $SCRATCH_MNT >/dev/null 2>&1
$quota_cmd -c 'limit -p isoft=53 bsoft=100m 42' $SCRATCH_MNT
+_scratch_supports_rtquota && \
+ $quota_cmd -c 'limit -p rtbsoft=100m 42' $SCRATCH_MNT
+
+# The golden output for this test was written with the assumption that the file
+# allocation unit divides 64k evenly, so the file block usage would be exactly
+# 64k. On realtime filesystems this isn't always true (e.g. -rextsize=28k) so
+# we'll accept the space usage being the same as what du reports for the file.
+file_nblocks=$(du -B 1024 $SCRATCH_MNT/t/file | awk '{print $1}')
# The itotal and size should be 53 and 102400(k), as above project quota limit.
# The isued and used should be 2 and 64(k), as this case takes.
df -k --output=file,itotal,iused,size,used $SCRATCH_MNT/t | \
- _filter_scratch | _filter_spaces
+ _filter_scratch | _filter_spaces | sed -e "s|$file_nblocks$|64|"
# success, all done
status=0
_qmount_option usrquota
_qmount
+# This test tries to exceed quota limits by creating an N>2 block bmbt, setting
+# the block limit to 2N, and rebuilding the bmbt. Hence we must force the
+# files to be created on the data device.
+_xfs_force_bdev data $SCRATCH_MNT
+
blocksize=$(_get_block_size $SCRATCH_MNT)
alloc_unit=$(_get_file_block_size $SCRATCH_MNT)