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 VERSION_WITH_QP="2.13.53"
44 [ $MDS1_VERSION -lt $(version_code $VERSION_WITH_QP) ] &&
45 skip "Needs MDS version $VERSION_WITH_QP or later."
48 require_dsh_mds || exit 0
49 require_dsh_ost || exit 0
51 # Does e2fsprogs support quota feature?
52 if [ "$mds1_FSTYPE" == ldiskfs ] &&
53 do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features |
54 grep -q 'quota'"; then
55 skip_env "e2fsprogs doesn't support quota"
58 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
60 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
65 QUOTA_AUTO_OLD=$QUOTA_AUTO
68 check_and_setup_lustre
70 ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
72 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
73 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
74 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
75 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
76 SHOW_QUOTA_PROJID="eval is_project_quota_supported && $LFS quota -v -p $TSTPRJID $DIR"
77 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
78 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
79 SHOW_QUOTA_INFO_PROJID="eval is_project_quota_supported && $LFS quota -t -p $DIR"
84 local fail_val=${3:-0}
88 mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
89 mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
90 ost) NODES="$(comma_list $(osts_nodes))";;
93 do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
99 lfs project $* || error "lfs project $* failed"
102 RUNAS="runas -u $TSTID -g $TSTID"
103 RUNAS2="runas -u $TSTID2 -g $TSTID2"
104 DD="dd if=/dev/zero bs=1M"
108 # clear quota limits for a user or a group
109 # usage: resetquota -u username
110 # resetquota -g groupname
111 # resetquota -p projid
114 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
115 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
116 error "resetquota: wrong specifier $1 passed"
118 if [ $1 == "-p" ]; then
119 is_project_quota_supported || return 0
122 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
123 error "clear quota for [type:$1 name:$2] failed"
124 # give a chance to slave to release space
132 if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
133 $LFS quota -v -u $local_id $DIR
134 log "Files for user ($local_id):"
135 ($LFS find --user $local_id $DIR | head -n 4 |
136 xargs stat 2>/dev/null)
139 if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
140 $LFS quota -v -g $local_id $DIR
141 log "Files for group ($local_id):"
142 ($LFS find --group $local_id $DIR | head -n 4 |
143 xargs stat 2>/dev/null)
146 is_project_quota_supported || return 0
147 if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
148 $LFS quota -v -p $TSTPRJID $DIR
149 log "Files for project ($TSTPRJID):"
150 ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
151 xargs stat 2>/dev/null)
167 # get quota for a user or a group
168 # usage: getquota -u|-g|-p <username>|<groupname>|<projid> global|<obd_uuid> \
169 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace \
176 sync_all_data > /dev/null 2>&1 || true
178 [ "$#" != 4 -a "$#" != 5 ] &&
179 error "getquota: wrong number of arguments: $#"
180 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
181 error "getquota: wrong u/g/p specifier $1 passed"
194 *) error "unknown quota parameter $4";;
197 [ ! -z "$5" ] && pool_arg="--pool $5 "
198 [ "$uuid" = "global" ] && uuid=$DIR
200 $LFS quota -v "$1" "$2" $pool_arg $DIR |
201 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
202 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
207 # usage: set_mdt_qtype ugp|u|g|p|none
211 local mdts=$(get_facets MDS)
213 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
214 qtype=$(tr -d 'p' <<<$qtype)
216 if [[ $PERM_CMD == *"set_param -P"* ]]; then
217 do_facet mgs $PERM_CMD \
218 osd-*.$FSNAME-MDT*.quota_slave.enabled=$qtype
220 do_facet mgs $PERM_CMD $FSNAME.quota.mdt=$qtype
222 # we have to make sure each MDT received config changes
223 for mdt in ${mdts//,/ }; do
225 cmd="$LCTL get_param -n "
226 cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc}
227 cmd=${cmd}.quota_slave.enabled
229 if $(facet_up $mdt); then
230 wait_update_facet $mdt "$cmd" "$qtype" || return 1
237 # usage: set_ost_qtype ugp|u|g|p|none
241 local osts=$(get_facets OST)
243 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
244 qtype=$(tr -d 'p' <<<$qtype)
246 if [[ $PERM_CMD == *"set_param -P"* ]]; then
247 do_facet mgs $PERM_CMD \
248 osd-*.$FSNAME-OST*.quota_slave.enabled=$qtype
250 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$qtype
252 # we have to make sure each OST received config changes
253 for ost in ${osts//,/ }; do
255 cmd="$LCTL get_param -n "
256 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
257 cmd=${cmd}.quota_slave.enabled
259 if $(facet_up $ost); then
260 wait_update_facet $ost "$cmd" "$qtype" || return 1
266 wait_reintegration() {
270 local result="glb[1],slv[1],reint[0]"
275 if [ $ntype == "mdt" ]; then
276 tgts=$(get_facets MDS)
278 tgts=$(get_facets OST)
281 for tgt in ${tgts//,/ }; do
283 cmd="$LCTL get_param -n "
284 cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc}
285 cmd=${cmd}.quota_slave.info
287 if $(facet_up $tgt); then
288 wait_update_facet $tgt "$cmd |
289 grep "$qtype" | awk '{ print \\\$3 }'" \
290 "$result" $max || return 1
300 if [[ "$qtype" =~ "u" ]]; then
301 wait_reintegration "mdt" "user" $max || return 1
304 if [[ "$qtype" =~ "g" ]]; then
305 wait_reintegration "mdt" "group" $max || return 1
308 if [[ "$qtype" =~ "p" ]]; then
309 ! is_project_quota_supported && return 0
310 wait_reintegration "mdt" "project" $max || return 1
319 if [[ "$qtype" =~ "u" ]]; then
320 wait_reintegration "ost" "user" $max || return 1
323 if [[ "$qtype" =~ "g" ]]; then
324 wait_reintegration "ost" "group" $max || return 1
327 if [[ "$qtype" =~ "p" ]]; then
328 ! is_project_quota_supported && return 0
329 wait_reintegration "ost" "project" $max || return 1
338 local extrasleep=${4:-5}
345 *) error "get_grace_time: Invalid quota type: $qtype"
350 echo "Quota info for $pool:"
351 $LFS quota -$qtype $qarg $parg $DIR
356 time=$(lfs quota -$qtype $qarg $parg $DIR|
357 awk 'NR == 3{ print $5 }')
360 time=$(lfs quota -$qtype $qarg $DIR|
361 awk 'NR == 3{ print $9 }')
364 error "Unknown quota type: $flavour"
368 local sleep_seconds=0
369 local orig_time=$time
371 echo "Grace time is $time"
372 # from lfs.c:__sec2str()
373 # const char spec[] = "smhdw";
374 # {1, 60, 60*60, 24*60*60, 7*24*60*60};
375 [[ $time == *w* ]] && w_time=${time%w*} &&
376 let sleep_seconds+=$((w_time*7*24*60*60));
378 [[ $time == *d* ]] && d_time=${time%d*} &&
379 let sleep_seconds+=$((d_time*24*60*60));
381 [[ $time == *h* ]] && h_time=${time%h*} &&
382 let sleep_seconds+=$((h_time*60*60));
384 [[ $time == *m* ]] && m_time=${time%m*} &&
385 let sleep_seconds+=$((m_time*60));
387 [[ $time == *s* ]] && s_time=${time%s*} &&
388 let sleep_seconds+=$s_time
390 echo "Sleep through grace ..."
391 [ "$orig_time" == "-" ] &&
392 error "Grace timeout was not set or quota not exceeded"
393 if [ "$orig_time" == "none" ]; then
394 echo "...Grace timeout already expired"
396 let sleep_seconds+=$extrasleep
397 echo "...sleep $sleep_seconds seconds"
403 wait_delete_completed
404 echo "Creating test directory"
405 mkdir_on_mdt0 $DIR/$tdir || return 1
406 chmod 0777 $DIR/$tdir || return 2
407 # always clear fail_loc in case of fail_loc isn't cleared
408 # properly when previous test failed
409 lustre_fail mds_ost 0
410 stack_trap cleanup_quota_test EXIT
413 cleanup_quota_test() {
414 echo "Delete files..."
416 [ -d $DIR/${tdir}_dom ] && rm -rf $DIR/${tdir}_dom
417 echo "Wait for unlink objects finished..."
418 wait_delete_completed
419 sync_all_data || true
429 $LFS quota -v -$ugp $qid $DIR
431 if [ "$bf" == "a" -o "$bf" == "b" ]; then
432 usage=$(getquota -$ugp $qid global curspace)
433 if [ -z $usage ]; then
434 quota_error $ugp $qid \
435 "Query block quota failed ($ugp:$qid)."
437 [ $usage -ne 0 ] && quota_log $ugp $qid \
438 "Block quota isn't 0 ($ugp:$qid:$usage)."
442 if [ "$bf" == "a" -o "$bf" == "f" ]; then
443 usage=$(getquota -$ugp $qid global curinodes)
444 if [ -z $usage ]; then
445 quota_error $ugp $qid \
446 "Query file quota failed ($ugp:$qid)."
448 [ $usage -ne 0 ] && quota_log $ugp $qid \
449 "File quota isn't 0 ($ugp:$qid:$usage)."
454 project_quota_enabled () {
456 local zfeat="feature@project_quota"
458 for facet in $(seq -f mds%g $MDSCOUNT) $(seq -f ost%g $OSTCOUNT); do
459 local facet_fstype=${facet:0:3}1_FSTYPE
462 if [ "${!facet_fstype}" = "zfs" ]; then
463 devname=$(zpool_name ${facet})
464 do_facet ${facet} $ZPOOL get -H "$zfeat" $devname |
465 grep -wq active || rc=1
467 [ ${facet:0:3} == "mds" ] &&
468 devname=$(mdsdevname ${facet:3}) ||
469 devname=$(ostdevname ${facet:3})
470 do_facet ${facet} $DEBUGFS -R features $devname |
471 grep -q project || rc=1
474 [ $rc -eq 0 ] && PQ_CLEANUP=false || PQ_CLEANUP=true
478 project_quota_enabled || enable_project_quota
480 reset_quota_settings() {
481 resetquota -u $TSTUSR
483 resetquota -g $TSTUSR
485 resetquota -u $TSTUSR2
486 resetquota -u $TSTID2
487 resetquota -g $TSTUSR2
488 resetquota -g $TSTID2
489 resetquota -p $TSTPRJID
494 do_nodes $(comma_list $(nodes_list)) \
495 "$LCTL set_param -n debug=+quota,trace"
500 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
501 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
502 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
503 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
505 test_quota_performance() {
506 local TESTFILE="$DIR/$tdir/$tfile-0"
507 local size=$1 # in MB
508 local stime=$(date +%s)
509 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
510 quota_error u $TSTUSR "write failure"
511 local etime=$(date +%s)
512 delta=$((etime - stime))
513 if [ $delta -gt 0 ]; then
514 rate=$((size * 1024 / delta))
515 if [ "$mds1_FSTYPE" = zfs ]; then
516 # LU-2872 - see LU-2887 for fix
518 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
520 [ $rate -gt 1024 ] ||
521 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
527 # test basic quota performance b=21696
530 [ "$SLOW" = "no" ] && MB=10
532 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
533 [ $free_space -le $((MB * 1024)) ] &&
534 skip "not enough space ${free_space} KB, " \
535 "required $((MB * 1024)) KB"
536 setup_quota_test || error "setup quota failed with $?"
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
546 run_test 0 "Test basic quota performance"
548 # usage: test_1_check_write tfile user|group|project
549 test_1_check_write() {
553 local short_qtype=${qtype:0:1}
556 $RUNAS $DD of=$testfile count=$((limit/2)) ||
557 quota_error $short_qtype $TSTUSR \
558 "$qtype write failure, but expect success"
559 log "Write out of block quota ..."
560 # this time maybe cache write, ignore it's failure
561 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
562 # flush cache, ensure noquota flag is set on client
564 sync; sync_all_data || true
565 # sync means client wrote all it's cache, but id doesn't
566 # guarantee that slave received new edquot through glimpse.
567 # so wait a little to be sure slave got it.
569 $RUNAS $DD of=$testfile count=1 seek=$limit &&
570 quota_error $short_qtype $TSTUSR \
571 "user write success, but expect EDQUOT"
575 check_write_fallocate() {
579 local short_qtype=${qtype:0:1}
582 log "Write ${count}MiB Using Fallocate"
583 $RUNAS fallocate -l${count}MiB $testfile ||
584 quota_error $short_qtype $TSTUSR "Write ${count}MiB fail"
587 sync; sync_all_data || true
591 log "Write ${count}MiB Using Fallocate"
592 $RUNAS fallocate -l${count}MiB $testfile &&
593 quota_error $short_qtype $TSTUSR \
594 "Write success, expect EDQUOT" || true
597 # test block hardlimit
600 local testfile="$DIR/$tdir/$tfile-0"
602 setup_quota_test || error "setup quota failed with $?"
605 set_ost_qtype $QTYPE || error "enable ost quota failed"
608 log "User quota (block hardlimit:$limit MB)"
609 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
610 error "set user quota failed"
612 # make sure the system is clean
613 local used=$(getquota -u $TSTUSR global curspace)
614 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
616 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
617 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
619 test_1_check_write $testfile "user" $limit
622 wait_delete_completed || error "wait_delete_completed failed"
623 sync_all_data || true
624 used=$(getquota -u $TSTUSR global curspace)
625 [ $used -ne 0 ] && quota_error u $TSTUSR \
626 "user quota isn't released after deletion"
627 resetquota -u $TSTUSR
630 log "--------------------------------------"
631 log "Group quota (block hardlimit:$limit MB)"
632 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
633 error "set group quota failed"
635 testfile="$DIR/$tdir/$tfile-1"
636 # make sure the system is clean
637 used=$(getquota -g $TSTUSR global curspace)
638 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
640 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
641 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
643 test_1_check_write $testfile "group" $limit
645 wait_delete_completed || error "wait_delete_completed failed"
646 sync_all_data || true
647 used=$(getquota -g $TSTUSR global curspace)
648 [ $used -ne 0 ] && quota_error g $TSTUSR \
649 "Group quota isn't released after deletion"
650 resetquota -g $TSTUSR
652 if ! is_project_quota_supported; then
653 echo "Project quota is not supported"
657 testfile="$DIR/$tdir/$tfile-2"
658 # make sure the system is clean
659 used=$(getquota -p $TSTPRJID global curspace)
661 error "used space($used) for project $TSTPRJID isn't 0"
664 log "--------------------------------------"
665 log "Project quota (block hardlimit:$limit mb)"
666 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
667 error "set project quota failed"
669 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
670 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
671 change_project -p $TSTPRJID $testfile
673 test_1_check_write $testfile "project" $limit
678 used=$(getquota -p $TSTPRJID global curspace)
679 [ $used -ne 0 ] && quota_error p $TSTPRJID \
680 "project quota isn't released after deletion"
682 resetquota -p $TSTPRJID
684 run_test 1a "Block hard limit (normal use and out of quota)"
688 local global_limit=20 # MB
689 local testfile="$DIR/$tdir/$tfile-0"
693 setup_quota_test || error "setup quota failed with $?"
696 set_ost_qtype $QTYPE || error "enable ost quota failed"
699 log "User quota (block hardlimit:$global_limit MB)"
700 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
701 error "set user quota failed"
703 pool_add $qpool || error "pool_add failed"
704 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
705 error "pool_add_targets failed"
707 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
708 error "set user quota failed"
710 # make sure the system is clean
711 local used=$(getquota -u $TSTUSR global curspace)
713 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
715 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
717 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
718 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
720 test_1_check_write $testfile "user" $limit
723 wait_delete_completed || error "wait_delete_completed failed"
724 sync_all_data || true
725 used=$(getquota -u $TSTUSR global curspace $qpool)
726 [ $used -ne 0 ] && quota_error u $TSTUSR \
727 "user quota isn't released after deletion"
728 resetquota -u $TSTUSR
731 log "--------------------------------------"
732 log "Group quota (block hardlimit:$global_limit MB)"
733 $LFS setquota -g $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
734 error "set group quota failed"
736 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M --pool $qpool $DIR ||
737 error "set group quota failed"
739 testfile="$DIR/$tdir/$tfile-1"
740 # make sure the system is clean
741 used=$(getquota -g $TSTUSR global curspace $qpool)
742 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
744 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
745 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
747 test_1_check_write $testfile "group" $limit
750 wait_delete_completed || error "wait_delete_completed failed"
751 sync_all_data || true
752 used=$(getquota -g $TSTUSR global curspace $qpool)
753 [ $used -ne 0 ] && quota_error g $TSTUSR \
754 "Group quota isn't released after deletion"
755 resetquota -g $TSTUSR
757 if ! is_project_quota_supported; then
758 echo "Project quota is not supported"
762 testfile="$DIR/$tdir/$tfile-2"
763 # make sure the system is clean
764 used=$(getquota -p $TSTPRJID global curspace $qpool)
766 error "used space($used) for project $TSTPRJID isn't 0"
769 log "--------------------------------------"
770 log "Project quota (block hardlimit:$global_limit mb)"
771 $LFS setquota -p $TSTPRJID -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
772 error "set project quota failed"
774 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M --pool $qpool $DIR ||
775 error "set project quota failed"
778 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
779 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
780 change_project -p $TSTPRJID $testfile
782 test_1_check_write $testfile "project" $limit
787 used=$(getquota -p $TSTPRJID global curspace)
788 [ $used -eq 0 ] || quota_error p $TSTPRJID \
789 "project quota isn't released after deletion"
791 run_test 1b "Quota pools: Block hard limit (normal use and out of quota)"
794 local global_limit=20 # MB
795 local testfile="$DIR/$tdir/$tfile-0"
796 local qpool1="qpool1"
797 local qpool2="qpool2"
800 setup_quota_test || error "setup quota failed with $?"
803 set_ost_qtype $QTYPE || error "enable ost quota failed"
806 log "User quota (block hardlimit:$global_limit MB)"
807 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
808 error "set user quota failed"
810 pool_add $qpool1 || error "pool_add failed"
811 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
812 error "pool_add_targets failed"
814 pool_add $qpool2 || error "pool_add failed"
815 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
816 error "pool_add_targets failed"
818 # create pools without hard limit
819 # initially such case raised several bugs
820 $LFS setquota -u $TSTUSR -B 0M --pool $qpool1 $DIR ||
821 error "set user quota failed"
823 $LFS setquota -u $TSTUSR -B 0M --pool $qpool2 $DIR ||
824 error "set user quota failed"
826 # make sure the system is clean
827 local used=$(getquota -u $TSTUSR global curspace)
829 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
831 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
833 test_1_check_write $testfile "user" $global_limit
835 used=$(getquota -u $TSTUSR global curspace $qpool1)
836 echo "qpool1 used $used"
837 used=$(getquota -u $TSTUSR global curspace $qpool2)
838 echo "qpool2 used $used"
841 wait_delete_completed || error "wait_delete_completed failed"
842 sync_all_data || true
844 used=$(getquota -u $TSTUSR global curspace $qpool1)
845 [ $used -eq 0 ] || quota_error u $TSTUSR \
846 "user quota isn't released after deletion"
848 run_test 1c "Quota pools: check 3 pools with hardlimit only for global"
853 local global_limit=20 # MB
854 local testfile="$DIR/$tdir/$tfile-0"
855 local qpool1="qpool1"
856 local qpool2="qpool2"
859 setup_quota_test || error "setup quota failed with $?"
862 set_ost_qtype $QTYPE || error "enable ost quota failed"
865 log "User quota (block hardlimit:$global_limit MB)"
866 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
867 error "set user quota failed"
869 pool_add $qpool1 || error "pool_add failed"
870 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
871 error "pool_add_targets failed"
873 pool_add $qpool2 || error "pool_add failed"
874 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
875 error "pool_add_targets failed"
877 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
878 error "set user quota failed"
880 $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
881 error "set user quota failed"
883 # make sure the system is clean
884 local used=$(getquota -u $TSTUSR global curspace)
886 [ $used -ne 0 ] && error "used space($used) for user $TSTUSR isn't 0."
888 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
890 test_1_check_write $testfile "user" $limit1
892 used=$(getquota -u $TSTUSR global curspace $qpool1)
893 echo "qpool1 used $used"
894 used=$(getquota -u $TSTUSR global curspace $qpool2)
895 echo "qpool2 used $used"
898 wait_delete_completed || error "wait_delete_completed failed"
899 sync_all_data || true
901 used=$(getquota -u $TSTUSR global curspace $qpool1)
902 [ $used -eq 0 ] || quota_error u $TSTUSR \
903 "user quota isn't released after deletion"
905 run_test 1d "Quota pools: check block hardlimit on different pools"
909 local global_limit=53000000 # MB
910 local testfile="$DIR/$tdir/$tfile-0"
911 local testfile2="$DIR/$tdir/$tfile-1"
912 local qpool1="qpool1"
915 setup_quota_test || error "setup quota failed with $?"
918 set_ost_qtype $QTYPE || error "enable ost quota failed"
920 # global_limit is much greater than limit1 to get
921 # different qunit's on osts. Since 1st qunit shrinking
922 # on OST1(that belongs to qpool1), this qunit should
924 log "User quota (block hardlimit:$global_limit MB)"
925 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
926 error "set user quota failed"
928 pool_add $qpool1 || error "pool_add failed"
929 pool_add_targets $qpool1 1 1 ||
930 error "pool_add_targets failed"
932 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
933 error "set user quota failed"
935 # make sure the system is clean
936 local used=$(getquota -u $TSTUSR global curspace)
937 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
939 $LFS setstripe $testfile -c 1 -i 1 || error "setstripe $testfile failed"
940 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
942 test_1_check_write $testfile "user" $limit1
944 $LFS setstripe $testfile2 -c 1 -i 0 ||
945 error "setstripe $testfile2 failed"
946 chown $TSTUSR.$TSTUSR $testfile2 || error "chown $testfile2 failed"
947 # Now write to file with a stripe on OST0, that doesn't belong to qpool1
949 $RUNAS $DD of=$testfile2 count=20 ||
950 quota_error u $TSTUSR \
951 "$qtype write failure, but expect success"
955 wait_delete_completed || error "wait_delete_completed failed"
956 sync_all_data || true
958 used=$(getquota -u $TSTUSR global curspace $qpool1)
959 [ $used -eq 0 ] || quota_error u $TSTUSR \
960 "user quota isn't released after deletion"
962 run_test 1e "Quota pools: global pool high block limit vs quota pool with small"
965 local global_limit=200 # MB
967 local TESTDIR="$DIR/$tdir/"
968 local testfile="$TESTDIR/$tfile-0"
969 local qpool1="qpool1"
972 setup_quota_test || error "setup quota failed with $?"
975 set_ost_qtype $QTYPE || error "enable ost quota failed"
977 log "User quota (block hardlimit:$global_limit MB)"
978 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
979 error "set user quota failed"
981 pool_add $qpool1 || error "pool_add failed"
982 pool_add_targets $qpool1 0 0 ||
983 error "pool_add_targets failed"
985 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
986 error "set user quota failed"
988 # make sure the system is clean
989 local used=$(getquota -u $TSTUSR global curspace)
990 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
992 $LFS setstripe $TESTDIR -c 1 -i 0 || error "setstripe $TESTDIR failed"
994 test_1_check_write $testfile "user" $limit1
996 pool_remove_target $qpool1 0
998 wait_delete_completed || error "wait_delete_completed failed"
999 sync_all_data || true
1001 pool_add_targets $qpool1 0 0 || error "pool_add_targets failed"
1002 # qunit for appropriate element in lgd array should be set
1003 # correctly(4096). Earlier it was not changed continuing to be 1024.
1004 # This caused write to hung when it hit limit1 - qunit shrinking to 1024
1005 # for qpool1 lqe didn't cause changing qunit for OST0 in gld array
1006 # as it already was 1024. As flag "need_update" for this qunit was
1007 # not set, new qunit wasn't sent to OST0. Thus revoke was not set
1008 # for "qpool1" lqe and it couldn't set EDQUOT despite granted
1009 # became > 10M. QMT returned EINPROGRESS in a loop.
1010 # Check that it doesn't hung anymore.
1011 test_1_check_write $testfile "user" $limit1
1013 run_test 1f "Quota pools: correct qunit after removing/adding OST"
1017 local global_limit=40 # MB
1018 local testfile="$DIR/$tdir/$tfile-0"
1019 local qpool="qpool1"
1020 local mdmb_param="osc.*.max_dirty_mb"
1021 local max_dirty_mb=$($LCTL get_param -n $mdmb_param | head -1)
1024 setup_quota_test || error "setup quota failed with $?"
1025 $LCTL set_param $mdmb_param=1
1026 stack_trap "$LCTL set_param $mdmb_param=$max_dirty_mb" EXIT
1029 set_ost_qtype $QTYPE || error "enable ost quota failed"
1032 log "User quota (block hardlimit:$global_limit MB)"
1033 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
1034 error "set user quota failed"
1036 pool_add $qpool || error "pool_add failed"
1037 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
1038 error "pool_add_targets failed"
1040 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
1041 error "set user quota failed"
1043 # make sure the system is clean
1044 local used=$(getquota -u $TSTUSR global curspace)
1046 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1048 $LFS setstripe $testfile -C 200 || error "setstripe $testfile failed"
1049 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1052 $RUNAS $DD of=$testfile count=$((limit/2)) ||
1053 quota_error u $TSTUSR \
1054 "$qtype write failure, but expect success"
1055 log "Write out of block quota ..."
1056 # this time maybe cache write, ignore it's failure
1057 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
1058 # flush cache, ensure noquota flag is set on client
1059 cancel_lru_locks osc
1060 sync; sync_all_data || true
1062 $RUNAS $DD of=$testfile count=$OSTCOUNT seek=$limit &&
1063 quota_error u $TSTUSR \
1064 "user write success, but expect EDQUOT"
1067 wait_delete_completed || error "wait_delete_completed failed"
1068 sync_all_data || true
1070 used=$(getquota -u $TSTUSR global curspace $qpool)
1071 [ $used -ne 0 ] && quota_error u $TSTUSR \
1072 "user quota isn't released after deletion"
1075 run_test 1g "Quota pools: Block hard limit with wide striping"
1079 local testfile="$DIR/$tdir/$tfile-0"
1081 check_set_fallocate_or_skip
1083 setup_quota_test || error "setup quota failed with $?"
1086 set_ost_qtype $QTYPE || error "enable ost quota failed"
1089 log "User quota (block hardlimit:$limit MB)"
1090 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
1091 error "set user quota failed"
1093 # make sure the system is clean
1094 local used=$(getquota -u $TSTUSR global curspace)
1095 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1097 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
1098 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1100 check_write_fallocate $testfile "user" $limit
1103 wait_delete_completed || error "wait_delete_completed failed"
1104 sync_all_data || true
1105 used=$(getquota -u $TSTUSR global curspace)
1106 [ $used -eq 0 ] || quota_error u $TSTUSR \
1107 "user quota isn't released after deletion"
1109 run_test 1h "Block hard limit test using fallocate"
1112 local global_limit=200 # 200M
1113 local limit1=10 # 10M
1114 local TESTDIR="$DIR/$tdir/"
1115 local testfile="$TESTDIR/$tfile-0"
1116 local testfile1="$TESTDIR/$tfile-1"
1117 local testfile2="$TESTDIR/$tfile-2"
1118 local qpool1="qpool1"
1121 setup_quota_test || error "setup quota failed with $?"
1122 stack_trap cleanup_quota_test EXIT
1125 set_ost_qtype $QTYPE || error "enable ost quota failed"
1127 log "User quota (block hardlimit:$global_limit MB)"
1128 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
1129 error "set user quota failed"
1131 pool_add $qpool1 || error "pool_add failed"
1132 pool_add_targets $qpool1 0 0 ||
1133 error "pool_add_targets failed"
1135 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
1136 error "set user quota failed"
1138 # make sure the system is clean
1139 local used=$(getquota -u $TSTUSR global curspace)
1140 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1142 $LFS setstripe $TESTDIR -c 1 -i 0 || error "setstripe $TESTDIR failed"
1145 test_1_check_write $testfile "user" $limit1
1146 $LFS setquota -u $TSTUSR -B 0 --pool $qpool1 $DIR ||
1147 error "set user quota failed"
1149 $LFS quota -uv $TSTUSR --pool $qpool1 $DIR
1150 $RUNAS $DD of=$testfile1 count=$((limit1/2)) ||
1151 quota_error u $TSTUSR "write failure, but expect success"
1155 wait_delete_completed || error "wait_delete_completed failed"
1156 sync_all_data || true
1158 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
1159 error "set user quota failed"
1160 test_1_check_write $testfile "user" $limit1
1161 local tmp_limit=$(($limit1*2))
1162 # increase pool limit
1163 $LFS setquota -u $TSTUSR -B ${tmp_limit}M --pool $qpool1 $DIR ||
1164 error "set user quota failed"
1165 # now write shouldn't fail
1166 $RUNAS $DD of=$testfile1 count=$((limit1/3)) ||
1167 quota_error u $TSTUSR "write failure, but expect success"
1168 # decrease pool limit
1169 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
1170 error "set user quota failed"
1171 $RUNAS $DD of=$testfile2 count=$((limit1/3))
1172 # flush cache, ensure noquota flag is set on client
1173 cancel_lru_locks osc
1174 sync; sync_all_data || true
1175 $RUNAS $DD of=$testfile2 seek=$((limit1/3)) count=1 &&
1176 quota_error u $TSTUSR "write success, but expect failure"
1179 run_test 1i "Quota pools: different limit and usage relations"
1181 # test inode hardlimit
1183 local TESTFILE="$DIR/$tdir/$tfile-0"
1184 local LIMIT=$(do_facet mds1 $LCTL get_param -n \
1185 qmt.$FSNAME-QMT0000.md-0x0.info |
1186 awk '/least qunit/{ print $3 }')
1187 local L2=$(do_facet mds1 $LCTL get_param -n \
1188 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1190 [ $L2 -le $LIMIT ] || LIMIT=$L2
1192 [ "$SLOW" = "no" ] || LIMIT=$((LIMIT * 1024))
1194 local FREE_INODES=$(mdt_free_inodes 0)
1195 echo "$FREE_INODES free inodes on master MDT"
1196 [ $FREE_INODES -lt $LIMIT ] &&
1197 skip "not enough free inodes $FREE_INODES required $LIMIT"
1199 setup_quota_test || error "setup quota failed with $?"
1202 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1205 log "User quota (inode hardlimit:$LIMIT files)"
1206 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1207 error "set user quota failed"
1209 # make sure the system is clean
1210 local USED=$(getquota -u $TSTUSR global curinodes)
1211 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
1213 log "Create $LIMIT files ..."
1214 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1215 quota_error u $TSTUSR "user create failure, but expect success"
1216 log "Create out of file quota ..."
1217 $RUNAS touch ${TESTFILE}_xxx &&
1218 quota_error u $TSTUSR "user create success, but expect EDQUOT"
1221 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1222 rm -f ${TESTFILE}_xxx
1223 wait_delete_completed
1225 USED=$(getquota -u $TSTUSR global curinodes)
1226 [ $USED -ne 0 ] && quota_error u $TSTUSR \
1227 "user quota isn't released after deletion"
1228 resetquota -u $TSTUSR
1231 log "--------------------------------------"
1232 log "Group quota (inode hardlimit:$LIMIT files)"
1233 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1234 error "set group quota failed"
1236 TESTFILE=$DIR/$tdir/$tfile-1
1237 # make sure the system is clean
1238 USED=$(getquota -g $TSTUSR global curinodes)
1239 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
1241 log "Create $LIMIT files ..."
1242 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1243 quota_error g $TSTUSR "group create failure, but expect success"
1244 log "Create out of file quota ..."
1245 $RUNAS touch ${TESTFILE}_xxx &&
1246 quota_error g $TSTUSR "group create success, but expect EDQUOT"
1249 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1250 rm -f ${TESTFILE}_xxx
1251 wait_delete_completed
1253 USED=$(getquota -g $TSTUSR global curinodes)
1254 [ $USED -ne 0 ] && quota_error g $TSTUSR \
1255 "user quota isn't released after deletion"
1257 resetquota -g $TSTUSR
1258 ! is_project_quota_supported &&
1259 echo "Skip project quota is not supported" && return 0
1262 log "--------------------------------------"
1263 log "Project quota (inode hardlimit:$LIMIT files)"
1264 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1265 error "set project quota failed"
1267 TESTFILE=$DIR/$tdir/$tfile-1
1268 # make sure the system is clean
1269 USED=$(getquota -p $TSTPRJID global curinodes)
1271 error "Used inodes($USED) for project $TSTPRJID isn't 0"
1273 change_project -sp $TSTPRJID $DIR/$tdir
1274 log "Create $LIMIT files ..."
1275 $RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
1276 $TSTPRJID "project create fail, but expect success"
1277 log "Create out of file quota ..."
1278 $RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
1279 "project create success, but expect EDQUOT"
1280 change_project -C $DIR/$tdir
1283 USED=$(getquota -p $TSTPRJID global curinodes)
1284 [ $USED -eq 0 ] || quota_error p $TSTPRJID \
1285 "project quota isn't released after deletion"
1288 run_test 2 "File hard limit (normal use and out of quota)"
1297 local soft_limit=$(do_facet $SINGLEMDS $LCTL get_param -n \
1298 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit)
1302 $LFS setstripe $testfile -c 1 -i 0
1303 chown $TSTUSR.$TSTUSR $testfile
1304 [ "$qtype" == "p" ] && is_project_quota_supported &&
1305 change_project -p $TSTPRJID $testfile
1307 echo "Write up to soft limit"
1308 $RUNAS $DD of=$testfile count=$limit ||
1309 quota_error a $TSTUSR "write failure, but expect success"
1310 OFFSET=$((limit * 1024))
1311 cancel_lru_locks osc
1313 echo "Write to exceed soft limit"
1314 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1315 quota_error a $TSTUSR "write failure, but expect success"
1316 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
1317 cancel_lru_locks osc
1319 echo "mmap write when over soft limit"
1320 $RUNAS $MULTIOP $testfile.mmap OT40960SMW ||
1321 quota_error a $TSTUSR "mmap write failure, but expect success"
1322 cancel_lru_locks osc
1327 $SHOW_QUOTA_INFO_USER
1328 $SHOW_QUOTA_INFO_GROUP
1329 $SHOW_QUOTA_INFO_PROJID
1331 echo "Write before timer goes off"
1332 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1333 quota_error a $TSTUSR "write failure, but expect success"
1334 OFFSET=$((OFFSET + 1024))
1335 cancel_lru_locks osc
1337 wait_grace_time $qtype "block" $pool
1342 $SHOW_QUOTA_INFO_USER
1343 $SHOW_QUOTA_INFO_GROUP
1344 $SHOW_QUOTA_INFO_PROJID
1346 log "Write after timer goes off"
1347 # maybe cache write, ignore.
1348 # write up to soft least quint to consume all
1349 # possible slave granted space.
1350 $RUNAS dd if=/dev/zero of=$testfile bs=1K \
1351 count=$soft_limit seek=$OFFSET || true
1352 OFFSET=$((OFFSET + soft_limit))
1353 cancel_lru_locks osc
1354 log "Write after cancel lru locks"
1355 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET &&
1356 quota_error a $TSTUSR "write success, but expect EDQUOT"
1361 $SHOW_QUOTA_INFO_USER
1362 $SHOW_QUOTA_INFO_GROUP
1363 $SHOW_QUOTA_INFO_PROJID
1365 echo "Unlink file to stop timer"
1367 wait_delete_completed
1368 sync_all_data || true
1373 $SHOW_QUOTA_INFO_USER
1374 $SHOW_QUOTA_INFO_GROUP
1375 $SHOW_QUOTA_INFO_PROJID
1377 $LFS setstripe $testfile -c 1 -i 0
1378 chown $TSTUSR.$TSTUSR $testfile
1379 [ "$qtype" == "p" ] && change_project -p $TSTPRJID $testfile
1382 $RUNAS $DD of=$testfile count=$limit ||
1383 quota_error a $TSTUSR "write failure, but expect success"
1390 local grace=20 # seconds
1391 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1394 local testfile=$DIR/$tdir/$tfile-0
1396 # get minimum soft qunit size
1397 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1398 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1400 set_ost_qtype $QTYPE || error "enable ost quota failed"
1402 echo "User quota (soft limit:$limit MB grace:$grace seconds)"
1403 # make sure the system is clean
1404 local used=$(getquota -u $TSTUSR global curspace)
1405 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1407 $LFS setquota -t -u --block-grace $grace --inode-grace \
1408 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1409 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1410 error "set user quota failed"
1412 test_block_soft $testfile $grace $limit "u"
1414 echo "Group quota (soft limit:$limit MB grace:$grace seconds)"
1415 testfile=$DIR/$tdir/$tfile-1
1416 # make sure the system is clean
1417 used=$(getquota -g $TSTUSR global curspace)
1418 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1420 $LFS setquota -t -g --block-grace $grace --inode-grace \
1421 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1422 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1423 error "set group quota failed"
1425 test_block_soft $testfile $grace $limit "g"
1427 if is_project_quota_supported; then
1428 echo "Project quota (soft limit:$limit MB grace:$grace sec)"
1429 testfile=$DIR/$tdir/$tfile-2
1430 # make sure the system is clean
1431 used=$(getquota -p $TSTPRJID global curspace)
1432 [ $used -ne 0 ] && error \
1433 "Used space($used) for project $TSTPRJID isn't 0."
1435 $LFS setquota -t -p --block-grace $grace --inode-grace \
1436 $MAX_IQ_TIME $DIR ||
1437 error "set project grace time failed"
1438 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 -i 0 -I 0 \
1439 $DIR || error "set project quota failed"
1441 test_block_soft $testfile $grace $limit "p"
1442 resetquota -p $TSTPRJID
1443 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1444 $MAX_IQ_TIME $DIR ||
1445 error "restore project grace time failed"
1449 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1450 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1451 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1452 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1454 run_test 3a "Block soft limit (start timer, timer goes off, stop timer)"
1457 local grace=20 # seconds
1458 local qpool="qpool1"
1459 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1462 local testfile=$DIR/$tdir/$tfile-0
1465 # get minimum soft qunit size
1466 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1467 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1468 local glbl_limit=$((2*limit))
1469 local glbl_grace=$((2*grace))
1470 echo "limit $limit glbl_limit $glbl_limit"
1471 echo "grace $grace glbl_grace $glbl_grace"
1473 set_ost_qtype $QTYPE || error "enable ost quota failed"
1475 echo "User quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1476 # make sure the system is clean
1477 local used=$(getquota -u $TSTUSR global curspace)
1478 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1480 pool_add $qpool || error "pool_add failed"
1481 pool_add_targets $qpool 0 1 ||
1482 error "pool_add_targets failed"
1484 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1485 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1486 $LFS setquota -t -u --block-grace $grace \
1487 --pool $qpool $DIR || error "set user grace time failed"
1489 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1490 error "set user quota failed"
1491 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1492 error "set user quota failed"
1494 test_block_soft $testfile $grace $limit "u" $qpool
1496 echo "Group quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1497 testfile=$DIR/$tdir/$tfile-1
1498 # make sure the system is clean
1499 used=$(getquota -g $TSTUSR global curspace)
1500 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1502 $LFS setquota -t -g --block-grace $glbl_grace --inode-grace \
1503 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1504 $LFS setquota -t -g --block-grace $grace \
1505 --pool $qpool $DIR || error "set group grace time failed"
1507 $LFS setquota -g $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1508 error "set group quota failed"
1509 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1510 error "set group quota failed"
1512 test_block_soft $testfile $grace $limit "g" $qpool
1514 if is_project_quota_supported; then
1515 echo "Project quota in $qpool(soft:$limit MB grace:$grace sec)"
1516 testfile=$DIR/$tdir/$tfile-2
1517 # make sure the system is clean
1518 used=$(getquota -p $TSTPRJID global curspace)
1519 [ $used -ne 0 ] && error \
1520 "Used space($used) for project $TSTPRJID isn't 0."
1522 $LFS setquota -t -p --block-grace $glbl_grace --inode-grace \
1523 $MAX_IQ_TIME $DIR ||
1524 error "set project grace time failed"
1525 $LFS setquota -t -p --block-grace $grace \
1526 --pool $qpool $DIR ||
1527 error "set project grace time failed"
1529 $LFS setquota -p $TSTPRJID -b ${glbl_limit}M -B 0 -i 0 -I 0 \
1530 $DIR || error "set project quota failed"
1531 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 \
1532 --pool $qpool $DIR || error "set project quota failed"
1534 test_block_soft $testfile $grace $limit "p" $qpool
1535 resetquota -p $TSTPRJID
1536 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1537 $MAX_IQ_TIME $DIR ||
1538 error "restore project grace time failed"
1539 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --pool $qpool \
1540 $DIR || error "set project grace time failed"
1544 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1545 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1546 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1547 --pool $qpool $DIR || error "restore user grace time failed"
1548 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1549 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1550 $LFS setquota -t -g --block-grace $MAX_DQ_TIME \
1551 --pool $qpool $DIR || error "restore group grace time failed"
1553 run_test 3b "Quota pools: Block soft limit (start timer, expires, stop timer)"
1556 local grace=20 # seconds
1557 local qpool="qpool1"
1558 local qpool2="qpool2"
1559 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1562 local testfile=$DIR/$tdir/$tfile-0
1565 # get minimum soft qunit size
1566 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1567 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1568 local limit2=$((limit+4))
1569 local glbl_limit=$((limit+8))
1570 local grace1=$((grace+10))
1572 local glbl_grace=$((grace+20))
1573 echo "limit $limit limit2 $limit2 glbl_limit $glbl_limit"
1574 echo "grace1 $grace1 grace2 $grace2 glbl_grace $glbl_grace"
1576 set_ost_qtype $QTYPE || error "enable ost quota failed"
1578 echo "User quota in qpool2(soft:$limit2 MB grace:$grace2 seconds)"
1579 # make sure the system is clean
1580 local used=$(getquota -u $TSTUSR global curspace)
1581 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1583 pool_add $qpool || error "pool_add failed"
1584 pool_add_targets $qpool 0 1 ||
1585 error "pool_add_targets failed"
1587 pool_add $qpool2 || error "pool_add failed"
1588 pool_add_targets $qpool2 0 1 ||
1589 error "pool_add_targets failed"
1592 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1593 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1594 $LFS setquota -t -u --block-grace $grace1 \
1595 --pool $qpool $DIR || error "set user grace time failed"
1596 $LFS setquota -t -u --block-grace $grace2 \
1597 --pool $qpool2 $DIR || error "set user grace time failed"
1599 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1600 error "set user quota failed"
1601 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1602 error "set user quota failed"
1603 # qpool has minimum soft limit, but its grace is greater than
1604 # the grace period of qpool2. Thus write shouldn't fail when
1605 # hit qpool soft limit - only when reaches up qpool2 limit
1606 # after grace2 seconds.
1607 $LFS setquota -u $TSTUSR -b ${limit2}M -B 0 --pool $qpool2 $DIR ||
1608 error "set user quota failed"
1610 test_block_soft $testfile $grace2 $limit2 "u" $qpool2
1613 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1614 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1615 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1616 --pool $qpool $DIR || error "restore user grace time failed"
1617 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1618 --pool $qpool2 $DIR || error "restore user grace time failed"
1620 run_test 3c "Quota pools: check block soft limit on different pools"
1627 local SOFT_LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1628 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1631 is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
1633 echo "Create files to exceed soft limit"
1634 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
1635 quota_error a $TSTUSR "create failure, but expect success"
1636 local trigger_time=$(date +%s)
1638 sync_all_data || true
1640 local cur_time=$(date +%s)
1641 [ $(($cur_time - $trigger_time)) -ge $grace ] &&
1642 error "Passed grace time $grace, $trigger_time, $cur_time"
1644 echo "Create file before timer goes off"
1645 $RUNAS touch ${TESTFILE}_before ||
1646 quota_error a $TSTUSR "failed create before timer expired," \
1647 "but expect success. $trigger_time, $cur_time"
1648 sync_all_data || true
1650 wait_grace_time $qtype "file"
1655 $SHOW_QUOTA_INFO_USER
1656 $SHOW_QUOTA_INFO_GROUP
1657 $SHOW_QUOTA_INFO_PROJID
1659 echo "Create file after timer goes off"
1660 # exceed least soft limit is possible
1661 $RUNAS createmany -m ${TESTFILE}_after_3 $((SOFT_LIMIT + 1)) &&
1662 quota_error a $TSTUSR "create after timer expired," \
1664 sync_all_data || true
1669 $SHOW_QUOTA_INFO_USER
1670 $SHOW_QUOTA_INFO_GROUP
1671 $SHOW_QUOTA_INFO_PROJID
1673 echo "Unlink files to stop timer"
1674 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
1675 wait_delete_completed
1678 $RUNAS touch ${TESTFILE}_xxx ||
1679 quota_error a $TSTUSR "touch after timer stop failure," \
1680 "but expect success"
1681 sync_all_data || true
1689 local LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1690 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1691 local TESTFILE=$DIR/$tdir/$tfile-0
1694 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1696 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1697 # make sure the system is clean
1698 local USED=$(getquota -u $TSTUSR global curinodes)
1699 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1701 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1702 $GRACE $DIR || error "set user grace time failed"
1703 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1704 error "set user quota failed"
1706 [ "$mds1_FSTYPE" = zfs ] && GRACE=20
1708 test_file_soft $TESTFILE $LIMIT $GRACE "u"
1710 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1711 # make sure the system is clean
1712 USED=$(getquota -g $TSTUSR global curinodes)
1713 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
1715 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1716 $GRACE $DIR || error "set group grace time failed"
1717 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1718 error "set group quota failed"
1719 TESTFILE=$DIR/$tdir/$tfile-1
1721 test_file_soft $TESTFILE $LIMIT $GRACE "g"
1723 if is_project_quota_supported; then
1724 echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)"
1725 # make sure the system is clean
1726 USED=$(getquota -p $TSTPRJID global curinodes)
1727 [ $USED -ne 0 ] && error \
1728 "Used space($USED) for project $TSTPRJID isn't 0."
1730 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1731 $GRACE $DIR || error "set project grace time failed"
1732 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1733 error "set project quota failed"
1735 TESTFILE=$DIR/$tdir/$tfile-1
1736 # one less than limit, because of parent directory included.
1737 test_file_soft $TESTFILE $((LIMIT-1)) $GRACE "p"
1738 resetquota -p $TSTPRJID
1739 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1740 $MAX_IQ_TIME $DIR ||
1741 error "restore project grace time failed"
1745 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1746 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1747 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1748 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1750 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
1753 local GR_STR1="1w3d"
1754 local GR_STR2="1000s"
1756 local GR_STR4="1w2d3h4m5s"
1758 local GR_STR6="18446744073709551615"
1761 wait_delete_completed
1763 # test of valid grace strings handling
1764 echo "Valid grace strings test"
1765 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
1766 $GR_STR2 $DIR || error "set user grace time failed"
1767 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
1768 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
1769 $GR_STR4 $DIR || error "set group grace time quota failed"
1770 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
1772 # test of invalid grace strings handling
1773 echo " Invalid grace strings test"
1774 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
1775 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
1776 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \
1780 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1781 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1782 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1783 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1785 run_test 4b "Grace time strings handling"
1787 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
1789 local BLIMIT=10 # MB
1790 local ILIMIT=10 # inodes
1792 setup_quota_test || error "setup quota failed with $?"
1794 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1795 set_ost_qtype $QTYPE || error "enable ost quota failed"
1797 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
1798 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1799 error "set user quota failed"
1800 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1801 if is_project_quota_supported; then
1802 error "set group quota failed"
1803 $LFS setquota -p $TSTPRJID -b 0 -B ${BLIMIT}M -i 0 \
1804 -I $ILIMIT $DIR || error "set project quota failed"
1807 # make sure the system is clean
1808 local USED=$(getquota -u $TSTUSR global curinodes)
1809 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1810 USED=$(getquota -g $TSTUSR global curinodes)
1811 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
1812 USED=$(getquota -u $TSTUSR global curspace)
1813 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
1814 USED=$(getquota -g $TSTUSR global curspace)
1815 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
1816 if is_project_quota_supported; then
1817 USED=$(getquota -p $TSTPRJID global curinodes)
1819 error "Used inode($USED) for project $TSTPRJID isn't 0."
1820 USED=$(getquota -p $TSTPRJID global curspace)
1822 error "Used block($USED) for project $TSTPRJID isn't 0."
1825 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
1826 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1827 error "create failure, expect success"
1828 if is_project_quota_supported; then
1829 touch $DIR/$tdir/$tfile-0_1
1830 change_project -p $TSTPRJID $DIR/$tdir/$tfile-0_1
1832 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
1833 error "write failure, expect success"
1835 echo "Chown files to $TSTUSR.$TSTUSR ..."
1836 for i in $(seq 0 $ILIMIT); do
1837 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
1838 quota_error a $TSTUSR "chown failure, expect success"
1842 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1843 error "unlinkmany $DIR/$tdir/$tfile-0_ failed"
1845 run_test 5 "Chown & chgrp successfully even out of block/file quota"
1847 # test dropping acquire request on master
1851 # Clear dmesg so watchdog is not triggered by previous
1853 do_facet ost1 dmesg -c > /dev/null
1855 setup_quota_test || error "setup quota failed with $?"
1857 # make sure the system is clean
1858 local USED=$(getquota -u $TSTUSR global curspace)
1859 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1861 # make sure no granted quota on ost
1862 set_ost_qtype $QTYPE || error "enable ost quota failed"
1863 resetquota -u $TSTUSR
1865 # create file for $TSTUSR
1866 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
1867 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1868 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1870 # create file for $TSTUSR2
1871 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
1872 $LFS setstripe $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed"
1873 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed"
1875 # cache per-ID lock for $TSTUSR on slave
1876 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1877 error "set quota failed"
1878 $RUNAS $DD of=$TESTFILE count=1 ||
1879 error "write $TESTFILE failure, expect success"
1880 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
1881 error "write $TESTFILE2 failure, expect success"
1883 if at_is_enabled; then
1884 at_max_saved=$(at_max_get ost1)
1885 at_max_set $TIMEOUT ost1
1887 # write to enforced ID ($TSTUSR) to exceed limit to make sure
1888 # DQACQ is sent, which makes at_max to take effect
1889 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync \
1892 wait_delete_completed
1896 sync_all_data || true
1898 #define QUOTA_DQACQ 601
1899 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
1900 lustre_fail mds 0x513 601
1902 do_facet ost1 $LCTL set_param \
1903 osd-*.$FSNAME-OST*.quota_slave.timeout=$((TIMEOUT / 2))
1905 # write to un-enforced ID ($TSTUSR2) should succeed
1906 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
1907 error "write failure, expect success"
1909 # write to enforced ID ($TSTUSR) in background, exceeding limit
1910 # to make sure DQACQ is sent
1911 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
1914 # watchdog timer uses a factor of 2
1915 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
1916 sleep $((TIMEOUT * 2 + 1))
1918 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
1920 # write should be blocked and never finished
1921 if ! ps -p $DDPID > /dev/null 2>&1; then
1923 error "write finished incorrectly!"
1928 # no watchdog is triggered
1929 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1930 watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
1931 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1932 [ -z "$watchdog" ] || error "$watchdog"
1934 rm -f $TMP/lustre-log-${TESTNAME}.log
1936 # write should continue then fail with EDQUOT
1940 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1941 if [ $count -ge 240 ]; then
1942 quota_error u $TSTUSR "dd not finished in $count secs"
1944 count=$((count + 1))
1945 if [ $((count % 30)) -eq 0 ]; then
1946 c_size=$(stat -c %s $TESTFILE)
1947 echo "Waiting $count secs. $c_size"
1953 run_test 6 "Test dropping acquire request on master"
1955 # quota reintegration (global index)
1957 local TESTFILE=$DIR/$tdir/$tfile
1960 [ "$SLOW" = "no" ] && LIMIT=5
1962 setup_quota_test || error "setup quota failed with $?"
1964 # make sure the system is clean
1965 local USED=$(getquota -u $TSTUSR global curspace)
1966 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1968 # make sure no granted quota on ost1
1969 set_ost_qtype $QTYPE || error "enable ost quota failed"
1970 resetquota -u $TSTUSR
1971 set_ost_qtype "none" || error "disable ost quota failed"
1973 local OSTUUID=$(ostuuid_from_index 0)
1974 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1976 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1979 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1980 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1985 echo "Enable quota & set quota limit for $TSTUSR"
1986 set_ost_qtype $QTYPE || error "enable ost quota failed"
1987 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1988 error "set quota failed"
1990 echo "Start ost1..."
1991 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1994 wait_ost_reint $QTYPE || error "reintegration failed"
1996 # hardlimit should have been fetched by slave during global
1997 # reintegration, write will exceed quota
1998 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1999 quota_error u $TSTUSR "write success, but expect EDQUOT"
2002 wait_delete_completed
2003 sync_all_data || true
2009 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
2010 error "clear quota failed"
2012 echo "Start ost1..."
2013 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
2016 wait_ost_reint $QTYPE || error "reintegration failed"
2018 # hardlimit should be cleared on slave during reintegration
2019 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
2020 quota_error u $TSTUSR "write error, but expect success"
2022 run_test 7a "Quota reintegration (global index)"
2024 # quota reintegration (slave index)
2026 local limit=100000 # MB
2027 local TESTFILE=$DIR/$tdir/$tfile
2029 setup_quota_test || error "setup quota failed with $?"
2031 # make sure the system is clean
2032 local USED=$(getquota -u $TSTUSR global curspace)
2033 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2035 # make sure no granted quota on ost1
2036 set_ost_qtype $QTYPE || error "enable ost quota failed"
2037 resetquota -u $TSTUSR
2038 set_ost_qtype "none" || error "disable ost quota failed"
2040 local OSTUUID=$(ostuuid_from_index 0)
2041 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2043 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
2046 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2047 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2049 # consume some space to make sure the granted space will not
2050 # be released during reconciliation
2051 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2052 error "consume space failure, expect success"
2054 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
2055 lustre_fail mds 0xa02
2057 set_ost_qtype $QTYPE || error "enable ost quota failed"
2058 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
2059 error "set quota failed"
2061 # ignore the write error
2062 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
2064 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2068 echo "Restart ost to trigger reintegration..."
2070 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
2073 wait_ost_reint $QTYPE || error "reintegration failed"
2075 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2076 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
2081 run_test 7b "Quota reintegration (slave index)"
2083 # quota reintegration (restart mds during reintegration)
2086 local TESTFILE=$DIR/$tdir/$tfile
2088 [ "$SLOW" = "no" ] && LIMIT=5
2090 setup_quota_test || error "setup quota failed with $?"
2092 # make sure the system is clean
2093 local USED=$(getquota -u $TSTUSR global curspace)
2094 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2096 set_ost_qtype "none" || error "disable ost quota failed"
2097 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
2098 error "set quota failed"
2100 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
2101 lustre_fail ost 0xa03
2104 set_ost_qtype $QTYPE || error "enable ost quota failed"
2105 # trigger reintegration
2106 local procf="osd-$ost1_FSTYPE.$FSNAME-OST*."
2107 procf=${procf}quota_slave.force_reint
2108 do_facet ost1 $LCTL set_param $procf=1 ||
2109 error "force reintegration failed"
2117 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
2120 # wait longer than usual to make sure the reintegration
2121 # is triggered by quota wb thread.
2122 wait_ost_reint $QTYPE 200 || error "reintegration failed"
2124 # hardlimit should have been fetched by slave during global
2125 # reintegration, write will exceed quota
2126 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
2127 quota_error u $TSTUSR "write success, but expect EDQUOT"
2130 run_test 7c "Quota reintegration (restart mds during reintegration)"
2132 # Quota reintegration (Transfer index in multiple bulks)
2134 local TESTFILE=$DIR/$tdir/$tfile
2135 local TESTFILE1="$DIR/$tdir/$tfile"-1
2138 setup_quota_test || error "setup quota failed with $?"
2140 set_ost_qtype "none" || error "disable ost quota failed"
2141 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
2142 error "set quota for $TSTUSR failed"
2143 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
2144 error "set quota for $TSTUSR2 failed"
2146 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
2147 lustre_fail mds 0x608 0
2149 # enable quota to tirgger reintegration
2150 set_ost_qtype "u" || error "enable ost quota failed"
2151 wait_ost_reint "u" || error "reintegration failed"
2155 # hardlimit should have been fetched by slave during global
2156 # reintegration, write will exceed quota
2157 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
2158 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
2160 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
2161 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
2164 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
2166 # quota reintegration (inode limits)
2168 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2170 # LU-2435: skip this quota test if underlying zfs version has not
2171 # supported native dnode accounting
2172 [ "$mds1_FSTYPE" == zfs ] && {
2173 local F="feature@userobj_accounting"
2174 local pool=$(zpool_name mds1)
2175 local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
2177 [[ "$feature" != *" active "* ]] &&
2178 skip "requires zpool with active userobj_accounting"
2181 local ilimit=$((1024 * 2)) # inodes
2182 local TESTFILE=$DIR/${tdir}-1/$tfile
2184 setup_quota_test || error "setup quota failed with $?"
2186 # make sure the system is clean
2187 local USED=$(getquota -u $TSTUSR global curinodes)
2188 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
2190 # make sure no granted quota on mdt1
2191 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2192 resetquota -u $TSTUSR
2193 set_mdt_qtype "none" || error "disable mdt quota failed"
2195 local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
2196 USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
2197 [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
2200 echo "Stop mds${MDSCOUNT}..."
2203 echo "Enable quota & set quota limit for $TSTUSR"
2204 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2205 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2206 error "set 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 echo "create remote dir"
2215 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
2216 error "create remote dir failed"
2217 chmod 0777 $DIR/${tdir}-1
2219 # hardlimit should have been fetched by slave during global
2220 # reintegration, create will exceed quota
2221 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
2222 quota_error u $TSTUSR "create succeeded, expect EDQUOT"
2224 $RUNAS unlinkmany $TESTFILE $ilimit || error "unlink files failed"
2225 wait_delete_completed
2226 sync_all_data || true
2228 echo "Stop mds${MDSCOUNT}..."
2231 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
2232 error "clear quota failed"
2234 echo "Start mds${MDSCOUNT}..."
2235 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
2238 wait_mdt_reint $QTYPE || error "reintegration failed"
2240 # hardlimit should be cleared on slave during reintegration
2241 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
2242 quota_error u $TSTUSR "create failed, expect success"
2244 $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
2245 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2247 run_test 7e "Quota reintegration (inode limits)"
2249 # run dbench with quota enabled
2251 local BLK_LIMIT="100g" #100G
2252 local FILE_LIMIT=1000000
2254 setup_quota_test || error "setup quota failed with $?"
2256 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2257 set_ost_qtype $QTYPE || error "enable ost quota failed"
2259 echo "Set enough high limit for user: $TSTUSR"
2260 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2261 error "set user quota failed"
2262 echo "Set enough high limit for group: $TSTUSR"
2263 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2264 error "set group quota failed"
2265 if is_project_quota_supported; then
2266 change_project -sp $TSTPRJID $DIR/$tdir
2267 echo "Set enough high limit for project: $TSTPRJID"
2268 $LFS setquota -p $TSTPRJID -b 0 \
2269 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2270 error "set project quota failed"
2274 [ "$SLOW" = "no" ] && duration=" -t 120"
2275 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
2276 quota_error a $TSTUSR "dbench failed!"
2278 is_project_quota_supported && change_project -C $DIR/$tdir
2280 run_test 8 "Run dbench with quota enabled"
2282 # this check is just for test_9
2283 OST0_MIN=4900000 #4.67G
2285 check_whether_skip () {
2286 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
2287 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
2288 if [ $OST0_SIZE -lt $OST0_MIN ]; then
2289 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
2296 # run for fixing bug10707, it needs a big room. test for 64bit
2298 local filesize=$((1024 * 9 / 2)) # 4.5G
2300 check_whether_skip && return 0
2302 setup_quota_test || error "setup quota failed with $?"
2304 set_ost_qtype "ug" || error "enable ost quota failed"
2306 local TESTFILE="$DIR/$tdir/$tfile-0"
2307 local BLK_LIMIT=100G #100G
2308 local FILE_LIMIT=1000000
2310 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
2312 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2314 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2315 error "set user quota failed"
2317 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2318 "for group: $TSTUSR"
2319 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2320 error "set group quota failed"
2322 quota_show_check a u $TSTUSR
2323 quota_show_check a g $TSTUSR
2325 echo "Create test file"
2326 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2327 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2329 log "Write the big file of 4.5G ..."
2330 $RUNAS $DD of=$TESTFILE count=$filesize ||
2331 quota_error a $TSTUSR "write 4.5G file failure, expect success"
2341 run_test 9 "Block limit larger than 4GB (b10707)"
2344 local TESTFILE=$DIR/$tdir/$tfile
2346 setup_quota_test || error "setup quota failed with $?"
2348 # set limit to root user should fail
2349 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
2350 error "set limit for root user successfully, expect failure"
2351 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
2352 error "set limit for root group successfully, expect failure"
2353 $LFS setquota -p 0 -b 1T -B 10T -i 5K -I 100M $DIR &&
2354 error "set limit for project 0 successfully, expect failure"
2356 # root user can overrun quota
2357 set_ost_qtype "ug" || error "enable ost quota failed"
2359 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
2360 error "set quota failed"
2361 quota_show_check b u $TSTUSR
2363 $LFS setstripe $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
2364 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2366 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
2367 error "write failure, expect success"
2369 run_test 10 "Test quota for root user"
2372 local TESTFILE=$DIR/$tdir/$tfile
2373 setup_quota_test || error "setup quota failed with $?"
2375 set_mdt_qtype "ug" || error "enable mdt quota failed"
2376 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
2377 error "set quota failed"
2379 touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed"
2380 touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed"
2382 chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed"
2383 chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed"
2386 local USED=$(getquota -u $TSTUSR global curinodes)
2387 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
2389 run_test 11 "Chown/chgrp ignores quota"
2392 [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs"
2394 local blimit=22 # MB
2395 local blk_cnt=$((blimit - 5))
2396 local TESTFILE0="$DIR/$tdir/$tfile"-0
2397 local TESTFILE1="$DIR/$tdir/$tfile"-1
2399 setup_quota_test || error "setup quota failed with $?"
2401 set_ost_qtype "u" || error "enable ost quota failed"
2402 quota_show_check b u $TSTUSR
2404 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $DIR ||
2405 error "set quota failed"
2407 $LFS setstripe $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed"
2408 $LFS setstripe $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed"
2409 chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed"
2410 chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed"
2412 echo "Write to ost0..."
2413 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
2414 quota_error a $TSTUSR "dd failed"
2416 echo "Write to ost1..."
2417 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
2418 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
2420 echo "Free space from ost0..."
2422 wait_delete_completed
2423 sync_all_data || true
2425 echo "Write to ost1 after space freed from ost0..."
2426 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
2427 quota_error a $TSTUSR "rebalancing failed"
2429 run_test 12a "Block quota rebalancing"
2432 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2434 local ilimit=$((1024 * 2)) # inodes
2435 local TESTFILE0=$DIR/$tdir/$tfile
2436 local TESTFILE1=$DIR/${tdir}-1/$tfile
2438 setup_quota_test || error "setup quota failed with $?"
2440 $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed"
2441 chmod 0777 $DIR/${tdir}-1
2443 set_mdt_qtype "u" || error "enable mdt quota failed"
2444 quota_show_check f u $TSTUSR
2446 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2447 error "set quota failed"
2449 echo "Create $ilimit files on mdt0..."
2450 $RUNAS createmany -m $TESTFILE0 $ilimit ||
2451 quota_error u $TSTUSR "create failed, but expect success"
2453 echo "Create files on mdt1..."
2454 $RUNAS createmany -m $TESTFILE1 1 &&
2455 quota_error a $TSTUSR "create succeeded, expect EDQUOT"
2457 echo "Free space from mdt0..."
2458 $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed"
2459 wait_delete_completed
2460 sync_all_data || true
2462 echo "Create files on mdt1 after space freed from mdt0..."
2463 $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) ||
2464 quota_error a $TSTUSR "rebalancing failed"
2466 $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) ||
2467 error "unlink mdt1 files failed"
2468 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2470 run_test 12b "Inode quota rebalancing"
2473 local TESTFILE=$DIR/$tdir/$tfile
2474 # the name of lwp on ost1 name is MDT0000-lwp-OST0000
2475 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size"
2477 setup_quota_test || error "setup quota failed with $?"
2479 set_ost_qtype "u" || error "enable ost quota failed"
2480 quota_show_check b u $TSTUSR
2482 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2483 error "set quota failed"
2484 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2485 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2487 # clear the locks in cache first
2488 do_facet ost1 $LCTL set_param -n $procf=clear
2489 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2490 [ $nlock -eq 0 ] || error "$nlock cached locks"
2492 # write to acquire the per-ID lock
2493 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2494 quota_error a $TSTUSR "dd failed"
2496 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2497 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
2499 # clear quota doesn't trigger per-ID lock cancellation
2500 resetquota -u $TSTUSR
2501 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2502 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
2504 # clear the per-ID lock
2505 do_facet ost1 $LCTL set_param -n $procf=clear
2506 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2507 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
2509 # spare quota should be released
2510 local OSTUUID=$(ostuuid_from_index 0)
2511 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2512 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
2513 [ $limit -le $space ] ||
2514 error "spare quota isn't released, limit:$limit, space:$space"
2516 run_test 13 "Cancel per-ID lock in the LRU list"
2519 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
2521 wait_delete_completed
2522 sync_all_data || true
2525 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2526 error "set user quota failed"
2527 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
2528 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2529 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2530 resetquota -u $TSTUSR
2533 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2534 error "set group quota failed"
2535 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
2536 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2537 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2538 resetquota -g $TSTUSR
2540 run_test 15 "Set over 4T block quota"
2544 local BLKS=1 # 1M less than limit
2545 local TESTFILE=$DIR/$tdir/$tfile
2547 setup_quota_test || error "setup quota failed with $?"
2549 # make sure the system is clean
2550 local USED=$(getquota -u $TSTUSR global curspace)
2551 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2553 set_ost_qtype "ug" || error "enable ost quota failed"
2554 # make sure no granted quota on ost
2555 resetquota -u $TSTUSR
2556 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2557 error "set quota failed"
2559 quota_show_check b u $TSTUSR
2561 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
2562 lustre_fail mds 0xa04 $err_code
2564 # write in background
2565 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
2569 # write should be blocked and never finished
2570 if ! ps -p $DDPID > /dev/null 2>&1; then
2572 quota_error u $TSTUSR "write finished incorrectly!"
2580 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2582 if [ $count -gt $timeout ]; then
2583 quota_error u $TSTUSR "dd is not finished!"
2588 sync; sync_all_data || true
2590 USED=$(getquota -u $TSTUSR global curspace)
2591 [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \
2592 "Used space(${USED}K) is less than ${BLKS}M"
2597 # DQACQ return recoverable error
2599 echo "DQACQ return -ENOLCK"
2601 test_17sub 37 || error "Handle -ENOLCK failed"
2603 echo "DQACQ return -EAGAIN"
2605 test_17sub 11 || error "Handle -EAGAIN failed"
2607 echo "DQACQ return -ETIMEDOUT"
2608 #define ETIMEDOUT 110
2609 test_17sub 110 || error "Handle -ETIMEDOUT failed"
2611 echo "DQACQ return -ENOTCONN"
2612 #define ENOTCONN 107
2613 test_17sub 107 || error "Handle -ENOTCONN failed"
2616 run_test 17 "DQACQ return recoverable error"
2620 local blimit=200 # MB
2621 local TESTFILE="$DIR/$tdir/$tfile"
2623 setup_quota_test || error "setup quota failed with $?"
2625 set_ost_qtype "u" || error "enable ost quota failed"
2626 log "User quota (limit: $blimit)"
2627 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2628 error "set quota failed"
2629 quota_show_check b u $TSTUSR
2631 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
2632 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2634 local timeout=$(sysctl -n lustre.timeout)
2636 if [ $io_type = "directio" ]; then
2637 log "Write 100M (directio) ..."
2638 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
2640 log "Write 100M (buffered) ..."
2641 $RUNAS $DD of=$TESTFILE count=100 &
2645 replay_barrier $SINGLEMDS
2646 log "Fail mds for $((2 * timeout)) seconds"
2647 fail $SINGLEMDS $((2 * timeout))
2650 if at_is_enabled; then
2651 timeout=$(at_max_get mds)
2653 timeout=$(lctl get_param -n timeout)
2657 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2658 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
2659 log "it took $count second"
2664 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
2666 cancel_lru_locks mdc
2667 cancel_lru_locks osc
2670 local testfile_size=$(stat -c %s $TESTFILE)
2671 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
2672 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \
2673 "got ${testfile_size}. Verifying file failed!"
2678 # test when mds does failover, the ost still could work well
2679 # this test shouldn't trigger watchdog b=14840
2681 # Clear dmesg so watchdog is not triggered by previous
2683 do_facet ost1 dmesg -c > /dev/null
2686 test_18_sub directio
2688 # check if watchdog is triggered
2689 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
2690 local watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
2691 { print; }' $TMP/lustre-log-${TESTNAME}.log)
2692 [ -z "$watchdog" ] || error "$watchdog"
2693 rm -f $TMP/lustre-log-${TESTNAME}.log
2695 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
2699 local TESTFILE=$DIR/$tdir/$tfile
2701 setup_quota_test || error "setup quota failed with $?"
2703 set_ost_qtype $QTYPE || error "enable ost quota failed"
2705 # bind file to a single OST
2706 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2707 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2709 echo "Set user quota (limit: ${blimit}M)"
2710 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2711 error "set user quota failed"
2712 quota_show_check b u $TSTUSR
2713 echo "Update quota limits"
2714 $LFS setquota -u $TSTUSR -b 0 -B ${blimit}M -i 0 -I 0 $MOUNT ||
2715 error "set group quota failed"
2716 quota_show_check b u $TSTUSR
2718 # first wirte might be cached
2719 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
2720 cancel_lru_locks osc
2722 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
2723 quota_error u $TSTUSR "Write success, expect failure"
2726 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
2728 test_20() { # b15754
2729 local LSTR=(2g 1t 4k 3m) # limits strings
2731 local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \
2734 resetquota -u $TSTUSR
2736 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
2737 $MOUNT || error "could not set quota limits"
2738 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
2739 --inode-softlimit ${LSTR[2]} \
2740 --inode-hardlimit ${LSTR[3]} \
2741 $MOUNT || error "could not set quota limits"
2743 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
2744 error "bsoftlimit was not set properly"
2745 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
2746 error "bhardlimit was not set properly"
2747 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
2748 error "isoftlimit was not set properly"
2749 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
2750 error "ihardlimit was not set properly"
2752 resetquota -u $TSTUSR
2754 run_test 20 "Test if setquota specifiers work properly (b15754)"
2761 local time=$(($(date +%s) + seconds))
2762 while [ $(date +%s) -lt $time ]; do
2763 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
2767 # run for fixing bug16053, setquota shouldn't fail when writing and
2768 # deleting are happening
2770 local TESTFILE="$DIR/$tdir/$tfile"
2771 local BLIMIT=10 # 10G
2772 local ILIMIT=1000000
2774 setup_quota_test || error "setup quota failed with $?"
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"
2839 run_test 21 "Setquota while writing & deleting (b16053)"
2841 # enable/disable quota enforcement permanently
2843 echo "Set both mdt & ost quota type as ug"
2845 is_project_quota_supported && qtype=$QTYPE
2846 set_mdt_qtype $qtype || error "enable mdt quota failed"
2847 set_ost_qtype $qtype || error "enable ost quota failed"
2850 stopall || error "failed to stopall (1)"
2854 echo "Verify if quota is enabled"
2855 local qtype1=$(mdt_quota_type)
2856 [ $qtype1 != $qtype ] && error "mdt quota setting is lost"
2857 qtype=$(ost_quota_type)
2858 [ $qtype1 != $qtype ] && error "ost quota setting is lost"
2860 echo "Set both mdt & ost quota type as none"
2861 set_mdt_qtype "none" || error "disable mdt quota failed"
2862 set_ost_qtype "none" || error "disable ost quota failed"
2865 stopall || error "failed to stopall (2)"
2870 echo "Verify if quota is disabled"
2871 qtype=$(mdt_quota_type)
2872 [ $qtype != "none" ] && error "mdt quota setting is lost"
2873 qtype=$(ost_quota_type)
2874 [ $qtype != "none" ] && error "ost quota setting is lost"
2878 run_test 22 "enable/disable quota by 'lctl conf_param/set_param -P'"
2881 local TESTFILE="$DIR/$tdir/$tfile"
2884 setup_quota_test || error "setup quota failed with $?"
2886 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2889 log "User quota (limit: $LIMIT MB)"
2890 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
2891 error "set quota failed"
2892 quota_show_check b u $TSTUSR
2894 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2895 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2897 log "Step1: trigger EDQUOT with O_DIRECT"
2898 log "Write half of file"
2899 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
2900 quota_error u $TSTUSR "(1) Write failure, expect success." \
2902 log "Write out of block quota ..."
2903 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
2904 oflag=direct conv=notrunc &&
2905 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
2909 log "Step2: rewrite should succeed"
2910 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
2911 quota_error u $TSTUSR "(3) Write failure, expect success." \
2917 local OST0_UUID=$(ostuuid_from_index 0)
2918 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
2919 [ $OST0_QUOTA_USED -ne 0 ] &&
2920 ($SHOW_QUOTA_USER; \
2921 quota_error u $TSTUSR "quota isn't released")
2926 [ "$ost1_FSTYPE" == zfs ] &&
2927 skip "Overwrite in place is not guaranteed to be " \
2928 "space neutral on ZFS"
2930 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
2931 check_whether_skip && return 0
2932 log "run for 4MB test file"
2935 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
2936 check_whether_skip && return 0
2937 log "run for 40MB test file"
2940 run_test 23 "Quota should be honored with directIO (b16125)"
2944 local TESTFILE="$DIR/$tdir/$tfile"
2946 setup_quota_test || error "setup quota failed with $?"
2948 set_ost_qtype $QTYPE || error "enable ost quota failed"
2950 # bind file to a single OST
2951 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2952 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2954 echo "Set user quota (limit: ${blimit}M)"
2955 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2956 error "set quota failed"
2958 # overrun quota by root user
2959 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
2960 error "write failure, expect success"
2961 cancel_lru_locks osc
2962 sync_all_data || true
2964 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
2966 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
2968 test_27a() { # b19612
2969 $LFS quota $TSTUSR $DIR &&
2970 error "lfs succeeded with no type, but should have failed"
2971 $LFS setquota $TSTUSR $DIR &&
2972 error "lfs succeeded with no type, but should have failed"
2975 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
2977 test_27b() { # b20200
2978 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2979 error "lfs setquota failed with uid argument"
2980 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2981 error "lfs stequota failed with gid argument"
2982 if is_project_quota_supported; then
2983 $LFS setquota -p $TSTPRJID -b 1000 -B 1000 -i 1000 -I \
2984 1000 $DIR || error \
2985 "lfs stequota failed with projid argument"
2987 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
2988 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
2989 if is_project_quota_supported; then
2990 $SHOW_QUOTA_PROJID ||
2991 error "lfs quota failed with projid argument"
2993 resetquota -u $TSTID
2994 resetquota -g $TSTID
2995 resetquota -p $TSTPRJID
2998 run_test 27b "lfs quota/setquota should handle user/group/project ID (b20200)"
3003 $LFS setquota -u $TSTID -b 30M -B 3T $DIR ||
3004 error "lfs setquota failed"
3006 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
3007 [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
3008 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
3009 [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
3011 $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
3012 error "lfs setquota for $TSTID failed"
3014 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
3015 [ $limit != "1.465G" ] && error "wrong softlimit $limit"
3016 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
3017 [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
3019 $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
3020 error "total allocated inode/block limit not printed"
3022 resetquota -u $TSTUSR
3024 run_test 27c "lfs quota should support human-readable output"
3031 $LFS setquota -u $TSTID -b ${softlimit}p -B ${hardlimit}P $DIR ||
3032 error "set fraction block limit failed"
3033 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $3}')
3034 [ $limit == ${softlimit}P ] || error "get fraction softlimit failed"
3035 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $4}')
3036 [ $limit == ${hardlimit}P ] || error "get fraction hardlimit failed"
3038 resetquota -u $TSTUSR
3040 run_test 27d "lfs setquota should support fraction block limit"
3044 local TESTFILE="$DIR/$tdir/$tfile"
3047 setup_quota_test || error "setup quota failed with $?"
3049 set_ost_qtype "u" || error "enable ost quota failed"
3051 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
3052 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
3054 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
3055 $MAX_IQ_TIME $DIR || error "set grace time failed"
3056 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
3057 error "set quota failed"
3058 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
3059 cancel_lru_locks osc
3061 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
3062 # over-quota flag has not yet settled since we do not trigger async
3063 # events based on grace time period expiration
3065 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
3066 cancel_lru_locks osc
3067 # now over-quota flag should be settled and further writes should fail
3069 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
3070 error "grace times were reset"
3071 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
3072 $MAX_IQ_TIME $DIR || error "restore grace time failed"
3074 run_test 30 "Hard limit updates should not reset grace times"
3076 # basic usage tracking for user & group
3078 local INODES=10 # files
3079 local BLK_CNT=2 # MB each
3080 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
3082 setup_quota_test || error "setup quota failed with $?"
3084 # make sure the system is clean
3085 local USED=$(getquota -u $TSTID global curspace)
3087 error "Used space ($USED) for user $TSTID isn't 0."
3088 USED=$(getquota -g $TSTID global curspace)
3090 error "Used space ($USED) for group $TSTID isn't 0."
3091 if is_project_quota_supported; then
3092 USED=$(getquota -p $TSTPRJID global curspace)
3093 [ $USED -ne 0 ] && error \
3094 "Used space ($USED) for project $TSTPRJID isn't 0."
3097 echo "Write files..."
3098 for i in $(seq 0 $INODES); do
3099 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
3100 error "write failed"
3101 is_project_quota_supported &&
3102 change_project -p $TSTPRJID $DIR/$tdir/$tfile-$i
3103 echo "Iteration $i/$INODES completed"
3105 cancel_lru_locks osc
3107 echo "Wait for setattr on objects finished..."
3108 wait_delete_completed
3110 sync; sync_all_data || true
3112 echo "Verify disk usage after write"
3113 USED=$(getquota -u $TSTID global curspace)
3114 [ $USED -lt $TOTAL_BLKS ] &&
3115 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
3116 USED=$(getquota -g $TSTID global curspace)
3117 [ $USED -lt $TOTAL_BLKS ] &&
3118 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
3119 if is_project_quota_supported; then
3120 USED=$(getquota -p $TSTPRJID global curspace)
3121 [ $USED -lt $TOTAL_BLKS ] && error \
3122 "Used space for project $TSTPRJID:$USED, expected:$TOTAL_BLKS"
3125 echo "Verify inode usage after write"
3126 USED=$(getquota -u $TSTID global curinodes)
3127 [ $USED -lt $INODES ] &&
3128 error "Used inode for user $TSTID is $USED, expected $INODES"
3129 USED=$(getquota -g $TSTID global curinodes)
3130 [ $USED -lt $INODES ] &&
3131 error "Used inode for group $TSTID is $USED, expected $INODES"
3132 if is_project_quota_supported; then
3133 USED=$(getquota -p $TSTPRJID global curinodes)
3134 [ $USED -lt $INODES ] && error \
3135 "Used inode for project $TSTPRJID is $USED, expected $INODES"
3140 echo "Verify disk usage after delete"
3141 USED=$(getquota -u $TSTID global curspace)
3142 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
3143 USED=$(getquota -u $TSTID global curinodes)
3144 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
3145 USED=$(getquota -g $TSTID global curspace)
3146 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
3147 USED=$(getquota -g $TSTID global curinodes)
3148 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
3149 if is_project_quota_supported; then
3150 USED=$(getquota -p $TSTPRJID global curspace)
3152 error "Used space for project $TSTPRJID isn't 0. $USED"
3153 USED=$(getquota -p $TSTPRJID global curinodes)
3155 error "Used inodes for project $TSTPRJID isn't 0. $USED"
3158 run_test 33 "Basic usage tracking for user & group & project"
3160 # usage transfer test for user & group & project
3162 local BLK_CNT=2 # MB
3163 local project_supported="no"
3165 is_project_quota_supported && project_supported="yes"
3166 setup_quota_test || error "setup quota failed with $?"
3168 # make sure the system is clean
3169 local USED=$(getquota -u $TSTID global curspace)
3170 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
3171 USED=$(getquota -g $TSTID global curspace)
3172 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
3174 local USED=$(getquota -u $TSTID2 global curspace)
3175 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID2 isn't 0."
3176 if [ $project_supported == "yes" ]; then
3177 USED=$(getquota -p $TSTPRJID global curspace)
3178 [ $USED -ne 0 ] && error \
3179 "Used space ($USED) for Project $TSTPRJID isn't 0."
3182 echo "Write file..."
3183 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
3184 error "write failed"
3185 cancel_lru_locks osc
3186 sync; sync_all_data || true
3188 echo "chown the file to user $TSTID"
3189 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
3191 echo "Wait for setattr on objects finished..."
3192 wait_delete_completed
3194 BLK_CNT=$((BLK_CNT * 1024))
3196 echo "Verify disk usage for user $TSTID"
3197 USED=$(getquota -u $TSTID global curspace)
3198 [ $USED -lt $BLK_CNT ] &&
3199 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
3200 USED=$(getquota -u $TSTID global curinodes)
3202 error "Used inodes for user $TSTID is $USED, expected 1"
3204 echo "chgrp the file to group $TSTID"
3205 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
3207 echo "Wait for setattr on objects finished..."
3208 wait_delete_completed
3210 echo "Verify disk usage for group $TSTID"
3211 USED=$(getquota -g $TSTID global curspace)
3212 [ $USED -ge $BLK_CNT ] ||
3213 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3214 USED=$(getquota -g $TSTID global curinodes)
3216 error "Used inodes for group $TSTID is $USED, expected 1"
3218 # chown won't change the ost object group. LU-4345 */
3219 echo "chown the file to user $TSTID2"
3220 chown $TSTID2 $DIR/$tdir/$tfile || error "chown to $TSTID2 failed"
3222 echo "Wait for setattr on objects finished..."
3223 wait_delete_completed
3225 echo "change_project project id to $TSTPRJID"
3226 [ $project_supported == "yes" ] &&
3227 change_project -p $TSTPRJID $DIR/$tdir/$tfile
3228 echo "Wait for setattr on objects finished..."
3229 wait_delete_completed
3231 echo "Verify disk usage for user $TSTID2/$TSTID and group $TSTID"
3232 USED=$(getquota -u $TSTID2 global curspace)
3233 [ $USED -lt $BLK_CNT ] &&
3234 error "Used space for user $TSTID2 is $USED, expected $BLK_CNT"
3235 USED=$(getquota -u $TSTID global curspace)
3237 error "Used space for user $TSTID is $USED, expected 0"
3238 USED=$(getquota -g $TSTID global curspace)
3239 [ $USED -lt $BLK_CNT ] &&
3240 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3241 if [ $project_supported == "yes" ]; then
3242 USED=$(getquota -p $TSTPRJID global curspace)
3243 [ $USED -lt $BLK_CNT ] && error \
3244 "Used space for group $TSTPRJID is $USED, expected $BLK_CNT"