3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
10 LUSTRE=${LUSTRE:-$(dirname $0)/..}
11 . $LUSTRE/tests/test-framework.sh
15 ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT "
16 # Bug number for skipped test:
18 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 # Test duration: 30 min
21 [ "$SLOW" = "no" ] && EXCEPT_SLOW="61"
23 if [ "$mds1_FSTYPE" = zfs ]; then
25 # Test duration: 21 9 min"
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW+=" 12a 9"
31 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
34 TSTID2=${TSTID2:-60001}
35 TSTUSR=${TSTUSR:-"quota_usr"}
36 TSTUSR2=${TSTUSR2:-"quota_2usr"}
37 TSTPRJID=${TSTPRJID:-1000}
42 # QP exists since this version. Should be finally set before landing.
43 VERSION_WITH_QP="2.13.53"
45 [ $MDS1_VERSION -lt $(version_code $VERSION_WITH_QP) ] &&
46 skip "Needs MDS version $VERSION_WITH_QP or later."
49 require_dsh_mds || exit 0
50 require_dsh_ost || exit 0
52 # Does e2fsprogs support quota feature?
53 if [ "$mds1_FSTYPE" == ldiskfs ] &&
54 do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features |
55 grep -q 'quota'"; then
56 skip_env "e2fsprogs doesn't support quota"
59 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
61 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
66 QUOTA_AUTO_OLD=$QUOTA_AUTO
69 check_and_setup_lustre
71 ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
73 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
74 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
75 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
76 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
77 SHOW_QUOTA_PROJID="eval is_project_quota_supported && $LFS quota -v -p $TSTPRJID $DIR"
78 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
79 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
80 SHOW_QUOTA_INFO_PROJID="eval is_project_quota_supported && $LFS quota -t -p $DIR"
85 local fail_val=${3:-0}
89 mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
90 mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
91 ost) NODES="$(comma_list $(osts_nodes))";;
94 do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
100 lfs project $* || error "lfs project $* failed"
103 RUNAS="runas -u $TSTID -g $TSTID"
104 RUNAS2="runas -u $TSTID2 -g $TSTID2"
105 DD="dd if=/dev/zero bs=1M"
109 # clear quota limits for a user or a group
110 # usage: resetquota -u username
111 # resetquota -g groupname
112 # resetquota -p projid
115 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
116 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
117 error "resetquota: wrong specifier $1 passed"
119 if [ $1 == "-p" ]; then
120 is_project_quota_supported || return 0
123 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
124 error "clear quota for [type:$1 name:$2] failed"
125 # give a chance to slave to release space
133 if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
134 $LFS quota -v -u $local_id $DIR
135 log "Files for user ($local_id):"
136 ($LFS find --user $local_id $DIR | head -n 4 |
137 xargs stat 2>/dev/null)
140 if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
141 $LFS quota -v -g $local_id $DIR
142 log "Files for group ($local_id):"
143 ($LFS find --group $local_id $DIR | head -n 4 |
144 xargs stat 2>/dev/null)
147 is_project_quota_supported || return 0
148 if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
149 $LFS quota -v -p $TSTPRJID $DIR
150 log "Files for project ($TSTPRJID):"
151 ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
152 xargs stat 2>/dev/null)
168 # get quota for a user or a group
169 # usage: getquota -u|-g|-p <username>|<groupname>|<projid> global|<obd_uuid> \
170 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace \
177 sync_all_data > /dev/null 2>&1 || true
179 [ "$#" != 4 -a "$#" != 5 ] &&
180 error "getquota: wrong number of arguments: $#"
181 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
182 error "getquota: wrong u/g/p specifier $1 passed"
195 *) error "unknown quota parameter $4";;
198 [ ! -z "$5" ] && pool_arg="--pool $5 "
199 [ "$uuid" = "global" ] && uuid=$DIR
201 $LFS quota -v "$1" "$2" $pool_arg $DIR |
202 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
203 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
208 # usage: set_mdt_qtype ugp|u|g|p|none
212 local mdts=$(get_facets MDS)
214 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
215 qtype=$(tr -d 'p' <<<$qtype)
217 if [[ $PERM_CMD == *"set_param -P"* ]]; then
218 do_facet mgs $PERM_CMD \
219 osd-*.$FSNAME-MDT*.quota_slave.enable=$qtype
221 do_facet mgs $PERM_CMD $FSNAME.quota.mdt=$qtype
223 # we have to make sure each MDT received config changes
224 for mdt in ${mdts//,/ }; do
226 cmd="$LCTL get_param -n "
227 cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc}
228 cmd=${cmd}.quota_slave.enabled
230 if $(facet_up $mdt); then
231 wait_update_facet $mdt "$cmd" "$qtype" || return 1
238 # usage: set_ost_qtype ugp|u|g|p|none
242 local osts=$(get_facets OST)
244 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
245 qtype=$(tr -d 'p' <<<$qtype)
247 if [[ $PERM_CMD == *"set_param -P"* ]]; then
248 do_facet mgs $PERM_CMD \
249 osd-*.$FSNAME-OST*.quota_slave.enable=$qtype
251 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$qtype
253 # we have to make sure each OST received config changes
254 for ost in ${osts//,/ }; do
256 cmd="$LCTL get_param -n "
257 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
258 cmd=${cmd}.quota_slave.enabled
260 if $(facet_up $ost); then
261 wait_update_facet $ost "$cmd" "$qtype" || return 1
267 wait_reintegration() {
271 local result="glb[1],slv[1],reint[0]"
276 if [ $ntype == "mdt" ]; then
277 tgts=$(get_facets MDS)
279 tgts=$(get_facets OST)
282 for tgt in ${tgts//,/ }; do
284 cmd="$LCTL get_param -n "
285 cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc}
286 cmd=${cmd}.quota_slave.info
288 if $(facet_up $tgt); then
289 wait_update_facet $tgt "$cmd |
290 grep "$qtype" | awk '{ print \\\$3 }'" \
291 "$result" $max || return 1
301 if [[ "$qtype" =~ "u" ]]; then
302 wait_reintegration "mdt" "user" $max || return 1
305 if [[ "$qtype" =~ "g" ]]; then
306 wait_reintegration "mdt" "group" $max || return 1
309 if [[ "$qtype" =~ "p" ]]; then
310 ! is_project_quota_supported && return 0
311 wait_reintegration "mdt" "project" $max || return 1
320 if [[ "$qtype" =~ "u" ]]; then
321 wait_reintegration "ost" "user" $max || return 1
324 if [[ "$qtype" =~ "g" ]]; then
325 wait_reintegration "ost" "group" $max || return 1
328 if [[ "$qtype" =~ "p" ]]; then
329 ! is_project_quota_supported && return 0
330 wait_reintegration "ost" "project" $max || return 1
339 local extrasleep=${4:-5}
346 *) error "get_grace_time: Invalid quota type: $qtype"
351 echo "Quota info for $pool:"
352 $LFS quota -$qtype $qarg $parg $DIR
357 time=$(lfs quota -$qtype $qarg $parg $DIR|
358 awk 'NR == 3{ print $5 }')
361 time=$(lfs quota -$qtype $qarg $DIR|
362 awk 'NR == 3{ print $9 }')
365 error "Unknown quota type: $flavour"
369 local sleep_seconds=0
370 local orig_time=$time
372 echo "Grace time is $time"
373 # from lfs.c:__sec2str()
374 # const char spec[] = "smhdw";
375 # {1, 60, 60*60, 24*60*60, 7*24*60*60};
376 [[ $time == *w* ]] && w_time=${time%w*} &&
377 let sleep_seconds+=$((w_time*7*24*60*60));
379 [[ $time == *d* ]] && d_time=${time%d*} &&
380 let sleep_seconds+=$((d_time*24*60*60));
382 [[ $time == *h* ]] && h_time=${time%h*} &&
383 let sleep_seconds+=$((h_time*60*60));
385 [[ $time == *m* ]] && m_time=${time%m*} &&
386 let sleep_seconds+=$((m_time*60));
388 [[ $time == *s* ]] && s_time=${time%s*} &&
389 let sleep_seconds+=$s_time
391 echo "Sleep through grace ..."
392 [ "$orig_time" == "-" ] &&
393 error "Grace timeout was not set or quota not exceeded"
394 if [ "$orig_time" == "none" ]; then
395 echo "...Grace timeout already expired"
397 let sleep_seconds+=$extrasleep
398 echo "...sleep $sleep_seconds seconds"
404 wait_delete_completed
405 echo "Creating test directory"
406 mkdir_on_mdt0 $DIR/$tdir || return 1
407 chmod 0777 $DIR/$tdir || return 2
408 # always clear fail_loc in case of fail_loc isn't cleared
409 # properly when previous test failed
410 lustre_fail mds_ost 0
413 cleanup_quota_test() {
414 echo "Delete files..."
416 echo "Wait for unlink objects finished..."
417 wait_delete_completed
418 sync_all_data || true
428 $LFS quota -v -$ugp $qid $DIR
430 if [ "$bf" == "a" -o "$bf" == "b" ]; then
431 usage=$(getquota -$ugp $qid global curspace)
432 if [ -z $usage ]; then
433 quota_error $ugp $qid \
434 "Query block quota failed ($ugp:$qid)."
436 [ $usage -ne 0 ] && quota_log $ugp $qid \
437 "Block quota isn't 0 ($ugp:$qid:$usage)."
441 if [ "$bf" == "a" -o "$bf" == "f" ]; then
442 usage=$(getquota -$ugp $qid global curinodes)
443 if [ -z $usage ]; then
444 quota_error $ugp $qid \
445 "Query file quota failed ($ugp:$qid)."
447 [ $usage -ne 0 ] && quota_log $ugp $qid \
448 "File quota isn't 0 ($ugp:$qid:$usage)."
453 project_quota_enabled () {
455 local zfeat="feature@project_quota"
457 for facet in $(seq -f mds%g $MDSCOUNT) $(seq -f ost%g $OSTCOUNT); do
458 local facet_fstype=${facet:0:3}1_FSTYPE
461 if [ "${!facet_fstype}" = "zfs" ]; then
462 devname=$(zpool_name ${facet})
463 do_facet ${facet} $ZPOOL get -H "$zfeat" $devname |
464 grep -wq active || rc=1
466 [ ${facet:0:3} == "mds" ] &&
467 devname=$(mdsdevname ${facet:3}) ||
468 devname=$(ostdevname ${facet:3})
469 do_facet ${facet} $DEBUGFS -R features $devname |
470 grep -q project || rc=1
473 [ $rc -eq 0 ] && PQ_CLEANUP=false || PQ_CLEANUP=true
477 project_quota_enabled || enable_project_quota
479 reset_quota_settings() {
480 resetquota -u $TSTUSR
482 resetquota -g $TSTUSR
484 resetquota -u $TSTUSR2
485 resetquota -u $TSTID2
486 resetquota -g $TSTUSR2
487 resetquota -g $TSTID2
488 resetquota -p $TSTPRJID
493 do_nodes $(comma_list $(nodes_list)) \
494 "$LCTL set_param -n debug=+quota,trace"
499 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
500 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
501 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
502 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
504 test_quota_performance() {
505 local TESTFILE="$DIR/$tdir/$tfile-0"
506 local size=$1 # in MB
507 local stime=$(date +%s)
508 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
509 quota_error u $TSTUSR "write failure"
510 local etime=$(date +%s)
511 delta=$((etime - stime))
512 if [ $delta -gt 0 ]; then
513 rate=$((size * 1024 / delta))
514 if [ "$mds1_FSTYPE" = zfs ]; then
515 # LU-2872 - see LU-2887 for fix
517 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
519 [ $rate -gt 1024 ] ||
520 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
526 # test basic quota performance b=21696
529 [ "$SLOW" = "no" ] && MB=10
531 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
532 [ $free_space -le $((MB * 1024)) ] &&
533 skip "not enough space ${free_space} KB, " \
534 "required $((MB * 1024)) KB"
535 setup_quota_test || error "setup quota failed with $?"
536 trap cleanup_quota_test EXIT
538 set_ost_qtype "none" || error "disable ost quota failed"
539 test_quota_performance $MB
541 set_ost_qtype $QTYPE || error "enable ost quota failed"
542 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
543 error "set quota failed"
544 test_quota_performance $MB
548 run_test 0 "Test basic quota performance"
550 # usage: test_1_check_write tfile user|group|project
551 test_1_check_write() {
555 local short_qtype=${qtype:0:1}
558 $RUNAS $DD of=$testfile count=$((limit/2)) ||
559 quota_error $short_qtype $TSTUSR \
560 "$qtype write failure, but expect success"
561 log "Write out of block quota ..."
562 # this time maybe cache write, ignore it's failure
563 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
564 # flush cache, ensure noquota flag is set on client
566 sync; sync_all_data || true
567 # sync means client wrote all it's cache, but id doesn't
568 # garantee that slave got new edquot trough glimpse.
569 # so wait a little to be sure slave got it.
571 $RUNAS $DD of=$testfile count=1 seek=$limit &&
572 quota_error $short_qtype $TSTUSR \
573 "user write success, but expect EDQUOT"
576 check_write_fallocate() {
580 local short_qtype=${qtype:0:1}
583 log "Write ${count}MiB Using Fallocate"
584 $RUNAS fallocate -l${count}MiB $testfile ||
585 quota_error $short_qtype $TSTUSR "Write ${count}MiB fail"
588 sync; sync_all_data || true
592 log "Write ${count}MiB Using Fallocate"
593 $RUNAS fallocate -l${count}MiB $testfile &&
594 quota_error $short_qtype $TSTUSR \
595 "Write success, expect EDQUOT" || true
598 # test block hardlimit
601 local testfile="$DIR/$tdir/$tfile-0"
603 setup_quota_test || error "setup quota failed with $?"
604 trap cleanup_quota_test EXIT
607 set_ost_qtype $QTYPE || error "enable ost quota failed"
610 log "User quota (block hardlimit:$limit MB)"
611 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
612 error "set user quota failed"
614 # make sure the system is clean
615 local used=$(getquota -u $TSTUSR global curspace)
616 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
618 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
619 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
621 test_1_check_write $testfile "user" $limit
624 wait_delete_completed || error "wait_delete_completed failed"
625 sync_all_data || true
626 used=$(getquota -u $TSTUSR global curspace)
627 [ $used -ne 0 ] && quota_error u $TSTUSR \
628 "user quota isn't released after deletion"
629 resetquota -u $TSTUSR
632 log "--------------------------------------"
633 log "Group quota (block hardlimit:$limit MB)"
634 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
635 error "set group quota failed"
637 testfile="$DIR/$tdir/$tfile-1"
638 # make sure the system is clean
639 used=$(getquota -g $TSTUSR global curspace)
640 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
642 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
643 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
645 test_1_check_write $testfile "group" $limit
647 wait_delete_completed || error "wait_delete_completed failed"
648 sync_all_data || true
649 used=$(getquota -g $TSTUSR global curspace)
650 [ $used -ne 0 ] && quota_error g $TSTUSR \
651 "Group quota isn't released after deletion"
652 resetquota -g $TSTUSR
654 if ! is_project_quota_supported; then
655 echo "Project quota is not supported"
660 testfile="$DIR/$tdir/$tfile-2"
661 # make sure the system is clean
662 used=$(getquota -p $TSTPRJID global curspace)
664 error "used space($used) for project $TSTPRJID isn't 0"
667 log "--------------------------------------"
668 log "Project quota (block hardlimit:$limit mb)"
669 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
670 error "set project quota failed"
672 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
673 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
674 change_project -p $TSTPRJID $testfile
676 test_1_check_write $testfile "project" $limit
681 used=$(getquota -p $TSTPRJID global curspace)
682 [ $used -ne 0 ] && quota_error p $TSTPRJID \
683 "project quota isn't released after deletion"
685 resetquota -p $TSTPRJID
687 run_test 1a "Block hard limit (normal use and out of quota)"
691 local global_limit=20 # MB
692 local testfile="$DIR/$tdir/$tfile-0"
696 setup_quota_test || error "setup quota failed with $?"
697 stack_trap cleanup_quota_test EXIT
700 set_ost_qtype $QTYPE || error "enable ost quota failed"
703 log "User quota (block hardlimit:$global_limit MB)"
704 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
705 error "set user quota failed"
707 pool_add $qpool || error "pool_add failed"
708 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
709 error "pool_add_targets failed"
711 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
712 error "set user quota failed"
714 # make sure the system is clean
715 local used=$(getquota -u $TSTUSR global curspace)
717 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
719 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
721 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
722 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
724 test_1_check_write $testfile "user" $limit
727 wait_delete_completed || error "wait_delete_completed failed"
728 sync_all_data || true
729 used=$(getquota -u $TSTUSR global curspace $qpool)
730 [ $used -ne 0 ] && quota_error u $TSTUSR \
731 "user quota isn't released after deletion"
732 resetquota -u $TSTUSR
735 log "--------------------------------------"
736 log "Group quota (block hardlimit:$global_limit MB)"
737 $LFS setquota -g $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
738 error "set group quota failed"
740 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M --pool $qpool $DIR ||
741 error "set group quota failed"
743 testfile="$DIR/$tdir/$tfile-1"
744 # make sure the system is clean
745 used=$(getquota -g $TSTUSR global curspace $qpool)
746 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
748 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
749 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
751 test_1_check_write $testfile "group" $limit
754 wait_delete_completed || error "wait_delete_completed failed"
755 sync_all_data || true
756 used=$(getquota -g $TSTUSR global curspace $qpool)
757 [ $used -ne 0 ] && quota_error g $TSTUSR \
758 "Group quota isn't released after deletion"
759 resetquota -g $TSTUSR
761 if ! is_project_quota_supported; then
762 echo "Project quota is not supported"
767 testfile="$DIR/$tdir/$tfile-2"
768 # make sure the system is clean
769 used=$(getquota -p $TSTPRJID global curspace $qpool)
771 error "used space($used) for project $TSTPRJID isn't 0"
774 log "--------------------------------------"
775 log "Project quota (block hardlimit:$global_limit mb)"
776 $LFS setquota -p $TSTPRJID -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
777 error "set project quota failed"
779 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M --pool $qpool $DIR ||
780 error "set project quota failed"
783 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
784 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
785 change_project -p $TSTPRJID $testfile
787 test_1_check_write $testfile "project" $limit
792 used=$(getquota -p $TSTPRJID global curspace)
793 [ $used -eq 0 ] || quota_error p $TSTPRJID \
794 "project quota isn't released after deletion"
796 run_test 1b "Quota pools: Block hard limit (normal use and out of quota)"
799 local global_limit=20 # MB
800 local testfile="$DIR/$tdir/$tfile-0"
801 local qpool1="qpool1"
802 local qpool2="qpool2"
805 setup_quota_test || error "setup quota failed with $?"
806 stack_trap cleanup_quota_test EXIT
809 set_ost_qtype $QTYPE || error "enable ost quota failed"
812 log "User quota (block hardlimit:$global_limit MB)"
813 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
814 error "set user quota failed"
816 pool_add $qpool1 || error "pool_add failed"
817 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
818 error "pool_add_targets failed"
820 pool_add $qpool2 || error "pool_add failed"
821 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
822 error "pool_add_targets failed"
824 # create pools without hard limit
825 # initially such case raised several bugs
826 $LFS setquota -u $TSTUSR -B 0M --pool $qpool1 $DIR ||
827 error "set user quota failed"
829 $LFS setquota -u $TSTUSR -B 0M --pool $qpool2 $DIR ||
830 error "set user quota failed"
832 # make sure the system is clean
833 local used=$(getquota -u $TSTUSR global curspace)
835 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
837 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
839 test_1_check_write $testfile "user" $global_limit
841 used=$(getquota -u $TSTUSR global curspace $qpool1)
842 echo "qpool1 used $used"
843 used=$(getquota -u $TSTUSR global curspace $qpool2)
844 echo "qpool2 used $used"
847 wait_delete_completed || error "wait_delete_completed failed"
848 sync_all_data || true
850 used=$(getquota -u $TSTUSR global curspace $qpool1)
851 [ $used -ne 0 ] && quota_error u $TSTUSR \
852 "user quota isn't released after deletion"
853 resetquota -u $TSTUSR
858 run_test 1c "Quota pools: check 3 pools with hardlimit only for global"
863 local global_limit=20 # MB
864 local testfile="$DIR/$tdir/$tfile-0"
865 local qpool1="qpool1"
866 local qpool2="qpool2"
869 setup_quota_test || error "setup quota failed with $?"
870 stack_trap cleanup_quota_test EXIT
873 set_ost_qtype $QTYPE || error "enable ost quota failed"
876 log "User quota (block hardlimit:$global_limit MB)"
877 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
878 error "set user quota failed"
880 pool_add $qpool1 || error "pool_add failed"
881 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
882 error "pool_add_targets failed"
884 pool_add $qpool2 || error "pool_add failed"
885 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
886 error "pool_add_targets failed"
888 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
889 error "set user quota failed"
891 $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
892 error "set user quota failed"
894 # make sure the system is clean
895 local used=$(getquota -u $TSTUSR global curspace)
897 [ $used -ne 0 ] && error "used space($used) for user $TSTUSR isn't 0."
899 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
901 test_1_check_write $testfile "user" $limit1
903 used=$(getquota -u $TSTUSR global curspace $qpool1)
904 echo "qpool1 used $used"
905 used=$(getquota -u $TSTUSR global curspace $qpool2)
906 echo "qpool2 used $used"
909 wait_delete_completed || error "wait_delete_completed failed"
910 sync_all_data || true
912 used=$(getquota -u $TSTUSR global curspace $qpool1)
913 [ $used -ne 0 ] && quota_error u $TSTUSR \
914 "user quota isn't released after deletion"
915 resetquota -u $TSTUSR
920 run_test 1d "Quota pools: check block hardlimit on different pools"
924 local global_limit=53000000 # MB
925 local testfile="$DIR/$tdir/$tfile-0"
926 local testfile2="$DIR/$tdir/$tfile-1"
927 local qpool1="qpool1"
930 setup_quota_test || error "setup quota failed with $?"
931 stack_trap cleanup_quota_test EXIT
934 set_ost_qtype $QTYPE || error "enable ost quota failed"
936 # global_limit is much greater than limit1 to get
937 # different qunit's on osts. Since 1st qunit shrinking
938 # on OST1(that belongs to qpool1), this qunit should
940 log "User quota (block hardlimit:$global_limit MB)"
941 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
942 error "set user quota failed"
944 pool_add $qpool1 || error "pool_add failed"
945 pool_add_targets $qpool1 1 1 ||
946 error "pool_add_targets failed"
948 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
949 error "set user quota failed"
951 # make sure the system is clean
952 local used=$(getquota -u $TSTUSR global curspace)
953 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
955 $LFS setstripe $testfile -c 1 -i 1 || error "setstripe $testfile failed"
956 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
958 test_1_check_write $testfile "user" $limit1
960 $LFS setstripe $testfile2 -c 1 -i 0 ||
961 error "setstripe $testfile2 failed"
962 chown $TSTUSR.$TSTUSR $testfile2 || error "chown $testfile2 failed"
963 # Now write to file with a stripe on OST0, that doesn't belong to qpool1
965 $RUNAS $DD of=$testfile2 count=20 ||
966 quota_error u $TSTUSR \
967 "$qtype write failure, but expect success"
971 wait_delete_completed || error "wait_delete_completed failed"
972 sync_all_data || true
974 used=$(getquota -u $TSTUSR global curspace $qpool1)
975 [ $used -ne 0 ] && quota_error u $TSTUSR \
976 "user quota isn't released after deletion"
977 resetquota -u $TSTUSR
982 run_test 1e "Quota pools: global pool high block limit vs quota pool with small"
985 local global_limit=200 # MB
987 local TESTDIR="$DIR/$tdir/"
988 local testfile="$TESTDIR/$tfile-0"
989 local qpool1="qpool1"
992 setup_quota_test || error "setup quota failed with $?"
993 stack_trap cleanup_quota_test EXIT
996 set_ost_qtype $QTYPE || error "enable ost quota failed"
998 log "User quota (block hardlimit:$global_limit MB)"
999 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
1000 error "set user quota failed"
1002 pool_add $qpool1 || error "pool_add failed"
1003 pool_add_targets $qpool1 0 0 ||
1004 error "pool_add_targets failed"
1006 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
1007 error "set user quota failed"
1009 # make sure the system is clean
1010 local used=$(getquota -u $TSTUSR global curspace)
1011 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1013 $LFS setstripe $TESTDIR -c 1 -i 0 || error "setstripe $TESTDIR failed"
1015 test_1_check_write $testfile "user" $limit1
1017 pool_remove_target $qpool1 0
1019 wait_delete_completed || error "wait_delete_completed failed"
1020 sync_all_data || true
1022 pool_add_targets $qpool1 0 0 || error "pool_add_targets failed"
1023 # qunit for appropriate element in lgd array should be set
1024 # correctly(4096). Earlier it was not changed continuing to be 1024.
1025 # This caused write to hung when it hit limit1 - qunit shrinking to 1024
1026 # for qpool1 lqe didn't cause changing qunit for OST0 in gld array
1027 # as it already was 1024. As flag "need_update" for this qunit was
1028 # not set, new qunit wasn't sent to OST0. Thus revoke was not set
1029 # for "qpool1" lqe and it couldn't set EDQUOT despite granted
1030 # became > 10M. QMT returned EINPROGRESS in a loop.
1031 # Check that it doesn't hung anymore.
1032 test_1_check_write $testfile "user" $limit1
1037 run_test 1f "Quota pools: correct qunit after removing/adding OST"
1041 local global_limit=40 # MB
1042 local testfile="$DIR/$tdir/$tfile-0"
1043 local qpool="qpool1"
1044 local mdmb_param="osc.*.max_dirty_mb"
1045 local max_dirty_mb=$($LCTL get_param -n $mdmb_param | head -1)
1048 setup_quota_test || error "setup quota failed with $?"
1049 stack_trap cleanup_quota_test EXIT
1050 $LCTL set_param $mdmb_param=1
1051 stack_trap "$LCTL set_param $mdmb_param=$max_dirty_mb" EXIT
1054 set_ost_qtype $QTYPE || error "enable ost quota failed"
1057 log "User quota (block hardlimit:$global_limit MB)"
1058 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
1059 error "set user quota failed"
1061 pool_add $qpool || error "pool_add failed"
1062 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
1063 error "pool_add_targets failed"
1065 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
1066 error "set user quota failed"
1068 # make sure the system is clean
1069 local used=$(getquota -u $TSTUSR global curspace)
1071 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1073 $LFS setstripe $testfile -C 200 || error "setstripe $testfile failed"
1074 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1077 $RUNAS $DD of=$testfile count=$((limit/2)) ||
1078 quota_error u $TSTUSR \
1079 "$qtype write failure, but expect success"
1080 log "Write out of block quota ..."
1081 # this time maybe cache write, ignore it's failure
1082 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
1083 # flush cache, ensure noquota flag is set on client
1084 cancel_lru_locks osc
1085 sync; sync_all_data || true
1087 $RUNAS $DD of=$testfile count=$OSTCOUNT seek=$limit &&
1088 quota_error u $TSTUSR \
1089 "user write success, but expect EDQUOT"
1092 wait_delete_completed || error "wait_delete_completed failed"
1093 sync_all_data || true
1095 used=$(getquota -u $TSTUSR global curspace $qpool)
1096 [ $used -ne 0 ] && quota_error u $TSTUSR \
1097 "user quota isn't released after deletion"
1100 run_test 1g "Quota pools: Block hard limit with wide striping"
1104 local testfile="$DIR/$tdir/$tfile-0"
1106 check_set_fallocate_or_skip
1108 setup_quota_test || error "setup quota failed with $?"
1109 trap cleanup_quota_test EXIT
1112 set_ost_qtype $QTYPE || error "enable ost quota failed"
1115 log "User quota (block hardlimit:$limit MB)"
1116 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
1117 error "set user quota failed"
1119 # make sure the system is clean
1120 local used=$(getquota -u $TSTUSR global curspace)
1121 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1123 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
1124 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1126 check_write_fallocate $testfile "user" $limit
1129 wait_delete_completed || error "wait_delete_completed failed"
1130 sync_all_data || true
1131 used=$(getquota -u $TSTUSR global curspace)
1132 [ $used -ne 0 ] && quota_error u $TSTUSR \
1133 "user quota isn't released after deletion"
1134 resetquota -u $TSTUSR
1136 run_test 1h "Block hard limit test using fallocate"
1138 # test inode hardlimit
1140 local TESTFILE="$DIR/$tdir/$tfile-0"
1141 local LIMIT=$(do_facet mds1 $LCTL get_param -n \
1142 qmt.$FSNAME-QMT0000.md-0x0.info |
1143 awk '/least qunit/{ print $3 }')
1144 local L2=$(do_facet mds1 $LCTL get_param -n \
1145 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1147 [ $L2 -le $LIMIT ] || LIMIT=$L2
1149 [ "$SLOW" = "no" ] || LIMIT=$((LIMIT * 1024))
1151 local FREE_INODES=$(mdt_free_inodes 0)
1152 echo "$FREE_INODES free inodes on master MDT"
1153 [ $FREE_INODES -lt $LIMIT ] &&
1154 skip "not enough free inodes $FREE_INODES required $LIMIT"
1156 setup_quota_test || error "setup quota failed with $?"
1157 trap cleanup_quota_test EXIT
1160 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1163 log "User quota (inode hardlimit:$LIMIT files)"
1164 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1165 error "set user quota failed"
1167 # make sure the system is clean
1168 local USED=$(getquota -u $TSTUSR global curinodes)
1169 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
1171 log "Create $LIMIT files ..."
1172 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1173 quota_error u $TSTUSR "user create failure, but expect success"
1174 log "Create out of file quota ..."
1175 $RUNAS touch ${TESTFILE}_xxx &&
1176 quota_error u $TSTUSR "user create success, but expect EDQUOT"
1179 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1180 rm -f ${TESTFILE}_xxx
1181 wait_delete_completed
1183 USED=$(getquota -u $TSTUSR global curinodes)
1184 [ $USED -ne 0 ] && quota_error u $TSTUSR \
1185 "user quota isn't released after deletion"
1186 resetquota -u $TSTUSR
1189 log "--------------------------------------"
1190 log "Group quota (inode hardlimit:$LIMIT files)"
1191 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1192 error "set group quota failed"
1194 TESTFILE=$DIR/$tdir/$tfile-1
1195 # make sure the system is clean
1196 USED=$(getquota -g $TSTUSR global curinodes)
1197 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
1199 log "Create $LIMIT files ..."
1200 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1201 quota_error g $TSTUSR "group create failure, but expect success"
1202 log "Create out of file quota ..."
1203 $RUNAS touch ${TESTFILE}_xxx &&
1204 quota_error g $TSTUSR "group create success, but expect EDQUOT"
1207 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1208 rm -f ${TESTFILE}_xxx
1209 wait_delete_completed
1211 USED=$(getquota -g $TSTUSR global curinodes)
1212 [ $USED -ne 0 ] && quota_error g $TSTUSR \
1213 "user quota isn't released after deletion"
1215 resetquota -g $TSTUSR
1216 ! is_project_quota_supported && cleanup_quota_test &&
1217 echo "Skip project quota is not supported" && return 0
1220 log "--------------------------------------"
1221 log "Project quota (inode hardlimit:$LIMIT files)"
1222 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1223 error "set project quota failed"
1225 TESTFILE=$DIR/$tdir/$tfile-1
1226 # make sure the system is clean
1227 USED=$(getquota -p $TSTPRJID global curinodes)
1229 error "Used inodes($USED) for project $TSTPRJID isn't 0"
1231 change_project -sp $TSTPRJID $DIR/$tdir
1232 log "Create $LIMIT files ..."
1233 $RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
1234 $TSTPRJID "project create fail, but expect success"
1235 log "Create out of file quota ..."
1236 $RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
1237 "project create success, but expect EDQUOT"
1238 change_project -C $DIR/$tdir
1241 USED=$(getquota -p $TSTPRJID global curinodes)
1242 [ $USED -eq 0 ] || quota_error p $TSTPRJID \
1243 "project quota isn't released after deletion"
1246 run_test 2 "File hard limit (normal use and out of quota)"
1255 local soft_limit=$(do_facet $SINGLEMDS $LCTL get_param -n \
1256 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit)
1259 stack_trap cleanup_quota_test EXIT
1261 $LFS setstripe $testfile -c 1 -i 0
1262 chown $TSTUSR.$TSTUSR $testfile
1263 [ "$qtype" == "p" ] && is_project_quota_supported &&
1264 change_project -p $TSTPRJID $testfile
1266 echo "Write up to soft limit"
1267 $RUNAS $DD of=$testfile count=$limit ||
1268 quota_error a $TSTUSR "write failure, but expect success"
1269 OFFSET=$((limit * 1024))
1270 cancel_lru_locks osc
1272 echo "Write to exceed soft limit"
1273 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1274 quota_error a $TSTUSR "write failure, but expect success"
1275 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
1276 cancel_lru_locks osc
1278 echo "mmap write when over soft limit"
1279 $RUNAS $MULTIOP $testfile.mmap OT40960SMW ||
1280 quota_error a $TSTUSR "mmap write failure, but expect success"
1281 cancel_lru_locks osc
1286 $SHOW_QUOTA_INFO_USER
1287 $SHOW_QUOTA_INFO_GROUP
1288 $SHOW_QUOTA_INFO_PROJID
1290 echo "Write before timer goes off"
1291 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1292 quota_error a $TSTUSR "write failure, but expect success"
1293 OFFSET=$((OFFSET + 1024))
1294 cancel_lru_locks osc
1296 wait_grace_time $qtype "block" $pool
1301 $SHOW_QUOTA_INFO_USER
1302 $SHOW_QUOTA_INFO_GROUP
1303 $SHOW_QUOTA_INFO_PROJID
1305 log "Write after timer goes off"
1306 # maybe cache write, ignore.
1307 # write up to soft least quint to consume all
1308 # possible slave granted space.
1309 $RUNAS dd if=/dev/zero of=$testfile bs=1K \
1310 count=$soft_limit seek=$OFFSET || true
1311 OFFSET=$((OFFSET + soft_limit))
1312 cancel_lru_locks osc
1313 log "Write after cancel lru locks"
1314 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET &&
1315 quota_error a $TSTUSR "write success, but expect EDQUOT"
1320 $SHOW_QUOTA_INFO_USER
1321 $SHOW_QUOTA_INFO_GROUP
1322 $SHOW_QUOTA_INFO_PROJID
1324 echo "Unlink file to stop timer"
1326 wait_delete_completed
1327 sync_all_data || true
1332 $SHOW_QUOTA_INFO_USER
1333 $SHOW_QUOTA_INFO_GROUP
1334 $SHOW_QUOTA_INFO_PROJID
1336 $LFS setstripe $testfile -c 1 -i 0
1337 chown $TSTUSR.$TSTUSR $testfile
1338 [ "$qtype" == "p" ] && change_project -p $TSTPRJID $testfile
1341 $RUNAS $DD of=$testfile count=$limit ||
1342 quota_error a $TSTUSR "write failure, but expect success"
1349 local grace=20 # seconds
1350 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1353 local testfile=$DIR/$tdir/$tfile-0
1355 # get minimum soft qunit size
1356 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1357 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1359 set_ost_qtype $QTYPE || error "enable ost quota failed"
1361 echo "User quota (soft limit:$limit MB grace:$grace seconds)"
1362 # make sure the system is clean
1363 local used=$(getquota -u $TSTUSR global curspace)
1364 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1366 $LFS setquota -t -u --block-grace $grace --inode-grace \
1367 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1368 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1369 error "set user quota failed"
1371 test_block_soft $testfile $grace $limit "u"
1373 echo "Group quota (soft limit:$limit MB grace:$grace seconds)"
1374 testfile=$DIR/$tdir/$tfile-1
1375 # make sure the system is clean
1376 used=$(getquota -g $TSTUSR global curspace)
1377 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1379 $LFS setquota -t -g --block-grace $grace --inode-grace \
1380 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1381 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1382 error "set group quota failed"
1384 test_block_soft $testfile $grace $limit "g"
1386 if is_project_quota_supported; then
1387 echo "Project quota (soft limit:$limit MB grace:$grace sec)"
1388 testfile=$DIR/$tdir/$tfile-2
1389 # make sure the system is clean
1390 used=$(getquota -p $TSTPRJID global curspace)
1391 [ $used -ne 0 ] && error \
1392 "Used space($used) for project $TSTPRJID isn't 0."
1394 $LFS setquota -t -p --block-grace $grace --inode-grace \
1395 $MAX_IQ_TIME $DIR ||
1396 error "set project grace time failed"
1397 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 -i 0 -I 0 \
1398 $DIR || error "set project quota failed"
1400 test_block_soft $testfile $grace $limit "p"
1401 resetquota -p $TSTPRJID
1402 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1403 $MAX_IQ_TIME $DIR ||
1404 error "restore project grace time failed"
1408 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1409 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1410 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1411 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1413 run_test 3a "Block soft limit (start timer, timer goes off, stop timer)"
1416 local grace=20 # seconds
1417 local qpool="qpool1"
1418 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1421 local testfile=$DIR/$tdir/$tfile-0
1424 # get minimum soft qunit size
1425 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1426 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1427 local glbl_limit=$((2*limit))
1428 local glbl_grace=$((2*grace))
1429 echo "limit $limit glbl_limit $glbl_limit"
1430 echo "grace $grace glbl_grace $glbl_grace"
1432 set_ost_qtype $QTYPE || error "enable ost quota failed"
1434 echo "User quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1435 # make sure the system is clean
1436 local used=$(getquota -u $TSTUSR global curspace)
1437 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1439 pool_add $qpool || error "pool_add failed"
1440 pool_add_targets $qpool 0 1 ||
1441 error "pool_add_targets failed"
1443 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1444 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1445 $LFS setquota -t -u --block-grace $grace \
1446 --pool $qpool $DIR || error "set user grace time failed"
1448 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1449 error "set user quota failed"
1450 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1451 error "set user quota failed"
1453 test_block_soft $testfile $grace $limit "u" $qpool
1455 echo "Group quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1456 testfile=$DIR/$tdir/$tfile-1
1457 # make sure the system is clean
1458 used=$(getquota -g $TSTUSR global curspace)
1459 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1461 $LFS setquota -t -g --block-grace $glbl_grace --inode-grace \
1462 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1463 $LFS setquota -t -g --block-grace $grace \
1464 --pool $qpool $DIR || error "set group grace time failed"
1466 $LFS setquota -g $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1467 error "set group quota failed"
1468 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1469 error "set group quota failed"
1471 test_block_soft $testfile $grace $limit "g" $qpool
1473 if is_project_quota_supported; then
1474 echo "Project quota in $qpool(soft:$limit MB grace:$grace sec)"
1475 testfile=$DIR/$tdir/$tfile-2
1476 # make sure the system is clean
1477 used=$(getquota -p $TSTPRJID global curspace)
1478 [ $used -ne 0 ] && error \
1479 "Used space($used) for project $TSTPRJID isn't 0."
1481 $LFS setquota -t -p --block-grace $glbl_grace --inode-grace \
1482 $MAX_IQ_TIME $DIR ||
1483 error "set project grace time failed"
1484 $LFS setquota -t -p --block-grace $grace \
1485 --pool $qpool $DIR ||
1486 error "set project grace time failed"
1488 $LFS setquota -p $TSTPRJID -b ${glbl_limit}M -B 0 -i 0 -I 0 \
1489 $DIR || error "set project quota failed"
1490 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 \
1491 --pool $qpool $DIR || error "set project quota failed"
1493 test_block_soft $testfile $grace $limit "p" $qpool
1494 resetquota -p $TSTPRJID
1495 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1496 $MAX_IQ_TIME $DIR ||
1497 error "restore project grace time failed"
1498 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --pool $qpool \
1499 $DIR || error "set project grace time failed"
1503 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1504 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1505 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1506 --pool $qpool $DIR || error "restore user grace time failed"
1507 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1508 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1509 $LFS setquota -t -g --block-grace $MAX_DQ_TIME \
1510 --pool $qpool $DIR || error "restore group grace time failed"
1512 run_test 3b "Quota pools: Block soft limit (start timer, expires, stop timer)"
1515 local grace=20 # seconds
1516 local qpool="qpool1"
1517 local qpool2="qpool2"
1518 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1521 local testfile=$DIR/$tdir/$tfile-0
1524 # get minimum soft qunit size
1525 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1526 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1527 local limit2=$((limit+4))
1528 local glbl_limit=$((limit+8))
1529 local grace1=$((grace+10))
1531 local glbl_grace=$((grace+20))
1532 echo "limit $limit limit2 $limit2 glbl_limit $glbl_limit"
1533 echo "grace1 $grace1 grace2 $grace2 glbl_grace $glbl_grace"
1535 set_ost_qtype $QTYPE || error "enable ost quota failed"
1537 echo "User quota in qpool2(soft:$limit2 MB grace:$grace2 seconds)"
1538 # make sure the system is clean
1539 local used=$(getquota -u $TSTUSR global curspace)
1540 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1542 pool_add $qpool || error "pool_add failed"
1543 pool_add_targets $qpool 0 1 ||
1544 error "pool_add_targets failed"
1546 pool_add $qpool2 || error "pool_add failed"
1547 pool_add_targets $qpool2 0 1 ||
1548 error "pool_add_targets failed"
1551 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1552 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1553 $LFS setquota -t -u --block-grace $grace1 \
1554 --pool $qpool $DIR || error "set user grace time failed"
1555 $LFS setquota -t -u --block-grace $grace2 \
1556 --pool $qpool2 $DIR || error "set user grace time failed"
1558 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1559 error "set user quota failed"
1560 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1561 error "set user quota failed"
1562 # qpool has minimum soft limit, but it's grace is grater than
1563 # grace period of qpool2. Thus write shouldn't fail when
1564 # hit qpool soft limit - only when reaches up qpool2 limit
1565 # after grace2 seconds.
1566 $LFS setquota -u $TSTUSR -b ${limit2}M -B 0 --pool $qpool2 $DIR ||
1567 error "set user quota failed"
1569 test_block_soft $testfile $grace2 $limit2 "u" $qpool2
1572 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1573 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1574 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1575 --pool $qpool $DIR || error "restore user grace time failed"
1576 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1577 --pool $qpool2 $DIR || error "restore user grace time failed"
1579 run_test 3c "Quota pools: check block soft limit on different pools"
1586 local SOFT_LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1587 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1590 trap cleanup_quota_test EXIT
1591 is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
1593 echo "Create files to exceed soft limit"
1594 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
1595 quota_error a $TSTUSR "create failure, but expect success"
1596 local trigger_time=$(date +%s)
1598 sync_all_data || true
1600 local cur_time=$(date +%s)
1601 [ $(($cur_time - $trigger_time)) -ge $grace ] &&
1602 error "Passed grace time $grace, $trigger_time, $cur_time"
1604 echo "Create file before timer goes off"
1605 $RUNAS touch ${TESTFILE}_before ||
1606 quota_error a $TSTUSR "failed create before timer expired," \
1607 "but expect success. $trigger_time, $cur_time"
1608 sync_all_data || true
1610 wait_grace_time $qtype "file"
1615 $SHOW_QUOTA_INFO_USER
1616 $SHOW_QUOTA_INFO_GROUP
1617 $SHOW_QUOTA_INFO_PROJID
1619 echo "Create file after timer goes off"
1620 # exceed least soft limit is possible
1621 $RUNAS createmany -m ${TESTFILE}_after_3 $((SOFT_LIMIT + 1)) &&
1622 quota_error a $TSTUSR "create after timer expired," \
1624 sync_all_data || true
1629 $SHOW_QUOTA_INFO_USER
1630 $SHOW_QUOTA_INFO_GROUP
1631 $SHOW_QUOTA_INFO_PROJID
1633 echo "Unlink files to stop timer"
1634 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
1635 wait_delete_completed
1638 $RUNAS touch ${TESTFILE}_xxx ||
1639 quota_error a $TSTUSR "touch after timer stop failure," \
1640 "but expect success"
1641 sync_all_data || true
1649 local LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1650 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1651 local TESTFILE=$DIR/$tdir/$tfile-0
1654 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1656 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1657 # make sure the system is clean
1658 local USED=$(getquota -u $TSTUSR global curinodes)
1659 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1661 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1662 $GRACE $DIR || error "set user grace time failed"
1663 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1664 error "set user quota failed"
1666 [ "$mds1_FSTYPE" = zfs ] && GRACE=20
1668 test_file_soft $TESTFILE $LIMIT $GRACE "u"
1670 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1671 # make sure the system is clean
1672 USED=$(getquota -g $TSTUSR global curinodes)
1673 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
1675 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1676 $GRACE $DIR || error "set group grace time failed"
1677 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1678 error "set group quota failed"
1679 TESTFILE=$DIR/$tdir/$tfile-1
1681 test_file_soft $TESTFILE $LIMIT $GRACE "g"
1683 if is_project_quota_supported; then
1684 echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)"
1685 # make sure the system is clean
1686 USED=$(getquota -p $TSTPRJID global curinodes)
1687 [ $USED -ne 0 ] && error \
1688 "Used space($USED) for project $TSTPRJID isn't 0."
1690 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1691 $GRACE $DIR || error "set project grace time failed"
1692 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1693 error "set project quota failed"
1695 TESTFILE=$DIR/$tdir/$tfile-1
1696 # one less than limit, because of parent directory included.
1697 test_file_soft $TESTFILE $((LIMIT-1)) $GRACE "p"
1698 resetquota -p $TSTPRJID
1699 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1700 $MAX_IQ_TIME $DIR ||
1701 error "restore project grace time failed"
1705 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1706 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1707 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1708 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1710 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
1713 local GR_STR1="1w3d"
1714 local GR_STR2="1000s"
1716 local GR_STR4="1w2d3h4m5s"
1718 local GR_STR6="18446744073709551615"
1721 wait_delete_completed
1723 # test of valid grace strings handling
1724 echo "Valid grace strings test"
1725 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
1726 $GR_STR2 $DIR || error "set user grace time failed"
1727 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
1728 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
1729 $GR_STR4 $DIR || error "set group grace time quota failed"
1730 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
1732 # test of invalid grace strings handling
1733 echo " Invalid grace strings test"
1734 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
1735 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
1736 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \
1740 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1741 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1742 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1743 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1745 run_test 4b "Grace time strings handling"
1747 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
1749 local BLIMIT=10 # MB
1750 local ILIMIT=10 # inodes
1752 setup_quota_test || error "setup quota failed with $?"
1753 trap cleanup_quota_test EXIT
1755 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1756 set_ost_qtype $QTYPE || error "enable ost quota failed"
1758 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
1759 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1760 error "set user quota failed"
1761 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1762 if is_project_quota_supported; then
1763 error "set group quota failed"
1764 $LFS setquota -p $TSTPRJID -b 0 -B ${BLIMIT}M -i 0 \
1765 -I $ILIMIT $DIR || error "set project quota failed"
1768 # make sure the system is clean
1769 local USED=$(getquota -u $TSTUSR global curinodes)
1770 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1771 USED=$(getquota -g $TSTUSR global curinodes)
1772 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
1773 USED=$(getquota -u $TSTUSR global curspace)
1774 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
1775 USED=$(getquota -g $TSTUSR global curspace)
1776 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
1777 if is_project_quota_supported; then
1778 USED=$(getquota -p $TSTPRJID global curinodes)
1780 error "Used inode($USED) for project $TSTPRJID isn't 0."
1781 USED=$(getquota -p $TSTPRJID global curspace)
1783 error "Used block($USED) for project $TSTPRJID isn't 0."
1786 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
1787 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1788 error "create failure, expect success"
1789 if is_project_quota_supported; then
1790 touch $DIR/$tdir/$tfile-0_1
1791 change_project -p $TSTPRJID $DIR/$tdir/$tfile-0_1
1793 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
1794 error "write failure, expect success"
1796 echo "Chown files to $TSTUSR.$TSTUSR ..."
1797 for i in $(seq 0 $ILIMIT); do
1798 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
1799 quota_error a $TSTUSR "chown failure, expect success"
1803 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1804 error "unlinkmany $DIR/$tdir/$tfile-0_ failed"
1807 run_test 5 "Chown & chgrp successfully even out of block/file quota"
1809 # test dropping acquire request on master
1813 # Clear dmesg so watchdog is not triggered by previous
1815 do_facet ost1 dmesg -c > /dev/null
1817 setup_quota_test || error "setup quota failed with $?"
1818 trap cleanup_quota_test EXIT
1820 # make sure the system is clean
1821 local USED=$(getquota -u $TSTUSR global curspace)
1822 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1824 # make sure no granted quota on ost
1825 set_ost_qtype $QTYPE || error "enable ost quota failed"
1826 resetquota -u $TSTUSR
1828 # create file for $TSTUSR
1829 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
1830 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1831 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1833 # create file for $TSTUSR2
1834 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
1835 $LFS setstripe $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed"
1836 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed"
1838 # cache per-ID lock for $TSTUSR on slave
1839 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1840 error "set quota failed"
1841 $RUNAS $DD of=$TESTFILE count=1 ||
1842 error "write $TESTFILE failure, expect success"
1843 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
1844 error "write $TESTFILE2 failure, expect success"
1846 if at_is_enabled; then
1847 at_max_saved=$(at_max_get ost1)
1848 at_max_set $TIMEOUT ost1
1850 # write to enforced ID ($TSTUSR) to exceed limit to make sure
1851 # DQACQ is sent, which makes at_max to take effect
1852 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync \
1855 wait_delete_completed
1859 sync_all_data || true
1861 #define QUOTA_DQACQ 601
1862 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
1863 lustre_fail mds 0x513 601
1865 do_facet ost1 $LCTL set_param \
1866 osd-*.$FSNAME-OST*.quota_slave.timeout=$((TIMEOUT / 2))
1868 # write to un-enforced ID ($TSTUSR2) should succeed
1869 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
1870 error "write failure, expect success"
1872 # write to enforced ID ($TSTUSR) in background, exceeding limit
1873 # to make sure DQACQ is sent
1874 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
1877 # watchdog timer uses a factor of 2
1878 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
1879 sleep $((TIMEOUT * 2 + 1))
1881 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
1883 # write should be blocked and never finished
1884 if ! ps -p $DDPID > /dev/null 2>&1; then
1886 error "write finished incorrectly!"
1891 # no watchdog is triggered
1892 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1893 watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
1894 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1895 [ -z "$watchdog" ] || error "$watchdog"
1897 rm -f $TMP/lustre-log-${TESTNAME}.log
1899 # write should continue then fail with EDQUOT
1903 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1904 if [ $count -ge 240 ]; then
1905 quota_error u $TSTUSR "dd not finished in $count secs"
1907 count=$((count + 1))
1908 if [ $((count % 30)) -eq 0 ]; then
1909 c_size=$(stat -c %s $TESTFILE)
1910 echo "Waiting $count secs. $c_size"
1918 run_test 6 "Test dropping acquire request on master"
1920 # quota reintegration (global index)
1922 local TESTFILE=$DIR/$tdir/$tfile
1925 [ "$SLOW" = "no" ] && LIMIT=5
1927 setup_quota_test || error "setup quota failed with $?"
1928 trap cleanup_quota_test EXIT
1930 # make sure the system is clean
1931 local USED=$(getquota -u $TSTUSR global curspace)
1932 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1934 # make sure no granted quota on ost1
1935 set_ost_qtype $QTYPE || error "enable ost quota failed"
1936 resetquota -u $TSTUSR
1937 set_ost_qtype "none" || error "disable ost quota failed"
1939 local OSTUUID=$(ostuuid_from_index 0)
1940 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1942 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1945 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1946 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1951 echo "Enable quota & set quota limit for $TSTUSR"
1952 set_ost_qtype $QTYPE || error "enable ost quota failed"
1953 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1954 error "set quota failed"
1956 echo "Start ost1..."
1957 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1960 wait_ost_reint $QTYPE || error "reintegration failed"
1962 # hardlimit should have been fetched by slave during global
1963 # reintegration, write will exceed quota
1964 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1965 quota_error u $TSTUSR "write success, but expect EDQUOT"
1968 wait_delete_completed
1969 sync_all_data || true
1975 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1976 error "clear quota failed"
1978 echo "Start ost1..."
1979 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1982 wait_ost_reint $QTYPE || error "reintegration failed"
1984 # hardlimit should be cleared on slave during reintegration
1985 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
1986 quota_error u $TSTUSR "write error, but expect success"
1990 run_test 7a "Quota reintegration (global index)"
1992 # quota reintegration (slave index)
1994 local limit=100000 # MB
1995 local TESTFILE=$DIR/$tdir/$tfile
1997 setup_quota_test || error "setup quota failed with $?"
1998 trap cleanup_quota_test EXIT
2000 # make sure the system is clean
2001 local USED=$(getquota -u $TSTUSR global curspace)
2002 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2004 # make sure no granted quota on ost1
2005 set_ost_qtype $QTYPE || error "enable ost quota failed"
2006 resetquota -u $TSTUSR
2007 set_ost_qtype "none" || error "disable ost quota failed"
2009 local OSTUUID=$(ostuuid_from_index 0)
2010 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2012 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
2015 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2016 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2018 # consume some space to make sure the granted space will not
2019 # be released during reconciliation
2020 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2021 error "consume space failure, expect success"
2023 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
2024 lustre_fail mds 0xa02
2026 set_ost_qtype $QTYPE || error "enable ost quota failed"
2027 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
2028 error "set quota failed"
2030 # ignore the write error
2031 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
2033 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2037 echo "Restart ost to trigger reintegration..."
2039 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
2042 wait_ost_reint $QTYPE || error "reintegration failed"
2044 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2045 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
2050 run_test 7b "Quota reintegration (slave index)"
2052 # quota reintegration (restart mds during reintegration)
2055 local TESTFILE=$DIR/$tdir/$tfile
2057 [ "$SLOW" = "no" ] && LIMIT=5
2059 setup_quota_test || error "setup quota failed with $?"
2060 trap cleanup_quota_test EXIT
2062 # make sure the system is clean
2063 local USED=$(getquota -u $TSTUSR global curspace)
2064 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2066 set_ost_qtype "none" || error "disable ost quota failed"
2067 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
2068 error "set quota failed"
2070 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
2071 lustre_fail ost 0xa03
2074 set_ost_qtype $QTYPE || error "enable ost quota failed"
2075 # trigger reintegration
2076 local procf="osd-$ost1_FSTYPE.$FSNAME-OST*."
2077 procf=${procf}quota_slave.force_reint
2078 do_facet ost1 $LCTL set_param $procf=1 ||
2079 error "force reintegration failed"
2087 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
2090 # wait longer than usual to make sure the reintegration
2091 # is triggered by quota wb thread.
2092 wait_ost_reint $QTYPE 200 || error "reintegration failed"
2094 # hardlimit should have been fetched by slave during global
2095 # reintegration, write will exceed quota
2096 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
2097 quota_error u $TSTUSR "write success, but expect EDQUOT"
2101 run_test 7c "Quota reintegration (restart mds during reintegration)"
2103 # Quota reintegration (Transfer index in multiple bulks)
2105 local TESTFILE=$DIR/$tdir/$tfile
2106 local TESTFILE1="$DIR/$tdir/$tfile"-1
2109 setup_quota_test || error "setup quota failed with $?"
2110 trap cleanup_quota_test EXIT
2112 set_ost_qtype "none" || error "disable ost quota failed"
2113 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
2114 error "set quota for $TSTUSR failed"
2115 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
2116 error "set quota for $TSTUSR2 failed"
2118 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
2119 lustre_fail mds 0x608 0
2121 # enable quota to tirgger reintegration
2122 set_ost_qtype "u" || error "enable ost quota failed"
2123 wait_ost_reint "u" || error "reintegration failed"
2127 # hardlimit should have been fetched by slave during global
2128 # reintegration, write will exceed quota
2129 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
2130 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
2132 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
2133 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
2137 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
2139 # quota reintegration (inode limits)
2141 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2143 # LU-2435: skip this quota test if underlying zfs version has not
2144 # supported native dnode accounting
2145 [ "$mds1_FSTYPE" == zfs ] && {
2146 local F="feature@userobj_accounting"
2147 local pool=$(zpool_name mds1)
2148 local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
2150 [[ "$feature" != *" active "* ]] &&
2151 skip "requires zpool with active userobj_accounting"
2154 local ilimit=$((1024 * 2)) # inodes
2155 local TESTFILE=$DIR/${tdir}-1/$tfile
2157 setup_quota_test || error "setup quota failed with $?"
2158 trap cleanup_quota_test EXIT
2160 # make sure the system is clean
2161 local USED=$(getquota -u $TSTUSR global curinodes)
2162 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
2164 # make sure no granted quota on mdt1
2165 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2166 resetquota -u $TSTUSR
2167 set_mdt_qtype "none" || error "disable mdt quota failed"
2169 local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
2170 USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
2171 [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
2174 echo "Stop mds${MDSCOUNT}..."
2177 echo "Enable quota & set quota limit for $TSTUSR"
2178 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2179 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2180 error "set quota failed"
2182 echo "Start mds${MDSCOUNT}..."
2183 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
2186 wait_mdt_reint $QTYPE || error "reintegration failed"
2188 echo "create remote dir"
2189 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
2190 error "create remote dir failed"
2191 chmod 0777 $DIR/${tdir}-1
2193 # hardlimit should have been fetched by slave during global
2194 # reintegration, create will exceed quota
2195 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
2196 quota_error u $TSTUSR "create succeeded, expect EDQUOT"
2198 $RUNAS unlinkmany $TESTFILE $ilimit || error "unlink files failed"
2199 wait_delete_completed
2200 sync_all_data || true
2202 echo "Stop mds${MDSCOUNT}..."
2205 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
2206 error "clear quota failed"
2208 echo "Start mds${MDSCOUNT}..."
2209 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
2212 wait_mdt_reint $QTYPE || error "reintegration failed"
2214 # hardlimit should be cleared on slave during reintegration
2215 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
2216 quota_error u $TSTUSR "create failed, expect success"
2218 $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
2219 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2223 run_test 7e "Quota reintegration (inode limits)"
2225 # run dbench with quota enabled
2227 local BLK_LIMIT="100g" #100G
2228 local FILE_LIMIT=1000000
2230 setup_quota_test || error "setup quota failed with $?"
2231 trap cleanup_quota_test EXIT
2233 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2234 set_ost_qtype $QTYPE || error "enable ost quota failed"
2236 echo "Set enough high limit for user: $TSTUSR"
2237 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2238 error "set user quota failed"
2239 echo "Set enough high limit for group: $TSTUSR"
2240 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2241 error "set group quota failed"
2242 if is_project_quota_supported; then
2243 change_project -sp $TSTPRJID $DIR/$tdir
2244 echo "Set enough high limit for project: $TSTPRJID"
2245 $LFS setquota -p $TSTPRJID -b 0 \
2246 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2247 error "set project quota failed"
2251 [ "$SLOW" = "no" ] && duration=" -t 120"
2252 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
2253 quota_error a $TSTUSR "dbench failed!"
2255 is_project_quota_supported && change_project -C $DIR/$tdir
2258 run_test 8 "Run dbench with quota enabled"
2260 # this check is just for test_9
2261 OST0_MIN=4900000 #4.67G
2263 check_whether_skip () {
2264 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
2265 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
2266 if [ $OST0_SIZE -lt $OST0_MIN ]; then
2267 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
2274 # run for fixing bug10707, it needs a big room. test for 64bit
2276 local filesize=$((1024 * 9 / 2)) # 4.5G
2278 check_whether_skip && return 0
2280 setup_quota_test || error "setup quota failed with $?"
2281 trap cleanup_quota_test EXIT
2283 set_ost_qtype "ug" || error "enable ost quota failed"
2285 local TESTFILE="$DIR/$tdir/$tfile-0"
2286 local BLK_LIMIT=100G #100G
2287 local FILE_LIMIT=1000000
2289 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
2291 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2293 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2294 error "set user quota failed"
2296 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2297 "for group: $TSTUSR"
2298 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2299 error "set group quota failed"
2301 quota_show_check a u $TSTUSR
2302 quota_show_check a g $TSTUSR
2304 echo "Create test file"
2305 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2306 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2308 log "Write the big file of 4.5G ..."
2309 $RUNAS $DD of=$TESTFILE count=$filesize ||
2310 quota_error a $TSTUSR "write 4.5G file failure, expect success"
2320 run_test 9 "Block limit larger than 4GB (b10707)"
2323 local TESTFILE=$DIR/$tdir/$tfile
2325 setup_quota_test || error "setup quota failed with $?"
2326 trap cleanup_quota_test EXIT
2328 # set limit to root user should fail
2329 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
2330 error "set limit for root user successfully, expect failure"
2331 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
2332 error "set limit for root group successfully, expect failure"
2333 $LFS setquota -p 0 -b 1T -B 10T -i 5K -I 100M $DIR &&
2334 error "set limit for project 0 successfully, expect failure"
2336 # root user can overrun quota
2337 set_ost_qtype "ug" || error "enable ost quota failed"
2339 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
2340 error "set quota failed"
2341 quota_show_check b u $TSTUSR
2343 $LFS setstripe $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
2344 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2346 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
2347 error "write failure, expect success"
2351 run_test 10 "Test quota for root user"
2354 local TESTFILE=$DIR/$tdir/$tfile
2355 setup_quota_test || error "setup quota failed with $?"
2356 trap cleanup_quota_test EXIT
2358 set_mdt_qtype "ug" || error "enable mdt quota failed"
2359 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
2360 error "set quota failed"
2362 touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed"
2363 touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed"
2365 chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed"
2366 chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed"
2369 local USED=$(getquota -u $TSTUSR global curinodes)
2370 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
2374 run_test 11 "Chown/chgrp ignores quota"
2377 [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs"
2379 local blimit=22 # MB
2380 local blk_cnt=$((blimit - 5))
2381 local TESTFILE0="$DIR/$tdir/$tfile"-0
2382 local TESTFILE1="$DIR/$tdir/$tfile"-1
2384 setup_quota_test || error "setup quota failed with $?"
2385 trap cleanup_quota_test EXIT
2387 set_ost_qtype "u" || error "enable ost quota failed"
2388 quota_show_check b u $TSTUSR
2390 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $DIR ||
2391 error "set quota failed"
2393 $LFS setstripe $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed"
2394 $LFS setstripe $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed"
2395 chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed"
2396 chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed"
2398 echo "Write to ost0..."
2399 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
2400 quota_error a $TSTUSR "dd failed"
2402 echo "Write to ost1..."
2403 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
2404 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
2406 echo "Free space from ost0..."
2408 wait_delete_completed
2409 sync_all_data || true
2411 echo "Write to ost1 after space freed from ost0..."
2412 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
2413 quota_error a $TSTUSR "rebalancing failed"
2417 run_test 12a "Block quota rebalancing"
2420 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2422 local ilimit=$((1024 * 2)) # inodes
2423 local TESTFILE0=$DIR/$tdir/$tfile
2424 local TESTFILE1=$DIR/${tdir}-1/$tfile
2426 setup_quota_test || error "setup quota failed with $?"
2427 trap cleanup_quota_test EXIT
2429 $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed"
2430 chmod 0777 $DIR/${tdir}-1
2432 set_mdt_qtype "u" || error "enable mdt quota failed"
2433 quota_show_check f u $TSTUSR
2435 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2436 error "set quota failed"
2438 echo "Create $ilimit files on mdt0..."
2439 $RUNAS createmany -m $TESTFILE0 $ilimit ||
2440 quota_error u $TSTUSR "create failed, but expect success"
2442 echo "Create files on mdt1..."
2443 $RUNAS createmany -m $TESTFILE1 1 &&
2444 quota_error a $TSTUSR "create succeeded, expect EDQUOT"
2446 echo "Free space from mdt0..."
2447 $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed"
2448 wait_delete_completed
2449 sync_all_data || true
2451 echo "Create files on mdt1 after space freed from mdt0..."
2452 $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) ||
2453 quota_error a $TSTUSR "rebalancing failed"
2455 $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) ||
2456 error "unlink mdt1 files failed"
2457 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2461 run_test 12b "Inode quota rebalancing"
2464 local TESTFILE=$DIR/$tdir/$tfile
2465 # the name of lwp on ost1 name is MDT0000-lwp-OST0000
2466 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size"
2468 setup_quota_test || error "setup quota failed with $?"
2469 trap cleanup_quota_test EXIT
2471 set_ost_qtype "u" || error "enable ost quota failed"
2472 quota_show_check b u $TSTUSR
2474 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2475 error "set quota failed"
2476 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2477 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2479 # clear the locks in cache first
2480 do_facet ost1 $LCTL set_param -n $procf=clear
2481 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2482 [ $nlock -eq 0 ] || error "$nlock cached locks"
2484 # write to acquire the per-ID lock
2485 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2486 quota_error a $TSTUSR "dd failed"
2488 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2489 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
2491 # clear quota doesn't trigger per-ID lock cancellation
2492 resetquota -u $TSTUSR
2493 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2494 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
2496 # clear the per-ID lock
2497 do_facet ost1 $LCTL set_param -n $procf=clear
2498 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2499 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
2501 # spare quota should be released
2502 local OSTUUID=$(ostuuid_from_index 0)
2503 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2504 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
2505 [ $limit -le $space ] ||
2506 error "spare quota isn't released, limit:$limit, space:$space"
2510 run_test 13 "Cancel per-ID lock in the LRU list"
2513 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
2515 wait_delete_completed
2516 sync_all_data || true
2519 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2520 error "set user quota failed"
2521 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
2522 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2523 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2524 resetquota -u $TSTUSR
2527 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2528 error "set group quota failed"
2529 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
2530 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2531 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2532 resetquota -g $TSTUSR
2534 run_test 15 "Set over 4T block quota"
2538 local BLKS=1 # 1M less than limit
2539 local TESTFILE=$DIR/$tdir/$tfile
2541 setup_quota_test || error "setup quota failed with $?"
2542 trap cleanup_quota_test EXIT
2544 # make sure the system is clean
2545 local USED=$(getquota -u $TSTUSR global curspace)
2546 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2548 set_ost_qtype "ug" || error "enable ost quota failed"
2549 # make sure no granted quota on ost
2550 resetquota -u $TSTUSR
2551 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2552 error "set quota failed"
2554 quota_show_check b u $TSTUSR
2556 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
2557 lustre_fail mds 0xa04 $err_code
2559 # write in background
2560 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
2564 # write should be blocked and never finished
2565 if ! ps -p $DDPID > /dev/null 2>&1; then
2567 quota_error u $TSTUSR "write finished incorrectly!"
2575 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2577 if [ $count -gt $timeout ]; then
2578 quota_error u $TSTUSR "dd is not finished!"
2583 sync; sync_all_data || true
2585 USED=$(getquota -u $TSTUSR global curspace)
2586 [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \
2587 "Used space(${USED}K) is less than ${BLKS}M"
2592 # DQACQ return recoverable error
2594 echo "DQACQ return -ENOLCK"
2596 test_17sub 37 || error "Handle -ENOLCK failed"
2598 echo "DQACQ return -EAGAIN"
2600 test_17sub 11 || error "Handle -EAGAIN failed"
2602 echo "DQACQ return -ETIMEDOUT"
2603 #define ETIMEDOUT 110
2604 test_17sub 110 || error "Handle -ETIMEDOUT failed"
2606 echo "DQACQ return -ENOTCONN"
2607 #define ENOTCONN 107
2608 test_17sub 107 || error "Handle -ENOTCONN failed"
2611 run_test 17 "DQACQ return recoverable error"
2615 local blimit=200 # MB
2616 local TESTFILE="$DIR/$tdir/$tfile"
2618 setup_quota_test || error "setup quota failed with $?"
2619 trap cleanup_quota_test EXIT
2621 set_ost_qtype "u" || error "enable ost quota failed"
2622 log "User quota (limit: $blimit)"
2623 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2624 error "set quota failed"
2625 quota_show_check b u $TSTUSR
2627 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
2628 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2630 local timeout=$(sysctl -n lustre.timeout)
2632 if [ $io_type = "directio" ]; then
2633 log "Write 100M (directio) ..."
2634 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
2636 log "Write 100M (buffered) ..."
2637 $RUNAS $DD of=$TESTFILE count=100 &
2641 replay_barrier $SINGLEMDS
2642 log "Fail mds for $((2 * timeout)) seconds"
2643 fail $SINGLEMDS $((2 * timeout))
2646 if at_is_enabled; then
2647 timeout=$(at_max_get mds)
2649 timeout=$(lctl get_param -n timeout)
2653 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2654 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
2655 log "it took $count second"
2660 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
2662 cancel_lru_locks mdc
2663 cancel_lru_locks osc
2666 local testfile_size=$(stat -c %s $TESTFILE)
2667 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
2668 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \
2669 "got ${testfile_size}. Verifying file failed!"
2674 # test when mds does failover, the ost still could work well
2675 # this test shouldn't trigger watchdog b=14840
2677 # Clear dmesg so watchdog is not triggered by previous
2679 do_facet ost1 dmesg -c > /dev/null
2682 test_18_sub directio
2684 # check if watchdog is triggered
2685 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
2686 local watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
2687 { print; }' $TMP/lustre-log-${TESTNAME}.log)
2688 [ -z "$watchdog" ] || error "$watchdog"
2689 rm -f $TMP/lustre-log-${TESTNAME}.log
2691 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
2695 local TESTFILE=$DIR/$tdir/$tfile
2697 setup_quota_test || error "setup quota failed with $?"
2698 trap cleanup_quota_test EXIT
2700 set_ost_qtype $QTYPE || error "enable ost quota failed"
2702 # bind file to a single OST
2703 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2704 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2706 echo "Set user quota (limit: ${blimit}M)"
2707 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2708 error "set user quota failed"
2709 quota_show_check b u $TSTUSR
2710 echo "Update quota limits"
2711 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2712 error "set group quota failed"
2713 quota_show_check b u $TSTUSR
2715 # first wirte might be cached
2716 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
2717 cancel_lru_locks osc
2719 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
2720 quota_error u $TSTUSR "Write success, expect failure"
2725 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
2727 test_20() { # b15754
2728 local LSTR=(2g 1t 4k 3m) # limits strings
2730 local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \
2733 resetquota -u $TSTUSR
2735 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
2736 $MOUNT || error "could not set quota limits"
2737 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
2738 --inode-softlimit ${LSTR[2]} \
2739 --inode-hardlimit ${LSTR[3]} \
2740 $MOUNT || error "could not set quota limits"
2742 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
2743 error "bsoftlimit was not set properly"
2744 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
2745 error "bhardlimit was not set properly"
2746 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
2747 error "isoftlimit was not set properly"
2748 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
2749 error "ihardlimit was not set properly"
2751 resetquota -u $TSTUSR
2753 run_test 20 "Test if setquota specifiers work properly (b15754)"
2760 local time=$(($(date +%s) + seconds))
2761 while [ $(date +%s) -lt $time ]; do
2762 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
2766 # run for fixing bug16053, setquota shouldn't fail when writing and
2767 # deleting are happening
2769 local TESTFILE="$DIR/$tdir/$tfile"
2770 local BLIMIT=10 # 10G
2771 local ILIMIT=1000000
2773 setup_quota_test || error "setup quota failed with $?"
2774 trap cleanup_quota_test EXIT
2776 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2778 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
2779 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
2780 error "set user quota failed"
2781 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
2782 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
2783 error "set group quota failed"
2784 if is_project_quota_supported; then
2785 log "Set limit(block:${BLIMIT}G; file:$LIMIT) for " \
2786 "project: $TSTPRJID"
2787 $LFS setquota -p $TSTPRJID -b 0 -B $BLIMIT -i 0 -I $ILIMIT \
2788 $MOUNT || error "set project quota failed"
2791 # repeat writing on a 1M file
2792 test_21_sub ${TESTFILE}_1 1 30 &
2794 # repeat writing on a 128M file
2795 test_21_sub ${TESTFILE}_2 128 30 &
2798 local time=$(($(date +%s) + 30))
2800 while [ $(date +%s) -lt $time ]; do
2801 log "Set quota for $i times"
2802 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2803 -I $((ILIMIT + i)) $MOUNT ||
2804 error "Set user quota failed"
2805 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2806 -I $((ILIMIT + i)) $MOUNT ||
2807 error "Set group quota failed"
2808 if is_project_quota_supported; then
2809 $LFS setquota -p $TSTPRJID -b 0 -B \
2810 "$((BLIMIT + i))G" -i 0 -I $((ILIMIT + i)) $MOUNT ||
2811 error "Set project quota failed"
2819 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
2821 if [ $count -gt 60 ]; then
2822 quota_error a $TSTUSR "dd should be finished!"
2826 echo "(dd_pid=$DDPID1, time=$count)successful"
2830 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
2832 if [ $count -gt 60 ]; then
2833 quota_error a $TSTUSR "dd should be finished!"
2837 echo "(dd_pid=$DDPID2, time=$count)successful"
2841 run_test 21 "Setquota while writing & deleting (b16053)"
2843 # enable/disable quota enforcement permanently
2845 echo "Set both mdt & ost quota type as ug"
2847 is_project_quota_supported && qtype=$QTYPE
2848 set_mdt_qtype $qtype || error "enable mdt quota failed"
2849 set_ost_qtype $qtype || error "enable ost quota failed"
2852 stopall || error "failed to stopall (1)"
2856 echo "Verify if quota is enabled"
2857 local qtype1=$(mdt_quota_type)
2858 [ $qtype1 != $qtype ] && error "mdt quota setting is lost"
2859 qtype=$(ost_quota_type)
2860 [ $qtype1 != $qtype ] && error "ost quota setting is lost"
2862 echo "Set both mdt & ost quota type as none"
2863 set_mdt_qtype "none" || error "disable mdt quota failed"
2864 set_ost_qtype "none" || error "disable ost quota failed"
2867 stopall || error "failed to stopall (2)"
2872 echo "Verify if quota is disabled"
2873 qtype=$(mdt_quota_type)
2874 [ $qtype != "none" ] && error "mdt quota setting is lost"
2875 qtype=$(ost_quota_type)
2876 [ $qtype != "none" ] && error "ost quota setting is lost"
2880 run_test 22 "enable/disable quota by 'lctl conf_param/set_param -P'"
2883 local TESTFILE="$DIR/$tdir/$tfile"
2886 setup_quota_test || error "setup quota failed with $?"
2887 trap cleanup_quota_test EXIT
2889 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2892 log "User quota (limit: $LIMIT MB)"
2893 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
2894 error "set quota failed"
2895 quota_show_check b u $TSTUSR
2897 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2898 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2900 log "Step1: trigger EDQUOT with O_DIRECT"
2901 log "Write half of file"
2902 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
2903 quota_error u $TSTUSR "(1) Write failure, expect success." \
2905 log "Write out of block quota ..."
2906 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
2907 oflag=direct conv=notrunc &&
2908 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
2912 log "Step2: rewrite should succeed"
2913 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
2914 quota_error u $TSTUSR "(3) Write failure, expect success." \
2920 local OST0_UUID=$(ostuuid_from_index 0)
2921 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
2922 [ $OST0_QUOTA_USED -ne 0 ] &&
2923 ($SHOW_QUOTA_USER; \
2924 quota_error u $TSTUSR "quota isn't released")
2929 [ "$ost1_FSTYPE" == zfs ] &&
2930 skip "Overwrite in place is not guaranteed to be " \
2931 "space neutral on ZFS"
2933 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
2934 check_whether_skip && return 0
2935 log "run for 4MB test file"
2938 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
2939 check_whether_skip && return 0
2940 log "run for 40MB test file"
2943 run_test 23 "Quota should be honored with directIO (b16125)"
2947 local TESTFILE="$DIR/$tdir/$tfile"
2949 setup_quota_test || error "setup quota failed with $?"
2950 trap cleanup_quota_test EXIT
2952 set_ost_qtype $QTYPE || error "enable ost quota failed"
2954 # bind file to a single OST
2955 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2956 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2958 echo "Set user quota (limit: ${blimit}M)"
2959 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2960 error "set quota failed"
2962 # overrun quota by root user
2963 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
2964 error "write failure, expect success"
2965 cancel_lru_locks osc
2966 sync_all_data || true
2968 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
2972 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
2974 test_27a() { # b19612
2975 $LFS quota $TSTUSR $DIR &&
2976 error "lfs succeeded with no type, but should have failed"
2977 $LFS setquota $TSTUSR $DIR &&
2978 error "lfs succeeded with no type, but should have failed"
2981 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
2983 test_27b() { # b20200
2984 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2985 error "lfs setquota failed with uid argument"
2986 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2987 error "lfs stequota failed with gid argument"
2988 if is_project_quota_supported; then
2989 $LFS setquota -p $TSTPRJID -b 1000 -B 1000 -i 1000 -I \
2990 1000 $DIR || error \
2991 "lfs stequota failed with projid argument"
2993 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
2994 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
2995 if is_project_quota_supported; then
2996 $SHOW_QUOTA_PROJID ||
2997 error "lfs quota failed with projid argument"
2999 resetquota -u $TSTID
3000 resetquota -g $TSTID
3001 resetquota -p $TSTPRJID
3004 run_test 27b "lfs quota/setquota should handle user/group/project ID (b20200)"
3009 $LFS setquota -u $TSTID -b 30M -B 3T $DIR ||
3010 error "lfs setquota failed"
3012 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
3013 [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
3014 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
3015 [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
3017 $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
3018 error "lfs setquota for $TSTID failed"
3020 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
3021 [ $limit != "1.465G" ] && error "wrong softlimit $limit"
3022 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
3023 [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
3025 $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
3026 error "total allocated inode/block limit not printed"
3028 resetquota -u $TSTUSR
3030 run_test 27c "lfs quota should support human-readable output"
3037 $LFS setquota -u $TSTID -b ${softlimit}p -B ${hardlimit}P $DIR ||
3038 error "set fraction block limit failed"
3039 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $3}')
3040 [ $limit == ${softlimit}P ] || error "get fraction softlimit failed"
3041 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $4}')
3042 [ $limit == ${hardlimit}P ] || error "get fraction hardlimit failed"
3044 resetquota -u $TSTUSR
3046 run_test 27d "lfs setquota should support fraction block limit"
3050 local TESTFILE="$DIR/$tdir/$tfile"
3053 setup_quota_test || error "setup quota failed with $?"
3054 trap cleanup_quota_test EXIT
3056 set_ost_qtype "u" || error "enable ost quota failed"
3058 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
3059 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
3061 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
3062 $MAX_IQ_TIME $DIR || error "set grace time failed"
3063 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
3064 error "set quota failed"
3065 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
3066 cancel_lru_locks osc
3068 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
3069 # over-quota flag has not yet settled since we do not trigger async
3070 # events based on grace time period expiration
3072 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
3073 cancel_lru_locks osc
3074 # now over-quota flag should be settled and further writes should fail
3076 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
3077 error "grace times were reset"
3080 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
3081 $MAX_IQ_TIME $DIR || error "restore grace time failed"
3083 run_test 30 "Hard limit updates should not reset grace times"
3085 # basic usage tracking for user & group
3087 local INODES=10 # files
3088 local BLK_CNT=2 # MB each
3089 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
3091 setup_quota_test || error "setup quota failed with $?"
3092 trap cleanup_quota_test EXIT
3094 # make sure the system is clean
3095 local USED=$(getquota -u $TSTID global curspace)
3097 error "Used space ($USED) for user $TSTID isn't 0."
3098 USED=$(getquota -g $TSTID global curspace)
3100 error "Used space ($USED) for group $TSTID isn't 0."
3101 if is_project_quota_supported; then
3102 USED=$(getquota -p $TSTPRJID global curspace)
3103 [ $USED -ne 0 ] && error \
3104 "Used space ($USED) for project $TSTPRJID isn't 0."
3107 echo "Write files..."
3108 for i in $(seq 0 $INODES); do
3109 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
3110 error "write failed"
3111 is_project_quota_supported &&
3112 change_project -p $TSTPRJID $DIR/$tdir/$tfile-$i
3113 echo "Iteration $i/$INODES completed"
3115 cancel_lru_locks osc
3117 echo "Wait for setattr on objects finished..."
3118 wait_delete_completed
3120 sync; sync_all_data || true
3122 echo "Verify disk usage after write"
3123 USED=$(getquota -u $TSTID global curspace)
3124 [ $USED -lt $TOTAL_BLKS ] &&
3125 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
3126 USED=$(getquota -g $TSTID global curspace)
3127 [ $USED -lt $TOTAL_BLKS ] &&
3128 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
3129 if is_project_quota_supported; then
3130 USED=$(getquota -p $TSTPRJID global curspace)
3131 [ $USED -lt $TOTAL_BLKS ] && error \
3132 "Used space for project $TSTPRJID:$USED, expected:$TOTAL_BLKS"
3135 echo "Verify inode usage after write"
3136 USED=$(getquota -u $TSTID global curinodes)
3137 [ $USED -lt $INODES ] &&
3138 error "Used inode for user $TSTID is $USED, expected $INODES"
3139 USED=$(getquota -g $TSTID global curinodes)
3140 [ $USED -lt $INODES ] &&
3141 error "Used inode for group $TSTID is $USED, expected $INODES"
3142 if is_project_quota_supported; then
3143 USED=$(getquota -p $TSTPRJID global curinodes)
3144 [ $USED -lt $INODES ] && error \
3145 "Used inode for project $TSTPRJID is $USED, expected $INODES"
3150 echo "Verify disk usage after delete"
3151 USED=$(getquota -u $TSTID global curspace)
3152 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
3153 USED=$(getquota -u $TSTID global curinodes)
3154 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
3155 USED=$(getquota -g $TSTID global curspace)
3156 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
3157 USED=$(getquota -g $TSTID global curinodes)
3158 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
3159 if is_project_quota_supported; then
3160 USED=$(getquota -p $TSTPRJID global curspace)
3162 error "Used space for project $TSTPRJID isn't 0. $USED"
3163 USED=$(getquota -p $TSTPRJID global curinodes)
3165 error "Used inodes for project $TSTPRJID isn't 0. $USED"
3168 run_test 33 "Basic usage tracking for user & group & project"
3170 # usage transfer test for user & group & project
3172 local BLK_CNT=2 # MB
3173 local project_supported="no"
3175 is_project_quota_supported && project_supported="yes"
3176 setup_quota_test || error "setup quota failed with $?"
3177 trap cleanup_quota_test EXIT
3179 # make sure the system is clean
3180 local USED=$(getquota -u $TSTID global curspace)
3181 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
3182 USED=$(getquota -g $TSTID global curspace)
3183 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
3185 local USED=$(getquota -u $TSTID2 global curspace)
3186 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID2 isn't 0."
3187 if [ $project_supported == "yes" ]; then
3188 USED=$(getquota -p $TSTPRJID global curspace)
3189 [ $USED -ne 0 ] && error \
3190 "Used space ($USED) for Project $TSTPRJID isn't 0."
3193 echo "Write file..."
3194 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
3195 error "write failed"
3196 cancel_lru_locks osc
3197 sync; sync_all_data || true
3199 echo "chown the file to user $TSTID"
3200 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
3202 echo "Wait for setattr on objects finished..."
3203 wait_delete_completed
3205 BLK_CNT=$((BLK_CNT * 1024))
3207 echo "Verify disk usage for user $TSTID"
3208 USED=$(getquota -u $TSTID global curspace)
3209 [ $USED -lt $BLK_CNT ] &&
3210 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
3211 USED=$(getquota -u $TSTID global curinodes)
3213 error "Used inodes for user $TSTID is $USED, expected 1"
3215 echo "chgrp the file to group $TSTID"
3216 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
3218 echo "Wait for setattr on objects finished..."
3219 wait_delete_completed
3221 echo "Verify disk usage for group $TSTID"
3222 USED=$(getquota -g $TSTID global curspace)
3223 [ $USED -ge $BLK_CNT ] ||
3224 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3225 USED=$(getquota -g $TSTID global curinodes)
3227 error "Used inodes for group $TSTID is $USED, expected 1"
3229 # chown won't change the ost object group. LU-4345 */
3230 echo "chown the file to user $TSTID2"
3231 chown $TSTID2 $DIR/$tdir/$tfile || error "chown to $TSTID2 failed"
3233 echo "Wait for setattr on objects finished..."
3234 wait_delete_completed
3236 echo "change_project project id to $TSTPRJID"
3237 [ $project_supported == "yes" ] &&
3238 change_project -p $TSTPRJID $DIR/$tdir/$tfile
3239 echo "Wait for setattr on objects finished..."
3240 wait_delete_completed
3242 echo "Verify disk usage for user $TSTID2/$TSTID and group $TSTID"
3243 USED=$(getquota -u $TSTID2 global curspace)
3244 [ $USED -lt $BLK_CNT ] &&
3245 error "Used space for user $TSTID2 is $USED, expected $BLK_CNT"
3246 USED=$(getquota -u $TSTID global curspace)
3248 error "Used space for user $TSTID is $USED, expected 0"
3249 USED=$(getquota -g $TSTID global curspace)
3250 [ $USED -lt $BLK_CNT ] &&
3251 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3252 if [ $project_supported == "yes" ]; then
3253 USED=$(getquota -p $TSTPRJID global curspace)
3254 [ $USED -lt $BLK_CNT ] && error \
3255 "Used space for group $TSTPRJID is $USED, expected $BLK_CNT"