SRCDIR=`dirname $0`
export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
-if [ "$1" == "9_10" ]; then
- echo "only run for test9 and test10"
- shift
- TEST_9_10=1
- ONLY="9 10"
-else
- TEST_9_10=0
-fi
ONLY=${ONLY:-"$*"}
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-""}
+ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
case `uname -r` in
MAX_DQ_TIME=604800
MAX_IQ_TIME=604800
-log() {
- echo "$*"
- $LCTL mark "$*" 2> /dev/null || true
-}
-
-trace() {
- log "STARTING: $*"
- strace -o $TMP/$1.strace -ttt $*
- RC=$?
- log "FINISHED: $*: rc $RC"
- return 1
-}
TRACE=${TRACE:-""}
+LUSTRE=${LUSTRE:-`dirname $0`/..}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
-run_one() {
- BEFORE=`date +%s`
- log "== test $1: $2= `date +%H:%M:%S` ($BEFORE)"
- export TESTNAME=test_$1
- test_$1 || error "exit with rc=$?"
- unset TESTNAME
- pass "($((`date +%s` - $BEFORE))s)"
- cd $SAVE_PWD
-}
-
-build_test_filter() {
- [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
- echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_QUOTA_EXCEPT`"
-
- for O in $ONLY; do
- eval ONLY_${O}=true
- done
- for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_QUOTA_EXCEPT; do
- eval EXCEPT_${E}=true
- done
- # turn on/off quota tests must be included
- eval ONLY_0=true
- eval ONLY_99=true
-}
-
-_basetest() {
- echo $*
-}
-
-basetest() {
- IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_test() {
- base=`basetest $1`
- if [ "$ONLY" ]; then
- testname=ONLY_$1
- if [ ${!testname}x != x ]; then
- run_one $1 "$2"
- return $?
- fi
- testname=ONLY_$base
- if [ ${!testname}x != x ]; then
- run_one $1 "$2"
- return $?
- fi
- echo -n "."
- return 0
- fi
- testname=EXCEPT_$1
- if [ ${!testname}x != x ]; then
- echo "skipping excluded test $1"
- return 0
- fi
- testname=EXCEPT_$base
- if [ ${!testname}x != x ]; then
- echo "skipping excluded test $1 (base $base)"
- return 0
- fi
- run_one $1 "$2"
- return $?
-}
+QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
+FAIL_ON_ERROR=false
[ "$QUOTALOG" ] && rm -f $QUOTALOG || true
-error() {
- sysctl -w lustre.fail_loc=0
- log "FAIL: $TESTNAME $@"
- if [ "$QUOTALOG" ]; then
- echo "FAIL: $TESTNAME $@" >> $QUOTALOG
- else
- exit 1
- fi
-}
-
-pass() {
- echo PASS $@
-}
-
mounted_lustre_filesystems() {
awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts | sed -n ${1}p
}
MOUNT_HINT2=$MOUNT_2
MOUNT="`mounted_lustre_filesystems 1`"
MOUNT_2="`mounted_lustre_filesystems 2`"
-if [ $TEST_9_10 -eq 1 -a "$MOUNT" ]; then
- echo "test9 and test10 will run on $MOUNT"
-elif [ "$MOUNT" -a "$MOUNT_2" ]; then
+if [ "$MOUNT" -a "$MOUNT_2" ]; then
echo "testing on $MOUNT and $MOUNT_2"
elif [ "$MOUNT" -o "$MOUNT_2" ]; then
error "test needs two mounts, only found $MOUNT $MOUNT_2!"
[ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
DIR2=${DIR2:-$MOUNT_2}
-LPROC=/proc/fs/lustre
LOVNAME=`cat $LPROC/llite/*/lov/common_name | tail -n 1`
-if [ $TEST_9_10 -eq 1 ]; then
- OSTCOUNT=2
-else
- OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
-fi
+OSTCOUNT=`cat $LPROC/lov/$LOVNAME/numobd`
STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
build_test_filter
+eval ONLY_0=true
+eval ONLY_99=true
# set_blk_tunables(btune_sz)
set_blk_tunesz() {
set_file_unitsz $IUNIT_SZ
fi
}
-if [ $TEST_9_10 -eq 0 ]; then
- pre_test
-fi
+pre_test
post_test() {
if [ -z "$NOSETUP" ]; then
setup() {
# create local test group
- GRP="`cat /etc/group | grep "$TSTUSR" | awk -F: '{print $1}'`"
+ GRP="`cat /etc/group | grep "^${TSTUSR}:" | awk -F: '{print $1}'`"
if [ -z "$GRP" ]; then
groupadd -g $TSTID "$TSTUSR"
fi
- TSTID="`cat /etc/group | grep "$TSTUSR" | awk -F: '{print $3}'`"
+ TSTID="`cat /etc/group | grep "^${TSTUSR}:" | awk -F: '{print $3}'`"
- GRP2="`cat /etc/group | grep "$TSTUSR2" | awk -F: '{print $1}'`"
+ GRP2="`cat /etc/group | grep "^${TSTUSR2}:" | awk -F: '{print $1}'`"
if [ -z "$GRP2" ]; then
groupadd -g $TSTID2 "$TSTUSR2"
fi
- TSTID2="`cat /etc/group | grep "$TSTUSR2" | awk -F: '{print $3}'`"
+ TSTID2="`cat /etc/group | grep "^${TSTUSR2}:" | awk -F: '{print $3}'`"
# create test user
- USR="`cat /etc/passwd | grep "$TSTUSR" | awk -F: '{print $1}'`"
+ USR="`cat /etc/passwd | grep "^${TSTUSR}:" | awk -F: '{print $1}'`"
if [ -z "$USR" ]; then
useradd -u $TSTID -g $TSTID -d /tmp "$TSTUSR"
fi
RUNAS="runas -u $TSTID"
- USR2="`cat /etc/passwd | grep "$TSTUSR2" | awk -F: '{print $1}'`"
+ USR2="`cat /etc/passwd | grep "^${TSTUSR2}:" | awk -F: '{print $1}'`"
if [ -z "$USR2" ]; then
useradd -u $TSTID2 -g $TSTID2 -d /tmp "$TSTUSR2"
fi
# block quota acquire & release
test_6() {
if [ $OSTCOUNT -lt 2 ]; then
- echo "WARN: too few osts, skip this test."
+ skip "$OSTCOUNT < 2, too few osts"
return 0;
fi
# quota recovery (block quota only by now)
test_7()
{
- if [ -z "`lsmod|grep mds`" ]; then
- echo "WARN: no local mds, skip this test"
- return 0
- fi
+ remote_mds && skip "remote mds" && return 0
LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
TESTFILE="$TSTDIR/quota_tst70"
[ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!"
echo " total limits = $TOTAL_LIMIT"
- OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'| head -n1`
- [ -z "$OST0_UUID" ] && OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'|head -n1`
+ OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
+ [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $MOUNT | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`"
[ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!"
echo " limits on $OST0_UUID = $OST0_LIMIT"
FILE_LIMIT=1000000
DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
- [ ! -d $DBENCH_LIB ] && echo "dbench not installed, skip this test" && return 0
+ [ ! -d $DBENCH_LIB ] && skip "dbench not installed" && return 0
echo " Set enough high limit for user: $TSTUSR"
$LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT
size_file=$((1024 * 1024 * 9 / 2 * $OSTCOUNT))
echo "lustrefs_size:$lustrefs_size size_file:$size_file"
if [ $lustrefs_size -lt $size_file ]; then
- echo "WARN: less than $size_file free, skip this test."
+ skip "less than $size_file free"
return 0;
fi
+ set_blk_unitsz $((1024 * 100))
+ set_blk_tunesz $((1024 * 50))
+
# set the D_QUOTA flag
- DBG_SAVE="`sysctl -n lnet.debug`"
- sysctl -w lnet.debug="$DBG_SAVE quota"
+ debugsave
+ sysctl -w lnet.debug="+quota"
TESTFILE="$TSTDIR/quota_tst90"
- echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
FILE_LIMIT=1000000
- echo " Set enough high limit for user: $TSTUSR"
+ echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
$LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT
- echo " Set enough high limit for group: $TSTUSR"
+ echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
$LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT
echo " Set stripe"
touch $TESTFILE
chown $TSTUSR.$TSTUSR $TESTFILE
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " Write the big file of $(($OSTCOUNT * 9 / 2 ))G ..."
$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$size_file || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success"
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " delete the big file of $(($OSTCOUNT * 9 / 2))G..."
$RUNAS rm -f $TESTFILE
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " write the big file of 2G..."
$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 1024 * 2)) || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect seccess"
$RUNAS rm -f $TESTFILE
RC=$?
- sysctl -w lnet.debug="$DBG_SAVE"
+ set_blk_tunesz $BTUNE_SZ
+ set_blk_unitsz $BUNIT_SZ
+
+ debugrestore
return $RC
}
run_test 9 "run for fixing bug10707(64bit) ==========="
size_file=$((1024 * 1024 * 9 / 2 * $OSTCOUNT))
echo "lustrefs_size:$lustrefs_size size_file:$size_file"
if [ $lustrefs_size -lt $size_file ]; then
- echo "WARN: less than $size_file free, skip this test."
+ skip "less than $size_file free"
return 0;
fi
if [ ! -d /proc/fs/lustre/ost/ -o ! -d /proc/fs/lustre/mds ]; then
- echo "WARN: mds or ost isn't local, skip this test."
+ skip "mds or ost isn't local"
return 0;
fi
sync; sleep 10; sync;
- # set the D_QUOTA flag
- set_flag=0
- if [ -z "`sysctl lnet.debug | grep quota`" ]; then
- sysctl -w lnet.debug="+quota"
- set_flag=1
- fi
+ set_blk_unitsz $((1024 * 100))
+ set_blk_tunesz $((1024 * 50))
+ # set the D_QUOTA flag
+ debugsave
+ sysctl -w lnet.debug="+quota"
+
# make qd_count 32 bit
sysctl -w lustre.fail_loc=0xA00
TESTFILE="$TSTDIR/quota_tst100"
- echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
FILE_LIMIT=1000000
- echo " Set enough high limit for user: $TSTUSR"
+ echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
$LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT
- echo " Set enough high limit for group: $TSTUSR"
+ echo " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
$LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $MOUNT
echo " Set stripe"
touch $TESTFILE
chown $TSTUSR.$TSTUSR $TESTFILE
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " Write the big file of $(($OSTCOUNT * 9 / 2 ))G ..."
$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$size_file || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success"
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " delete the big file of $(($OSTCOUNT * 9 / 2))G..."
$RUNAS rm -f $TESTFILE
+ $SHOW_QUOTA_USER
+ $SHOW_QUOTA_GROUP
+
echo " write the big file of 2G..."
$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 1024 * 2)) || error "(usr) write $((9 / 2 * $OSTCOUNT))G file failure, but expect success"
RC=$?
# clear the flage
- if [ $set_flag -eq 1 ]; then
- sysctl -w lnet.debug="-quota"
- fi
+ debugrestore
# make qd_count 64 bit
sysctl -w lustre.fail_loc=0
+ set_blk_tunesz $BTUNE_SZ
+ set_blk_unitsz $BUNIT_SZ
+
return $RC
}
run_test 10 "run for fixing bug10707(32bit) ==========="
$SHOW_QUOTA_USER
[ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
error "files too small $fz + $fz < $((BUNIT_SZ * BLK_SZ * 10))"
- [ $((fz + fz2)) -gt $((BUNIT_SZ * BLK_SZ * 11)) ] && \
- error "files too large $fz + $fz > $((BUNIT_SZ * BLK_SZ * 11))"
rm -f $TESTFILE $TESTFILE.2
}
run_test 13 "test multiple clients write block quota ==="
+check_if_quota_zero(){
+ line=`$LFS quota -$1 $2 $MOUNT | wc -l`
+ for i in `seq 3 $line`; do
+ for j in 3 4 6 7; do
+ tmp=`$LFS quota -$1 $2 $MOUNT | sed -n ${i}p |
+ awk '{print $'"$j"'}'`
+ [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -$1 $2 $MOUNT && \
+ error "quota on $1 isn't clean"
+ done
+ done
+ echo "pass check_if_quota_zero"
+}
+
+pre_test_14 () {
+ # reboot the lustre
+ cd $T_PWD; sh llmountcleanup.sh || error "llmountcleanup failed"
+ sh llmount.sh
+ pre_test
+ setup
+ run_test 0 "reboot lustre"
+}
+
+pre_test_14
+
+test_14(){ # b=12223 -- setting quota on root
+ mkdir $TSTDIR/$tdir || error "mkdir $TSTDIR/$tdir failed"
+ TESTFILE="$TSTDIR/$tdir/$tfile"
+
+ # out of root's file and block quota
+ $LFS setquota -u root 10 10 10 10 $MOUNT
+ createmany -m ${TESTFILE} 20 || \
+ error "unexpected: user(root) create files failly!"
+ dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
+ error "unexpected: user(root) write files failly!"
+ chmod 666 $TESTFILE
+ $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
+ error "unexpected: user(quota_usr) write a file successfully!"
+
+ # trigger the llog
+ chmod 777 $MOUNT
+ for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done
+ for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done
+
+ # do the check
+ dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
+ $LFS setquota -u root 0 0 0 0 $MOUNT
+ #check_if_quota_zero u root
+
+ # clean
+ unlinkmany ${TESTFILE} 15
+ rm -f $TESTFILE
+}
+run_test 14 "test setting quota on root ==="
+
# turn off quota
test_99()
{
log "cleanup: ======================================================"
if [ "`mount | grep ^$NAME`" ]; then
rm -fr $TSTDIR
- if [ $TEST_9_10 -eq 0 ]; then
post_test
- fi
# delete test user and group
userdel "$TSTUSR"
userdel "$TSTUSR2"
fi
echo '=========================== finished ==============================='
-[ -f "$QUOTALOG" ] && cat $QUOTALOG && exit 1
+[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
echo "$0: completed"