2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 108
|
|
|
|
|
#
|
|
|
|
|
# Simple quota accounting test for direct/buffered/mmap IO.
|
2005-06-02 06:02:53 +00:00
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2005-06-02 06:02:53 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/quota
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
_require_scratch
|
2009-08-10 13:18:50 -05:00
|
|
|
_require_xfs_quota
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
test_files()
|
|
|
|
|
{
|
|
|
|
|
echo; echo "### create files, setting up ownership (type=$type)"
|
|
|
|
|
rm -f $SCRATCH_MNT/{buffer,direct,mmap}
|
2005-06-02 15:09:19 +00:00
|
|
|
$XFS_IO_PROG -fc "chproj $prid" $SCRATCH_MNT/{buffer,direct,mmap}
|
2005-06-02 06:02:53 +00:00
|
|
|
chown $uid $SCRATCH_MNT/{buffer,direct,mmap}
|
|
|
|
|
chgrp $gid $SCRATCH_MNT/{buffer,direct,mmap}
|
|
|
|
|
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
|
2010-10-21 19:00:08 +00:00
|
|
|
$here/src/lstat64 $file | head -3 | _filter_scratch
|
2005-06-02 15:09:19 +00:00
|
|
|
$XFS_IO_PROG -c lsproj $file
|
2005-06-02 06:02:53 +00:00
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
test_accounting()
|
|
|
|
|
{
|
|
|
|
|
echo "### some controlled buffered, direct and mmapd IO (type=$type)"
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "--- initiating parallel IO..." >>$seqres.full
|
2005-06-02 15:09:19 +00:00
|
|
|
$XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -c 'fsync' \
|
2013-03-15 12:28:02 +00:00
|
|
|
$SCRATCH_MNT/buffer >>$seqres.full 2>&1 &
|
2005-06-02 15:09:19 +00:00
|
|
|
$XFS_IO_PROG -c 'pwrite -b 1m 0 16m' -d \
|
2013-03-15 12:28:02 +00:00
|
|
|
$SCRATCH_MNT/direct >>$seqres.full 2>&1 &
|
2005-06-02 15:09:19 +00:00
|
|
|
$XFS_IO_PROG -c 't 16m' -c 'mm -rw 0 16m' -c 'mw 0 16m' -c 'ms -s' \
|
2013-03-15 12:28:02 +00:00
|
|
|
$SCRATCH_MNT/mmap >>$seqres.full 2>&1 &
|
2005-06-02 06:02:53 +00:00
|
|
|
wait
|
2013-03-15 12:28:02 +00:00
|
|
|
echo "--- completed parallel IO ($type)" >>$seqres.full
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
for file in $SCRATCH_MNT/{buffer,direct,mmap}; do
|
2010-10-21 19:00:08 +00:00
|
|
|
$here/src/lstat64 $file | head -3 | _filter_scratch
|
2005-06-02 06:02:53 +00:00
|
|
|
done
|
2013-10-06 22:46:19 +00:00
|
|
|
xfs_quota -c "quota -hnb -$type $id" $QARGS | _filter_quota
|
|
|
|
|
xfs_quota -c "quota -hni -$type $id" $QARGS | _filter_quota
|
|
|
|
|
xfs_quota -c "quota -hnr -$type $id" $QARGS | _filter_quota
|
2005-06-02 06:02:53 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-09 19:47:35 +02:00
|
|
|
export MOUNT_OPTIONS="-opquota"
|
2019-03-19 17:46:01 -07:00
|
|
|
_scratch_mkfs_xfs >> $seqres.full
|
2010-09-09 19:47:35 +02:00
|
|
|
_qmount
|
2010-10-01 06:04:33 +02:00
|
|
|
_require_prjquota $SCRATCH_DEV
|
2010-09-09 19:47:35 +02:00
|
|
|
|
2005-06-02 06:02:53 +00:00
|
|
|
# real QA test starts here
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $tmp.projects $seqres.full
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2005-06-02 06:02:53 +00:00
|
|
|
_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
|
2013-03-15 12:28:02 +00:00
|
|
|
cat $tmp.mkfs >>$seqres.full
|
2005-06-02 06:02:53 +00:00
|
|
|
_scratch_mount
|
|
|
|
|
|
|
|
|
|
uid=1
|
|
|
|
|
gid=2
|
|
|
|
|
prid=3
|
|
|
|
|
export QARGS="-x -D /dev/null -P /dev/null $SCRATCH_MNT"
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
echo; echo "### test user accounting"
|
|
|
|
|
export MOUNT_OPTIONS="-ouquota"
|
|
|
|
|
_qmount
|
|
|
|
|
type=u
|
|
|
|
|
id=$uid
|
|
|
|
|
test_files
|
|
|
|
|
test_accounting
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
echo; echo "### test group accounting"
|
|
|
|
|
export MOUNT_OPTIONS="-ogquota"
|
|
|
|
|
_qmount
|
|
|
|
|
type=g
|
|
|
|
|
id=$gid
|
|
|
|
|
test_files
|
|
|
|
|
test_accounting
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
#echo; echo "### test project accounting"
|
|
|
|
|
export MOUNT_OPTIONS="-opquota"
|
|
|
|
|
_qmount
|
|
|
|
|
type=p
|
|
|
|
|
id=$prid
|
2005-06-03 03:48:40 +00:00
|
|
|
test_files
|
|
|
|
|
test_accounting
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2005-06-02 06:02:53 +00:00
|
|
|
|
|
|
|
|
status=0
|
|
|
|
|
exit
|