X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-quota.sh;h=ef00fdfc3fdb3a796ed47a04d1b3157ad93222c2;hp=fc74236af0726955fea18dbbaaa797308b67ffc5;hb=3172a9e96e63f70c306d03336cc6407659502b9c;hpb=8692681ee4e92e016ac0ac8a5401a90fb09d8f70 diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index fc74236..ef00fdf 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -6,25 +6,22 @@ # Run test by setting NOSETUP=true when ltest has setup env for us set -e -#kernel 2.4.x doesn't support quota -K_VER=`uname --kernel-release | cut -b 1-3` -if [ $K_VER = "2.4" ]; then - echo "Kernel 2.4 doesn't support quota" - exit 0 -fi - SRCDIR=`dirname $0` export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin +if [ "$USE_OFD" = "yes" -a -z "$ONLY" ]; then + # only accounting tests are supported with OFD for the time being + ONLY="33 34 35" +fi + ONLY=${ONLY:-"$*"} -ALWAYS_EXCEPT="10 $SANITY_QUOTA_EXCEPT" +# test_11 has been used to protect a kernel bug(bz10912), now it isn't +# useful any more. Then add it to ALWAYS_EXCEPT. b=19835 +# We have changed the mechanism of quota, test_12 is meanless now. +# b=20877 +ALWAYS_EXCEPT="10 12 $SANITY_QUOTA_EXCEPT" # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT! -case `uname -r` in -2.6*) FSTYPE=${FSTYPE:-ldiskfs};; -*) error "unsupported kernel" ;; -esac - [ "$ALWAYS_EXCEPT$EXCEPT" ] && \ echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`" @@ -40,19 +37,25 @@ BUNIT_SZ=${BUNIT_SZ:-1024} # min block quota unit(kB) IUNIT_SZ=${IUNIT_SZ:-10} # min inode quota unit MAX_DQ_TIME=604800 MAX_IQ_TIME=604800 +SANITY_QUOTA_USERS="quota15_1 quota15_2 quota15_3 quota15_4 quota15_5 quota15_6 \ + quota15_7 quota15_8 quota15_9 quota15_10 quota15_11 quota15_12 \ + quota15_13 quota15_14 quota15_15 quota15_16 quota15_17 quota15_18 \ + quota15_19 quota15_20 quota15_21 quota15_22 quota15_23 quota15_24 \ + quota15_25 quota15_26 quota15_27 quota15_28 quota15_29 quota15_30" -unset ENABLE_QUOTA - +export MULTIOP=${MULTIOP:-multiop} TRACE=${TRACE:-""} LUSTRE=${LUSTRE:-`dirname $0`/..} . $LUSTRE/tests/test-framework.sh init_test_env $@ . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh} +init_logging DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio} [ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0 -remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0 -remote_ost_nodsh && skip "remote OST with nodsh" && exit 0 + +require_dsh_mds || exit 0 +require_dsh_ost || exit 0 [ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11 18b 21" @@ -63,16 +66,22 @@ QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log} DIR=${DIR:-$MOUNT} DIR2=${DIR2:-$MOUNT2} +QUOTA_AUTO_OLD=$QUOTA_AUTO +export QUOTA_AUTO=0 + check_and_setup_lustre LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1` OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd` SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR" +SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR" SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR" SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR" +SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR" SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR" -SHOW_QUOTA_INFO="$LFS quota -t $DIR" +SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR" +SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR" # control the time of tests cycle=30 @@ -80,14 +89,27 @@ cycle=30 build_test_filter -eval ONLY_0=true -eval ONLY_99=true +if [ "$USE_OFD" = "yes" ]; then + for num in `seq $OSTCOUNT`; do + if [ $(facet_fstype ost$num) = ldiskfs ]; then + # not the most efficient way to enable the quota feature + # on ost, but it still allows us to test ofd accounting + # for now + device=$(ostdevname $num) + stop ost$num + do_facet ost$num "$TUNE2FS -O quota $device" + [ ${PIPESTATUS[0]} -ne 0] && \ + error "failed to enable quota feature for ost$num" + start ost$num $device $OST_MOUNT_OPTS + fi + done +fi # set_blk_tunables(btune_sz) set_blk_tunesz() { local btune=$(($1 * BLK_SZ)) # set btune size on all obdfilters - do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_btune_sz=$btune" + do_nodes $(comma_list $(osts_nodes)) "lctl set_param lquota.${FSNAME}-OST*.quota_btune_sz=$btune" # set btune size on mds do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_btune_sz=$btune" } @@ -96,7 +118,7 @@ set_blk_tunesz() { set_blk_unitsz() { local bunit=$(($1 * BLK_SZ)) # set bunit size on all obdfilters - do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_bunit_sz=$bunit" + do_nodes $(comma_list $(osts_nodes)) "lctl set_param lquota.${FSNAME}-OST*.quota_bunit_sz=$bunit" # set bunit size on mds do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_bunit_sz=$bunit" } @@ -104,8 +126,6 @@ set_blk_unitsz() { # set_file_tunesz(itune_sz) set_file_tunesz() { local itune=$1 - # set itune size on all obdfilters - do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_itune_sz=$itune" # set itune size on mds do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_itune_sz=$itune" } @@ -113,8 +133,6 @@ set_file_tunesz() { # set_file_unitsz(iunit_sz) set_file_unitsz() { local iunit=$1 - # set iunit size on all obdfilters - do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_iunit_sz=$iunit" # set iunit size on mds do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_iunit_sz=$iunit" } @@ -177,22 +195,22 @@ resetquota() { [ "$1" != "-u" -a "$1" != "-g" ] && error "resetquota: wrong specifier $1 passed" count=0 - if at_is_valid && at_is_enabled; then + if at_is_enabled; then timeout=$(at_max_get mds) else timeout=$(lctl get_param -n timeout) fi while [ $((count++)) -lt $timeout ]; do - $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT - RC=$? + local RC=0 + OUTPUT=`$LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT 2>&1` || RC=${PIPESTATUS[0]} if [ $RC -ne 0 ]; then - if [ $RC -eq 240 ]; then # 240 means -EBUSY - log "resetquota is blocked for quota master recovery, retry after 1 sec" - sleep 1 + if echo "$OUTPUT" | grep -q busy; then + log "resetquota is blocked for quota master recovery, retry after $((count * 3)) sec" + sleep 3 continue else - error "resetquota failed: $RC" + error "resetquota failed" fi fi break @@ -228,6 +246,36 @@ quota_log() { log "$*" } +# +# get quota info for a user or a group +# usage: getquota -u|-g | global| bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace +# +getquota() { + local spec + local uuid + + [ "$#" != 4 ] && error "getquota: wrong number of arguments: $#" + [ "$1" != "-u" -a "$1" != "-g" ] && error "getquota: wrong u/g specifier $1 passed" + + uuid="$3" + + case "$4" in + curspace) spec=1;; + bsoftlimit) spec=2;; + bhardlimit) spec=3;; + bgrace) spec=4;; + curinodes) spec=5;; + isoftlimit) spec=6;; + ihardlimit) spec=7;; + igrace) spec=8;; + *) error "unknown quota parameter $4";; + esac + + [ "$uuid" = "global" ] && uuid=$DIR + + $LFS quota -v "$1" "$2" $DIR | awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") { if (NF == 1) { getline } else { num++ } ; print $num;} }' | tr -d "*" +} + quota_show_check() { LOCAL_BF=$1 LOCAL_UG=$2 @@ -237,7 +285,7 @@ quota_show_check() { $LFS quota -v -$LOCAL_UG $LOCAL_ID $DIR if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then - USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`" + USAGE=`getquota -$LOCAL_UG $LOCAL_ID global curspace` if [ -z $USAGE ]; then quota_error $LOCAL_UG $LOCAL_ID "System is error when query quota for block ($LOCAL_UG:$LOCAL_ID)." else @@ -246,7 +294,7 @@ quota_show_check() { fi if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then - USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`" + USAGE=`getquota -$LOCAL_UG $LOCAL_ID global curinodes` if [ -z $USAGE ]; then quota_error $LOCAL_UG $LOCAL_ID "System is error when query quota for file ($LOCAL_UG:$LOCAL_ID)." else @@ -256,20 +304,46 @@ quota_show_check() { } # set quota -test_0() { - $LFS quotaoff -ug $DIR +quota_init() { + do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota" + + log "do the quotacheck ..." $LFS quotacheck -ug $DIR - resetquota -u $TSTUSR - resetquota -g $TSTUSR + resetquota -u $TSTUSR + resetquota -g $TSTUSR +} +quota_init - lctl set_param debug="+quota" - do_facet $SINGLEMDS "lctl set_param debug=+quota" - for num in `seq $OSTCOUNT`; do - do_facet ost$num "lctl set_param debug=+quota" - done +test_quota_performance() { + TESTFILE="$DIR/$tdir/$tfile-0" + local size=$1 + local stime=`date +%s` + $RUNAS dd if=/dev/zero of=$TESTFILE bs=1M count=$size || quota_error u $TSTUSR "write failure" + local etime=`date +%s` + delta=$((etime - stime)) + if [ $delta -gt 0 ]; then + rate=$((size * 1024 / delta)) + [ $rate -gt 1024 ] || error "SLOW IO for $TSTUSR (user): $rate KB/sec" + fi + rm -f $TESTFILE +} + +# test basic quota performance b=21696 +test_0() { + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + MB=100 + [ "$SLOW" = "no" ] && MB=10 + + test_quota_performance $MB + + $LFS setquota -u $TSTUSR -b 0 -B $((1024*1024)) -i 0 -I 0 $DIR + test_quota_performance $MB + + resetquota -u $TSTUSR } -run_test_with_stat 0 "Set quota =============================" +run_test_with_stat 0 "Test basic quota performance ===" # test for specific quota limitation, qunit, qtune $1=block_quota_limit test_1_sub() { @@ -302,7 +376,7 @@ test_1_sub() { rm -f $TESTFILE sync; sleep 1; sync; OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'` - OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED=`getquota -u $TSTUSR $OST0_UUID curspace` echo $OST0_QUOTA_USED [ $OST0_QUOTA_USED -ne 0 ] && \ ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released") @@ -333,7 +407,7 @@ test_1_sub() { rm -f $TESTFILE sync; sleep 1; sync; OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'` - OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED=`getquota -g $TSTUSR $OST0_UUID curspace` echo $OST0_QUOTA_USED [ $OST0_QUOTA_USED -ne 0 ] && \ ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released") @@ -348,7 +422,7 @@ test_1() { blk_qunit=$(( $RANDOM % 3072 + 1024 )) blk_qtune=$(( $RANDOM % $blk_qunit )) # other osts and mds will occupy at 1M blk quota - b_limit=$(( ($RANDOM - 16384) / 8 + $OSTCOUNT * $blk_qunit * 4 )) + b_limit=$(( ($RANDOM - 16384) / 8 + ($OSTCOUNT + 1) * $blk_qunit * 4 )) set_blk_tunesz $blk_qtune set_blk_unitsz $blk_qunit echo "cycle: $i(total $cycle) bunit:$blk_qunit, btune:$blk_qtune, blimit:$b_limit" @@ -388,7 +462,7 @@ test_2_sub() { sync; sleep 1; sync; MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'` - MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` + MDS_QUOTA_USED=`getquota -u $TSTUSR $MDS_UUID curinodes` echo $MDS_QUOTA_USED [ $MDS_QUOTA_USED -ne 0 ] && \ ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released") @@ -416,7 +490,7 @@ test_2_sub() { sync; sleep 1; sync; MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'` - MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` + MDS_QUOTA_USED=`getquota -g $TSTUSR $MDS_UUID curinodes` echo $MDS_QUOTA_USED [ $MDS_QUOTA_USED -ne 0 ] && \ ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released") @@ -466,7 +540,8 @@ test_block_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Write before timer goes off" $RUNDD count=$BUNIT_SZ seek=$OFFSET || \ @@ -480,7 +555,8 @@ test_block_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Write after timer goes off" # maybe cache write, ignore. @@ -492,7 +568,8 @@ test_block_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Unlink file to stop timer" rm -f $TESTFILE @@ -501,7 +578,8 @@ test_block_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Write ..." $RUNDD count=$BUNIT_SZ || quota_error a $TSTUSR "write failure, but expect success" @@ -571,7 +649,8 @@ test_file_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Create file after timer goes off" # the least of inode qunit is 2, so there are at most 3(qunit:2+qtune:1) @@ -584,7 +663,8 @@ test_file_soft() { $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP - $SHOW_QUOTA_INFO + $SHOW_QUOTA_INFO_USER + $SHOW_QUOTA_INFO_GROUP echo " Unlink files to stop timer" find `dirname $TESTFILE` -name "`basename ${TESTFILE}`*" | xargs rm -f @@ -698,7 +778,7 @@ run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota == # block quota acquire & release test_6() { if [ $OSTCOUNT -lt 2 ]; then - skip "$OSTCOUNT < 2, too few osts" + skip_env "$OSTCOUNT < 2, too few osts" return 0; fi @@ -747,7 +827,7 @@ test_6() { echo " Remove filea to let OST0 release quota" rm -f $FILEA - if at_is_valid && at_is_enabled; then + if at_is_enabled; then timeout=$(at_max_get mds) else timeout=$(lctl get_param -n timeout) @@ -758,7 +838,7 @@ test_6() { while [ $((count--)) -gt 0 ]; do sync && sleep 5 - OST0_QUOTA_HOLD=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'` + OST0_QUOTA_HOLD=`getquota -u $TSTUSR $OST0_UUID bhardlimit` if [ -z $OST0_QUOTA_HOLD ]; then error "System is error when query quota for block (U:$TSTUSR)." else @@ -774,7 +854,7 @@ test_6() { while [ $((count--)) -gt 0 ]; do sync && sleep 5 - OST0_QUOTA_HOLD=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'` + OST0_QUOTA_HOLD=`getquota -g $TSTUSR $OST0_UUID bhardlimit` if [ -z $OST0_QUOTA_HOLD ]; then error "System is error when query quota for block (G:$TSTUSR)." else @@ -839,13 +919,13 @@ test_7() # check limits PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`" - TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`" + TOTAL_LIMIT=`getquota -u $TSTUSR global bhardlimit` [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!" echo " total limits = $TOTAL_LIMIT" 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 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`" + OST0_LIMIT=`getquota -u $TSTUSR $OST0_UUID bhardlimit` [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!" echo " limits on $OST0_UUID = $OST0_LIMIT" @@ -886,7 +966,7 @@ GB=$((KB * 1024 * 1024)) # inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS); blksize=$((1 << 21)) # 2Mb size_file=$((GB * 9 / 2)) -# this check is just for test9 and test10 +# this check is just for test_9 OST0_MIN=4900000 #4.67G check_whether_skip () { OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'` @@ -924,7 +1004,7 @@ test_9() { quota_show_check a g $TSTUSR echo " Set stripe" - $LFS setstripe $TESTFILE -c 1 + $LFS setstripe $TESTFILE -c 1 -i 0 touch $TESTFILE chown $TSTUSR.$TSTUSR $TESTFILE @@ -951,134 +1031,8 @@ test_9() { } run_test_with_stat 9 "run for fixing bug10707(64bit) ===========" -# run for fixing bug10707, it need a big room. test for 32bit -# 2.0 version does not support 32 bit qd_count, so such test is obsolete. -test_10() { - mkdir -p $DIR/$tdir - chmod 0777 $DIR/$tdir - check_whether_skip && return 0 - - wait_delete_completed - - set_blk_tunesz 512 - set_blk_unitsz 1024 - - # make qd_count 32 bit - lustre_fail mds_ost 0xA00 - - TESTFILE="$DIR/$tdir/$tfile-0" - - BLK_LIMIT=$((100 * KB * KB)) # 100G - FILE_LIMIT=1000000 - - log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR" - $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR - log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR" - $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR - - quota_show_check a u $TSTUSR - quota_show_check a g $TSTUSR - - echo " Set stripe" - $LFS setstripe $TESTFILE -c 1 - touch $TESTFILE - chown $TSTUSR.$TSTUSR $TESTFILE - - log " Write the big file of 4.5 G ..." - $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \ - quota_error a $TSTUSR "(usr) write 4.5 G file failure, but expect success" - - $SHOW_QUOTA_USER - $SHOW_QUOTA_GROUP - - log " delete the big file of 4.5 G..." - $RUNAS rm -f $TESTFILE - sync; sleep 3; sync; - - $SHOW_QUOTA_USER - $SHOW_QUOTA_GROUP - - RC=$? - - # make qd_count 64 bit - lustre_fail mds_ost 0 - - set_blk_unitsz $((128 * 1024)) - set_blk_tunesz $((128 * 1024 / 2)) - - return $RC -} -#run_test_with_stat 10 "run for fixing bug10707(32bit) ===========" - -test_11() { - wait_delete_completed - - #prepare the test - block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1` - echo $block_limit - orig_dbr=`sysctl -n vm.dirty_background_ratio` - orig_dec=`sysctl -n vm.dirty_expire_centisecs` - orig_dr=`sysctl -n vm.dirty_ratio` - orig_dwc=`sysctl -n vm.dirty_writeback_centisecs` - sysctl -w vm.dirty_background_ratio=1 - sysctl -w vm.dirty_expire_centisecs=30 - sysctl -w vm.dirty_ratio=1 - sysctl -w vm.dirty_writeback_centisecs=50 - TESTDIR="$DIR/$tdir" - local RV=0 - - #do the test - local SECS=0 - local REPS=3 - [ "$SLOW" = no ] && REPS=1 - local sleep=20 - local i=1 - while [ $i -le $REPS ]; do - echo "test: cycle($i of $REPS) start at $(date)" - mkdir -p $TESTDIR && chmod 777 $TESTDIR - echo -n " create a file for uid " - for j in `seq 1 30`; do - echo -n "$j " - # 30MB per dd for a total of 900MB (if space even permits) - runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile bs=$blksize count=15 > /dev/null 2>&1 & - done - echo "" - PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) - LAST_USED=0 - while [ $PROCS -gt 0 ]; do - sleep 20 - SECS=$((SECS + sleep)) - PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) - USED=$(du -s $TESTDIR | awk '{print $1}') - PCT=$(($USED * 100 / $block_limit)) - echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} " - if [ $USED -le $LAST_USED ]; then - kill -9 $(ps -ef | grep "dd if /dev/zero of $TESTDIR" | grep -v grep | awk '{ print $2 }') - i=$REPS - RV=2 - break - fi - LAST_USED=$USED - done - echo " removing the test files..." - rm -f $TESTDIR/$tfile - echo "cycle $i done at $(date)" - i=$[$i+1] - done - echo "Test took $SECS sec" - - #clean - sysctl -w vm.dirty_background_ratio=$orig_dbr - sysctl -w vm.dirty_expire_centisecs=$orig_dec - sysctl -w vm.dirty_ratio=$orig_dr - sysctl -w vm.dirty_writeback_centisecs=$orig_dwc - if [ $RV -ne 0 ]; then - error "Nothing was written for $SECS sec ... aborting" - fi - return $RV -} -run_test_with_stat 11 "run for fixing bug10912 ===========" - +# 2.0 version does not support 32 bit qd_count, +# test_10 "run for fixing bug10707(32bit) " is obsolete # test a deadlock between quota and journal b=11693 test_12() { @@ -1086,7 +1040,7 @@ test_12() { chmod 0777 $DIR/$tdir [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \ - { skip "Need lustre mounted on $MOUNT2 " && retutn 0; } + { skip_env "Need lustre mounted on $MOUNT2 " && retutn 0; } LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever TESTFILE="$DIR/$tdir/$tfile-0" @@ -1113,17 +1067,24 @@ test_12() { DDPID=$! echo " step2: testing ......" - count=0 - while [ true ]; do - if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi - count=$[count+1] - if [ $count -gt 64 ]; then + local last_size=$(stat -c %s $TESTFILE2) + local stall_secs=0 + local start_secs=$SECONDS + while [ -d /proc/${DDPID1} ]; do + local size=$(stat -c %s $TESTFILE2) + if [ $size -eq $last_size ]; then + stall_secs=$[stall_secs+1] + else + stall_secs=0 + fi + if [ $stall_secs -gt 30 ]; then lustre_fail ost 0 - quota_error u $TSTUSR2 "dd should be finished!" + quota_error u $TSTUSR2 "giving up: dd stalled (i.e. made no progress) for 30 seconds!" fi + last_size=$size sleep 1 done - echo "(dd_pid=$DDPID1, time=$count)successful" + echo "(dd_pid=$DDPID1, time=$((SECONDS-start_secs)))successful" #Recover fail_loc and dd will finish soon lustre_fail ost 0 @@ -1215,9 +1176,9 @@ check_if_quota_zero(){ line=`$LFS quota -v -$1 $2 $DIR | wc -l` for i in `seq 3 $line`; do if [ $i -eq 3 ]; then - field="3 4 6 7" + field="3 4 7 8" else - field="3 5" + field="3 6" fi for j in $field; do tmp=`$LFS quota -v -$1 $2 $DIR | sed -n ${i}p | @@ -1235,7 +1196,7 @@ test_14a() { # was test_14 b=12223 -- setting quota on root # reboot the lustre sync; sleep 5; sync cleanup_and_setup_lustre - test_0 + quota_init mkdir -p $DIR/$tdir @@ -1243,10 +1204,10 @@ test_14a() { # was test_14 b=12223 -- setting quota on root $LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR createmany -m ${TESTFILE} 20 || \ quota_error u root "unexpected: user(root) create files failly!" - dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \ + $MULTIOP ${TESTFILE} oO_CREAT:O_WRONLY:O_DIRECT:w$((4096 * 4096))c || \ quota_error u root "unexpected: user(root) write files failly!" chmod 666 $TESTFILE - $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \ + $RUNAS $MULTIOP ${TESTFILE} oO_WRONLY:O_APPEND:O_DIRECT:w$((4096 * 4096))c && \ quota_error u root "unexpected: user(quota_usr) write a file successfully!" # trigger the llog @@ -1274,14 +1235,14 @@ test_15(){ # test for user $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR - TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`" + TOTAL_LIMIT=`getquota -u $TSTUSR global bhardlimit` [ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!" echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!" resetquota -u $TSTUSR # test for group $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR - TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`" + TOTAL_LIMIT=`getquota -g $TSTUSR global bhardlimit` [ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!" echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!" resetquota -g $TSTUSR @@ -1300,67 +1261,8 @@ test_15(){ } run_test_with_stat 15 "set block quota more than 4T ===" -# $1=u/g $2=with qunit adjust or not -test_16_tub() { - LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4)) - TESTFILE="$DIR/$tdir/$tfile" - mkdir -p $DIR/$tdir - - wait_delete_completed - - echo " User quota (limit: $LIMIT kbytes)" - if [ $1 == "u" ]; then - $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR - quota_show_check b u $TSTUSR - else - $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR - quota_show_check b g $TSTUSR - fi - - $LFS setstripe $TESTFILE -c 1 - chown $TSTUSR.$TSTUSR $TESTFILE - - echo " Write ..." - $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \ - quota_error a $TSTUSR "(usr) write failure, but expect success" - echo " Done" - echo " Write out of block quota ..." - # this time maybe cache write, ignore it's failure - $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true - # flush cache, ensure noquota flag is setted on client - cancel_lru_locks osc - if [ $2 -eq 1 ]; then - $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \ - quota_error a $TSTUSR "(write failure, but expect success" - else - $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \ - quota_error a $TSTUSR "(write success, but expect EDQUOT" - fi - - rm -f $TESTFILE - sync; sleep 3; sync; - resetquota -$1 $TSTUSR -} - -# test without adjusting qunit -# 2.0 version does not support WITHOUT_CHANGE_QS, so such test is obsolete -test_16 () { - set_blk_tunesz $((BUNIT_SZ * 2)) - set_blk_unitsz $((BUNIT_SZ * 4)) - for i in u g; do - for j in 0 1; do - # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS 0xA01 - echo " grp/usr: $i, adjust qunit: $j" - echo "-------------------------------" - [ $j -eq 1 ] && lustre_fail mds_ost 0 - [ $j -eq 0 ] && lustre_fail mds_ost 0xA01 - test_16_tub $i $j - done - done - set_blk_unitsz $((128 * 1024)) - set_blk_tunesz $((128 * 1024 / 2)) -} -#run_test_with_stat 16 "test without adjusting qunit" +# 2.0 version does not support WITHOUT_CHANGE_QS, +# test_16 "test without adjusting qunit" is obsolete # run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre. test_17() { @@ -1453,7 +1355,7 @@ test_18() { echo " step2: testing ......" count=0 - if at_is_valid && at_is_enabled; then + if at_is_enabled; then timeout=$(at_max_get mds) else timeout=$(lctl get_param -n timeout) @@ -1511,7 +1413,7 @@ test_18a() { echo " step2: testing ......" count=0 - if at_is_valid && at_is_enabled; then + if at_is_enabled; then timeout=$(at_max_get mds) else timeout=$(lctl get_param -n timeout) @@ -1542,7 +1444,7 @@ run_test_with_stat 18a "run for fixing bug14840 ===========" test_18bc_sub() { type=$1 - LIMIT=$((110 * 1024 )) # 110M + LIMIT=$(((100 + $OSTCOUNT * 3) * 1024)) TESTFILE="$DIR/$tdir/$tfile" mkdir -p $DIR/$tdir @@ -1571,19 +1473,21 @@ test_18bc_sub() { DDPID=$! do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug" + replay_barrier $SINGLEMDS + log "failing mds for $((2 * timeout)) seconds" fail $SINGLEMDS $((2 * timeout)) # check if quotaon successful $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled" if [ $? -eq 0 ]; then - error "quotaon failed!" rm -rf $TESTFILE + error "quotaon failed!" return fi count=0 - if at_is_valid && at_is_enabled; then + if at_is_enabled; then timeout=$(at_max_get mds) else timeout=$(lctl get_param -n timeout) @@ -1599,17 +1503,18 @@ test_18bc_sub() { sync cancel_lru_locks mdc cancel_lru_locks osc - - testfile_size=$(stat -c %s $TESTFILE) - [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \ - quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!" $SHOW_QUOTA_USER - rm -f $TESTFILE - sync resetquota -u $TSTUSR set_blk_unitsz $((128 * 1024)) set_blk_tunesz $((128 * 1024 / 2)) + testfile_size=$(stat -c %s $TESTFILE) + if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then + rm -f $TESTFILE + quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!" + fi + rm -f $TESTFILE + } # test when mds does failover, the ost still could work well @@ -1620,7 +1525,7 @@ test_18b() { # check if watchdog is triggered do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log watchdog=`awk '/test 18b/ {start = 1;} - /Watchdog triggered/ { + /Service thread pid/ && /was inactive/ { if (start) { print; } @@ -1701,9 +1606,10 @@ test_20() --inode-hardlimit ${LSTR[3]} \ $MOUNT || error "could not set quota limits" - ($LFS quota -v -u $TSTUSR $MOUNT | \ - grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \ - || error "lfs quota output is unexpected" + [ "`getquota -u $TSTUSR global bsoftlimit`" = "${LVAL[0]}" ] || error "bsoftlimit was not set properly" + [ "`getquota -u $TSTUSR global bhardlimit`" = "${LVAL[1]}" ] || error "bhardlimit was not set properly" + [ "`getquota -u $TSTUSR global isoftlimit`" = "${LVAL[2]}" ] || error "isoftlimit was not set properly" + [ "`getquota -u $TSTUSR global ihardlimit`" = "${LVAL[3]}" ] || error "ihardlimit was not set properly" resetquota -u $TSTUSR } @@ -1788,9 +1694,7 @@ test_21() { run_test_with_stat 21 "run for fixing bug16053 ===========" test_22() { - $LFS quotaoff -ug $DIR || error "could not turn quotas off" - - quota_save_version "ug" + quota_save_version "ug3" stopall mount @@ -1798,10 +1702,10 @@ test_22() { echo "checking parameters" - do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure" - do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure" + do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug3" || error "admin failure" + do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug3" || error "op failure" - run_test 0 "reboot lustre" + quota_init } run_test_with_stat 22 "test if quota_type saved as permanent parameter ====" @@ -1821,7 +1725,7 @@ test_23_sub() { sleep 3 quota_show_check b u $TSTUSR - $LFS setstripe $TESTFILE -c 1 + $LFS setstripe $TESTFILE -c 1 -i 0 chown $TSTUSR.$TSTUSR $TESTFILE log " Step1: trigger quota with 0_DIRECT" @@ -1841,7 +1745,7 @@ test_23_sub() { rm -f $TESTFILE wait_delete_completed OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'` - OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED=`getquota -u $TSTUSR $OST0_UUID curspace` echo $OST0_QUOTA_USED [ $OST0_QUOTA_USED -ne 0 ] && \ ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released") @@ -1850,13 +1754,17 @@ test_23_sub() { } test_23() { - log "run for $((OSTCOUNT * 4))MB test file" - test_23_sub $((OSTCOUNT * 4 * 1024)) + local slave_cnt=$((OSTCOUNT + 1)) # 1 mds, n osts - OST0_MIN=120000 + OST0_MIN=$((6 * $slave_cnt * 1024)) # extra space for meta blocks. check_whether_skip && return 0 - log "run for $((OSTCOUNT * 40))MB test file" - test_23_sub $((OSTCOUNT * 40 * 1024)) + log "run for $((4 * $slave_cnt))MB test file" + test_23_sub $((4 * $slave_cnt * 1024)) + + OST0_MIN=$((60 * $slave_cnt * 1024)) # extra space for meta blocks. + check_whether_skip && return 0 + log "run for $((40 * $slave_cnt))MB test file" + test_23_sub $((40 * $slave_cnt * 1024)) } run_test_with_stat 23 "run for fixing bug16125 ===========" @@ -1927,10 +1835,10 @@ test_25_sub() { $LFS setstripe $DIR/$tdir -c 1 -i 0 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'` OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'` - MDS_QUOTA_USED_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` - OST0_QUOTA_USED_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` - MDS_QUOTA_USED2_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` - OST0_QUOTA_USED2_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + MDS_QUOTA_USED_OLD=`getquota $1 $TSTUSR $MDS_UUID curinodes` + OST0_QUOTA_USED_OLD=`getquota $1 $TSTUSR $OST0_UUID curspace` + MDS_QUOTA_USED2_OLD=`getquota $1 $TSTUSR2 $MDS_UUID curinodes` + OST0_QUOTA_USED2_OLD=`getquota $1 $TSTUSR2 $OST0_UUID curspace` # TSTUSR write 4M log "$TSTUSR write 4M to $TESTFILE" @@ -1938,10 +1846,10 @@ test_25_sub() { sync show_quota $1 $TSTUSR show_quota $1 $TSTUSR2 - MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` + MDS_QUOTA_USED_NEW=`getquota $1 $TSTUSR $MDS_UUID curinodes` [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \ quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]" - OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED_NEW=`getquota $1 $TSTUSR $OST0_UUID curspace` OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD)) [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \ quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]" @@ -1957,17 +1865,19 @@ test_25_sub() { sync show_quota $1 $TSTUSR show_quota $1 $TSTUSR2 - MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` + MDS_QUOTA_USED2_NEW=`getquota $1 $TSTUSR2 $MDS_UUID curinodes` [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \ quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]" - OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED2_NEW=`getquota $1 $TSTUSR2 $OST0_UUID curspace` + # when chown, the quota on ost could be displayed out of quota temporarily. Delete the '*' in this situation. b=20433 + OST0_QUOTA_USED2_NEW=${OST0_QUOTA_USED2_NEW%\*} OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD)) [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \ quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]" - MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'` + MDS_QUOTA_USED_NEW=`getquota $1 $TSTUSR $MDS_UUID curinodes` [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \ quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]" - OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'` + OST0_QUOTA_USED_NEW=`getquota $1 $TSTUSR $OST0_UUID curspace` [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \ quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]" @@ -1997,7 +1907,7 @@ test_26() { wait_delete_completed # every quota slave gets 20MB - b_limit=$((OSTCOUNT * 20 * 1024)) + b_limit=$(((OSTCOUNT + 1) * 20 * 1024)) log "limit: ${b_limit}KB" $LFS setquota -u $TSTUSR -b 0 -B $b_limit -i 0 -I 0 $DIR sleep 3 @@ -2031,20 +1941,456 @@ test_26() { } run_test_with_stat 26 "test for false quota error(bz18491) ======================================" -# turn off quota -test_99() +test_27a() { + $LFS quota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed" + $LFS setquota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed" + return 0 +} +run_test_with_stat 27a "lfs quota/setquota should handle wrong arguments (19612) =================" + +test_27b() { + $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR || \ + error "lfs setquota failed with uid argument" + $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR || \ + error "lfs stequota failed with gid argument" + $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument" + $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument" + resetquota -u $TSTUSR + resetquota -g $TSTUSR + return 0 +} +run_test 27b "lfs quota/setquota should handle user/group ID (20200) =================" + +test_28() { + BLK_LIMIT=$((100 * 1024 * 1024)) # 100G + echo "Step 1: set enough high limit for user [$TSTUSR:$BLK_LIMIT]" + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR + $SHOW_QUOTA_USER + + echo "Step 2: reset system ..." + cleanup_and_setup_lustre + quota_init + + echo "Step 3: change qunit for user [$TSTUSR:512:1024]" + set_blk_tunesz 512 + set_blk_unitsz 1024 + + wait_delete_completed + + #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE + lustre_fail ost 0x80000A02 + + TESTFILE="$DIR/$tdir/$tfile" + mkdir -p $DIR/$tdir + + BLK_LIMIT=$((100 * 1024)) # 100M + echo "Step 4: set enough high limit for user [$TSTUSR:$BLK_LIMIT]" + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR + $SHOW_QUOTA_USER + + touch $TESTFILE + chown $TSTUSR.$TSTUSR $TESTFILE + + echo "Step 5: write the test file1 [10M] ..." + $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(( 10 * 1024 )) \ + || quota_error a $TSTUSR "write 10M file failure" + $SHOW_QUOTA_USER + + rm -f $TESTFILE + sync; sleep 3; sync; + + # make qd_count 64 bit + lustre_fail ost 0 + + set_blk_unitsz $((128 * 1024)) + set_blk_tunesz $((128 * 1024 / 2)) + + resetquota -u $TSTUSR +} +run_test_with_stat 28 "test for consistency for qunit when setquota (18574) ===========" + +test_29() { - $LFS quotaoff $DIR - lctl set_param debug="-quota" + local BLK_LIMIT=$((100 * 1024 * 1024)) # 100G + local timeout + local pid - return 0 + if at_is_enabled; then + timeout=$(at_max_get client) + at_max_set 10 client + else + timeout=$(lctl get_param -n timeout) + lctl set_param timeout=10 + fi + # actually send a RPC to make service at_current confined within at_max + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR || error "should succeed" + + #define OBD_FAIL_MDS_QUOTACTL_NET 0x12e + lustre_fail mds 0x12e + + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR & pid=$! + + echo "sleeping for 10 * 1.25 + 5 + 10 seconds" + sleep 28 + ps -p $pid && error "lfs hadn't finished by timeout" + wait $pid && error "succeeded, but should have failed" + + lustre_fail mds 0 + + if at_is_enabled; then + at_max_set $timeout client + else + lctl set_param timeout=$timeout + fi + + resetquota -u $TSTUSR } -run_test_with_stat 99 "Quota off ===============================" +run_test_with_stat 29 "unhandled quotactls must not hang lustre client (19778) ========" + +test_30() +{ + local output + local LIMIT=1024 + local TESTFILE="$DIR/$tdir/$tfile" + local GRACE=10 + + set_blk_tunesz 512 + set_blk_unitsz 1024 + + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + + $LFS setstripe $TESTFILE -i 0 -c 1 + chown $TSTUSR.$TSTUSR $TESTFILE + $LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR + $LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR + $RUNAS dd if=/dev/zero of=$TESTFILE bs=1024 count=$((LIMIT * 2)) || true + cancel_lru_locks osc + sleep $GRACE + $LFS setquota -u $TSTUSR -B 0 $DIR + # over-quota flag has not yet settled since we do not trigger async events + # based on grace time period expiration + $SHOW_QUOTA_USER + $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 || true + cancel_lru_locks osc + # now over-quota flag should be settled and further writes should fail + $SHOW_QUOTA_USER + $RUNAS dd if=/dev/zero of=$TESTFILE conv=notrunc oflag=append bs=1048576 count=1 && error "grace times were reset" + rm -f $TESTFILE + resetquota -u $TSTUSR + $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR + + set_blk_unitsz $((128 * 1024)) + set_blk_tunesz $((128 * 1024 / 2)) +} +run_test_with_stat 30 "hard limit updates should not reset grace times ================" + +# test duplicate quota releases b=18630 +test_31() { + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + + LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever + TESTFILE="$DIR/$tdir/$tfile-0" + TESTFILE2="$DIR/$tdir/$tfile-1" + + wait_delete_completed + + log " User quota (limit: $LIMIT kbytes)" + $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR + + $LFS setstripe $TESTFILE -i 0 -c 1 + chown $TSTUSR.$TSTUSR $TESTFILE + $LFS setstripe $TESTFILE2 -i 0 -c 1 + chown $TSTUSR.$TSTUSR $TESTFILE2 + + log " step1: write out of block quota ..." + $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=5120 + $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=5120 + + #define OBD_FAIL_QUOTA_DELAY_SD 0xA04 + #define OBD_FAIL_SOME 0x10000000 /* fail N times */ + lustre_fail ost $((0x00000A04 | 0x10000000)) 1 + + log " step2: delete two files so that triggering duplicate quota release ..." + rm -f $TESTFILE $TESTFILE2 + sync; sleep 5; sync # OBD_FAIL_QUOTA_DELAY_SD will delay for 5 seconds + wait_delete_completed + + log " step3: verify if the ost failed" + do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log + watchdog=`awk '/test 31/ {start = 1;} + /release quota error/ { + if (start) { + print; + } + }' $TMP/lustre-log-${TESTNAME}.log` + [ "$watchdog" ] && error "$watchdog" + rm -f $TMP/lustre-log-${TESTNAME}.log + + lustre_fail ost 0 + resetquota -u $TSTUSR +} +run_test_with_stat 31 "test duplicate quota releases ===" + +# check hash_cur_bits +check_quota_hash_cur_bits() { + local bits=$1 + + # check quota_hash_cur_bits on all obdfilters + for num in `seq $OSTCOUNT`; do + cb=`do_facet ost$num "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"` + if [ $cb -gt $bits ]; then + echo "hash_lqs_cur_bits of ost$num is too large(cur_bits=$cb)" + return 1; + fi + done + # check quota_hash_cur_bits on mds + cb=`do_facet $SINGLEMDS "cat /sys/module/lquota/parameters/hash_lqs_cur_bits"` + if [ $cb -gt $bits ]; then + echo "hash_lqs_cur_bits of mds is too large(cur_bits=$cb)" + return 1; + fi + return 0; +} + +# check lqs hash +check_lqs_hash() { + # check distribution of all obdfilters + for num in `seq $OSTCOUNT`; do + do_facet ost$num "lctl get_param obdfilter.${FSNAME}-OST*.hash_stats | grep LQS_HASH" | while read line; do + rehash_count=`echo $line | awk '{print $9}'` + if [ $rehash_count -eq 0 ]; then + echo -e "ost$num:\n $line" + error "Rehearsh didn't happen" + fi + done + done + # check distribution of mds + do_facet $SINGLEMDS "lctl get_param mdt.${FSNAME}-MDT*.hash_stats | grep LQS_HASH" | while read line; do + rehash_count=`echo $line | awk '{print $9}'` + if [ $rehash_count -eq 0 ]; then + echo -e "mdt:\n $line" + error "Rehearsh didn't happen" + fi + done +} + +test_32() +{ + # reset system so that quota_hash_cur_bits==3 + echo "Reset system ..." + local LMR_orig=$LOAD_MODULES_REMOTE + LOAD_MODULES_REMOTE=true + cleanup_and_setup_lustre + LOAD_MODULES_REMOTE=$LMR_orig + + client_up + wait_mds_ost_sync + quota_init + + for user in $SANITY_QUOTA_USERS; do + check_runas_id_ret $user quota_usr "runas -u $user -g quota_usr" >/dev/null 2>/dev/null || \ + missing_users="$missing_users $user" + done + [ -n "$missing_users" ] && { skip_env "the following users are missing: $missing_users" ; return 0 ; } + check_quota_hash_cur_bits 3 || { skip_env "hash_lqs_cur_bits isn't set properly"; return 0;} + + $LFS quotaoff -ug $DIR + $LFS quotacheck -ug $DIR + + for user in $SANITY_QUOTA_USERS; do + $LFS setquota -u $user --block-hardlimit 1048576 $DIR + done + + check_lqs_hash + + for user in $SANITY_QUOTA_USERS; do + resetquota -u $user + done +} +run_test 32 "check lqs hash(bug 21846) ==========================================" + +cleanup_quota_test() { + trap 0 + echo "Delete files..." + rm -rf $DIR/$tdir +} + +# basic usage tracking for user & group +test_33() { + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + INODES=10 + BLK_CNT=1024 + TOTAL_BLKS=$(($INODES * $BLK_CNT)) + + trap cleanup_quota_test EXIT + + # make sure the system is clean + USED=`getquota -u $TSTID global curspace` + [ $USED -ne 0 ] && \ + error "Used space ($USED) for user $TSTID isn't 0." + USED=`getquota -g $TSTID global curspace` + [ $USED -ne 0 ] && \ + error "Used space ($USED) for group $TSTID isn't 0." + + for i in `seq 0 $INODES`; do + $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile-$i conv=fsync \ + bs=$((BLK_SZ * BLK_CNT)) count=1 2>/dev/null || + error "write failed" + echo "Iteration $i/$INODES completed" + done + sync; sync_all_data; + + echo "Verify disk usage after write" + USED=`getquota -u $TSTID global curspace` + [ $USED -lt $TOTAL_BLKS ] && \ + error "Used space for user $TSTID is $USED, expected $TOTAL_BLKS" + USED=`getquota -u $TSTID global curinodes` + [ $USED -lt $INODES ] && \ + error "Used inode for user $TSTID is $USED, expected $INODES" + + USED=`getquota -g $TSTID global curspace` + [ $USED -lt $TOTAL_BLKS ] && \ + error "Used space for group $TSTID is $USED, expected $TOTAL_BLKS" + USED=`getquota -g $TSTID global curinodes` + [ $USED -lt $INODES ] && \ + error "Used inode for group $TSTID is $USED, expected $INODES" + + cleanup_quota_test + + echo "Verify disk usage after delete" + wait_delete_completed + USED=`getquota -u $TSTID global curspace` + [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED" + USED=`getquota -u $TSTID global curinodes` + [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED" + USED=`getquota -g $TSTID global curspace` + [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED" + USED=`getquota -g $TSTID global curinodes` + [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED" +} +run_test 33 "basic usage tracking for user & group ==============================" + +# usage transfer test for user & group +test_34() { + BLK_CNT=1024 + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + + trap cleanup_quota_test EXIT + + # make sure the system is clean + USED=`getquota -u $TSTID global curspace` + [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0." + USED=`getquota -g $TSTID global curspace` + [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0." + + echo "Write file..." + dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$((BLK_SZ * BLK_CNT)) count=1 \ + conv=fsync 2>/dev/null || error "write failed" + sync; sync_all_data; + + echo "chown the file to user $TSTID" + chown $TSTID $DIR/$tdir/$tfile || error "chown failed" + + echo "Wait for setattr on objects finished..." + wait_delete_completed + + echo "Verify disk usage for user $TSTID" + USED=`getquota -u $TSTID global curspace` + [ $USED -lt $BLK_CNT ] && \ + error "Used space for user $TSTID is $USED, expected $BLK_CNT" + USED=`getquota -u $TSTID global curinodes` + [ $USED -ne 1 ] && \ + error "Used inodes for user $TSTID is $USED, expected 1" + + echo "chgrp the file to group $TSTID" + chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed" + + echo "Wait for setattr on objects finished..." + wait_delete_completed + + echo "Verify disk usage for group $TSTID" + USED=`getquota -g $TSTID global curspace` + [ $USED -ge $BLK_CNT ] || \ + error "Used space for group $TSTID is $USED, expected $BLK_CNT" + USED=`getquota -g $TSTID global curinodes` + [ $USED -eq 1 ] || \ + error "Used inodes for group $TSTID is $USED, expected 1" + + cleanup_quota_test +} +run_test 34 "usage transfer for user & group ====================================" + +# usage is still accessible across restart +test_35() { + mkdir -p $DIR/$tdir + chmod 0777 $DIR/$tdir + BLK_CNT=1024 + + trap cleanup_quota_test EXIT + + echo "Write file..." + $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$((BLK_SZ * BLK_CNT)) \ + count=1 conv=fsync 2>/dev/null || error "write failed" + sync; sync_all_data; + + echo "Save disk usage before restart" + ORIG_USR_SPACE=`getquota -u $TSTID global curspace` + [ $ORIG_USR_SPACE -eq 0 ] && \ + error "Used space for user $TSTID is 0, expected $BLK_CNT" + ORIG_USR_INODES=`getquota -u $TSTID global curinodes` + [ $ORIG_USR_INODES -eq 0 ] && \ + error "Used inodes for user $TSTID is 0, expected 1" + ORIG_GRP_SPACE=`getquota -g $TSTID global curspace` + [ $ORIG_GRP_SPACE -eq 0 ] && \ + error "Used space for group $TSTID is 0, expected $BLK_CNT" + ORIG_GRP_INODES=`getquota -g $TSTID global curinodes` + [ $ORIG_GRP_INODES -eq 0 ] && \ + error "Used inodes for group $TSTID is 0, expected 1" + + log "Restart..." + local ORIG_REFORMAT=$REFORMAT + REFORMAT="" + cleanup_and_setup_lustre + REFORMAT=$ORIG_REFORMAT + quota_init + + echo "Verify disk usage after restart" + USED=`getquota -u $TSTID global curspace` + [ $USED -eq $ORIG_USR_SPACE ] || \ + error "Used space for user $TSTID changed from " \ + "$ORIG_USR_SPACE to $USED" + USED=`getquota -u $TSTID global curinodes` + [ $USED -eq $ORIG_USR_INODES ] || \ + error "Used inodes for user $TSTID changed from " \ + "$ORIG_USR_INODES to $USED" + USED=`getquota -g $TSTID global curspace` + [ $USED -eq $ORIG_GRP_SPACE ] || \ + error "Used space for group $TSTID changed from " \ + "$ORIG_GRP_SPACE to $USED" + USED=`getquota -g $TSTID global curinodes` + [ $USED -eq $ORIG_GRP_INODES ] || \ + error "Used inodes for group $TSTID changed from " \ + "$ORIG_GRP_INODES to $USED" + + cleanup_quota_test +} +run_test 35 "usage is still accessible across reboot ============================" + +# turn off quota +quota_fini() +{ + $LFS quotaoff $DIR + do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota" +} +quota_fini -log "cleanup: ======================================================" cd $ORIG_PWD +complete $(basename $0) $SECONDS check_and_cleanup_lustre -echo '=========================== finished ===============================' -[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true -echo "$0: completed" +export QUOTA_AUTO=$QUOTA_AUTO_OLD +exit_status