Files
apfstests/tests/generic/230
T

145 lines
4.7 KiB
Bash
Raw Normal View History

2010-05-18 23:26:57 +02:00
#! /bin/bash
2018-06-09 11:35:42 +10:00
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2010 Jan Kara. All Rights Reserved.
# Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
#
2010-05-18 23:26:57 +02:00
# FS QA Test No. 230
#
# Simple quota enforcement test.
#
seq=`basename $0`
seqres=$RESULT_DIR/$seq
2010-05-18 23:26:57 +02: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
2010-05-18 23:26:57 +02:00
# real QA test starts here
_supported_fs generic
_require_scratch
_require_quota
_require_user
test_files()
{
echo; echo "### create files, setting up ownership (type=$type)"
touch $SCRATCH_MNT/file{1,2} 2>/dev/null
chown $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
chgrp $qa_user $SCRATCH_MNT/file{1,2} 2>/dev/null
chmod 777 $SCRATCH_MNT 2>/dev/null
}
test_enforcement()
{
echo "### some buffered IO (type=$type)"
echo "--- initiating IO..." >>$seqres.full
2010-05-18 23:26:57 +02:00
# Firstly fit below block soft limit
2018-09-24 20:49:38 +05:30
echo "Write 225 blocks..."
su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((225 * $BLOCK_SIZE))' -c fsync \
$SCRATCH_MNT/file1" 2>&1 >>$seqres.full | \
_filter_xfs_io_error | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# Secondly overcome block soft limit
2018-09-24 20:49:38 +05:30
echo "Rewrite 250 blocks plus 1 byte..."
su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE + 1))' -c fsync \
$SCRATCH_MNT/file1" 2>&1 >>$seqres.full | \
_filter_xfs_io_error | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# Now try to overcome block hardlimit
# Reset grace time here due to the repquota will invoke Q_SYNC on
# old quota which may be time consuming on the low speed or busy
# scratch device that may leed to grace time exceed.
setquota -$type $qa_user -T $grace $grace $SCRATCH_MNT 2>/dev/null
2018-09-24 20:49:38 +05:30
echo "Write 250 blocks..."
su $qa_user -c "$XFS_IO_PROG -c 'pwrite 0 $((250 * $BLOCK_SIZE))' -c fsync \
$SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \
_filter_xfs_io_error | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# Now sleep for grace time and check that softlimit got enforced
sleep $((grace+1))
2018-09-24 20:49:38 +05:30
echo "Write 1 block..."
su $qa_user -c "$XFS_IO_PROG -c 'truncate 0' -c 'pwrite 0 $BLOCK_SIZE' \
$SCRATCH_MNT/file2" 2>&1 >>$seqres.full | \
_filter_xfs_io_error | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# And now the softlimit test for inodes
# First reset space limits so that we don't have problems with
# space reservations on XFS
setquota -$type $qa_user 0 0 3 5 $SCRATCH_MNT
echo "Touch 3+4"
su $qa_user -c "touch $SCRATCH_MNT/file3 $SCRATCH_MNT/file4" \
2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# Try to exceed inode hardlimit
# Reset grace time here due to the repquota will invoke Q_SYNC on
# old quota which may be time consuming on the low speed or busy
# scratch device that may leed to grace time exceed.
setquota -$type $qa_user -T $grace $grace $SCRATCH_MNT 2>/dev/null
2010-05-18 23:26:57 +02:00
echo "Touch 5+6"
su $qa_user -c "touch $SCRATCH_MNT/file5 $SCRATCH_MNT/file6" \
2>&1 >>$seqres.full | _filter_scratch | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
# Wait and check grace time enforcement
rm -f $SCRATCH_MNT/file5 >>$seqres.full 2>&1
2010-05-18 23:26:57 +02:00
sleep $((grace+1))
echo "Touch 5"
su $qa_user -c "touch $SCRATCH_MNT/file5" 2>&1 >>$seqres.full |
_filter_scratch | tee -a $seqres.full
repquota -$type $SCRATCH_MNT | grep -v "^root" >>$seqres.full 2>&1
echo "--- completed IO ($type)" >>$seqres.full
2010-05-18 23:26:57 +02:00
}
cleanup_files()
{
rm -f $SCRATCH_MNT/file{1,2,3,4,5,6}
}
# real QA test starts here
rm -f $seqres.full
2010-05-18 23:26:57 +02:00
grace=2
# Test only the quota type specified in each _scratch_mount clause below.
_qmount_option 'defaults'
_scratch_mkfs >> $seqres.full 2>&1
2010-05-18 23:26:57 +02:00
_scratch_mount "-o usrquota,grpquota"
2018-09-24 20:49:38 +05:30
BLOCK_SIZE=$(_get_file_block_size $SCRATCH_MNT)
2010-05-18 23:26:57 +02:00
quotacheck -u -g $SCRATCH_MNT 2>/dev/null
quotaon $SCRATCH_MNT 2>/dev/null
2018-09-24 20:49:38 +05:30
setquota -u $qa_user $((250 * $BLOCK_SIZE / 1024)) \
$((500 * $BLOCK_SIZE / 1024)) 3 5 $SCRATCH_MNT
2010-05-18 23:26:57 +02:00
setquota -u -t $grace $grace $SCRATCH_MNT
2018-09-24 20:49:38 +05:30
setquota -g $qa_user $((250 * $BLOCK_SIZE / 1024)) \
$((500 * $BLOCK_SIZE / 1024)) 3 5 $SCRATCH_MNT
2010-05-18 23:26:57 +02:00
setquota -g -t $grace $grace $SCRATCH_MNT
2015-12-21 18:07:43 +11:00
_scratch_unmount
2010-05-18 23:26:57 +02:00
echo; echo "### test user limit enforcement"
_scratch_mount "-o usrquota"
quotaon $SCRATCH_MNT 2>/dev/null
type=u
test_files
test_enforcement
cleanup_files
2015-12-21 18:07:43 +11:00
_scratch_unmount 2>/dev/null
2010-05-18 23:26:57 +02:00
echo; echo "### test group limit enforcement"
_scratch_mount "-o grpquota"
quotaon $SCRATCH_MNT 2>/dev/null
type=g
test_files
test_enforcement
cleanup_files
2015-12-21 18:07:43 +11:00
_scratch_unmount 2>/dev/null
2010-05-18 23:26:57 +02:00
status=0
exit