X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-quota.sh;h=634d7f982a051f19ffadf82beeb2406c55a1b5f5;hb=69dda0cf5fb34a1a7ff93468ca1c155dd3a53060;hp=366bbdf92cc8634ba4960c49438c2fbfa187cf93;hpb=e88b3bf26a477a2b42182c4b451bc2fe55fa88fa;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index 366bbdf..634d7f9 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -34,8 +34,6 @@ init_test_env $@ init_logging DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio} -[ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0 - require_dsh_mds || exit 0 require_dsh_ost || exit 0 @@ -45,13 +43,24 @@ if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then exec $LUSTRE/tests/sanity-quota-old.sh fi -# if e2fsprogs support quota feature? -if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] && \ - ! $DEBUGFS -c -R supported_features | grep -q 'quota'; then +# Does e2fsprogs support quota feature? +if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] && + do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features | + grep -q 'quota'"; then skip "e2fsprogs doesn't support quota" && exit 0 fi -[ "$SLOW" = "no" ] && EXCEPT_SLOW="9 18 21" +# bug number for skipped test: LU-4515 +ALWAYS_EXCEPT="$ALWAYS_EXCEPT 34" + +if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then +# bug number for skipped test: LU-2872 LU-2836 LU-2836 LU-2059 + ALWAYS_EXCEPT="$ALWAYS_EXCEPT 1 3 6 7d" +# bug number: LU-2887 + ZFS_SLOW="12a" +fi + +[ "$SLOW" = "no" ] && EXCEPT_SLOW="$ZFS_SLOW 9 18 21" QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log} @@ -80,21 +89,18 @@ SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR" build_test_filter lustre_fail() { - local fail_node=$1 + local fail_node=$1 local fail_loc=$2 local fail_val=${3:-0} + local NODES= - if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then - do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val" - do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc" - fi + case $fail_node in + mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";; + mds|mdt) NODES="$(comma_list $(mdts_nodes))";; + ost) NODES="$(comma_list $(osts_nodes))";; + esac - if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then - for num in `seq $OSTCOUNT`; do - do_facet ost$num "lctl set_param fail_val=$fail_val" - do_facet ost$num "lctl set_param fail_loc=$fail_loc" - done - fi + do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc" } RUNAS="runas -u $TSTID -g $TSTID" @@ -117,7 +123,8 @@ resetquota() { [ "$1" != "-u" -a "$1" != "-g" ] && error "resetquota: wrong specifier $1 passed" - $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT + $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT || + error "clear quota for [type:$1 name:$2] failed" # give a chance to slave to release space sleep 1 } @@ -191,30 +198,41 @@ getquota() { # usage: set_mdt_qtype ug|u|g|none set_mdt_qtype() { local qtype=$1 - local varsvc=${SINGLEMDS}_svc + local varsvc + local mdts=$(get_facets MDS) + local cmd do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$qtype - if $(facet_up $SINGLEMDS); then - wait_update_facet $SINGLEMDS "$LCTL get_param -n \ - osd-$FSTYPE.${!varsvc}.quota_slave.enabled" "$qtype" || - return 1 - fi + # we have to make sure each MDT received config changes + for mdt in ${mdts//,/ }; do + varsvc=${mdt}_svc + cmd="$LCTL get_param -n " + cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc} + cmd=${cmd}.quota_slave.enabled + + if $(facet_up $mdt); then + wait_update_facet $mdt "$cmd" "$qtype" || return 1 + fi + done return 0 } # set ost quota type -# usage: set_ost_quota_type ug|u|g|none +# usage: set_ost_qtype ug|u|g|none set_ost_qtype() { local qtype=$1 local varsvc local osts=$(get_facets OST) + local cmd do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$qtype # we have to make sure each OST received config changes for ost in ${osts//,/ }; do varsvc=${ost}_svc + cmd="$LCTL get_param -n " + cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc} + cmd=${cmd}.quota_slave.enabled + if $(facet_up $ost); then - wait_update_facet $ost "$LCTL get_param -n \ - osd-$FSTYPE.${!varsvc}.quota_slave.enabled" \ - "$qtype" || return 1 + wait_update_facet $ost "$cmd" "$qtype" || return 1 fi done return 0 @@ -223,54 +241,57 @@ set_ost_qtype() { wait_reintegration() { local ntype=$1 local qtype=$2 + local max=$3 local result="glb[1],slv[1],reint[0]" local varsvc + local cmd + local tgts if [ $ntype == "mdt" ]; then - varsvc=${SINGLEMDS}_svc - if $(facet_up $SINGLEMDS); then - wait_update_facet $SINGLEMDS "$LCTL get_param -n \ - osd-$FSTYPE.${!varsvc}.quota_slave.info | - grep "$qtype" | awk '{ print \\\$3 }'" "$result" || - return 1 - fi + tgts=$(get_facets MDS) else - local osts=$(get_facets OST) - for ost in ${osts//,/ }; do - varsvc=${ost}_svc - if $(facet_up $ost); then - wait_update_facet $ost "$LCTL get_param -n \ - osd-$FSTYPE.${!varsvc}.quota_slave.info | - grep "$qtype" | awk '{ print \\\$3 }'" \ - "$result" || return 1 - fi - done + tgts=$(get_facets OST) fi + + for tgt in ${tgts//,/ }; do + varsvc=${tgt}_svc + cmd="$LCTL get_param -n " + cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc} + cmd=${cmd}.quota_slave.info + + if $(facet_up $tgt); then + wait_update_facet $tgt "$cmd | + grep "$qtype" | awk '{ print \\\$3 }'" \ + "$result" $max || return 1 + fi + done return 0 } wait_mdt_reint() { local qtype=$1 + local max=${2:-90} if [ $qtype == "u" ] || [ $qtype == "ug" ]; then - wait_reintegration "mdt" "user" || return 1 + wait_reintegration "mdt" "user" $max || return 1 fi if [ $qtype == "g" ] || [ $qtype == "ug" ]; then - wait_reintegration "mdt" "group" || return 1 + wait_reintegration "mdt" "group" $max || return 1 fi return 0 } wait_ost_reint() { local qtype=$1 + local max=${2:-90} if [ $qtype == "u" ] || [ $qtype == "ug" ]; then - wait_reintegration "ost" "user" || return 1 + wait_reintegration "ost" "user" $max || return 1 fi if [ $qtype == "g" ] || [ $qtype == "ug" ]; then - wait_reintegration "ost" "group" || return 1 + wait_reintegration "ost" "group" $max || return 1 fi return 0 } @@ -280,7 +301,7 @@ setup_quota_test() { wait_delete_completed echo "Creating test directory" mkdir -p $DIR/$tdir - chmod 077 $DIR/$tdir + chmod 0777 $DIR/$tdir # always clear fail_loc in case of fail_loc isn't cleared # properly when previous test failed lustre_fail mds_ost 0 @@ -332,6 +353,11 @@ quota_init() { } quota_init +resetquota -u $TSTUSR +resetquota -g $TSTUSR +resetquota -u $TSTUSR2 +resetquota -g $TSTUSR2 + test_quota_performance() { local TESTFILE="$DIR/$tdir/$tfile-0" local size=$1 # in MB @@ -342,8 +368,14 @@ test_quota_performance() { delta=$((etime - stime)) if [ $delta -gt 0 ]; then rate=$((size * 1024 / delta)) - [ $rate -gt 1024 ] || - error "SLOW IO for $TSTUSR (user): $rate KB/sec" + if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then + # LU-2872 - see LU-2887 for fix + [ $rate -gt 64 ] || + error "SLOW IO for $TSTUSR (user): $rate KB/sec" + else + [ $rate -gt 1024 ] || + error "SLOW IO for $TSTUSR (user): $rate KB/sec" + fi fi rm -f $TESTFILE } @@ -353,8 +385,7 @@ test_0() { local MB=100 # 100M [ "$SLOW" = "no" ] && MB=10 - local free_space=$(lfs df | grep "filesystem summary" | \ - awk '{print $5}') + local free_space=$(lfs_df | grep "summary" | awk '{print $4}') [ $free_space -le $((MB * 1024)) ] && skip "not enough space ${free_space} KB, " \ "required $((MB * 1024)) KB" && return @@ -365,7 +396,8 @@ test_0() { test_quota_performance $MB set_ost_qtype "ug" || error "enable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR || + error "set quota failed" test_quota_performance $MB cleanup_quota_test @@ -386,7 +418,8 @@ test_1() { # test for user log "User quota (block hardlimit:$LIMIT MB)" - $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || + error "set user quota failed" # make sure the system is clean local USED=$(getquota -u $TSTUSR global curspace) @@ -417,7 +450,8 @@ test_1() { # test for group log "--------------------------------------" log "Group quota (block hardlimit:$LIMIT MB)" - $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR + $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || + error "set group quota failed" TESTFILE="$DIR/$tdir/$tfile-1" # make sure the system is clean @@ -455,6 +489,12 @@ test_2() { [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes + local FREE_INODES=$(mdt_free_inodes 0) + echo "$FREE_INODES free inodes on master MDT" + [ $FREE_INODES -lt $LIMIT ] && + skip "not enough free inodes $FREE_INODES required $LIMIT" && + return + setup_quota_test trap cleanup_quota_test EXIT @@ -463,7 +503,8 @@ test_2() { # test for user log "User quota (inode hardlimit:$LIMIT files)" - $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR || + error "set user quota failed" # make sure the system is clean local USED=$(getquota -u $TSTUSR global curinodes) @@ -489,7 +530,8 @@ test_2() { # test for group log "--------------------------------------" log "Group quota (inode hardlimit:$LIMIT files)" - $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR + $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR || + error "set group quota failed" TESTFILE=$DIR/$tdir/$tfile-1 # make sure the system is clean @@ -596,7 +638,7 @@ test_block_soft() { # block soft limit test_3() { local LIMIT=1 # 1MB - local GRACE=10 # 10s + local GRACE=20 # 20s local TESTFILE=$DIR/$tdir/$tfile-0 set_ost_qtype "ug" || error "enable ost quota failed" @@ -606,8 +648,10 @@ test_3() { local USED=$(getquota -u $TSTUSR global curspace) [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0." - $LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR - $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR + $LFS setquota -t -u --block-grace $GRACE --inode-grace \ + $MAX_IQ_TIME $DIR || error "set user grace time failed" + $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR || + error "set user quota failed" test_block_soft $TESTFILE $GRACE $LIMIT resetquota -u $TSTUSR @@ -618,17 +662,19 @@ test_3() { USED=$(getquota -g $TSTUSR global curspace) [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0." - $LFS setquota -t -g --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR - $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR + $LFS setquota -t -g --block-grace $GRACE --inode-grace \ + $MAX_IQ_TIME $DIR || error "set group grace time failed" + $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR || + error "set group quota failed" test_block_soft $TESTFILE $GRACE $LIMIT resetquota -g $TSTUSR # cleanup $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore user grace time failed" $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore group grace time failed" } run_test 3 "Block soft limit (start timer, timer goes off, stop timer)" @@ -702,8 +748,10 @@ test_4a() { local USED=$(getquota -u $TSTUSR global curinodes) [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0." - $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR - $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR + $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ + $GRACE $DIR || error "set user grace time failed" + $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR || + error "set user quota failed" test_file_soft $TESTFILE $LIMIT $GRACE resetquota -u $TSTUSR @@ -713,8 +761,10 @@ test_4a() { USED=$(getquota -g $TSTUSR global curinodes) [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0." - $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR - $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR + $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \ + $GRACE $DIR || error "set group grace time failed" + $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR || + error "set group quota failed" TESTFILE=$DIR/$tdir/$tfile-1 test_file_soft $TESTFILE $LIMIT $GRACE @@ -722,9 +772,9 @@ test_4a() { # cleanup $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore user grace time failed" $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore group grace time failed" } run_test 4a "File soft limit (start timer, timer goes off, stop timer)" @@ -740,9 +790,11 @@ test_4b() { # test of valid grace strings handling echo "Valid grace strings test" - $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace $GR_STR2 $DIR + $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \ + $GR_STR2 $DIR || error "set user grace time failed" $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1" - $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace $GR_STR4 $DIR + $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \ + $GR_STR4 $DIR || error "set group grace time quota failed" $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4" # test of invalid grace strings handling @@ -752,9 +804,9 @@ test_4b() { # cleanup $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore user grace time failed" $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore group grace time failed" } run_test 4b "Grace time strings handling" @@ -770,8 +822,10 @@ test_5() { set_ost_qtype "ug" || error "enable ost quota failed" echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR" - $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR - $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR + $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR || + error "set user quota failed" + $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR || + error "set group quota failed" # make sure the system is clean local USED=$(getquota -u $TSTUSR global curinodes) @@ -808,6 +862,10 @@ run_test 5 "Chown & chgrp successfully even out of block/file quota" test_6() { local LIMIT=3 # 3M + # Clear dmesg so watchdog is not triggered by previous + # test output + do_facet ost1 dmesg -c > /dev/null + setup_quota_test trap cleanup_quota_test EXIT @@ -830,7 +888,8 @@ test_6() { chown $TSTUSR2.$TSTUSR2 $TESTFILE2 # cache per-ID lock for $TSTUSR on slave - $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || + error "set quota failed" $RUNAS $DD of=$TESTFILE count=1 || error "write $TESTFILE failure, expect success" $RUNAS2 $DD of=$TESTFILE2 count=1 || @@ -865,25 +924,26 @@ test_6() { # no watchdog is triggered do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log - watchdog=$(awk '/sanity-quota test 6/ {start = 1;} - /Service thread pid/ && /was inactive/ { - if (start) { - print; - } - }' $TMP/lustre-log-${TESTNAME}.log) + watchdog=$(awk '/Service thread pid/ && /was inactive/ \ + { print; }' $TMP/lustre-log-${TESTNAME}.log) [ -z "$watchdog" ] || error "$watchdog" rm -f $TMP/lustre-log-${TESTNAME}.log - # write should continue & succeed + # write should continue then fail with EDQUOT local count=0 + local c_size while [ true ]; do if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi - if [ $count -ge 120 ]; then + if [ $count -ge 240 ]; then quota_error u $TSTUSR "dd not finished in $count secs" fi count=$((count + 1)) - [ $((count % 10)) -eq 0 ] && echo "Waiting $count secs" + if [ $((count % 30)) -eq 0 ]; then + c_size=$(stat -c %s $TESTFILE) + echo "Waiting $count secs. $c_size" + $SHOW_QUOTA_USER + fi sleep 1 done @@ -925,10 +985,12 @@ test_7a() { echo "Enable quota & set quota limit for $TSTUSR" set_ost_qtype "ug" || error "enable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || + error "set quota failed" echo "Start ost1..." start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + quota_init wait_ost_reint "ug" || error "reintegration failed" @@ -937,6 +999,27 @@ test_7a() { $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync && quota_error u $TSTUSR "write success, but expect EDQUOT" + rm -f $TESTFILE + wait_delete_completed + sync_all_data || true + sleep 3 + + echo "Stop ost1..." + stop ost1 + + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR || + error "clear quota failed" + + echo "Start ost1..." + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + quota_init + + wait_ost_reint "ug" || error "reintegration failed" + + # hardlimit should be cleared on slave during reintegration + $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync || + quota_error u $TSTUSR "write error, but expect success" + cleanup_quota_test resetquota -u $TSTUSR } @@ -977,7 +1060,8 @@ test_7b() { lustre_fail mds 0xa02 set_ost_qtype "ug" || error "enable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR || + error "set quota failed" # ignore the write error $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc @@ -989,6 +1073,7 @@ test_7b() { echo "Restart ost to trigger reintegration..." stop ost1 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + quota_init wait_ost_reint "ug" || error "reintegration failed" @@ -1016,13 +1101,19 @@ test_7c() { [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0." set_ost_qtype "none" || error "disable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR || + error "set quota failed" # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03 lustre_fail ost 0xa03 - # enable ost quota to trigger reintegration + # enable ost quota set_ost_qtype "ug" || error "enable ost quota failed" + # trigger reintegration + local procf="osd-$(facet_fstype ost1).$FSNAME-OST*." + procf=${procf}quota_slave.force_reint + do_facet ost1 $LCTL set_param $procf=1 || + error "force reintegration failed" echo "Stop mds..." stop mds1 @@ -1031,8 +1122,11 @@ test_7c() { echo "Start mds..." start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS + quota_init - wait_ost_reint "ug" || error "reintegration failed" + # wait longer than usual to make sure the reintegration + # is triggered by quota wb thread. + wait_ost_reint "ug" 200 || error "reintegration failed" # hardlimit should have been fetched by slave during global # reintegration, write will exceed quota @@ -1044,6 +1138,120 @@ test_7c() { } run_test 7c "Quota reintegration (restart mds during reintegration)" +# Quota reintegration (Transfer index in multiple bulks) +test_7d(){ + local TESTFILE=$DIR/$tdir/$tfile + local TESTFILE1="$DIR/$tdir/$tfile"-1 + local limit=20 #20M + + setup_quota_test + trap cleanup_quota_test EXIT + + set_ost_qtype "none" || error "disable ost quota failed" + $LFS setquota -u $TSTUSR -B ${limit}M $DIR || + error "set quota for $TSTUSR failed" + $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR || + error "set quota for $TSTUSR2 failed" + + #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608 + lustre_fail mds 0x608 0 + + # enable quota to tirgger reintegration + set_ost_qtype "u" || error "enable ost quota failed" + wait_ost_reint "u" || error "reintegration failed" + + lustre_fail mds 0 + + # hardlimit should have been fetched by slave during global + # reintegration, write will exceed quota + $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync && + quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT" + + $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync && + quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT" + + cleanup_quota_test + resetquota -u $TSTUSR + resetquota -u $TSTUSR2 +} +run_test 7d "Quota reintegration (Transfer index in multiple bulks)" + +# quota reintegration (inode limits) +test_7e() { + [ "$MDSCOUNT" -lt "2" ] && skip "Required more MDTs" && return + + local ilimit=$((1024 * 2)) # 2k inodes + local TESTFILE=$DIR/${tdir}-1/$tfile + + setup_quota_test + trap cleanup_quota_test EXIT + + # make sure the system is clean + local USED=$(getquota -u $TSTUSR global curinodes) + [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0." + + # make sure no granted quota on mdt1 + set_mdt_qtype "ug" || error "enable mdt quota failed" + resetquota -u $TSTUSR + set_mdt_qtype "none" || error "disable mdt quota failed" + + local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1))) + USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit) + [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \ + "$TSTUSR isn't 0." + + echo "Stop mds${MDSCOUNT}..." + stop mds${MDSCOUNT} + + echo "Enable quota & set quota limit for $TSTUSR" + set_mdt_qtype "ug" || error "enable mdt quota failed" + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR || + error "set quota failed" + + echo "Start mds${MDSCOUNT}..." + start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS + quota_init + + wait_mdt_reint "ug" || error "reintegration failed" + + echo "create remote dir" + $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 || + error "create remote dir failed" + chmod 0777 $DIR/${tdir}-1 + + # hardlimit should have been fetched by slave during global + # reintegration, create will exceed quota + $RUNAS createmany -m $TESTFILE $((ilimit + 1)) && + quota_error u $TSTUSR "create succeeded, expect EDQUOT" + + $RUNAS unlinkmany $TESTFILE $ilimit || "unlink files failed" + wait_delete_completed + sync_all_data || true + + echo "Stop mds${MDSCOUNT}..." + stop mds${MDSCOUNT} + + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR || + error "clear quota failed" + + echo "Start mds${MDSCOUNT}..." + start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS + quota_init + + wait_mdt_reint "ug" || error "reintegration failed" + + # hardlimit should be cleared on slave during reintegration + $RUNAS createmany -m $TESTFILE $((ilimit + 1)) || + quota_error -u $TSTUSR "create failed, expect success" + + $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || "unlink failed" + rmdir $DIR/${tdir}-1 || "unlink remote dir failed" + + cleanup_quota_test + resetquota -u $TSTUSR +} +run_test 7e "Quota reintegration (inode limits)" + # run dbench with quota enabled test_8() { local BLK_LIMIT="100g" #100G @@ -1056,9 +1264,11 @@ test_8() { set_ost_qtype "ug" || error "enable ost quota failed" echo "Set enough high limit for user: $TSTUSR" - $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR || + error "set user quota failed" echo "Set enough high limit for group: $TSTUSR" - $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR + $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR || + error "set group quota failed" local duration="" [ "$SLOW" = "no" ] && duration=" -t 120" @@ -1087,7 +1297,7 @@ check_whether_skip () { # run for fixing bug10707, it needs a big room. test for 64bit test_9() { - local filesize=$((1024 * 1024 * 1024 * 9 / 2)) # 4.5G + local filesize=$((1024 * 9 / 2)) # 4.5G check_whether_skip && return 0 @@ -1104,11 +1314,13 @@ test_9() { 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 + $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR || + error "set user quota failed" 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 + $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR || + error "set group quota failed" quota_show_check a u $TSTUSR quota_show_check a g $TSTUSR @@ -1148,7 +1360,8 @@ test_10() { # root user can overrun quota set_ost_qtype "ug" || "enable ost quota failed" - $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR || + error "set quota failed" quota_show_check b u $TSTUSR $LFS setstripe $TESTFILE -c 1 @@ -1168,7 +1381,8 @@ test_11() { trap cleanup_quota_test EXIT set_mdt_qtype "ug" || "enable mdt quota failed" - $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR || + error "set quota failed" touch "$TESTFILE"-0 touch "$TESTFILE"-1 @@ -1185,7 +1399,7 @@ test_11() { } run_test 11 "Chown/chgrp ignores quota" -test_12() { +test_12a() { [ "$OSTCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return local blimit=22 # 22M @@ -1199,7 +1413,8 @@ test_12() { set_ost_qtype "u" || "enable ost quota failed" quota_show_check b u $TSTUSR - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR || + error "set quota failed" $LFS setstripe $TESTFILE0 -c 1 -i 0 $LFS setstripe $TESTFILE1 -c 1 -i 1 @@ -1226,12 +1441,57 @@ test_12() { cleanup_quota_test resetquota -u $TSTUSR } -run_test 12 "Block quota rebalancing" +run_test 12a "Block quota rebalancing" + +test_12b() { + [ "$MDSCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return + + local ilimit=$((1024 * 2)) # 2k inodes + local TESTFILE0=$DIR/$tdir/$tfile + local TESTFILE1=$DIR/${tdir}-1/$tfile + + setup_quota_test + trap cleanup_quota_test EXIT + + $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed" + chmod 0777 $DIR/${tdir}-1 + + set_mdt_qtype "u" || "enable mdt quota failed" + quota_show_check f u $TSTUSR + + $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR || + error "set quota failed" + + echo "Create $ilimit files on mdt0..." + $RUNAS createmany -m $TESTFILE0 $ilimit || + quota_error u $TSTUSR "create failed, but expect success" + + echo "Create files on mdt1..." + $RUNAS createmany -m $TESTFILE1 1 && + quota_error a $TSTUSR "create succeeded, expect EDQUOT" + + echo "Free space from mdt0..." + $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed" + wait_delete_completed + sync_all_data || true + + echo "Create files on mdt1 after space freed from mdt0..." + $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) || + quota_error a $TSTUSR "rebalancing failed" + + $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) || + error "unlink mdt1 files failed" + rmdir $DIR/${tdir}-1 || error "unlink remote dir failed" + + cleanup_quota_test + resetquota -u $TSTUSR +} +run_test 12b "Inode quota rebalancing" test_13(){ local TESTFILE=$DIR/$tdir/$tfile - # the name of osp on ost1 name is MDT0000-osp-OST0000 - local procf="ldlm.namespaces.*MDT0000-osp-OST0000.lru_size" + # the name of lwp on ost1 name is MDT0000-lwp-OST0000 + local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size" setup_quota_test trap cleanup_quota_test EXIT @@ -1239,7 +1499,8 @@ test_13(){ set_ost_qtype "u" || "enable ost quota failed" quota_show_check b u $TSTUSR - $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR || + error "set quota failed" $LFS setstripe $TESTFILE -c 1 -i 0 chown $TSTUSR.$TSTUSR $TESTFILE @@ -1283,14 +1544,16 @@ test_15(){ sync_all_data || true # test for user - $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR || + error "set user quota failed" local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit) [ $TOTAL_LIMIT -eq $LIMIT ] || error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!" resetquota -u $TSTUSR # test for group - $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR + $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR || + error "set group quota failed" TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit) [ $TOTAL_LIMIT -eq $LIMIT ] || error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!" @@ -1313,7 +1576,8 @@ test_17sub() { set_ost_qtype "ug" || error "enable ost quota failed" # make sure no granted quota on ost resetquota -u $TSTUSR - $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR || + error "set quota failed" quota_show_check b u $TSTUSR @@ -1385,7 +1649,8 @@ test_18_sub () { set_ost_qtype "u" || error "enable ost quota failed" log "User quota (limit: $blimit)" - $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT + $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT || + error "set quota failed" quota_show_check b u $TSTUSR $LFS setstripe $TESTFILE -i 0 -c 1 @@ -1429,7 +1694,7 @@ test_18_sub () { local testfile_size=$(stat -c %s $TESTFILE) if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then - quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," + quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \ "got ${testfile_size}. Verifying file failed!" fi cleanup_quota_test @@ -1439,17 +1704,17 @@ test_18_sub () { # test when mds does failover, the ost still could work well # this test shouldn't trigger watchdog b=14840 test_18() { + # Clear dmesg so watchdog is not triggered by previous + # test output + do_facet ost1 dmesg -c > /dev/null + test_18_sub normal test_18_sub directio # check if watchdog is triggered do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log - local watchdog=$(awk '/test 18b/ {start = 1;} - /Service thread pid/ && /was inactive/ { - if (start) { - print; - } - }' $TMP/lustre-log-${TESTNAME}.log) + local watchdog=$(awk '/Service thread pid/ && /was inactive/ \ + { print; }' $TMP/lustre-log-${TESTNAME}.log) [ -z "$watchdog" ] || error "$watchdog" rm -f $TMP/lustre-log-${TESTNAME}.log } @@ -1469,10 +1734,12 @@ test_19() { chown $TSTUSR.$TSTUSR $TESTFILE echo "Set user quota (limit: "$blimit"M)" - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT + $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || + error "set user quota failed" quota_show_check b u $TSTUSR echo "Update quota limits" - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT + $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || + error "set group quota failed" quota_show_check b u $TSTUSR # first wirte might be cached @@ -1539,9 +1806,11 @@ test_21() { set_ost_qtype "ug" || error "Enable ost quota failed" log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR" - $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT + $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT || + error "set user quota failed" log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR" - $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT + $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT || + error "set group quota failed" # repeat writing on a 1M file test_21_sub ${TESTFILE}_1 1 30 & @@ -1617,6 +1886,7 @@ test_22() { stopall mount setupall + quota_init echo "Verify if quota is disabled" qtype=$(mdt_quota_type) @@ -1624,7 +1894,7 @@ test_22() { qtype=$(ost_quota_type) [ $qtype != "none" ] && error "ost quota setting is lost" - quota_init + return 0 } run_test 22 "enable/disable quota by 'lctl conf_param'" @@ -1639,7 +1909,8 @@ test_23_sub() { # test for user log "User quota (limit: $LIMIT MB)" - $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR + $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR || + error "set quota failed" quota_show_check b u $TSTUSR $LFS setstripe $TESTFILE -c 1 -i 0 @@ -1701,7 +1972,8 @@ test_24() { chown $TSTUSR.$TSTUSR $TESTFILE echo "Set user quota (limit: "$blimit"M)" - $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT + $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT || + error "set quota failed" # overrun quota by root user runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) || @@ -1738,6 +2010,32 @@ test_27b() { # b20200 } run_test 27b "lfs quota/setquota should handle user/group ID (b20200)" +test_27c() { + local limit + + $LFS setquota -u $TSTID -b 30M -B 3T $DIR || + error "lfs setquota failed" + + limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}') + [ $limit != "30M" ] && error "softlimit $limit isn't human-readable" + limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}') + [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable" + + $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR || + error "lfs setquota for $TSTID failed" + + limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}') + [ $limit != "1.465G" ] && error "wrong softlimit $limit" + limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}') + [ $limit != "18.07T" ] && error "wrong hardlimit $limit" + + $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" || + error "total allocated inode/block limit not printed" + + resetquota -u $TSTUSR +} +run_test 27c "lfs quota should support human-readable output" + test_30() { local output local LIMIT=4 # 4MB @@ -1752,26 +2050,28 @@ test_30() { $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}M -B 0 -i 0 -I 0 $DIR + $LFS setquota -t -u --block-grace $GRACE --inode-grace \ + $MAX_IQ_TIME $DIR || error "set grace time failed" + $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR || + error "set quota failed" $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true cancel_lru_locks osc sleep $GRACE - $LFS setquota -u $TSTUSR -B 0 $DIR + $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed" # 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 of=$TESTFILE conv=notrunc oflag=append count=1 || true + $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true cancel_lru_locks osc # now over-quota flag should be settled and further writes should fail $SHOW_QUOTA_USER - $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 && + $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 && error "grace times were reset" # cleanup cleanup_quota_test resetquota -u $TSTUSR $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \ - $MAX_IQ_TIME $DIR + $MAX_IQ_TIME $DIR || error "restore grace time failed" } run_test 30 "Hard limit updates should not reset grace times" @@ -1984,7 +2284,7 @@ test_36() { do_node $mdt0_node mkdir $mntpt/OBJECTS do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.usr $mntpt/OBJECTS do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.grp $mntpt/OBJECTS - do_node $mdt0_node umount -f $mntpt + do_node $mdt0_node umount -d -f $mntpt echo "Setup all..." setupall @@ -1995,7 +2295,7 @@ test_36() { local proc="qmt.*.md-0x0.glb-usr" id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l) - [ $id_cnt -eq 401 ] || error "Migrate inode user limit failed: $id_cnt" + [ $id_cnt -eq 403 ] || error "Migrate inode user limit failed: $id_cnt" limit=$(getquota -u 1 global isoftlimit) [ $limit -eq 1024 ] || error "User inode softlimit: $limit" limit=$(getquota -u 1 global ihardlimit) @@ -2003,7 +2303,7 @@ test_36() { proc="qmt.*.md-0x0.glb-grp" id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l) - [ $id_cnt -eq 401 ] || error "Migrate inode group limit failed: $id_cnt" + [ $id_cnt -eq 403 ] || error "Migrate inode group limit failed: $id_cnt" limit=$(getquota -g 1 global isoftlimit) [ $limit -eq 1024 ] || error "Group inode softlimit: $limit" limit=$(getquota -g 1 global ihardlimit) @@ -2011,7 +2311,7 @@ test_36() { proc=" qmt.*.dt-0x0.glb-usr" id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l) - [ $id_cnt -eq 401 ] || error "Migrate block user limit failed: $id_cnt" + [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt" limit=$(getquota -u 60001 global bsoftlimit) [ $limit -eq 10485760 ] || error "User block softlimit: $limit" limit=$(getquota -u 60001 global bhardlimit) @@ -2019,7 +2319,7 @@ test_36() { proc="qmt.*.dt-0x0.glb-grp" id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l) - [ $id_cnt -eq 401 ] || error "Migrate block user limit failed: $id_cnt" + [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt" limit=$(getquota -g 60001 global bsoftlimit) [ $limit -eq 10485760 ] || error "Group block softlimit: $limit" limit=$(getquota -g 60001 global bhardlimit)