2016-08-15 22:23:11 -05:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2016 Red Hat, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2016-08-15 22:23:11 -05:00
|
|
|
# FS QA Test 263
|
|
|
|
|
#
|
|
|
|
|
# test xfs_quota state command
|
|
|
|
|
#
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
seqres=$RESULT_DIR/$seq
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=1 # failure is the default!
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
|
|
|
|
cd /
|
|
|
|
|
rm -f $tmp.*
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/quota
|
|
|
|
|
|
|
|
|
|
# remove previous $seqres.full before test
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
# real QA test starts here
|
|
|
|
|
|
|
|
|
|
# Modify as appropriate.
|
|
|
|
|
_supported_fs xfs
|
|
|
|
|
|
|
|
|
|
_require_scratch
|
|
|
|
|
_require_xfs_quota
|
|
|
|
|
|
|
|
|
|
# We could test older, non-project capable kernels but keep it simpler;
|
|
|
|
|
# Only test crc and beyond (but we will test with and without the feature)
|
|
|
|
|
_require_xfs_mkfs_crc
|
|
|
|
|
_require_xfs_crc
|
|
|
|
|
|
|
|
|
|
rm -f $seqres.full
|
|
|
|
|
|
|
|
|
|
function option_string()
|
|
|
|
|
{
|
|
|
|
|
VAL=$1
|
|
|
|
|
# Treat 3 options as a bit field, prjquota|grpquota|usrquota
|
|
|
|
|
OPT="rw"
|
|
|
|
|
if [ "$((VAL & 4))" -ne "0" ]; then OPT=prjquota,${OPT}; fi;
|
|
|
|
|
if [ "$((VAL & 2))" -ne "0" ]; then OPT=grpquota,${OPT}; fi;
|
|
|
|
|
if [ "$((VAL & 1))" -ne "0" ]; then OPT=usrquota,${OPT}; fi;
|
|
|
|
|
echo $OPT
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-28 09:38:12 -08:00
|
|
|
filter_quota_state() {
|
2020-07-30 11:35:33 -07:00
|
|
|
sed -e 's/Inode: #[0-9]\+/Inode #XXX/g' \
|
|
|
|
|
-e '/max warnings:/d' \
|
2020-08-03 08:46:00 -05:00
|
|
|
-e '/Blocks grace time:/d' \
|
|
|
|
|
-e '/Inodes grace time:/d' \
|
|
|
|
|
| _filter_scratch
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
filter_quota_state2() {
|
|
|
|
|
sed -e '/User quota state on/d' \
|
|
|
|
|
-e '/ Accounting: /d' \
|
|
|
|
|
-e '/ Enforcement: /d' \
|
|
|
|
|
-e '/ Inode: /d' \
|
|
|
|
|
-e '/Blocks max warnings: /d' \
|
|
|
|
|
-e '/Inodes max warnings: /d' \
|
2020-07-30 11:35:33 -07:00
|
|
|
| _filter_scratch
|
2017-01-28 09:38:12 -08:00
|
|
|
}
|
|
|
|
|
|
2016-08-15 22:23:11 -05:00
|
|
|
function test_all_state()
|
|
|
|
|
{
|
|
|
|
|
for I in `seq 0 7`; do
|
|
|
|
|
OPTIONS=`option_string $I`
|
|
|
|
|
echo "== Options: $OPTIONS =="
|
|
|
|
|
# Some combinations won't mount on V4 supers (grp + prj)
|
|
|
|
|
_qmount_option "$OPTIONS"
|
2018-02-07 17:31:36 +08:00
|
|
|
_try_scratch_mount &>> $seqres.full || continue
|
2020-08-03 08:46:00 -05:00
|
|
|
$XFS_QUOTA_PROG -x -c "state -u" $SCRATCH_MNT | filter_quota_state
|
|
|
|
|
$XFS_QUOTA_PROG -x -c "state -g" $SCRATCH_MNT | filter_quota_state
|
|
|
|
|
$XFS_QUOTA_PROG -x -c "state -p" $SCRATCH_MNT | filter_quota_state
|
|
|
|
|
$XFS_QUOTA_PROG -x -c "state -u" $SCRATCH_MNT | filter_quota_state2
|
2016-08-15 22:23:11 -05:00
|
|
|
_scratch_unmount
|
|
|
|
|
done
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
echo "==== NO CRC ===="
|
|
|
|
|
# Control size to control inode numbers
|
2019-10-07 18:03:23 -07:00
|
|
|
_scratch_mkfs_xfs "-m crc=0 -n ftype=0 -d size=512m" >> $seqres.full
|
2016-08-15 22:23:11 -05:00
|
|
|
test_all_state
|
|
|
|
|
|
|
|
|
|
echo "==== CRC ===="
|
2019-10-07 18:03:23 -07:00
|
|
|
_scratch_mkfs_xfs "-m crc=1 -d size=512m" >>$seqres.full
|
2016-08-15 22:23:11 -05:00
|
|
|
test_all_state
|
|
|
|
|
|
|
|
|
|
status=0
|
|
|
|
|
exit
|