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: LU-5152
18 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
20 # Test duration: 30 min
21 [ "$SLOW" = "no" ] && EXCEPT_SLOW="61"
23 if [ "$mds1_FSTYPE" = zfs ]; then
25 # Test duration: 21 9 min"
26 [ "$SLOW" = "no" ] && EXCEPT_SLOW+=" 12a 9"
31 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
34 TSTID2=${TSTID2:-60001}
35 TSTUSR=${TSTUSR:-"quota_usr"}
36 TSTUSR2=${TSTUSR2:-"quota_2usr"}
37 TSTPRJID=${TSTPRJID:-1000}
42 # QP exists since this version. Should be finally set before landing.
43 VERSION_WITH_QP="2.13.53"
45 [ $MDS1_VERSION -lt $(version_code $VERSION_WITH_QP) ] &&
46 skip "Needs MDS version $VERSION_WITH_QP or later."
49 require_dsh_mds || exit 0
50 require_dsh_ost || exit 0
52 # Does e2fsprogs support quota feature?
53 if [ "$mds1_FSTYPE" == ldiskfs ] &&
54 do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features |
55 grep -q 'quota'"; then
56 skip_env "e2fsprogs doesn't support quota"
59 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
61 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
66 QUOTA_AUTO_OLD=$QUOTA_AUTO
69 check_and_setup_lustre
71 ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
73 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
74 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
75 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
76 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
77 SHOW_QUOTA_PROJID="eval is_project_quota_supported && $LFS quota -v -p $TSTPRJID $DIR"
78 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
79 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
80 SHOW_QUOTA_INFO_PROJID="eval is_project_quota_supported && $LFS quota -t -p $DIR"
85 local fail_val=${3:-0}
89 mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
90 mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
91 ost) NODES="$(comma_list $(osts_nodes))";;
94 do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
100 lfs project $* || error "lfs project $* failed"
103 RUNAS="runas -u $TSTID -g $TSTID"
104 RUNAS2="runas -u $TSTID2 -g $TSTID2"
105 DD="dd if=/dev/zero bs=1M"
109 # clear quota limits for a user or a group
110 # usage: resetquota -u username
111 # resetquota -g groupname
112 # resetquota -p projid
115 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
116 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
117 error "resetquota: wrong specifier $1 passed"
119 if [ $1 == "-p" ]; then
120 is_project_quota_supported || return 0
123 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
124 error "clear quota for [type:$1 name:$2] failed"
125 # give a chance to slave to release space
133 if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
134 $LFS quota -v -u $local_id $DIR
135 log "Files for user ($local_id):"
136 ($LFS find --user $local_id $DIR | head -n 4 |
137 xargs stat 2>/dev/null)
140 if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
141 $LFS quota -v -g $local_id $DIR
142 log "Files for group ($local_id):"
143 ($LFS find --group $local_id $DIR | head -n 4 |
144 xargs stat 2>/dev/null)
147 is_project_quota_supported || return 0
148 if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
149 $LFS quota -v -p $TSTPRJID $DIR
150 log "Files for project ($TSTPRJID):"
151 ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
152 xargs stat 2>/dev/null)
168 # get quota for a user or a group
169 # usage: getquota -u|-g|-p <username>|<groupname>|<projid> global|<obd_uuid> \
170 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace \
177 sync_all_data > /dev/null 2>&1 || true
179 [ "$#" != 4 -a "$#" != 5 ] &&
180 error "getquota: wrong number of arguments: $#"
181 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
182 error "getquota: wrong u/g/p specifier $1 passed"
195 *) error "unknown quota parameter $4";;
198 [ ! -z "$5" ] && pool_arg="--pool $5 "
199 [ "$uuid" = "global" ] && uuid=$DIR
201 $LFS quota -v "$1" "$2" $pool_arg $DIR |
202 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
203 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
208 # usage: set_mdt_qtype ugp|u|g|p|none
212 local mdts=$(get_facets MDS)
214 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
215 qtype=$(tr -d 'p' <<<$qtype)
217 if [[ $PERM_CMD == *"set_param -P"* ]]; then
218 do_facet mgs $PERM_CMD \
219 osd-*.$FSNAME-MDT*.quota_slave.enable=$qtype
221 do_facet mgs $PERM_CMD $FSNAME.quota.mdt=$qtype
223 # we have to make sure each MDT received config changes
224 for mdt in ${mdts//,/ }; do
226 cmd="$LCTL get_param -n "
227 cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc}
228 cmd=${cmd}.quota_slave.enabled
230 if $(facet_up $mdt); then
231 wait_update_facet $mdt "$cmd" "$qtype" || return 1
238 # usage: set_ost_qtype ugp|u|g|p|none
242 local osts=$(get_facets OST)
244 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
245 qtype=$(tr -d 'p' <<<$qtype)
247 if [[ $PERM_CMD == *"set_param -P"* ]]; then
248 do_facet mgs $PERM_CMD \
249 osd-*.$FSNAME-OST*.quota_slave.enable=$qtype
251 do_facet mgs $PERM_CMD $FSNAME.quota.ost=$qtype
253 # we have to make sure each OST received config changes
254 for ost in ${osts//,/ }; do
256 cmd="$LCTL get_param -n "
257 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
258 cmd=${cmd}.quota_slave.enabled
260 if $(facet_up $ost); then
261 wait_update_facet $ost "$cmd" "$qtype" || return 1
267 wait_reintegration() {
271 local result="glb[1],slv[1],reint[0]"
276 if [ $ntype == "mdt" ]; then
277 tgts=$(get_facets MDS)
279 tgts=$(get_facets OST)
282 for tgt in ${tgts//,/ }; do
284 cmd="$LCTL get_param -n "
285 cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc}
286 cmd=${cmd}.quota_slave.info
288 if $(facet_up $tgt); then
289 wait_update_facet $tgt "$cmd |
290 grep "$qtype" | awk '{ print \\\$3 }'" \
291 "$result" $max || return 1
301 if [[ "$qtype" =~ "u" ]]; then
302 wait_reintegration "mdt" "user" $max || return 1
305 if [[ "$qtype" =~ "g" ]]; then
306 wait_reintegration "mdt" "group" $max || return 1
309 if [[ "$qtype" =~ "p" ]]; then
310 ! is_project_quota_supported && return 0
311 wait_reintegration "mdt" "project" $max || return 1
320 if [[ "$qtype" =~ "u" ]]; then
321 wait_reintegration "ost" "user" $max || return 1
324 if [[ "$qtype" =~ "g" ]]; then
325 wait_reintegration "ost" "group" $max || return 1
328 if [[ "$qtype" =~ "p" ]]; then
329 ! is_project_quota_supported && return 0
330 wait_reintegration "ost" "project" $max || return 1
339 local extrasleep=${4:-5}
346 *) error "get_grace_time: Invalid quota type: $qtype"
351 echo "Quota info for $pool:"
352 $LFS quota -$qtype $qarg $parg $DIR
357 time=$(lfs quota -$qtype $qarg $parg $DIR|
358 awk 'NR == 3{ print $5 }'| sed 's/s$//')
361 time=$(lfs quota -$qtype $qarg $DIR|
362 awk 'NR == 3{ print $9 }'| sed 's/s$//')
365 error "Unknown quota type: $flavour"
369 # from lfs.c:__sec2str()
370 # const char spec[] = "smhdw";
371 # {1, 60, 60*60, 24*60*60, 7*24*60*60};
372 [[ $time == *m* ]] && time=${time//m/} && time=$((time*60));
373 [[ $time == *h* ]] && time=${time//h/} && time=$((time*60*60));
374 [[ $time == *d* ]] && time=${time//d/} && time=$((time*24*60*60));
375 [[ $time == *w* ]] && time=${time//w/} && time=$((time*7*24*60*60));
377 echo "Sleep through grace ..."
378 [ "$time" == "-" ] &&
379 error "Grace timeout was not set or quota not exceeded"
380 if [ "$time" == "none" ]; then
381 echo "...Grace timeout already expired"
383 let time+=$extrasleep
384 echo "...sleep $time seconds"
390 wait_delete_completed
391 echo "Creating test directory"
392 mkdir $DIR/$tdir || return 1
393 chmod 0777 $DIR/$tdir || return 2
394 # always clear fail_loc in case of fail_loc isn't cleared
395 # properly when previous test failed
396 lustre_fail mds_ost 0
399 cleanup_quota_test() {
400 echo "Delete files..."
402 echo "Wait for unlink objects finished..."
403 wait_delete_completed
404 sync_all_data || true
414 $LFS quota -v -$ugp $qid $DIR
416 if [ "$bf" == "a" -o "$bf" == "b" ]; then
417 usage=$(getquota -$ugp $qid global curspace)
418 if [ -z $usage ]; then
419 quota_error $ugp $qid \
420 "Query block quota failed ($ugp:$qid)."
422 [ $usage -ne 0 ] && quota_log $ugp $qid \
423 "Block quota isn't 0 ($ugp:$qid:$usage)."
427 if [ "$bf" == "a" -o "$bf" == "f" ]; then
428 usage=$(getquota -$ugp $qid global curinodes)
429 if [ -z $usage ]; then
430 quota_error $ugp $qid \
431 "Query file quota failed ($ugp:$qid)."
433 [ $usage -ne 0 ] && quota_log $ugp $qid \
434 "File quota isn't 0 ($ugp:$qid:$usage)."
439 project_quota_enabled () {
441 local zfeat="feature@project_quota"
443 for facet in $(seq -f mds%g $MDSCOUNT) $(seq -f ost%g $OSTCOUNT); do
444 local facet_fstype=${facet:0:3}1_FSTYPE
447 if [ "${!facet_fstype}" = "zfs" ]; then
448 devname=$(zpool_name ${facet})
449 do_facet ${facet} $ZPOOL get -H "$zfeat" $devname |
450 grep -wq active || rc=1
452 [ ${facet:0:3} == "mds" ] &&
453 devname=$(mdsdevname ${facet:3}) ||
454 devname=$(ostdevname ${facet:3})
455 do_facet ${facet} $DEBUGFS -R features $devname |
456 grep -q project || rc=1
459 [ $rc -eq 0 ] && PQ_CLEANUP=false || PQ_CLEANUP=true
463 project_quota_enabled || enable_project_quota
465 reset_quota_settings() {
466 resetquota -u $TSTUSR
468 resetquota -g $TSTUSR
470 resetquota -u $TSTUSR2
471 resetquota -u $TSTID2
472 resetquota -g $TSTUSR2
473 resetquota -g $TSTID2
474 resetquota -p $TSTPRJID
479 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota+trace"
484 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
485 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
486 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
487 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
489 test_quota_performance() {
490 local TESTFILE="$DIR/$tdir/$tfile-0"
491 local size=$1 # in MB
492 local stime=$(date +%s)
493 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
494 quota_error u $TSTUSR "write failure"
495 local etime=$(date +%s)
496 delta=$((etime - stime))
497 if [ $delta -gt 0 ]; then
498 rate=$((size * 1024 / delta))
499 if [ "$mds1_FSTYPE" = zfs ]; then
500 # LU-2872 - see LU-2887 for fix
502 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
504 [ $rate -gt 1024 ] ||
505 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
511 # test basic quota performance b=21696
514 [ "$SLOW" = "no" ] && MB=10
516 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
517 [ $free_space -le $((MB * 1024)) ] &&
518 skip "not enough space ${free_space} KB, " \
519 "required $((MB * 1024)) KB"
520 setup_quota_test || error "setup quota failed with $?"
521 trap cleanup_quota_test EXIT
523 set_ost_qtype "none" || error "disable ost quota failed"
524 test_quota_performance $MB
526 set_ost_qtype $QTYPE || error "enable ost quota failed"
527 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
528 error "set quota failed"
529 test_quota_performance $MB
533 run_test 0 "Test basic quota performance"
535 # usage: test_1_check_write tfile user|group|project
536 test_1_check_write() {
540 local short_qtype=${qtype:0:1}
543 $RUNAS $DD of=$testfile count=$((limit/2)) ||
544 quota_error $short_qtype $TSTUSR \
545 "$qtype write failure, but expect success"
546 log "Write out of block quota ..."
547 # this time maybe cache write, ignore it's failure
548 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
549 # flush cache, ensure noquota flag is set on client
551 sync; sync_all_data || true
552 # sync means client wrote all it's cache, but id doesn't
553 # garantee that slave got new edquot trough glimpse.
554 # so wait a little to be sure slave got it.
556 $RUNAS $DD of=$testfile count=1 seek=$limit &&
557 quota_error $short_qtype $TSTUSR \
558 "user write success, but expect EDQUOT"
561 check_write_fallocate() {
565 local short_qtype=${qtype:0:1}
568 log "Write ${count}MiB Using Fallocate"
569 $RUNAS fallocate -l${count}MiB $testfile ||
570 quota_error $short_qtype $TSTUSR "Write ${count}MiB fail"
573 sync; sync_all_data || true
577 log "Write ${count}MiB Using Fallocate"
578 $RUNAS fallocate -l${count}MiB $testfile &&
579 quota_error $short_qtype $TSTUSR \
580 "Write success, expect EDQUOT" || true
583 # test block hardlimit
586 local testfile="$DIR/$tdir/$tfile-0"
588 setup_quota_test || error "setup quota failed with $?"
589 trap cleanup_quota_test EXIT
592 set_ost_qtype $QTYPE || error "enable ost quota failed"
595 log "User quota (block hardlimit:$limit MB)"
596 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
597 error "set user quota failed"
599 # make sure the system is clean
600 local used=$(getquota -u $TSTUSR global curspace)
601 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
603 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
604 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
606 test_1_check_write $testfile "user" $limit
609 wait_delete_completed || error "wait_delete_completed failed"
610 sync_all_data || true
611 used=$(getquota -u $TSTUSR global curspace)
612 [ $used -ne 0 ] && quota_error u $TSTUSR \
613 "user quota isn't released after deletion"
614 resetquota -u $TSTUSR
617 log "--------------------------------------"
618 log "Group quota (block hardlimit:$limit MB)"
619 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
620 error "set group quota failed"
622 testfile="$DIR/$tdir/$tfile-1"
623 # make sure the system is clean
624 used=$(getquota -g $TSTUSR global curspace)
625 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
627 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
628 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
630 test_1_check_write $testfile "group" $limit
632 wait_delete_completed || error "wait_delete_completed failed"
633 sync_all_data || true
634 used=$(getquota -g $TSTUSR global curspace)
635 [ $used -ne 0 ] && quota_error g $TSTUSR \
636 "Group quota isn't released after deletion"
637 resetquota -g $TSTUSR
639 if ! is_project_quota_supported; then
640 echo "Project quota is not supported"
645 testfile="$DIR/$tdir/$tfile-2"
646 # make sure the system is clean
647 used=$(getquota -p $TSTPRJID global curspace)
649 error "used space($used) for project $TSTPRJID isn't 0"
652 log "--------------------------------------"
653 log "Project quota (block hardlimit:$limit mb)"
654 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
655 error "set project quota failed"
657 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
658 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
659 change_project -p $TSTPRJID $testfile
661 test_1_check_write $testfile "project" $limit
666 used=$(getquota -p $TSTPRJID global curspace)
667 [ $used -ne 0 ] && quota_error p $TSTPRJID \
668 "project quota isn't released after deletion"
670 resetquota -p $TSTPRJID
672 run_test 1a "Block hard limit (normal use and out of quota)"
676 local global_limit=20 # 100M
677 local testfile="$DIR/$tdir/$tfile-0"
681 setup_quota_test || error "setup quota failed with $?"
682 stack_trap cleanup_quota_test EXIT
685 set_ost_qtype $QTYPE || error "enable ost quota failed"
688 log "User quota (block hardlimit:$global_limit MB)"
689 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
690 error "set user quota failed"
692 pool_add $qpool || error "pool_add failed"
693 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
694 error "pool_add_targets failed"
696 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
697 error "set user quota failed"
699 # make sure the system is clean
700 local used=$(getquota -u $TSTUSR global curspace)
702 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
704 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
706 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
707 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
709 test_1_check_write $testfile "user" $limit
712 wait_delete_completed || error "wait_delete_completed failed"
713 sync_all_data || true
714 used=$(getquota -u $TSTUSR global curspace $qpool)
715 [ $used -ne 0 ] && quota_error u $TSTUSR \
716 "user quota isn't released after deletion"
717 resetquota -u $TSTUSR
720 log "--------------------------------------"
721 log "Group quota (block hardlimit:$global_limit MB)"
722 $LFS setquota -g $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
723 error "set group quota failed"
725 $LFS setquota -g $TSTUSR -b 0 -B ${limit}M --pool $qpool $DIR ||
726 error "set group quota failed"
728 testfile="$DIR/$tdir/$tfile-1"
729 # make sure the system is clean
730 used=$(getquota -g $TSTUSR global curspace $qpool)
731 [ $used -ne 0 ] && error "Used space ($used) for group $TSTUSR isn't 0"
733 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
734 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
736 test_1_check_write $testfile "group" $limit
739 wait_delete_completed || error "wait_delete_completed failed"
740 sync_all_data || true
741 used=$(getquota -g $TSTUSR global curspace $qpool)
742 [ $used -ne 0 ] && quota_error g $TSTUSR \
743 "Group quota isn't released after deletion"
744 resetquota -g $TSTUSR
746 if ! is_project_quota_supported; then
747 echo "Project quota is not supported"
752 testfile="$DIR/$tdir/$tfile-2"
753 # make sure the system is clean
754 used=$(getquota -p $TSTPRJID global curspace $qpool)
756 error "used space($used) for project $TSTPRJID isn't 0"
759 log "--------------------------------------"
760 log "Project quota (block hardlimit:$global_limit mb)"
761 $LFS setquota -p $TSTPRJID -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
762 error "set project quota failed"
764 $LFS setquota -p $TSTPRJID -b 0 -B ${limit}M --pool $qpool $DIR ||
765 error "set project quota failed"
768 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
769 chown $TSTUSR:$TSTUSR $testfile || error "chown $testfile failed"
770 change_project -p $TSTPRJID $testfile
772 test_1_check_write $testfile "project" $limit
777 used=$(getquota -p $TSTPRJID global curspace)
778 [ $used -eq 0 ] || quota_error p $TSTPRJID \
779 "project quota isn't released after deletion"
781 run_test 1b "Quota pools: Block hard limit (normal use and out of quota)"
784 local global_limit=20 # 100M
785 local testfile="$DIR/$tdir/$tfile-0"
786 local qpool1="qpool1"
787 local qpool2="qpool2"
790 setup_quota_test || error "setup quota failed with $?"
791 stack_trap cleanup_quota_test EXIT
794 set_ost_qtype $QTYPE || error "enable ost quota failed"
797 log "User quota (block hardlimit:$global_limit MB)"
798 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
799 error "set user quota failed"
801 pool_add $qpool1 || error "pool_add failed"
802 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
803 error "pool_add_targets failed"
805 pool_add $qpool2 || error "pool_add failed"
806 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
807 error "pool_add_targets failed"
809 # create pools without hard limit
810 # initially such case raised several bugs
811 $LFS setquota -u $TSTUSR -B 0M --pool $qpool1 $DIR ||
812 error "set user quota failed"
814 $LFS setquota -u $TSTUSR -B 0M --pool $qpool2 $DIR ||
815 error "set user quota failed"
817 # make sure the system is clean
818 local used=$(getquota -u $TSTUSR global curspace)
820 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
822 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
824 test_1_check_write $testfile "user" $global_limit
826 used=$(getquota -u $TSTUSR global curspace $qpool1)
827 echo "qpool1 used $used"
828 used=$(getquota -u $TSTUSR global curspace $qpool2)
829 echo "qpool2 used $used"
832 wait_delete_completed || error "wait_delete_completed failed"
833 sync_all_data || true
835 used=$(getquota -u $TSTUSR global curspace $qpool1)
836 [ $used -ne 0 ] && quota_error u $TSTUSR \
837 "user quota isn't released after deletion"
838 resetquota -u $TSTUSR
843 run_test 1c "Quota pools: check 3 pools with hardlimit only for global"
846 local limit1=10 # 10M
847 local limit2=12 # 12M
848 local global_limit=20 # 100M
849 local testfile="$DIR/$tdir/$tfile-0"
850 local qpool1="qpool1"
851 local qpool2="qpool2"
854 setup_quota_test || error "setup quota failed with $?"
855 stack_trap cleanup_quota_test EXIT
858 set_ost_qtype $QTYPE || error "enable ost quota failed"
861 log "User quota (block hardlimit:$global_limit MB)"
862 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
863 error "set user quota failed"
865 pool_add $qpool1 || error "pool_add failed"
866 pool_add_targets $qpool1 0 $(($OSTCOUNT - 1)) ||
867 error "pool_add_targets failed"
869 pool_add $qpool2 || error "pool_add failed"
870 pool_add_targets $qpool2 0 $(($OSTCOUNT - 1)) ||
871 error "pool_add_targets failed"
873 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
874 error "set user quota failed"
876 $LFS setquota -u $TSTUSR -B ${limit2}M --pool $qpool2 $DIR ||
877 error "set user quota failed"
879 # make sure the system is clean
880 local used=$(getquota -u $TSTUSR global curspace)
882 [ $used -ne 0 ] && error "used space($used) for user $TSTUSR isn't 0."
884 used=$(getquota -u $TSTUSR global bhardlimit $qpool)
886 test_1_check_write $testfile "user" $limit1
888 used=$(getquota -u $TSTUSR global curspace $qpool1)
889 echo "qpool1 used $used"
890 used=$(getquota -u $TSTUSR global curspace $qpool2)
891 echo "qpool2 used $used"
894 wait_delete_completed || error "wait_delete_completed failed"
895 sync_all_data || true
897 used=$(getquota -u $TSTUSR global curspace $qpool1)
898 [ $used -ne 0 ] && quota_error u $TSTUSR \
899 "user quota isn't released after deletion"
900 resetquota -u $TSTUSR
905 run_test 1d "Quota pools: check block hardlimit on different pools"
908 local limit1=10 # 10M
909 local global_limit=200 # 200M
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 $?"
916 stack_trap cleanup_quota_test EXIT
919 set_ost_qtype $QTYPE || error "enable ost quota failed"
921 # global_limit is much greater than limit1 to get
922 # different qunit's on osts. Since 1st qunit shrinking
923 # on OST1(that belongs to qpool1), this qunit should
925 log "User quota (block hardlimit:$global_limit MB)"
926 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
927 error "set user quota failed"
929 pool_add $qpool1 || error "pool_add failed"
930 pool_add_targets $qpool1 1 1 ||
931 error "pool_add_targets failed"
933 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
934 error "set user quota failed"
936 # make sure the system is clean
937 local used=$(getquota -u $TSTUSR global curspace)
938 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
940 $LFS setstripe $testfile -c 1 -i 1 || error "setstripe $testfile failed"
941 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
943 test_1_check_write $testfile "user" $limit1
945 $LFS setstripe $testfile2 -c 1 -i 0 ||
946 error "setstripe $testfile2 failed"
947 chown $TSTUSR.$TSTUSR $testfile2 || error "chown $testfile2 failed"
948 # Now write to file with a stripe on OST0, that doesn't belong to qpool1
950 $RUNAS $DD of=$testfile2 count=20 ||
951 quota_error u $TSTUSR \
952 "$qtype write failure, but expect success"
956 wait_delete_completed || error "wait_delete_completed failed"
957 sync_all_data || true
959 used=$(getquota -u $TSTUSR global curspace $qpool1)
960 [ $used -ne 0 ] && quota_error u $TSTUSR \
961 "user quota isn't released after deletion"
962 resetquota -u $TSTUSR
967 run_test 1e "Quota pools: global pool high block limit vs quota pool with small"
970 local global_limit=200 # 200M
971 local limit1=10 # 10M
972 local TESTDIR="$DIR/$tdir/"
973 local testfile="$TESTDIR/$tfile-0"
974 local qpool1="qpool1"
977 setup_quota_test || error "setup quota failed with $?"
978 stack_trap cleanup_quota_test EXIT
981 set_ost_qtype $QTYPE || error "enable ost quota failed"
983 log "User quota (block hardlimit:$global_limit MB)"
984 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
985 error "set user quota failed"
987 pool_add $qpool1 || error "pool_add failed"
988 pool_add_targets $qpool1 0 0 ||
989 error "pool_add_targets failed"
991 $LFS setquota -u $TSTUSR -B ${limit1}M --pool $qpool1 $DIR ||
992 error "set user quota failed"
994 # make sure the system is clean
995 local used=$(getquota -u $TSTUSR global curspace)
996 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
998 $LFS setstripe $TESTDIR -c 1 -i 0 || error "setstripe $TESTDIR failed"
1000 test_1_check_write $testfile "user" $limit1
1002 pool_remove_target $qpool1 0
1004 wait_delete_completed || error "wait_delete_completed failed"
1005 sync_all_data || true
1007 pool_add_targets $qpool1 0 0 || error "pool_add_targets failed"
1008 # qunit for appropriate element in lgd array should be set
1009 # correctly(4096). Earlier it was not changed continuing to be 1024.
1010 # This caused write to hung when it hit limit1 - qunit shrinking to 1024
1011 # for qpool1 lqe didn't cause changing qunit for OST0 in gld array
1012 # as it already was 1024. As flag "need_update" for this qunit was
1013 # not set, new qunit wasn't sent to OST0. Thus revoke was not set
1014 # for "qpool1" lqe and it couldn't set EDQUOT despite granted
1015 # became > 10M. QMT returned EINPROGRESS in a loop.
1016 # Check that it doesn't hung anymore.
1017 test_1_check_write $testfile "user" $limit1
1022 run_test 1f "Quota pools: correct qunit after removing/adding OST"
1025 local limit=20 # 20M
1026 local global_limit=40 # 40M
1027 local testfile="$DIR/$tdir/$tfile-0"
1028 local qpool="qpool1"
1029 local mdmb_param="osc.*.max_dirty_mb"
1030 local max_dirty_mb=$($LCTL get_param -n $mdmb_param | head -1)
1033 setup_quota_test || error "setup quota failed with $?"
1034 stack_trap cleanup_quota_test EXIT
1035 $LCTL set_param $mdmb_param=1
1036 stack_trap "$LCTL set_param $mdmb_param=$max_dirty_mb" EXIT
1039 set_ost_qtype $QTYPE || error "enable ost quota failed"
1042 log "User quota (block hardlimit:$global_limit MB)"
1043 $LFS setquota -u $TSTUSR -b 0 -B ${global_limit}M -i 0 -I 0 $DIR ||
1044 error "set user quota failed"
1046 pool_add $qpool || error "pool_add failed"
1047 pool_add_targets $qpool 0 $(($OSTCOUNT - 1)) ||
1048 error "pool_add_targets failed"
1050 $LFS setquota -u $TSTUSR -B ${limit}M --pool $qpool $DIR ||
1051 error "set user quota failed"
1053 # make sure the system is clean
1054 local used=$(getquota -u $TSTUSR global curspace)
1056 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1058 $LFS setstripe $testfile -C 200 || error "setstripe $testfile failed"
1059 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1062 $RUNAS $DD of=$testfile count=$((limit/2)) ||
1063 quota_error u $TSTUSR \
1064 "$qtype write failure, but expect success"
1065 log "Write out of block quota ..."
1066 # this time maybe cache write, ignore it's failure
1067 $RUNAS $DD of=$testfile count=$((limit/2)) seek=$((limit/2)) || true
1068 # flush cache, ensure noquota flag is set on client
1069 cancel_lru_locks osc
1070 sync; sync_all_data || true
1072 $RUNAS $DD of=$testfile count=$OSTCOUNT seek=$limit &&
1073 quota_error u $TSTUSR \
1074 "user write success, but expect EDQUOT"
1077 wait_delete_completed || error "wait_delete_completed failed"
1078 sync_all_data || true
1080 used=$(getquota -u $TSTUSR global curspace $qpool)
1081 [ $used -ne 0 ] && quota_error u $TSTUSR \
1082 "user quota isn't released after deletion"
1085 run_test 1g "Quota pools: Block hard limit with wide striping"
1088 local limit=10 # 10M
1089 local testfile="$DIR/$tdir/$tfile-0"
1093 setup_quota_test || error "setup quota failed with $?"
1094 trap cleanup_quota_test EXIT
1097 set_ost_qtype $QTYPE || error "enable ost quota failed"
1100 log "User quota (block hardlimit:$limit MB)"
1101 $LFS setquota -u $TSTUSR -b 0 -B ${limit}M -i 0 -I 0 $DIR ||
1102 error "set user quota failed"
1104 # make sure the system is clean
1105 local used=$(getquota -u $TSTUSR global curspace)
1106 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1108 $LFS setstripe $testfile -c 1 || error "setstripe $testfile failed"
1109 chown $TSTUSR.$TSTUSR $testfile || error "chown $testfile failed"
1111 check_write_fallocate $testfile "user" $limit
1114 wait_delete_completed || error "wait_delete_completed failed"
1115 sync_all_data || true
1116 used=$(getquota -u $TSTUSR global curspace)
1117 [ $used -ne 0 ] && quota_error u $TSTUSR \
1118 "user quota isn't released after deletion"
1119 resetquota -u $TSTUSR
1121 run_test 1h "Block hard limit test using fallocate"
1123 # test inode hardlimit
1125 local TESTFILE="$DIR/$tdir/$tfile-0"
1126 local LIMIT=$(do_facet mds1 $LCTL get_param -n \
1127 qmt.$FSNAME-QMT0000.md-0x0.info |
1128 awk '/least qunit/{ print $3 }')
1129 local L2=$(do_facet mds1 $LCTL get_param -n \
1130 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1132 [ $L2 -le $LIMIT ] || LIMIT=$L2
1134 [ "$SLOW" = "no" ] || LIMIT=$((LIMIT * 1024))
1136 local FREE_INODES=$(mdt_free_inodes 0)
1137 echo "$FREE_INODES free inodes on master MDT"
1138 [ $FREE_INODES -lt $LIMIT ] &&
1139 skip "not enough free inodes $FREE_INODES required $LIMIT"
1141 setup_quota_test || error "setup quota failed with $?"
1142 trap cleanup_quota_test EXIT
1145 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1148 log "User quota (inode hardlimit:$LIMIT files)"
1149 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1150 error "set user quota failed"
1152 # make sure the system is clean
1153 local USED=$(getquota -u $TSTUSR global curinodes)
1154 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
1156 log "Create $LIMIT files ..."
1157 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1158 quota_error u $TSTUSR "user create failure, but expect success"
1159 log "Create out of file quota ..."
1160 $RUNAS touch ${TESTFILE}_xxx &&
1161 quota_error u $TSTUSR "user create success, but expect EDQUOT"
1164 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1165 rm -f ${TESTFILE}_xxx
1166 wait_delete_completed
1168 USED=$(getquota -u $TSTUSR global curinodes)
1169 [ $USED -ne 0 ] && quota_error u $TSTUSR \
1170 "user quota isn't released after deletion"
1171 resetquota -u $TSTUSR
1174 log "--------------------------------------"
1175 log "Group quota (inode hardlimit:$LIMIT files)"
1176 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1177 error "set group quota failed"
1179 TESTFILE=$DIR/$tdir/$tfile-1
1180 # make sure the system is clean
1181 USED=$(getquota -g $TSTUSR global curinodes)
1182 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
1184 log "Create $LIMIT files ..."
1185 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
1186 quota_error g $TSTUSR "group create failure, but expect success"
1187 log "Create out of file quota ..."
1188 $RUNAS touch ${TESTFILE}_xxx &&
1189 quota_error g $TSTUSR "group create success, but expect EDQUOT"
1192 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
1193 rm -f ${TESTFILE}_xxx
1194 wait_delete_completed
1196 USED=$(getquota -g $TSTUSR global curinodes)
1197 [ $USED -ne 0 ] && quota_error g $TSTUSR \
1198 "user quota isn't released after deletion"
1200 resetquota -g $TSTUSR
1201 ! is_project_quota_supported && cleanup_quota_test &&
1202 echo "Skip project quota is not supported" && return 0
1205 log "--------------------------------------"
1206 log "Project quota (inode hardlimit:$LIMIT files)"
1207 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
1208 error "set project quota failed"
1210 TESTFILE=$DIR/$tdir/$tfile-1
1211 # make sure the system is clean
1212 USED=$(getquota -p $TSTPRJID global curinodes)
1214 error "Used inodes($USED) for project $TSTPRJID isn't 0"
1216 change_project -sp $TSTPRJID $DIR/$tdir
1217 log "Create $LIMIT files ..."
1218 $RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
1219 $TSTPRJID "project create fail, but expect success"
1220 log "Create out of file quota ..."
1221 $RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
1222 "project create success, but expect EDQUOT"
1223 change_project -C $DIR/$tdir
1226 USED=$(getquota -p $TSTPRJID global curinodes)
1227 [ $USED -eq 0 ] || quota_error p $TSTPRJID \
1228 "project quota isn't released after deletion"
1231 run_test 2 "File hard limit (normal use and out of quota)"
1242 stack_trap cleanup_quota_test EXIT
1244 $LFS setstripe $testfile -c 1 -i 0
1245 chown $TSTUSR.$TSTUSR $testfile
1246 [ "$qtype" == "p" ] && is_project_quota_supported &&
1247 change_project -p $TSTPRJID $testfile
1249 echo "Write up to soft limit"
1250 $RUNAS $DD of=$testfile count=$limit ||
1251 quota_error a $TSTUSR "write failure, but expect success"
1252 OFFSET=$((limit * 1024))
1253 cancel_lru_locks osc
1255 echo "Write to exceed soft limit"
1256 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1257 quota_error a $TSTUSR "write failure, but expect success"
1258 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
1259 cancel_lru_locks osc
1261 echo "mmap write when over soft limit"
1262 $RUNAS $MULTIOP $testfile.mmap OT40960SMW ||
1263 quota_error a $TSTUSR "mmap write failure, but expect success"
1264 cancel_lru_locks osc
1269 $SHOW_QUOTA_INFO_USER
1270 $SHOW_QUOTA_INFO_GROUP
1271 $SHOW_QUOTA_INFO_PROJID
1273 echo "Write before timer goes off"
1274 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET ||
1275 quota_error a $TSTUSR "write failure, but expect success"
1276 OFFSET=$((OFFSET + 1024))
1277 cancel_lru_locks osc
1279 wait_grace_time $qtype "block" $pool
1284 $SHOW_QUOTA_INFO_USER
1285 $SHOW_QUOTA_INFO_GROUP
1286 $SHOW_QUOTA_INFO_PROJID
1288 log "Write after timer goes off"
1289 # maybe cache write, ignore.
1290 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET || true
1291 OFFSET=$((OFFSET + 1024))
1292 cancel_lru_locks osc
1293 log "Write after cancel lru locks"
1294 $RUNAS dd if=/dev/zero of=$testfile bs=1K count=10 seek=$OFFSET &&
1295 quota_error a $TSTUSR "write success, but expect EDQUOT"
1300 $SHOW_QUOTA_INFO_USER
1301 $SHOW_QUOTA_INFO_GROUP
1302 $SHOW_QUOTA_INFO_PROJID
1304 echo "Unlink file to stop timer"
1306 wait_delete_completed
1307 sync_all_data || true
1312 $SHOW_QUOTA_INFO_USER
1313 $SHOW_QUOTA_INFO_GROUP
1314 $SHOW_QUOTA_INFO_PROJID
1316 $LFS setstripe $testfile -c 1 -i 0
1317 chown $TSTUSR.$TSTUSR $testfile
1318 [ "$qtype" == "p" ] && change_project -p $TSTPRJID $testfile
1321 $RUNAS $DD of=$testfile count=$limit ||
1322 quota_error a $TSTUSR "write failure, but expect success"
1329 local grace=20 # 20s
1330 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1333 local testfile=$DIR/$tdir/$tfile-0
1335 # get minimum soft qunit size
1336 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1337 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1339 set_ost_qtype $QTYPE || error "enable ost quota failed"
1341 echo "User quota (soft limit:$limit MB grace:$grace seconds)"
1342 # make sure the system is clean
1343 local used=$(getquota -u $TSTUSR global curspace)
1344 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1346 $LFS setquota -t -u --block-grace $grace --inode-grace \
1347 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1348 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1349 error "set user quota failed"
1351 test_block_soft $testfile $grace $limit "u"
1353 echo "Group quota (soft limit:$limit MB grace:$grace seconds)"
1354 testfile=$DIR/$tdir/$tfile-1
1355 # make sure the system is clean
1356 used=$(getquota -g $TSTUSR global curspace)
1357 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1359 $LFS setquota -t -g --block-grace $grace --inode-grace \
1360 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1361 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 -i 0 -I 0 $DIR ||
1362 error "set group quota failed"
1364 test_block_soft $testfile $grace $limit "g"
1366 if is_project_quota_supported; then
1367 echo "Project quota (soft limit:$limit MB grace:$grace sec)"
1368 testfile=$DIR/$tdir/$tfile-2
1369 # make sure the system is clean
1370 used=$(getquota -p $TSTPRJID global curspace)
1371 [ $used -ne 0 ] && error \
1372 "Used space($used) for project $TSTPRJID isn't 0."
1374 $LFS setquota -t -p --block-grace $grace --inode-grace \
1375 $MAX_IQ_TIME $DIR ||
1376 error "set project grace time failed"
1377 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 -i 0 -I 0 \
1378 $DIR || error "set project quota failed"
1380 test_block_soft $testfile $grace $limit "p"
1381 resetquota -p $TSTPRJID
1382 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1383 $MAX_IQ_TIME $DIR ||
1384 error "restore project grace time failed"
1388 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1389 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1390 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1391 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1393 run_test 3a "Block soft limit (start timer, timer goes off, stop timer)"
1396 local grace=20 # 20s
1397 local qpool="qpool1"
1398 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1401 local testfile=$DIR/$tdir/$tfile-0
1404 # get minimum soft qunit size
1405 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1406 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1407 local glbl_limit=$((2*limit))
1408 local glbl_grace=$((2*grace))
1409 echo "limit $limit glbl_limit $glbl_limit"
1410 echo "grace $grace glbl_grace $glbl_grace"
1412 set_ost_qtype $QTYPE || error "enable ost quota failed"
1414 echo "User quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1415 # make sure the system is clean
1416 local used=$(getquota -u $TSTUSR global curspace)
1417 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1419 pool_add $qpool || error "pool_add failed"
1420 pool_add_targets $qpool 0 1 ||
1421 error "pool_add_targets failed"
1423 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1424 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1425 $LFS setquota -t -u --block-grace $grace \
1426 --pool $qpool $DIR || error "set user grace time failed"
1428 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1429 error "set user quota failed"
1430 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1431 error "set user quota failed"
1433 test_block_soft $testfile $grace $limit "u" $qpool
1435 echo "Group quota in $qpool(soft limit:$limit MB grace:$grace seconds)"
1436 testfile=$DIR/$tdir/$tfile-1
1437 # make sure the system is clean
1438 used=$(getquota -g $TSTUSR global curspace)
1439 [ $used -ne 0 ] && error "Used space($used) for group $TSTUSR isn't 0."
1441 $LFS setquota -t -g --block-grace $glbl_grace --inode-grace \
1442 $MAX_IQ_TIME $DIR || error "set group grace time failed"
1443 $LFS setquota -t -g --block-grace $grace \
1444 --pool $qpool $DIR || error "set group grace time failed"
1446 $LFS setquota -g $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1447 error "set group quota failed"
1448 $LFS setquota -g $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1449 error "set group quota failed"
1451 test_block_soft $testfile $grace $limit "g" $qpool
1453 if is_project_quota_supported; then
1454 echo "Project quota in $qpool(soft:$limit MB grace:$grace sec)"
1455 testfile=$DIR/$tdir/$tfile-2
1456 # make sure the system is clean
1457 used=$(getquota -p $TSTPRJID global curspace)
1458 [ $used -ne 0 ] && error \
1459 "Used space($used) for project $TSTPRJID isn't 0."
1461 $LFS setquota -t -p --block-grace $glbl_grace --inode-grace \
1462 $MAX_IQ_TIME $DIR ||
1463 error "set project grace time failed"
1464 $LFS setquota -t -p --block-grace $grace \
1465 --pool $qpool $DIR ||
1466 error "set project grace time failed"
1468 $LFS setquota -p $TSTPRJID -b ${glbl_limit}M -B 0 -i 0 -I 0 \
1469 $DIR || error "set project quota failed"
1470 $LFS setquota -p $TSTPRJID -b ${limit}M -B 0 \
1471 --pool $qpool $DIR || error "set project quota failed"
1473 test_block_soft $testfile $grace $limit "p" $qpool
1474 resetquota -p $TSTPRJID
1475 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1476 $MAX_IQ_TIME $DIR ||
1477 error "restore project grace time failed"
1478 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --pool $qpool \
1479 $DIR || error "set project grace time failed"
1483 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1484 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1485 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1486 --pool $qpool $DIR || error "restore user grace time failed"
1487 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1488 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1489 $LFS setquota -t -g --block-grace $MAX_DQ_TIME \
1490 --pool $qpool $DIR || error "restore group grace time failed"
1492 run_test 3b "Quota pools: Block soft limit (start timer, expires, stop timer)"
1495 local grace=20 # 20s
1496 local qpool="qpool1"
1497 local qpool2="qpool2"
1498 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
1501 local testfile=$DIR/$tdir/$tfile-0
1504 # get minimum soft qunit size
1505 local limit=$(( $(do_facet $SINGLEMDS $LCTL get_param -n \
1506 qmt.$FSNAME-QMT0000.dt-0x0.soft_least_qunit) / 1024 ))
1507 local limit2=$((limit+4))
1508 local glbl_limit=$((limit+8))
1509 local grace1=$((grace+10))
1511 local glbl_grace=$((grace+20))
1512 echo "limit $limit limit2 $limit2 glbl_limit $glbl_limit"
1513 echo "grace1 $grace1 grace2 $grace2 glbl_grace $glbl_grace"
1515 set_ost_qtype $QTYPE || error "enable ost quota failed"
1517 echo "User quota in qpool2(soft:$limit2 MB grace:$grace2 seconds)"
1518 # make sure the system is clean
1519 local used=$(getquota -u $TSTUSR global curspace)
1520 [ $used -ne 0 ] && error "Used space($used) for user $TSTUSR isn't 0."
1522 pool_add $qpool || error "pool_add failed"
1523 pool_add_targets $qpool 0 1 ||
1524 error "pool_add_targets failed"
1526 pool_add $qpool2 || error "pool_add failed"
1527 pool_add_targets $qpool2 0 1 ||
1528 error "pool_add_targets failed"
1531 $LFS setquota -t -u --block-grace $glbl_grace --inode-grace \
1532 $MAX_IQ_TIME $DIR || error "set user grace time failed"
1533 $LFS setquota -t -u --block-grace $grace1 \
1534 --pool $qpool $DIR || error "set user grace time failed"
1535 $LFS setquota -t -u --block-grace $grace2 \
1536 --pool $qpool2 $DIR || error "set user grace time failed"
1538 $LFS setquota -u $TSTUSR -b ${glbl_limit}M -B 0 -i 0 -I 0 $DIR ||
1539 error "set user quota failed"
1540 $LFS setquota -u $TSTUSR -b ${limit}M -B 0 --pool $qpool $DIR ||
1541 error "set user quota failed"
1542 # qpool has minimum soft limit, but it's grace is grater than
1543 # grace period of qpool2. Thus write shouldn't fail when
1544 # hit qpool soft limit - only when reaches up qpool2 limit
1545 # after grace2 seconds.
1546 $LFS setquota -u $TSTUSR -b ${limit2}M -B 0 --pool $qpool2 $DIR ||
1547 error "set user quota failed"
1549 test_block_soft $testfile $grace2 $limit2 "u" $qpool2
1552 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1553 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1554 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1555 --pool $qpool $DIR || error "restore user grace time failed"
1556 $LFS setquota -t -u --block-grace $MAX_DQ_TIME \
1557 --pool $qpool2 $DIR || error "restore user grace time failed"
1559 run_test 3c "Quota pools: check block soft limit on different pools"
1566 local SOFT_LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1567 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1570 trap cleanup_quota_test EXIT
1571 is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
1573 echo "Create files to exceed soft limit"
1574 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
1575 quota_error a $TSTUSR "create failure, but expect success"
1576 local trigger_time=$(date +%s)
1578 sync_all_data || true
1580 local cur_time=$(date +%s)
1581 [ $(($cur_time - $trigger_time)) -ge $grace ] &&
1582 error "Passed grace time $grace, $trigger_time, $cur_time"
1584 echo "Create file before timer goes off"
1585 $RUNAS touch ${TESTFILE}_before ||
1586 quota_error a $TSTUSR "failed create before timer expired," \
1587 "but expect success. $trigger_time, $cur_time"
1588 sync_all_data || true
1590 wait_grace_time $qtype "file"
1595 $SHOW_QUOTA_INFO_USER
1596 $SHOW_QUOTA_INFO_GROUP
1597 $SHOW_QUOTA_INFO_PROJID
1599 echo "Create file after timer goes off"
1600 # exceed least soft limit is possible
1601 $RUNAS createmany -m ${TESTFILE}_after_3 $((SOFT_LIMIT + 1)) &&
1602 quota_error a $TSTUSR "create after timer expired," \
1604 sync_all_data || true
1609 $SHOW_QUOTA_INFO_USER
1610 $SHOW_QUOTA_INFO_GROUP
1611 $SHOW_QUOTA_INFO_PROJID
1613 echo "Unlink files to stop timer"
1614 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
1615 wait_delete_completed
1618 $RUNAS touch ${TESTFILE}_xxx ||
1619 quota_error a $TSTUSR "touch after timer stop failure," \
1620 "but expect success"
1621 sync_all_data || true
1629 local LIMIT=$(do_facet $SINGLEMDS $LCTL get_param -n \
1630 qmt.$FSNAME-QMT0000.md-0x0.soft_least_qunit)
1631 local TESTFILE=$DIR/$tdir/$tfile-0
1634 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1636 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1637 # make sure the system is clean
1638 local USED=$(getquota -u $TSTUSR global curinodes)
1639 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1641 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1642 $GRACE $DIR || error "set user grace time failed"
1643 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1644 error "set user quota failed"
1646 [ "$mds1_FSTYPE" = zfs ] && GRACE=20
1648 test_file_soft $TESTFILE $LIMIT $GRACE "u"
1650 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
1651 # make sure the system is clean
1652 USED=$(getquota -g $TSTUSR global curinodes)
1653 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
1655 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1656 $GRACE $DIR || error "set group grace time failed"
1657 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1658 error "set group quota failed"
1659 TESTFILE=$DIR/$tdir/$tfile-1
1661 test_file_soft $TESTFILE $LIMIT $GRACE "g"
1663 if is_project_quota_supported; then
1664 echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)"
1665 # make sure the system is clean
1666 USED=$(getquota -p $TSTPRJID global curinodes)
1667 [ $USED -ne 0 ] && error \
1668 "Used space($USED) for project $TSTPRJID isn't 0."
1670 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1671 $GRACE $DIR || error "set project grace time failed"
1672 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
1673 error "set project quota failed"
1675 TESTFILE=$DIR/$tdir/$tfile-1
1676 # one less than limit, because of parent directory included.
1677 test_file_soft $TESTFILE $((LIMIT-1)) $GRACE "p"
1678 resetquota -p $TSTPRJID
1679 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
1680 $MAX_IQ_TIME $DIR ||
1681 error "restore project grace time failed"
1685 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1686 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1687 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1688 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1690 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
1693 local GR_STR1="1w3d"
1694 local GR_STR2="1000s"
1696 local GR_STR4="1w2d3h4m5s"
1698 local GR_STR6="18446744073709551615"
1701 wait_delete_completed
1703 # test of valid grace strings handling
1704 echo "Valid grace strings test"
1705 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
1706 $GR_STR2 $DIR || error "set user grace time failed"
1707 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
1708 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
1709 $GR_STR4 $DIR || error "set group grace time quota failed"
1710 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
1712 # test of invalid grace strings handling
1713 echo " Invalid grace strings test"
1714 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
1715 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
1716 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \
1720 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1721 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1722 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1723 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1725 run_test 4b "Grace time strings handling"
1727 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
1729 local BLIMIT=10 # 10M
1730 local ILIMIT=10 # 10 inodes
1732 setup_quota_test || error "setup quota failed with $?"
1733 trap cleanup_quota_test EXIT
1735 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1736 set_ost_qtype $QTYPE || error "enable ost quota failed"
1738 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
1739 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1740 error "set user quota failed"
1741 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1742 if is_project_quota_supported; then
1743 error "set group quota failed"
1744 $LFS setquota -p $TSTPRJID -b 0 -B ${BLIMIT}M -i 0 \
1745 -I $ILIMIT $DIR || error "set project quota failed"
1748 # make sure the system is clean
1749 local USED=$(getquota -u $TSTUSR global curinodes)
1750 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1751 USED=$(getquota -g $TSTUSR global curinodes)
1752 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
1753 USED=$(getquota -u $TSTUSR global curspace)
1754 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
1755 USED=$(getquota -g $TSTUSR global curspace)
1756 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
1757 if is_project_quota_supported; then
1758 USED=$(getquota -p $TSTPRJID global curinodes)
1760 error "Used inode($USED) for project $TSTPRJID isn't 0."
1761 USED=$(getquota -p $TSTPRJID global curspace)
1763 error "Used block($USED) for project $TSTPRJID isn't 0."
1766 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
1767 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1768 error "create failure, expect success"
1769 if is_project_quota_supported; then
1770 touch $DIR/$tdir/$tfile-0_1
1771 change_project -p $TSTPRJID $DIR/$tdir/$tfile-0_1
1773 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
1774 error "write failure, expect success"
1776 echo "Chown files to $TSTUSR.$TSTUSR ..."
1777 for i in $(seq 0 $ILIMIT); do
1778 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
1779 quota_error a $TSTUSR "chown failure, expect success"
1783 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1784 error "unlinkmany $DIR/$tdir/$tfile-0_ failed"
1787 run_test 5 "Chown & chgrp successfully even out of block/file quota"
1789 # test dropping acquire request on master
1793 # Clear dmesg so watchdog is not triggered by previous
1795 do_facet ost1 dmesg -c > /dev/null
1797 setup_quota_test || error "setup quota failed with $?"
1798 trap cleanup_quota_test EXIT
1800 # make sure the system is clean
1801 local USED=$(getquota -u $TSTUSR global curspace)
1802 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1804 # make sure no granted quota on ost
1805 set_ost_qtype $QTYPE || error "enable ost quota failed"
1806 resetquota -u $TSTUSR
1808 # create file for $TSTUSR
1809 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
1810 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1811 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1813 # create file for $TSTUSR2
1814 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
1815 $LFS setstripe $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed"
1816 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed"
1818 # cache per-ID lock for $TSTUSR on slave
1819 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1820 error "set quota failed"
1821 $RUNAS $DD of=$TESTFILE count=1 ||
1822 error "write $TESTFILE failure, expect success"
1823 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
1824 error "write $TESTFILE2 failure, expect success"
1826 if at_is_enabled; then
1827 at_max_saved=$(at_max_get ost1)
1828 at_max_set $TIMEOUT ost1
1830 # write to enforced ID ($TSTUSR) to exceed limit to make sure
1831 # DQACQ is sent, which makes at_max to take effect
1832 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync \
1835 wait_delete_completed
1839 sync_all_data || true
1841 #define QUOTA_DQACQ 601
1842 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
1843 lustre_fail mds 0x513 601
1845 do_facet ost1 $LCTL set_param \
1846 osd-*.$FSNAME-OST*.quota_slave.timeout=$((TIMEOUT / 2))
1848 # write to un-enforced ID ($TSTUSR2) should succeed
1849 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
1850 error "write failure, expect success"
1852 # write to enforced ID ($TSTUSR) in background, exceeding limit
1853 # to make sure DQACQ is sent
1854 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
1857 # watchdog timer uses a factor of 2
1858 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
1859 sleep $((TIMEOUT * 2 + 1))
1861 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved ost1
1863 # write should be blocked and never finished
1864 if ! ps -p $DDPID > /dev/null 2>&1; then
1866 error "write finished incorrectly!"
1871 # no watchdog is triggered
1872 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1873 watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
1874 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1875 [ -z "$watchdog" ] || error "$watchdog"
1877 rm -f $TMP/lustre-log-${TESTNAME}.log
1879 # write should continue then fail with EDQUOT
1883 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1884 if [ $count -ge 240 ]; then
1885 quota_error u $TSTUSR "dd not finished in $count secs"
1887 count=$((count + 1))
1888 if [ $((count % 30)) -eq 0 ]; then
1889 c_size=$(stat -c %s $TESTFILE)
1890 echo "Waiting $count secs. $c_size"
1898 run_test 6 "Test dropping acquire request on master"
1900 # quota reintegration (global index)
1902 local TESTFILE=$DIR/$tdir/$tfile
1903 local LIMIT=20 # 20M
1905 [ "$SLOW" = "no" ] && LIMIT=5
1907 setup_quota_test || error "setup quota failed with $?"
1908 trap cleanup_quota_test EXIT
1910 # make sure the system is clean
1911 local USED=$(getquota -u $TSTUSR global curspace)
1912 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1914 # make sure no granted quota on ost1
1915 set_ost_qtype $QTYPE || error "enable ost quota failed"
1916 resetquota -u $TSTUSR
1917 set_ost_qtype "none" || error "disable ost quota failed"
1919 local OSTUUID=$(ostuuid_from_index 0)
1920 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1922 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1925 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1926 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1931 echo "Enable quota & set quota limit for $TSTUSR"
1932 set_ost_qtype $QTYPE || error "enable ost quota failed"
1933 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1934 error "set quota failed"
1936 echo "Start ost1..."
1937 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1940 wait_ost_reint $QTYPE || error "reintegration failed"
1942 # hardlimit should have been fetched by slave during global
1943 # reintegration, write will exceed quota
1944 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1945 quota_error u $TSTUSR "write success, but expect EDQUOT"
1948 wait_delete_completed
1949 sync_all_data || true
1955 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1956 error "clear quota failed"
1958 echo "Start ost1..."
1959 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1962 wait_ost_reint $QTYPE || error "reintegration failed"
1964 # hardlimit should be cleared on slave during reintegration
1965 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
1966 quota_error u $TSTUSR "write error, but expect success"
1970 run_test 7a "Quota reintegration (global index)"
1972 # quota reintegration (slave index)
1975 local TESTFILE=$DIR/$tdir/$tfile
1977 setup_quota_test || error "setup quota failed with $?"
1978 trap cleanup_quota_test EXIT
1980 # make sure the system is clean
1981 local USED=$(getquota -u $TSTUSR global curspace)
1982 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1984 # make sure no granted quota on ost1
1985 set_ost_qtype $QTYPE || error "enable ost quota failed"
1986 resetquota -u $TSTUSR
1987 set_ost_qtype "none" || error "disable ost quota failed"
1989 local OSTUUID=$(ostuuid_from_index 0)
1990 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1992 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1995 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1996 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1998 # consume some space to make sure the granted space will not
1999 # be released during reconciliation
2000 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2001 error "consume space failure, expect success"
2003 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
2004 lustre_fail mds 0xa02
2006 set_ost_qtype $QTYPE || error "enable ost quota failed"
2007 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2008 error "set quota failed"
2010 # ignore the write error
2011 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
2013 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2017 echo "Restart ost to trigger reintegration..."
2019 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
2022 wait_ost_reint $QTYPE || error "reintegration failed"
2024 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2025 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
2030 run_test 7b "Quota reintegration (slave index)"
2032 # quota reintegration (restart mds during reintegration)
2034 local LIMIT=20 # 20M
2035 local TESTFILE=$DIR/$tdir/$tfile
2037 [ "$SLOW" = "no" ] && LIMIT=5
2039 setup_quota_test || error "setup quota failed with $?"
2040 trap cleanup_quota_test EXIT
2042 # make sure the system is clean
2043 local USED=$(getquota -u $TSTUSR global curspace)
2044 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2046 set_ost_qtype "none" || error "disable ost quota failed"
2047 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
2048 error "set quota failed"
2050 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
2051 lustre_fail ost 0xa03
2054 set_ost_qtype $QTYPE || error "enable ost quota failed"
2055 # trigger reintegration
2056 local procf="osd-$ost1_FSTYPE.$FSNAME-OST*."
2057 procf=${procf}quota_slave.force_reint
2058 do_facet ost1 $LCTL set_param $procf=1 ||
2059 error "force reintegration failed"
2067 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
2070 # wait longer than usual to make sure the reintegration
2071 # is triggered by quota wb thread.
2072 wait_ost_reint $QTYPE 200 || error "reintegration failed"
2074 # hardlimit should have been fetched by slave during global
2075 # reintegration, write will exceed quota
2076 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
2077 quota_error u $TSTUSR "write success, but expect EDQUOT"
2081 run_test 7c "Quota reintegration (restart mds during reintegration)"
2083 # Quota reintegration (Transfer index in multiple bulks)
2085 local TESTFILE=$DIR/$tdir/$tfile
2086 local TESTFILE1="$DIR/$tdir/$tfile"-1
2089 setup_quota_test || error "setup quota failed with $?"
2090 trap cleanup_quota_test EXIT
2092 set_ost_qtype "none" || error "disable ost quota failed"
2093 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
2094 error "set quota for $TSTUSR failed"
2095 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
2096 error "set quota for $TSTUSR2 failed"
2098 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
2099 lustre_fail mds 0x608 0
2101 # enable quota to tirgger reintegration
2102 set_ost_qtype "u" || error "enable ost quota failed"
2103 wait_ost_reint "u" || error "reintegration failed"
2107 # hardlimit should have been fetched by slave during global
2108 # reintegration, write will exceed quota
2109 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
2110 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
2112 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
2113 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
2117 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
2119 # quota reintegration (inode limits)
2121 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2123 # LU-2435: skip this quota test if underlying zfs version has not
2124 # supported native dnode accounting
2125 [ "$mds1_FSTYPE" == zfs ] && {
2126 local F="feature@userobj_accounting"
2127 local pool=$(zpool_name mds1)
2128 local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
2130 [[ "$feature" != *" active "* ]] &&
2131 skip "requires zpool with active userobj_accounting"
2134 local ilimit=$((1024 * 2)) # 2k inodes
2135 local TESTFILE=$DIR/${tdir}-1/$tfile
2137 setup_quota_test || error "setup quota failed with $?"
2138 trap cleanup_quota_test EXIT
2140 # make sure the system is clean
2141 local USED=$(getquota -u $TSTUSR global curinodes)
2142 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
2144 # make sure no granted quota on mdt1
2145 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2146 resetquota -u $TSTUSR
2147 set_mdt_qtype "none" || error "disable mdt quota failed"
2149 local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
2150 USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
2151 [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
2154 echo "Stop mds${MDSCOUNT}..."
2157 echo "Enable quota & set quota limit for $TSTUSR"
2158 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2159 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2160 error "set quota failed"
2162 echo "Start mds${MDSCOUNT}..."
2163 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
2166 wait_mdt_reint $QTYPE || error "reintegration failed"
2168 echo "create remote dir"
2169 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
2170 error "create remote dir failed"
2171 chmod 0777 $DIR/${tdir}-1
2173 # hardlimit should have been fetched by slave during global
2174 # reintegration, create will exceed quota
2175 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
2176 quota_error u $TSTUSR "create succeeded, expect EDQUOT"
2178 $RUNAS unlinkmany $TESTFILE $ilimit || error "unlink files failed"
2179 wait_delete_completed
2180 sync_all_data || true
2182 echo "Stop mds${MDSCOUNT}..."
2185 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
2186 error "clear quota failed"
2188 echo "Start mds${MDSCOUNT}..."
2189 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
2192 wait_mdt_reint $QTYPE || error "reintegration failed"
2194 # hardlimit should be cleared on slave during reintegration
2195 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
2196 quota_error u $TSTUSR "create failed, expect success"
2198 $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
2199 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2203 run_test 7e "Quota reintegration (inode limits)"
2205 # run dbench with quota enabled
2207 local BLK_LIMIT="100g" #100G
2208 local FILE_LIMIT=1000000
2210 setup_quota_test || error "setup quota failed with $?"
2211 trap cleanup_quota_test EXIT
2213 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
2214 set_ost_qtype $QTYPE || error "enable ost quota failed"
2216 echo "Set enough high limit for user: $TSTUSR"
2217 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2218 error "set user quota failed"
2219 echo "Set enough high limit for group: $TSTUSR"
2220 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2221 error "set group quota failed"
2222 if is_project_quota_supported; then
2223 change_project -sp $TSTPRJID $DIR/$tdir
2224 echo "Set enough high limit for project: $TSTPRJID"
2225 $LFS setquota -p $TSTPRJID -b 0 \
2226 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2227 error "set project quota failed"
2231 [ "$SLOW" = "no" ] && duration=" -t 120"
2232 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
2233 quota_error a $TSTUSR "dbench failed!"
2235 is_project_quota_supported && change_project -C $DIR/$tdir
2238 run_test 8 "Run dbench with quota enabled"
2240 # this check is just for test_9
2241 OST0_MIN=4900000 #4.67G
2243 check_whether_skip () {
2244 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
2245 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
2246 if [ $OST0_SIZE -lt $OST0_MIN ]; then
2247 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
2254 # run for fixing bug10707, it needs a big room. test for 64bit
2256 local filesize=$((1024 * 9 / 2)) # 4.5G
2258 check_whether_skip && return 0
2260 setup_quota_test || error "setup quota failed with $?"
2261 trap cleanup_quota_test EXIT
2263 set_ost_qtype "ug" || error "enable ost quota failed"
2265 local TESTFILE="$DIR/$tdir/$tfile-0"
2266 local BLK_LIMIT=100G #100G
2267 local FILE_LIMIT=1000000
2269 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
2271 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2273 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2274 error "set user quota failed"
2276 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
2277 "for group: $TSTUSR"
2278 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
2279 error "set group quota failed"
2281 quota_show_check a u $TSTUSR
2282 quota_show_check a g $TSTUSR
2284 echo "Create test file"
2285 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2286 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2288 log "Write the big file of 4.5G ..."
2289 $RUNAS $DD of=$TESTFILE count=$filesize ||
2290 quota_error a $TSTUSR "write 4.5G file failure, expect success"
2300 run_test 9 "Block limit larger than 4GB (b10707)"
2303 local TESTFILE=$DIR/$tdir/$tfile
2305 setup_quota_test || error "setup quota failed with $?"
2306 trap cleanup_quota_test EXIT
2308 # set limit to root user should fail
2309 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
2310 error "set limit for root user successfully, expect failure"
2311 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
2312 error "set limit for root group successfully, expect failure"
2313 $LFS setquota -p 0 -b 1T -B 10T -i 5K -I 100M $DIR &&
2314 error "set limit for project 0 successfully, expect failure"
2316 # root user can overrun quota
2317 set_ost_qtype "ug" || error "enable ost quota failed"
2319 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
2320 error "set quota failed"
2321 quota_show_check b u $TSTUSR
2323 $LFS setstripe $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
2324 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2326 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
2327 error "write failure, expect success"
2331 run_test 10 "Test quota for root user"
2334 local TESTFILE=$DIR/$tdir/$tfile
2335 setup_quota_test || error "setup quota failed with $?"
2336 trap cleanup_quota_test EXIT
2338 set_mdt_qtype "ug" || error "enable mdt quota failed"
2339 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
2340 error "set quota failed"
2342 touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed"
2343 touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed"
2345 chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed"
2346 chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed"
2349 local USED=$(getquota -u $TSTUSR global curinodes)
2350 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
2354 run_test 11 "Chown/chgrp ignores quota"
2357 [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs"
2359 local blimit=22 # 22M
2360 local blk_cnt=$((blimit - 5))
2361 local TESTFILE0="$DIR/$tdir/$tfile"-0
2362 local TESTFILE1="$DIR/$tdir/$tfile"-1
2364 setup_quota_test || error "setup quota failed with $?"
2365 trap cleanup_quota_test EXIT
2367 set_ost_qtype "u" || error "enable ost quota failed"
2368 quota_show_check b u $TSTUSR
2370 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
2371 error "set quota failed"
2373 $LFS setstripe $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed"
2374 $LFS setstripe $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed"
2375 chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed"
2376 chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed"
2378 echo "Write to ost0..."
2379 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
2380 quota_error a $TSTUSR "dd failed"
2382 echo "Write to ost1..."
2383 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
2384 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
2386 echo "Free space from ost0..."
2388 wait_delete_completed
2389 sync_all_data || true
2391 echo "Write to ost1 after space freed from ost0..."
2392 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
2393 quota_error a $TSTUSR "rebalancing failed"
2397 run_test 12a "Block quota rebalancing"
2400 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
2402 local ilimit=$((1024 * 2)) # 2k inodes
2403 local TESTFILE0=$DIR/$tdir/$tfile
2404 local TESTFILE1=$DIR/${tdir}-1/$tfile
2406 setup_quota_test || error "setup quota failed with $?"
2407 trap cleanup_quota_test EXIT
2409 $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed"
2410 chmod 0777 $DIR/${tdir}-1
2412 set_mdt_qtype "u" || error "enable mdt quota failed"
2413 quota_show_check f u $TSTUSR
2415 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
2416 error "set quota failed"
2418 echo "Create $ilimit files on mdt0..."
2419 $RUNAS createmany -m $TESTFILE0 $ilimit ||
2420 quota_error u $TSTUSR "create failed, but expect success"
2422 echo "Create files on mdt1..."
2423 $RUNAS createmany -m $TESTFILE1 1 &&
2424 quota_error a $TSTUSR "create succeeded, expect EDQUOT"
2426 echo "Free space from mdt0..."
2427 $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed"
2428 wait_delete_completed
2429 sync_all_data || true
2431 echo "Create files on mdt1 after space freed from mdt0..."
2432 $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) ||
2433 quota_error a $TSTUSR "rebalancing failed"
2435 $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) ||
2436 error "unlink mdt1 files failed"
2437 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
2441 run_test 12b "Inode quota rebalancing"
2444 local TESTFILE=$DIR/$tdir/$tfile
2445 # the name of lwp on ost1 name is MDT0000-lwp-OST0000
2446 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size"
2448 setup_quota_test || error "setup quota failed with $?"
2449 trap cleanup_quota_test EXIT
2451 set_ost_qtype "u" || error "enable ost quota failed"
2452 quota_show_check b u $TSTUSR
2454 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2455 error "set quota failed"
2456 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2457 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2459 # clear the locks in cache first
2460 do_facet ost1 $LCTL set_param -n $procf=clear
2461 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2462 [ $nlock -eq 0 ] || error "$nlock cached locks"
2464 # write to acquire the per-ID lock
2465 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
2466 quota_error a $TSTUSR "dd failed"
2468 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2469 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
2471 # clear quota doesn't trigger per-ID lock cancellation
2472 resetquota -u $TSTUSR
2473 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2474 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
2476 # clear the per-ID lock
2477 do_facet ost1 $LCTL set_param -n $procf=clear
2478 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
2479 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
2481 # spare quota should be released
2482 local OSTUUID=$(ostuuid_from_index 0)
2483 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
2484 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
2485 [ $limit -le $space ] ||
2486 error "spare quota isn't released, limit:$limit, space:$space"
2490 run_test 13 "Cancel per-ID lock in the LRU list"
2493 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
2495 wait_delete_completed
2496 sync_all_data || true
2499 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2500 error "set user quota failed"
2501 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
2502 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2503 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2504 resetquota -u $TSTUSR
2507 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
2508 error "set group quota failed"
2509 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
2510 [ $TOTAL_LIMIT -eq $LIMIT ] ||
2511 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
2512 resetquota -g $TSTUSR
2514 run_test 15 "Set over 4T block quota"
2518 local BLKS=1 # 1M less than limit
2519 local TESTFILE=$DIR/$tdir/$tfile
2521 setup_quota_test || error "setup quota failed with $?"
2522 trap cleanup_quota_test EXIT
2524 # make sure the system is clean
2525 local USED=$(getquota -u $TSTUSR global curspace)
2526 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
2528 set_ost_qtype "ug" || error "enable ost quota failed"
2529 # make sure no granted quota on ost
2530 resetquota -u $TSTUSR
2531 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
2532 error "set quota failed"
2534 quota_show_check b u $TSTUSR
2536 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
2537 lustre_fail mds 0xa04 $err_code
2539 # write in background
2540 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
2544 # write should be blocked and never finished
2545 if ! ps -p $DDPID > /dev/null 2>&1; then
2547 quota_error u $TSTUSR "write finished incorrectly!"
2555 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2557 if [ $count -gt $timeout ]; then
2558 quota_error u $TSTUSR "dd is not finished!"
2563 sync; sync_all_data || true
2565 USED=$(getquota -u $TSTUSR global curspace)
2566 [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \
2567 "Used space(${USED}K) is less than ${BLKS}M"
2572 # DQACQ return recoverable error
2574 echo "DQACQ return -ENOLCK"
2576 test_17sub 37 || error "Handle -ENOLCK failed"
2578 echo "DQACQ return -EAGAIN"
2580 test_17sub 11 || error "Handle -EAGAIN failed"
2582 echo "DQACQ return -ETIMEDOUT"
2583 #define ETIMEDOUT 110
2584 test_17sub 110 || error "Handle -ETIMEDOUT failed"
2586 echo "DQACQ return -ENOTCONN"
2587 #define ENOTCONN 107
2588 test_17sub 107 || error "Handle -ENOTCONN failed"
2591 run_test 17 "DQACQ return recoverable error"
2595 local blimit="200m" # 200M
2596 local TESTFILE="$DIR/$tdir/$tfile"
2598 setup_quota_test || error "setup quota failed with $?"
2599 trap cleanup_quota_test EXIT
2601 set_ost_qtype "u" || error "enable ost quota failed"
2602 log "User quota (limit: $blimit)"
2603 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
2604 error "set quota failed"
2605 quota_show_check b u $TSTUSR
2607 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
2608 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2610 local timeout=$(sysctl -n lustre.timeout)
2612 if [ $io_type = "directio" ]; then
2613 log "Write 100M (directio) ..."
2614 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
2616 log "Write 100M (buffered) ..."
2617 $RUNAS $DD of=$TESTFILE count=100 &
2621 replay_barrier $SINGLEMDS
2622 log "Fail mds for $((2 * timeout)) seconds"
2623 fail $SINGLEMDS $((2 * timeout))
2626 if at_is_enabled; then
2627 timeout=$(at_max_get mds)
2629 timeout=$(lctl get_param -n timeout)
2633 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
2634 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
2635 log "it took $count second"
2640 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
2642 cancel_lru_locks mdc
2643 cancel_lru_locks osc
2646 local testfile_size=$(stat -c %s $TESTFILE)
2647 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
2648 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \
2649 "got ${testfile_size}. Verifying file failed!"
2654 # test when mds does failover, the ost still could work well
2655 # this test shouldn't trigger watchdog b=14840
2657 # Clear dmesg so watchdog is not triggered by previous
2659 do_facet ost1 dmesg -c > /dev/null
2662 test_18_sub directio
2664 # check if watchdog is triggered
2665 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
2666 local watchdog=$(awk '/[Ss]ervice thread pid/ && /was inactive/ \
2667 { print; }' $TMP/lustre-log-${TESTNAME}.log)
2668 [ -z "$watchdog" ] || error "$watchdog"
2669 rm -f $TMP/lustre-log-${TESTNAME}.log
2671 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
2675 local TESTFILE=$DIR/$tdir/$tfile
2677 setup_quota_test || error "setup quota failed with $?"
2678 trap cleanup_quota_test EXIT
2680 set_ost_qtype $QTYPE || error "enable ost quota failed"
2682 # bind file to a single OST
2683 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2684 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2686 echo "Set user quota (limit: ${blimit}M)"
2687 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2688 error "set user quota failed"
2689 quota_show_check b u $TSTUSR
2690 echo "Update quota limits"
2691 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2692 error "set group quota failed"
2693 quota_show_check b u $TSTUSR
2695 # first wirte might be cached
2696 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
2697 cancel_lru_locks osc
2699 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
2700 quota_error u $TSTUSR "Write success, expect failure"
2705 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
2707 test_20() { # b15754
2708 local LSTR=(2g 1t 4k 3m) # limits strings
2710 local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \
2713 resetquota -u $TSTUSR
2715 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
2716 $MOUNT || error "could not set quota limits"
2717 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
2718 --inode-softlimit ${LSTR[2]} \
2719 --inode-hardlimit ${LSTR[3]} \
2720 $MOUNT || error "could not set quota limits"
2722 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
2723 error "bsoftlimit was not set properly"
2724 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
2725 error "bhardlimit was not set properly"
2726 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
2727 error "isoftlimit was not set properly"
2728 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
2729 error "ihardlimit was not set properly"
2731 resetquota -u $TSTUSR
2733 run_test 20 "Test if setquota specifiers work properly (b15754)"
2740 local time=$(($(date +%s) + seconds))
2741 while [ $(date +%s) -lt $time ]; do
2742 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
2746 # run for fixing bug16053, setquota shouldn't fail when writing and
2747 # deleting are happening
2749 local TESTFILE="$DIR/$tdir/$tfile"
2750 local BLIMIT=10 # 10G
2751 local ILIMIT=1000000
2753 setup_quota_test || error "setup quota failed with $?"
2754 trap cleanup_quota_test EXIT
2756 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2758 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
2759 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
2760 error "set user quota failed"
2761 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
2762 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
2763 error "set group quota failed"
2764 if is_project_quota_supported; then
2765 log "Set limit(block:${BLIMIT}G; file:$LIMIT) for " \
2766 "project: $TSTPRJID"
2767 $LFS setquota -p $TSTPRJID -b 0 -B $BLIMIT -i 0 -I $ILIMIT \
2768 $MOUNT || error "set project quota failed"
2771 # repeat writing on a 1M file
2772 test_21_sub ${TESTFILE}_1 1 30 &
2774 # repeat writing on a 128M file
2775 test_21_sub ${TESTFILE}_2 128 30 &
2778 local time=$(($(date +%s) + 30))
2780 while [ $(date +%s) -lt $time ]; do
2781 log "Set quota for $i times"
2782 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2783 -I $((ILIMIT + i)) $MOUNT ||
2784 error "Set user quota failed"
2785 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2786 -I $((ILIMIT + i)) $MOUNT ||
2787 error "Set group quota failed"
2788 if is_project_quota_supported; then
2789 $LFS setquota -p $TSTPRJID -b 0 -B \
2790 "$((BLIMIT + i))G" -i 0 -I $((ILIMIT + i)) $MOUNT ||
2791 error "Set project quota failed"
2799 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
2801 if [ $count -gt 60 ]; then
2802 quota_error a $TSTUSR "dd should be finished!"
2806 echo "(dd_pid=$DDPID1, time=$count)successful"
2810 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
2812 if [ $count -gt 60 ]; then
2813 quota_error a $TSTUSR "dd should be finished!"
2817 echo "(dd_pid=$DDPID2, time=$count)successful"
2821 run_test 21 "Setquota while writing & deleting (b16053)"
2823 # enable/disable quota enforcement permanently
2825 echo "Set both mdt & ost quota type as ug"
2827 is_project_quota_supported && qtype=$QTYPE
2828 set_mdt_qtype $qtype || error "enable mdt quota failed"
2829 set_ost_qtype $qtype || error "enable ost quota failed"
2832 stopall || error "failed to stopall (1)"
2836 echo "Verify if quota is enabled"
2837 local qtype1=$(mdt_quota_type)
2838 [ $qtype1 != $qtype ] && error "mdt quota setting is lost"
2839 qtype=$(ost_quota_type)
2840 [ $qtype1 != $qtype ] && error "ost quota setting is lost"
2842 echo "Set both mdt & ost quota type as none"
2843 set_mdt_qtype "none" || error "disable mdt quota failed"
2844 set_ost_qtype "none" || error "disable ost quota failed"
2847 stopall || error "failed to stopall (2)"
2852 echo "Verify if quota is disabled"
2853 qtype=$(mdt_quota_type)
2854 [ $qtype != "none" ] && error "mdt quota setting is lost"
2855 qtype=$(ost_quota_type)
2856 [ $qtype != "none" ] && error "ost quota setting is lost"
2860 run_test 22 "enable/disable quota by 'lctl conf_param/set_param -P'"
2863 local TESTFILE="$DIR/$tdir/$tfile"
2866 setup_quota_test || error "setup quota failed with $?"
2867 trap cleanup_quota_test EXIT
2869 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2872 log "User quota (limit: $LIMIT MB)"
2873 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
2874 error "set quota failed"
2875 quota_show_check b u $TSTUSR
2877 $LFS setstripe $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2878 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2880 log "Step1: trigger EDQUOT with O_DIRECT"
2881 log "Write half of file"
2882 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
2883 quota_error u $TSTUSR "(1) Write failure, expect success." \
2885 log "Write out of block quota ..."
2886 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
2887 oflag=direct conv=notrunc &&
2888 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
2892 log "Step2: rewrite should succeed"
2893 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
2894 quota_error u $TSTUSR "(3) Write failure, expect success." \
2900 local OST0_UUID=$(ostuuid_from_index 0)
2901 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
2902 [ $OST0_QUOTA_USED -ne 0 ] &&
2903 ($SHOW_QUOTA_USER; \
2904 quota_error u $TSTUSR "quota isn't released")
2909 [ "$ost1_FSTYPE" == zfs ] &&
2910 skip "Overwrite in place is not guaranteed to be " \
2911 "space neutral on ZFS"
2913 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
2914 check_whether_skip && return 0
2915 log "run for 4MB test file"
2918 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
2919 check_whether_skip && return 0
2920 log "run for 40MB test file"
2923 run_test 23 "Quota should be honored with directIO (b16125)"
2927 local TESTFILE="$DIR/$tdir/$tfile"
2929 setup_quota_test || error "setup quota failed with $?"
2930 trap cleanup_quota_test EXIT
2932 set_ost_qtype $QTYPE || error "enable ost quota failed"
2934 # bind file to a single OST
2935 $LFS setstripe -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2936 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2938 echo "Set user quota (limit: ${blimit}M)"
2939 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2940 error "set quota failed"
2942 # overrun quota by root user
2943 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
2944 error "write failure, expect success"
2945 cancel_lru_locks osc
2946 sync_all_data || true
2948 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
2952 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
2954 test_27a() { # b19612
2955 $LFS quota $TSTUSR $DIR &&
2956 error "lfs succeeded with no type, but should have failed"
2957 $LFS setquota $TSTUSR $DIR &&
2958 error "lfs succeeded with no type, but should have failed"
2961 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
2963 test_27b() { # b20200
2964 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2965 error "lfs setquota failed with uid argument"
2966 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2967 error "lfs stequota failed with gid argument"
2968 if is_project_quota_supported; then
2969 $LFS setquota -p $TSTPRJID -b 1000 -B 1000 -i 1000 -I \
2970 1000 $DIR || error \
2971 "lfs stequota failed with projid argument"
2973 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
2974 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
2975 if is_project_quota_supported; then
2976 $SHOW_QUOTA_PROJID ||
2977 error "lfs quota failed with projid argument"
2979 resetquota -u $TSTID
2980 resetquota -g $TSTID
2981 resetquota -p $TSTPRJID
2984 run_test 27b "lfs quota/setquota should handle user/group/project ID (b20200)"
2989 $LFS setquota -u $TSTID -b 30M -B 3T $DIR ||
2990 error "lfs setquota failed"
2992 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
2993 [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
2994 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
2995 [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
2997 $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
2998 error "lfs setquota for $TSTID failed"
3000 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
3001 [ $limit != "1.465G" ] && error "wrong softlimit $limit"
3002 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
3003 [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
3005 $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
3006 error "total allocated inode/block limit not printed"
3008 resetquota -u $TSTUSR
3010 run_test 27c "lfs quota should support human-readable output"
3017 $LFS setquota -u $TSTID -b ${softlimit}p -B ${hardlimit}P $DIR ||
3018 error "set fraction block limit failed"
3019 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $3}')
3020 [ $limit == ${softlimit}P ] || error "get fraction softlimit failed"
3021 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $4}')
3022 [ $limit == ${hardlimit}P ] || error "get fraction hardlimit failed"
3024 resetquota -u $TSTUSR
3026 run_test 27d "lfs setquota should support fraction block limit"
3030 local TESTFILE="$DIR/$tdir/$tfile"
3033 setup_quota_test || error "setup quota failed with $?"
3034 trap cleanup_quota_test EXIT
3036 set_ost_qtype "u" || error "enable ost quota failed"
3038 $LFS setstripe $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
3039 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
3041 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
3042 $MAX_IQ_TIME $DIR || error "set grace time failed"
3043 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
3044 error "set quota failed"
3045 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
3046 cancel_lru_locks osc
3048 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
3049 # over-quota flag has not yet settled since we do not trigger async
3050 # events based on grace time period expiration
3052 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
3053 cancel_lru_locks osc
3054 # now over-quota flag should be settled and further writes should fail
3056 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
3057 error "grace times were reset"
3060 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
3061 $MAX_IQ_TIME $DIR || error "restore grace time failed"
3063 run_test 30 "Hard limit updates should not reset grace times"
3065 # basic usage tracking for user & group
3067 local INODES=10 # 10 files
3068 local BLK_CNT=2 # of 2M each
3069 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
3071 setup_quota_test || error "setup quota failed with $?"
3072 trap cleanup_quota_test EXIT
3074 # make sure the system is clean
3075 local USED=$(getquota -u $TSTID global curspace)
3077 error "Used space ($USED) for user $TSTID isn't 0."
3078 USED=$(getquota -g $TSTID global curspace)
3080 error "Used space ($USED) for group $TSTID isn't 0."
3081 if is_project_quota_supported; then
3082 USED=$(getquota -p $TSTPRJID global curspace)
3083 [ $USED -ne 0 ] && error \
3084 "Used space ($USED) for project $TSTPRJID isn't 0."
3087 echo "Write files..."
3088 for i in $(seq 0 $INODES); do
3089 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
3090 error "write failed"
3091 is_project_quota_supported &&
3092 change_project -p $TSTPRJID $DIR/$tdir/$tfile-$i
3093 echo "Iteration $i/$INODES completed"
3095 cancel_lru_locks osc
3097 echo "Wait for setattr on objects finished..."
3098 wait_delete_completed
3100 sync; sync_all_data || true
3102 echo "Verify disk usage after write"
3103 USED=$(getquota -u $TSTID global curspace)
3104 [ $USED -lt $TOTAL_BLKS ] &&
3105 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
3106 USED=$(getquota -g $TSTID global curspace)
3107 [ $USED -lt $TOTAL_BLKS ] &&
3108 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
3109 if is_project_quota_supported; then
3110 USED=$(getquota -p $TSTPRJID global curspace)
3111 [ $USED -lt $TOTAL_BLKS ] && error \
3112 "Used space for project $TSTPRJID:$USED, expected:$TOTAL_BLKS"
3115 echo "Verify inode usage after write"
3116 USED=$(getquota -u $TSTID global curinodes)
3117 [ $USED -lt $INODES ] &&
3118 error "Used inode for user $TSTID is $USED, expected $INODES"
3119 USED=$(getquota -g $TSTID global curinodes)
3120 [ $USED -lt $INODES ] &&
3121 error "Used inode for group $TSTID is $USED, expected $INODES"
3122 if is_project_quota_supported; then
3123 USED=$(getquota -p $TSTPRJID global curinodes)
3124 [ $USED -lt $INODES ] && error \
3125 "Used inode for project $TSTPRJID is $USED, expected $INODES"
3130 echo "Verify disk usage after delete"
3131 USED=$(getquota -u $TSTID global curspace)
3132 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
3133 USED=$(getquota -u $TSTID global curinodes)
3134 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
3135 USED=$(getquota -g $TSTID global curspace)
3136 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
3137 USED=$(getquota -g $TSTID global curinodes)
3138 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
3139 if is_project_quota_supported; then
3140 USED=$(getquota -p $TSTPRJID global curspace)
3142 error "Used space for project $TSTPRJID isn't 0. $USED"
3143 USED=$(getquota -p $TSTPRJID global curinodes)
3145 error "Used inodes for project $TSTPRJID isn't 0. $USED"
3148 run_test 33 "Basic usage tracking for user & group & project"
3150 # usage transfer test for user & group & project
3152 local BLK_CNT=2 # 2MB
3153 local project_supported="no"
3155 is_project_quota_supported && project_supported="yes"
3156 setup_quota_test || error "setup quota failed with $?"
3157 trap cleanup_quota_test EXIT
3159 # make sure the system is clean
3160 local USED=$(getquota -u $TSTID global curspace)
3161 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
3162 USED=$(getquota -g $TSTID global curspace)
3163 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
3165 local USED=$(getquota -u $TSTID2 global curspace)
3166 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID2 isn't 0."
3167 if [ $project_supported == "yes" ]; then
3168 USED=$(getquota -p $TSTPRJID global curspace)
3169 [ $USED -ne 0 ] && error \
3170 "Used space ($USED) for Project $TSTPRJID isn't 0."
3173 echo "Write file..."
3174 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
3175 error "write failed"
3176 cancel_lru_locks osc
3177 sync; sync_all_data || true
3179 echo "chown the file to user $TSTID"
3180 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
3182 echo "Wait for setattr on objects finished..."
3183 wait_delete_completed
3185 BLK_CNT=$((BLK_CNT * 1024))
3187 echo "Verify disk usage for user $TSTID"
3188 USED=$(getquota -u $TSTID global curspace)
3189 [ $USED -lt $BLK_CNT ] &&
3190 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
3191 USED=$(getquota -u $TSTID global curinodes)
3193 error "Used inodes for user $TSTID is $USED, expected 1"
3195 echo "chgrp the file to group $TSTID"
3196 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
3198 echo "Wait for setattr on objects finished..."
3199 wait_delete_completed
3201 echo "Verify disk usage for group $TSTID"
3202 USED=$(getquota -g $TSTID global curspace)
3203 [ $USED -ge $BLK_CNT ] ||
3204 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3205 USED=$(getquota -g $TSTID global curinodes)
3207 error "Used inodes for group $TSTID is $USED, expected 1"
3209 # chown won't change the ost object group. LU-4345 */
3210 echo "chown the file to user $TSTID2"
3211 chown $TSTID2 $DIR/$tdir/$tfile || error "chown to $TSTID2 failed"
3213 echo "Wait for setattr on objects finished..."
3214 wait_delete_completed
3216 echo "change_project project id to $TSTPRJID"
3217 [ $project_supported == "yes" ] &&
3218 change_project -p $TSTPRJID $DIR/$tdir/$tfile
3219 echo "Wait for setattr on objects finished..."
3220 wait_delete_completed
3222 echo "Verify disk usage for user $TSTID2/$TSTID and group $TSTID"
3223 USED=$(getquota -u $TSTID2 global curspace)
3224 [ $USED -lt $BLK_CNT ] &&
3225 error "Used space for user $TSTID2 is $USED, expected $BLK_CNT"
3226 USED=$(getquota -u $TSTID global curspace)
3228 error "Used space for user $TSTID is $USED, expected 0"
3229 USED=$(getquota -g $TSTID global curspace)
3230 [ $USED -lt $BLK_CNT ] &&
3231 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
3232 if [ $project_supported == "yes" ]; then
3233 USED=$(getquota -p $TSTPRJID global curspace)
3234 [ $USED -lt $BLK_CNT ] && error \
3235 "Used space for group $TSTPRJID is $USED, expected $BLK_CNT"
3240 run_test 34 "Usage transfer for user & group & project"
3242 # usage is still accessible across restart
3244 local BLK_CNT=2 # 2 MB
3246 setup_quota_test || error "setup quota failed with $?"
3247 trap cleanup_quota_test EXIT
3249 echo "Write file..."
3250 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
3251 error "write failed"
3252 is_project_quota_supported &&
3253 change_project -p $TSTPRJID $DIR/$tdir/$tfile
3254 cancel_lru_locks osc
3256 echo "Wait for setattr on objects finished..."