3 # Run select tests by setting ONLY, or as arguments to the script.
4 # Skip specific tests by setting EXCEPT.
6 # Run test by setting NOSETUP=true when ltest has setup env for us
10 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
13 # Bug number for skipped test:
14 ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
15 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
17 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
18 echo "Skipping tests: $ALWAYS_EXCEPT $EXCEPT"
24 TSTID2=${TSTID2:-60001}
25 TSTUSR=${TSTUSR:-"quota_usr"}
26 TSTUSR2=${TSTUSR2:-"quota_2usr"}
27 TSTPRJID=${TSTPRJID:-1000}
33 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
34 . $LUSTRE/tests/test-framework.sh
36 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
38 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
40 require_dsh_mds || exit 0
41 require_dsh_ost || exit 0
43 # Does e2fsprogs support quota feature?
44 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
45 do_facet $SINGLEMDS "! $DEBUGFS -c -R supported_features |
46 grep -q 'quota'"; then
47 skip_env "e2fsprogs doesn't support quota" && exit 0
50 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
51 # bug number for skipped test: LU-2836 LU-6836 LU-2836
52 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 3 4a 6"
59 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$ZFS_SLOW"
61 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
63 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
68 QUOTA_AUTO_OLD=$QUOTA_AUTO
71 check_and_setup_lustre
73 ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
74 is_project_quota_supported() {
75 $ENABLE_PROJECT_QUOTAS || return 1
76 [ "$(facet_fstype $SINGLEMDS)" == "ldiskfs" ] &&
77 [ $(lustre_version_code $SINGLEMDS) -gt \
78 $(version_code 2.9.55) ] &&
79 lfs --help | grep project >&/dev/null &&
80 egrep -q "7." /etc/redhat-release && return 0
82 if [ "$(facet_fstype $SINGLEMDS)" == "zfs" ]; then
83 [ $(lustre_version_code $SINGLEMDS) -le \
84 $(version_code 2.10.53) ] && return 1
86 $ZPOOL upgrade -v | grep project_quota && return 0
92 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
93 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
94 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
95 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
96 SHOW_QUOTA_PROJID="eval is_project_quota_supported && $LFS quota -v -p $TSTPRJID $DIR"
97 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
98 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
99 SHOW_QUOTA_INFO_PROJID="eval is_project_quota_supported && $LFS quota -t -p $DIR"
106 local fail_val=${3:-0}
110 mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
111 mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
112 ost) NODES="$(comma_list $(osts_nodes))";;
115 do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
120 echo "lfs project $*"
121 lfs project $* || error "lfs project $* failed"
124 RUNAS="runas -u $TSTID -g $TSTID"
125 RUNAS2="runas -u $TSTID2 -g $TSTID2"
126 DD="dd if=/dev/zero bs=1M"
130 # clear quota limits for a user or a group
131 # usage: resetquota -u username
132 # resetquota -g groupname
133 # resetquota -p projid
136 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
137 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
138 error "resetquota: wrong specifier $1 passed"
140 if [ $1 == "-p" ]; then
141 is_project_quota_supported || return 0
144 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
145 error "clear quota for [type:$1 name:$2] failed"
146 # give a chance to slave to release space
154 if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
155 $LFS quota -v -u $local_id $DIR
156 log "Files for user ($local_id):"
157 ($LFS find --user $local_id $DIR | head -n 4 |
158 xargs stat 2>/dev/null)
161 if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
162 $LFS quota -v -g $local_id $DIR
163 log "Files for group ($local_id):"
164 ($LFS find --group $local_id $DIR | head -n 4 |
165 xargs stat 2>/dev/null)
168 if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
169 $LFS quota -v -p $TSTPRJID $DIR
170 log "Files for project ($TSTPRJID):"
171 ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
172 xargs stat 2>/dev/null)
188 # get quota for a user or a group
189 # usage: getquota -u|-g|-p <username>|<groupname>|<projid> global|<obd_uuid> \
190 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace
195 sync_all_data > /dev/null 2>&1 || true
197 [ "$#" != 4 ] && error "getquota: wrong number of arguments: $#"
198 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
199 error "getquota: wrong u/g/p specifier $1 passed"
212 *) error "unknown quota parameter $4";;
215 [ "$uuid" = "global" ] && uuid=$DIR
217 $LFS quota -v "$1" "$2" $DIR |
218 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
219 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
224 # usage: set_mdt_qtype ugp|u|g|p|none
228 local mdts=$(get_facets MDS)
230 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
231 qtype=$(tr -d 'p' <<<$qtype)
232 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$qtype
233 # we have to make sure each MDT received config changes
234 for mdt in ${mdts//,/ }; do
236 cmd="$LCTL get_param -n "
237 cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc}
238 cmd=${cmd}.quota_slave.enabled
240 if $(facet_up $mdt); then
241 wait_update_facet $mdt "$cmd" "$qtype" || return 1
248 # usage: set_ost_qtype ugp|u|g|p|none
252 local osts=$(get_facets OST)
254 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
255 qtype=$(tr -d 'p' <<<$qtype)
256 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$qtype
257 # we have to make sure each OST received config changes
258 for ost in ${osts//,/ }; do
260 cmd="$LCTL get_param -n "
261 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
262 cmd=${cmd}.quota_slave.enabled
264 if $(facet_up $ost); then
265 wait_update_facet $ost "$cmd" "$qtype" || return 1
271 wait_reintegration() {
275 local result="glb[1],slv[1],reint[0]"
280 if [ $ntype == "mdt" ]; then
281 tgts=$(get_facets MDS)
283 tgts=$(get_facets OST)
286 for tgt in ${tgts//,/ }; do
288 cmd="$LCTL get_param -n "
289 cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc}
290 cmd=${cmd}.quota_slave.info
292 if $(facet_up $tgt); then
293 wait_update_facet $tgt "$cmd |
294 grep "$qtype" | awk '{ print \\\$3 }'" \
295 "$result" $max || return 1
305 if [[ "$qtype" =~ "u" ]]; then
306 wait_reintegration "mdt" "user" $max || return 1
309 if [[ "$qtype" =~ "g" ]]; then
310 wait_reintegration "mdt" "group" $max || return 1
313 if [[ "$qtype" =~ "p" ]]; then
314 ! is_project_quota_supported && return 0
315 wait_reintegration "mdt" "project" $max || return 1
324 if [[ "$qtype" =~ "u" ]]; then
325 wait_reintegration "ost" "user" $max || return 1
328 if [[ "$qtype" =~ "g" ]]; then
329 wait_reintegration "ost" "group" $max || return 1
332 if [[ "$qtype" =~ "p" ]]; then
333 ! is_project_quota_supported && return 0
334 wait_reintegration "ost" "project" $max || return 1
339 disable_project_quota() {
340 is_project_quota_supported || return 0
341 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
342 stopall || error "failed to stopall (1)"
344 for num in $(seq $MDSCOUNT); do
345 do_facet mds$num $TUNE2FS -Q ^prj $(mdsdevname $num) ||
346 error "tune2fs $(mdsdevname $num) failed"
349 for num in $(seq $OSTCOUNT); do
350 do_facet ost$num $TUNE2FS -Q ^prj $(ostdevname $num) ||
351 error "tune2fs $(ostdevname $num) failed"
359 wait_delete_completed
360 echo "Creating test directory"
361 mkdir $DIR/$tdir || return 1
362 chmod 0777 $DIR/$tdir || return 2
363 # always clear fail_loc in case of fail_loc isn't cleared
364 # properly when previous test failed
365 lustre_fail mds_ost 0
368 cleanup_quota_test() {
370 echo "Delete files..."
372 echo "Wait for unlink objects finished..."
373 wait_delete_completed
374 sync_all_data || true
383 $LFS quota -v -$ugp $qid $DIR
385 if [ "$bf" == "a" -o "$bf" == "b" ]; then
386 usage=$(getquota -$ugp $qid global curspace)
387 if [ -z $usage ]; then
388 quota_error $ugp $qid \
389 "Query block quota failed ($ugp:$qid)."
391 [ $usage -ne 0 ] && quota_log $ugp $qid \
392 "Block quota isn't 0 ($ugp:$qid:$usage)."
396 if [ "$bf" == "a" -o "$bf" == "f" ]; then
397 usage=$(getquota -$ugp $qid global curinodes)
398 if [ -z $usage ]; then
399 quota_error $ugp $qid \
400 "Query file quota failed ($ugp:$qid)."
402 [ $usage -ne 0 ] && quota_log $ugp $qid \
403 "File quota isn't 0 ($ugp:$qid:$usage)."
408 enable_project_quota() {
409 is_project_quota_supported || return 0
410 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
411 stopall || error "failed to stopall (1)"
413 for num in $(seq $MDSCOUNT); do
414 do_facet mds$num $TUNE2FS -O project $(mdsdevname $num) ||
415 error "tune2fs $(mdsdevname $num) failed"
418 for num in $(seq $OSTCOUNT); do
419 do_facet ost$num $TUNE2FS -O project $(ostdevname $num) ||
420 error "tune2fs $(ostdevname $num) failed"
428 reset_quota_settings() {
429 resetquota -u $TSTUSR
430 resetquota -g $TSTUSR
431 resetquota -u $TSTUSR2
432 resetquota -g $TSTUSR2
433 resetquota -p $TSTPRJID
438 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
443 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
444 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
445 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
446 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
448 test_quota_performance() {
449 local TESTFILE="$DIR/$tdir/$tfile-0"
450 local size=$1 # in MB
451 local stime=$(date +%s)
452 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
453 quota_error u $TSTUSR "write failure"
454 local etime=$(date +%s)
455 delta=$((etime - stime))
456 if [ $delta -gt 0 ]; then
457 rate=$((size * 1024 / delta))
458 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
459 # LU-2872 - see LU-2887 for fix
461 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
463 [ $rate -gt 1024 ] ||
464 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
470 # test basic quota performance b=21696
473 [ "$SLOW" = "no" ] && MB=10
475 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
476 [ $free_space -le $((MB * 1024)) ] &&
477 skip "not enough space ${free_space} KB, " \
478 "required $((MB * 1024)) KB" && return
479 setup_quota_test || error "setup quota failed with $?"
480 trap cleanup_quota_test EXIT
482 set_ost_qtype "none" || error "disable ost quota failed"
483 test_quota_performance $MB
485 set_ost_qtype $QTYPE || error "enable ost quota failed"
486 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
487 error "set quota failed"
488 test_quota_performance $MB
491 resetquota -u $TSTUSR
493 run_test 0 "Test basic quota performance"
495 # test block hardlimit
498 local TESTFILE="$DIR/$tdir/$tfile-0"
500 setup_quota_test || error "setup quota failed with $?"
501 trap cleanup_quota_test EXIT
504 set_ost_qtype $QTYPE || error "enable ost quota failed"
507 log "User quota (block hardlimit:$LIMIT MB)"
508 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
509 error "set user quota failed"
511 # make sure the system is clean
512 local USED=$(getquota -u $TSTUSR global curspace)
513 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
515 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
516 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
519 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
520 quota_error u $TSTUSR "user write failure, but expect success"
521 log "Write out of block quota ..."
522 # this time maybe cache write, ignore it's failure
523 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
524 # flush cache, ensure noquota flag is set on client
526 sync; sync_all_data || true
527 $RUNAS $DD of=$TESTFILE count=1 seek=$LIMIT &&
528 quota_error u $TSTUSR "user write success, but expect EDQUOT"
531 wait_delete_completed || error "wait_delete_completed failed"
532 sync_all_data || true
533 USED=$(getquota -u $TSTUSR global curspace)
534 [ $USED -ne 0 ] && quota_error u $TSTUSR \
535 "user quota isn't released after deletion"
536 resetquota -u $TSTUSR
539 log "--------------------------------------"
540 log "Group quota (block hardlimit:$LIMIT MB)"
541 $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
542 error "set group quota failed"
544 TESTFILE="$DIR/$tdir/$tfile-1"
545 # make sure the system is clean
546 USED=$(getquota -g $TSTUSR global curspace)
547 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTUSR isn't 0"
549 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
550 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
553 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
554 quota_error g $TSTUSR "Group write failure, but expect success"
555 log "Write out of block quota ..."
556 # this time maybe cache write, ignore it's failure
557 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
559 sync; sync_all_data || true
560 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT &&
561 quota_error g $TSTUSR "Group write success, but expect EDQUOT"
563 wait_delete_completed || error "wait_delete_completed failed"
564 sync_all_data || true
565 USED=$(getquota -g $TSTUSR global curspace)
566 [ $USED -ne 0 ] && quota_error g $TSTUSR \
567 "Group quota isn't released after deletion"
568 resetquota -g $TSTUSR
570 if ! is_project_quota_supported; then
571 echo "Project quota is not supported"
576 TESTFILE="$DIR/$tdir/$tfile-2"
577 # make sure the system is clean
578 USED=$(getquota -p $TSTPRJID global curspace)
580 error "used space($USED) for project $TSTPRJID isn't 0"
583 log "--------------------------------------"
584 log "Project quota (block hardlimit:$LIMIT mb)"
585 $LFS setquota -p $TSTPRJID -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
586 error "set project quota failed"
588 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
589 chown $TSTUSR:$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
590 change_project -p $TSTPRJID $TESTFILE
593 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) || quota_error p $TSTPRJID \
594 "project write failure, but expect success"
595 log "write out of block quota ..."
596 # this time maybe cache write, ignore it's failure
597 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
599 sync; sync_all_data || true
600 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT && quota_error p \
601 $TSTPRJID "project write success, but expect EDQUOT"
606 USED=$(getquota -p $TSTPRJID global curspace)
607 [ $USED -ne 0 ] && quota_error p $TSTPRJID \
608 "project quota isn't released after deletion"
610 resetquota -p $TSTPRJID
612 run_test 1 "Block hard limit (normal use and out of quota)"
614 # test inode hardlimit
616 local LIMIT=$((1024 * 1024)) # 1M inodes
617 local TESTFILE="$DIR/$tdir/$tfile-0"
619 [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes
621 local FREE_INODES=$(mdt_free_inodes 0)
622 echo "$FREE_INODES free inodes on master MDT"
623 [ $FREE_INODES -lt $LIMIT ] &&
624 skip "not enough free inodes $FREE_INODES required $LIMIT" &&
627 setup_quota_test || error "setup quota failed with $?"
628 trap cleanup_quota_test EXIT
631 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
634 log "User quota (inode hardlimit:$LIMIT files)"
635 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
636 error "set user quota failed"
638 # make sure the system is clean
639 local USED=$(getquota -u $TSTUSR global curinodes)
640 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
642 log "Create $LIMIT files ..."
643 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
644 quota_error u $TSTUSR "user create failure, but expect success"
645 log "Create out of file quota ..."
646 $RUNAS touch ${TESTFILE}_xxx &&
647 quota_error u $TSTUSR "user create success, but expect EDQUOT"
650 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
651 rm -f ${TESTFILE}_xxx
652 wait_delete_completed
654 USED=$(getquota -u $TSTUSR global curinodes)
655 [ $USED -ne 0 ] && quota_error u $TSTUSR \
656 "user quota isn't released after deletion"
657 resetquota -u $TSTUSR
660 log "--------------------------------------"
661 log "Group quota (inode hardlimit:$LIMIT files)"
662 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
663 error "set group quota failed"
665 TESTFILE=$DIR/$tdir/$tfile-1
666 # make sure the system is clean
667 USED=$(getquota -g $TSTUSR global curinodes)
668 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
670 log "Create $LIMIT files ..."
671 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
672 quota_error g $TSTUSR "group create failure, but expect success"
673 log "Create out of file quota ..."
674 $RUNAS touch ${TESTFILE}_xxx &&
675 quota_error g $TSTUSR "group create success, but expect EDQUOT"
678 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
679 rm -f ${TESTFILE}_xxx
680 wait_delete_completed
682 USED=$(getquota -g $TSTUSR global curinodes)
683 [ $USED -ne 0 ] && quota_error g $TSTUSR \
684 "user quota isn't released after deletion"
686 resetquota -g $TSTUSR
687 ! is_project_quota_supported && cleanup_quota_test &&
688 echo "Skip project quota is not supported" && return 0
691 log "--------------------------------------"
692 log "Project quota (inode hardlimit:$LIMIT files)"
693 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
694 error "set project quota failed"
696 TESTFILE=$DIR/$tdir/$tfile-1
697 # make sure the system is clean
698 USED=$(getquota -p $TSTPRJID global curinodes)
700 error "Used inodes($USED) for project $TSTPRJID isn't 0"
702 change_project -sp $TSTPRJID $DIR/$tdir
703 log "Create $LIMIT files ..."
704 $RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
705 $TSTPRJID "project create fail, but expect success"
706 log "Create out of file quota ..."
707 $RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
708 "project create success, but expect EDQUOT"
709 change_project -C $DIR/$tdir
712 USED=$(getquota -p $TSTPRJID global curinodes)
713 [ $USED -ne 0 ] && quota_error p $TSTPRJID \
714 "project quota isn't released after deletion"
716 resetquota -p $TSTPRJID
719 run_test 2 "File hard limit (normal use and out of quota)"
723 local TIMER=$(($2 * 3 / 2))
729 trap cleanup_quota_test EXIT
731 $SETSTRIPE $TESTFILE -c 1 -i 0
732 chown $TSTUSR.$TSTUSR $TESTFILE
733 [ "$qtype" == "p" ] && is_project_quota_supported &&
734 change_project -p $TSTPRJID $TESTFILE
736 echo "Write up to soft limit"
737 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
738 quota_error a $TSTUSR "write failure, but expect success"
739 OFFSET=$((LIMIT * 1024))
742 echo "Write to exceed soft limit"
743 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
744 quota_error a $TSTUSR "write failure, but expect success"
745 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
751 $SHOW_QUOTA_INFO_USER
752 $SHOW_QUOTA_INFO_GROUP
753 $SHOW_QUOTA_INFO_PROJID
755 echo "Write before timer goes off"
756 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
757 quota_error a $TSTUSR "write failure, but expect success"
758 OFFSET=$((OFFSET + 1024))
761 echo "Sleep $TIMER seconds ..."
767 $SHOW_QUOTA_INFO_USER
768 $SHOW_QUOTA_INFO_GROUP
769 $SHOW_QUOTA_INFO_PROJID
771 echo "Write after timer goes off"
772 # maybe cache write, ignore.
773 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET || true
774 OFFSET=$((OFFSET + 1024))
776 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET &&
777 quota_error a $TSTUSR "write success, but expect EDQUOT"
782 $SHOW_QUOTA_INFO_USER
783 $SHOW_QUOTA_INFO_GROUP
784 $SHOW_QUOTA_INFO_PROJID
786 echo "Unlink file to stop timer"
788 wait_delete_completed
789 sync_all_data || true
794 $SHOW_QUOTA_INFO_USER
795 $SHOW_QUOTA_INFO_GROUP
796 $SHOW_QUOTA_INFO_PROJID
798 $SETSTRIPE $TESTFILE -c 1 -i 0
799 chown $TSTUSR.$TSTUSR $TESTFILE
800 [ "$qtype" == "p" ] && change_project -p $TSTPRJID $TESTFILE
803 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
804 quota_error a $TSTUSR "write failure, but expect success"
813 local TESTFILE=$DIR/$tdir/$tfile-0
815 set_ost_qtype $QTYPE || error "enable ost quota failed"
817 echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
818 # make sure the system is clean
819 local USED=$(getquota -u $TSTUSR global curspace)
820 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
822 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
823 $MAX_IQ_TIME $DIR || error "set user grace time failed"
824 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
825 error "set user quota failed"
827 test_block_soft $TESTFILE $GRACE $LIMIT "u"
828 resetquota -u $TSTUSR
830 echo "Group quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
831 TESTFILE=$DIR/$tdir/$tfile-1
832 # make sure the system is clean
833 USED=$(getquota -g $TSTUSR global curspace)
834 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
836 $LFS setquota -t -g --block-grace $GRACE --inode-grace \
837 $MAX_IQ_TIME $DIR || error "set group grace time failed"
838 $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
839 error "set group quota failed"
841 test_block_soft $TESTFILE $GRACE $LIMIT "g"
842 resetquota -g $TSTUSR
844 if is_project_quota_supported; then
845 echo "Project quota (soft limit:$LIMIT MB grace:$GRACE sec)"
846 TESTFILE=$DIR/$tdir/$tfile-2
847 # make sure the system is clean
848 USED=$(getquota -p $TSTPRJID global curspace)
849 [ $USED -ne 0 ] && error \
850 "Used space($USED) for project $TSTPRJID isn't 0."
852 $LFS setquota -t -p --block-grace $GRACE --inode-grace \
854 error "set project grace time failed"
855 $LFS setquota -p $TSTPRJID -b ${LIMIT}M -B 0 -i 0 -I 0 \
856 $DIR || error "set project quota failed"
858 test_block_soft $TESTFILE $GRACE $LIMIT "p"
859 resetquota -p $TSTPRJID
860 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
862 error "restore project grace time failed"
866 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
867 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
868 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
869 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
871 run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
877 local TIMER=$(($grace * 3 / 2))
880 trap cleanup_quota_test EXIT
881 is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
883 echo "Create files to exceed soft limit"
884 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
885 quota_error a $TSTUSR "create failure, but expect success"
886 local trigger_time=$(date +%s)
888 sync_all_data || true
890 local cur_time=$(date +%s)
891 [ $(($cur_time - $trigger_time)) -ge $grace ] &&
892 error "Passed grace time $grace, $trigger_time, $cur_time"
894 echo "Create file before timer goes off"
895 $RUNAS touch ${TESTFILE}_before ||
896 quota_error a $TSTUSR "failed create before timer expired," \
897 "but expect success. $trigger_time, $cur_time"
898 sync_all_data || true
900 echo "Sleep $TIMER seconds ..."
906 $SHOW_QUOTA_INFO_USER
907 $SHOW_QUOTA_INFO_GROUP
908 $SHOW_QUOTA_INFO_PROJID
910 echo "Create file after timer goes off"
911 # There is a window that space is accounted in the quota usage but
912 # hasn't been decreased from the pending write, if we acquire quota
913 # in this window, we'll acquire more than we needed.
914 $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
915 sync_all_data || true
916 $RUNAS touch ${TESTFILE}_after_3 &&
917 quota_error a $TSTUSR "create after timer expired," \
919 sync_all_data || true
924 $SHOW_QUOTA_INFO_USER
925 $SHOW_QUOTA_INFO_GROUP
926 $SHOW_QUOTA_INFO_PROJID
928 echo "Unlink files to stop timer"
929 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
930 wait_delete_completed
933 $RUNAS touch ${TESTFILE}_xxx ||
934 quota_error a $TSTUSR "touch after timer stop failure," \
936 sync_all_data || true
944 local LIMIT=10 # inodes
945 local TESTFILE=$DIR/$tdir/$tfile-0
948 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
950 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
951 # make sure the system is clean
952 local USED=$(getquota -u $TSTUSR global curinodes)
953 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
955 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
956 $GRACE $DIR || error "set user grace time failed"
957 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
958 error "set user quota failed"
960 test_file_soft $TESTFILE $LIMIT $GRACE
961 resetquota -u $TSTUSR
963 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
964 # make sure the system is clean
965 USED=$(getquota -g $TSTUSR global curinodes)
966 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
968 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
969 $GRACE $DIR || error "set group grace time failed"
970 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
971 error "set group quota failed"
972 TESTFILE=$DIR/$tdir/$tfile-1
974 test_file_soft $TESTFILE $LIMIT $GRACE
975 resetquota -g $TSTUSR
977 if is_project_quota_supported; then
978 echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)"
979 # make sure the system is clean
980 USED=$(getquota -p $TSTPRJID global curinodes)
981 [ $USED -ne 0 ] && error \
982 "Used space($USED) for project $TSTPRJID isn't 0."
984 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
985 $GRACE $DIR || error "set project grace time failed"
986 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
987 error "set project quota failed"
989 TESTFILE=$DIR/$tdir/$tfile-1
990 # one less than limit, because of parent directory included.
991 test_file_soft $TESTFILE $((LIMIT-1)) $GRACE
992 resetquota -p $TSTPRJID
993 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
995 error "restore project grace time failed"
999 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1000 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1001 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1002 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1004 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
1007 local GR_STR1="1w3d"
1008 local GR_STR2="1000s"
1010 local GR_STR4="1w2d3h4m5s"
1012 local GR_STR6="18446744073709551615"
1015 wait_delete_completed
1017 # test of valid grace strings handling
1018 echo "Valid grace strings test"
1019 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
1020 $GR_STR2 $DIR || error "set user grace time failed"
1021 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
1022 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
1023 $GR_STR4 $DIR || error "set group grace time quota failed"
1024 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
1026 # test of invalid grace strings handling
1027 echo " Invalid grace strings test"
1028 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
1029 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
1030 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \
1034 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1035 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1036 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1037 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1039 run_test 4b "Grace time strings handling"
1041 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
1043 local BLIMIT=10 # 10M
1044 local ILIMIT=10 # 10 inodes
1046 setup_quota_test || error "setup quota failed with $?"
1047 trap cleanup_quota_test EXIT
1049 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1050 set_ost_qtype $QTYPE || error "enable ost quota failed"
1052 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
1053 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1054 error "set user quota failed"
1055 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1056 if is_project_quota_supported; then
1057 error "set group quota failed"
1058 $LFS setquota -p $TSTPRJID -b 0 -B ${BLIMIT}M -i 0 \
1059 -I $ILIMIT $DIR || error "set project quota failed"
1062 # make sure the system is clean
1063 local USED=$(getquota -u $TSTUSR global curinodes)
1064 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1065 USED=$(getquota -g $TSTUSR global curinodes)
1066 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
1067 USED=$(getquota -u $TSTUSR global curspace)
1068 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
1069 USED=$(getquota -g $TSTUSR global curspace)
1070 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
1071 if is_project_quota_supported; then
1072 USED=$(getquota -p $TSTPRJID global curinodes)
1074 error "Used inode($USED) for project $TSTPRJID isn't 0."
1075 USED=$(getquota -p $TSTPRJID global curspace)
1077 error "Used block($USED) for project $TSTPRJID isn't 0."
1080 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
1081 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1082 error "create failure, expect success"
1083 if is_project_quota_supported; then
1084 touch $DIR/$tdir/$tfile-0_1
1085 change_project -p $TSTPRJID $DIR/$tdir/$tfile-0_1
1087 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
1088 error "write failure, expect success"
1090 echo "Chown files to $TSTUSR.$TSTUSR ..."
1091 for i in $(seq 0 $ILIMIT); do
1092 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
1093 quota_error a $TSTUSR "chown failure, expect success"
1097 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1098 error "unlinkmany $DIR/$tdir/$tfile-0_ failed"
1101 resetquota -u $TSTUSR
1102 resetquota -g $TSTUSR
1103 resetquota -p $TSTPRJID
1105 run_test 5 "Chown & chgrp successfully even out of block/file quota"
1107 # test dropping acquire request on master
1111 # Clear dmesg so watchdog is not triggered by previous
1113 do_facet ost1 dmesg -c > /dev/null
1115 setup_quota_test || error "setup quota failed with $?"
1116 trap cleanup_quota_test EXIT
1118 # make sure the system is clean
1119 local USED=$(getquota -u $TSTUSR global curspace)
1120 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1122 # make sure no granted quota on ost
1123 set_ost_qtype $QTYPE || error "enable ost quota failed"
1124 resetquota -u $TSTUSR
1126 # create file for $TSTUSR
1127 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
1128 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1129 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1131 # create file for $TSTUSR2
1132 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
1133 $SETSTRIPE $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed"
1134 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed"
1136 # cache per-ID lock for $TSTUSR on slave
1137 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1138 error "set quota failed"
1139 $RUNAS $DD of=$TESTFILE count=1 ||
1140 error "write $TESTFILE failure, expect success"
1141 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
1142 error "write $TESTFILE2 failure, expect success"
1144 sync_all_data || true
1146 #define QUOTA_DQACQ 601
1147 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
1148 lustre_fail mds 0x513 601
1150 # write to un-enforced ID ($TSTUSR2) should succeed
1151 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
1152 error "write failure, expect success"
1154 # write to enforced ID ($TSTUSR) in background, exceeding limit
1155 # to make sure DQACQ is sent
1156 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
1159 # watchdog timer uses a factor of 2
1160 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
1161 sleep $((TIMEOUT * 2 + 1))
1163 # write should be blocked and never finished
1164 if ! ps -p $DDPID > /dev/null 2>&1; then
1166 error "write finished incorrectly!"
1171 # no watchdog is triggered
1172 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1173 watchdog=$(awk '/Service thread pid/ && /was inactive/ \
1174 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1175 [ -z "$watchdog" ] || error "$watchdog"
1177 rm -f $TMP/lustre-log-${TESTNAME}.log
1179 # write should continue then fail with EDQUOT
1183 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1184 if [ $count -ge 240 ]; then
1185 quota_error u $TSTUSR "dd not finished in $count secs"
1187 count=$((count + 1))
1188 if [ $((count % 30)) -eq 0 ]; then
1189 c_size=$(stat -c %s $TESTFILE)
1190 echo "Waiting $count secs. $c_size"
1197 resetquota -u $TSTUSR
1199 run_test 6 "Test dropping acquire request on master"
1201 # quota reintegration (global index)
1203 local TESTFILE=$DIR/$tdir/$tfile
1204 local LIMIT=20 # 20M
1206 [ "$SLOW" = "no" ] && LIMIT=5
1208 setup_quota_test || error "setup quota failed with $?"
1209 trap cleanup_quota_test EXIT
1211 # make sure the system is clean
1212 local USED=$(getquota -u $TSTUSR global curspace)
1213 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1215 # make sure no granted quota on ost1
1216 set_ost_qtype $QTYPE || error "enable ost quota failed"
1217 resetquota -u $TSTUSR
1218 set_ost_qtype "none" || error "disable ost quota failed"
1220 local OSTUUID=$(ostuuid_from_index 0)
1221 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1223 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1226 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1227 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1232 echo "Enable quota & set quota limit for $TSTUSR"
1233 set_ost_qtype $QTYPE || error "enable ost quota failed"
1234 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1235 error "set quota failed"
1237 echo "Start ost1..."
1238 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1241 wait_ost_reint $QTYPE || error "reintegration failed"
1243 # hardlimit should have been fetched by slave during global
1244 # reintegration, write will exceed quota
1245 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1246 quota_error u $TSTUSR "write success, but expect EDQUOT"
1249 wait_delete_completed
1250 sync_all_data || true
1256 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1257 error "clear quota failed"
1259 echo "Start ost1..."
1260 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1263 wait_ost_reint $QTYPE || error "reintegration failed"
1265 # hardlimit should be cleared on slave during reintegration
1266 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
1267 quota_error u $TSTUSR "write error, but expect success"
1270 resetquota -u $TSTUSR
1272 run_test 7a "Quota reintegration (global index)"
1274 # quota reintegration (slave index)
1277 local TESTFILE=$DIR/$tdir/$tfile
1279 setup_quota_test || error "setup quota failed with $?"
1280 trap cleanup_quota_test EXIT
1282 # make sure the system is clean
1283 local USED=$(getquota -u $TSTUSR global curspace)
1284 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1286 # make sure no granted quota on ost1
1287 set_ost_qtype $QTYPE || error "enable ost quota failed"
1288 resetquota -u $TSTUSR
1289 set_ost_qtype "none" || error "disable ost quota failed"
1291 local OSTUUID=$(ostuuid_from_index 0)
1292 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1294 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1297 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1298 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1300 # consume some space to make sure the granted space will not
1301 # be released during reconciliation
1302 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1303 error "consume space failure, expect success"
1305 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
1306 lustre_fail mds 0xa02
1308 set_ost_qtype $QTYPE || error "enable ost quota failed"
1309 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1310 error "set quota failed"
1312 # ignore the write error
1313 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
1315 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1319 echo "Restart ost to trigger reintegration..."
1321 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1324 wait_ost_reint $QTYPE || error "reintegration failed"
1326 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1327 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1330 resetquota -u $TSTUSR
1333 run_test 7b "Quota reintegration (slave index)"
1335 # quota reintegration (restart mds during reintegration)
1337 local LIMIT=20 # 20M
1338 local TESTFILE=$DIR/$tdir/$tfile
1340 [ "$SLOW" = "no" ] && LIMIT=5
1342 setup_quota_test || error "setup quota failed with $?"
1343 trap cleanup_quota_test EXIT
1345 # make sure the system is clean
1346 local USED=$(getquota -u $TSTUSR global curspace)
1347 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1349 set_ost_qtype "none" || error "disable ost quota failed"
1350 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1351 error "set quota failed"
1353 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1354 lustre_fail ost 0xa03
1357 set_ost_qtype $QTYPE || error "enable ost quota failed"
1358 # trigger reintegration
1359 local procf="osd-$(facet_fstype ost1).$FSNAME-OST*."
1360 procf=${procf}quota_slave.force_reint
1361 do_facet ost1 $LCTL set_param $procf=1 ||
1362 error "force reintegration failed"
1370 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1373 # wait longer than usual to make sure the reintegration
1374 # is triggered by quota wb thread.
1375 wait_ost_reint $QTYPE 200 || error "reintegration failed"
1377 # hardlimit should have been fetched by slave during global
1378 # reintegration, write will exceed quota
1379 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1380 quota_error u $TSTUSR "write success, but expect EDQUOT"
1383 resetquota -u $TSTUSR
1385 run_test 7c "Quota reintegration (restart mds during reintegration)"
1387 # Quota reintegration (Transfer index in multiple bulks)
1389 local TESTFILE=$DIR/$tdir/$tfile
1390 local TESTFILE1="$DIR/$tdir/$tfile"-1
1393 setup_quota_test || error "setup quota failed with $?"
1394 trap cleanup_quota_test EXIT
1396 set_ost_qtype "none" || error "disable ost quota failed"
1397 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1398 error "set quota for $TSTUSR failed"
1399 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1400 error "set quota for $TSTUSR2 failed"
1402 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1403 lustre_fail mds 0x608 0
1405 # enable quota to tirgger reintegration
1406 set_ost_qtype "u" || error "enable ost quota failed"
1407 wait_ost_reint "u" || error "reintegration failed"
1411 # hardlimit should have been fetched by slave during global
1412 # reintegration, write will exceed quota
1413 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1414 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1416 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1417 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1420 resetquota -u $TSTUSR
1421 resetquota -u $TSTUSR2
1423 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1425 # quota reintegration (inode limits)
1427 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
1429 # LU-2435: skip this quota test if underlying zfs version has not
1430 # supported native dnode accounting
1431 [ "$(facet_fstype mds1)" == "zfs" ] && {
1432 local F="feature@userobj_accounting"
1433 local pool=$(zpool_name mds1)
1434 local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
1436 [[ "$feature" != *" active "* ]] &&
1437 skip "requires zpool with active userobj_accounting" &&
1441 local ilimit=$((1024 * 2)) # 2k inodes
1442 local TESTFILE=$DIR/${tdir}-1/$tfile
1444 setup_quota_test || error "setup quota failed with $?"
1445 trap cleanup_quota_test EXIT
1447 # make sure the system is clean
1448 local USED=$(getquota -u $TSTUSR global curinodes)
1449 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1451 # make sure no granted quota on mdt1
1452 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1453 resetquota -u $TSTUSR
1454 set_mdt_qtype "none" || error "disable mdt quota failed"
1456 local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
1457 USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
1458 [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
1461 echo "Stop mds${MDSCOUNT}..."
1464 echo "Enable quota & set quota limit for $TSTUSR"
1465 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1466 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
1467 error "set quota failed"
1469 echo "Start mds${MDSCOUNT}..."
1470 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
1473 wait_mdt_reint $QTYPE || error "reintegration failed"
1475 echo "create remote dir"
1476 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
1477 error "create remote dir failed"
1478 chmod 0777 $DIR/${tdir}-1
1480 # hardlimit should have been fetched by slave during global
1481 # reintegration, create will exceed quota
1482 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
1483 quota_error u $TSTUSR "create succeeded, expect EDQUOT"
1485 $RUNAS unlinkmany $TESTFILE $ilimit || error "unlink files failed"
1486 wait_delete_completed
1487 sync_all_data || true
1489 echo "Stop mds${MDSCOUNT}..."
1492 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1493 error "clear quota failed"
1495 echo "Start mds${MDSCOUNT}..."
1496 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
1499 wait_mdt_reint $QTYPE || error "reintegration failed"
1501 # hardlimit should be cleared on slave during reintegration
1502 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
1503 quota_error u $TSTUSR "create failed, expect success"
1505 $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
1506 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
1509 resetquota -u $TSTUSR
1511 run_test 7e "Quota reintegration (inode limits)"
1513 # run dbench with quota enabled
1515 local BLK_LIMIT="100g" #100G
1516 local FILE_LIMIT=1000000
1518 setup_quota_test || error "setup quota failed with $?"
1519 trap cleanup_quota_test EXIT
1521 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1522 set_ost_qtype $QTYPE || error "enable ost quota failed"
1524 echo "Set enough high limit for user: $TSTUSR"
1525 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1526 error "set user quota failed"
1527 echo "Set enough high limit for group: $TSTUSR"
1528 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1529 error "set group quota failed"
1530 if is_project_quota_supported; then
1531 change_project -sp $TSTPRJID $DIR/$tdir
1532 echo "Set enough high limit for project: $TSTPRJID"
1533 $LFS setquota -p $TSTPRJID -b 0 \
1534 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1535 error "set project quota failed"
1539 [ "$SLOW" = "no" ] && duration=" -t 120"
1540 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1541 quota_error a $TSTUSR "dbench failed!"
1543 is_project_quota_supported && change_project -C $DIR/$tdir
1545 resetquota -u $TSTUSR
1546 resetquota -g $TSTUSR
1547 resetquota -p $TSTPRJID
1549 run_test 8 "Run dbench with quota enabled"
1551 # this check is just for test_9
1552 OST0_MIN=4900000 #4.67G
1554 check_whether_skip () {
1555 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1556 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1557 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1558 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1565 # run for fixing bug10707, it needs a big room. test for 64bit
1567 local filesize=$((1024 * 9 / 2)) # 4.5G
1569 check_whether_skip && return 0
1571 setup_quota_test || error "setup quota failed with $?"
1572 trap cleanup_quota_test EXIT
1574 set_ost_qtype "ug" || error "enable ost quota failed"
1576 local TESTFILE="$DIR/$tdir/$tfile-0"
1577 local BLK_LIMIT=100G #100G
1578 local FILE_LIMIT=1000000
1580 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1582 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1584 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1585 error "set user quota failed"
1587 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1588 "for group: $TSTUSR"
1589 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1590 error "set group quota failed"
1592 quota_show_check a u $TSTUSR
1593 quota_show_check a g $TSTUSR
1595 echo "Create test file"
1596 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1597 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1599 log "Write the big file of 4.5G ..."
1600 $RUNAS $DD of=$TESTFILE count=$filesize ||
1601 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1607 resetquota -u $TSTUSR
1608 resetquota -g $TSTUSR
1613 run_test 9 "Block limit larger than 4GB (b10707)"
1616 local TESTFILE=$DIR/$tdir/$tfile
1618 setup_quota_test || error "setup quota failed with $?"
1619 trap cleanup_quota_test EXIT
1621 # set limit to root user should fail
1622 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1623 error "set limit for root user successfully, expect failure"
1624 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1625 error "set limit for root group successfully, expect failure"
1626 $LFS setquota -p 0 -b 1T -B 10T -i 5K -I 100M $DIR &&
1627 error "set limit for project 0 successfully, expect failure"
1629 # root user can overrun quota
1630 set_ost_qtype "ug" || error "enable ost quota failed"
1632 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1633 error "set quota failed"
1634 quota_show_check b u $TSTUSR
1636 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
1637 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1639 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1640 error "write failure, expect success"
1643 resetquota -u $TSTUSR
1645 run_test 10 "Test quota for root user"
1648 local TESTFILE=$DIR/$tdir/$tfile
1649 setup_quota_test || error "setup quota failed with $?"
1650 trap cleanup_quota_test EXIT
1652 set_mdt_qtype "ug" || error "enable mdt quota failed"
1653 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1654 error "set quota failed"
1656 touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed"
1657 touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed"
1659 chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed"
1660 chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed"
1663 local USED=$(getquota -u $TSTUSR global curinodes)
1664 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1667 resetquota -u $TSTUSR
1669 run_test 11 "Chown/chgrp ignores quota"
1672 [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs" && return
1674 local blimit=22 # 22M
1675 local blk_cnt=$((blimit - 5))
1676 local TESTFILE0="$DIR/$tdir/$tfile"-0
1677 local TESTFILE1="$DIR/$tdir/$tfile"-1
1679 setup_quota_test || error "setup quota failed with $?"
1680 trap cleanup_quota_test EXIT
1682 set_ost_qtype "u" || error "enable ost quota failed"
1683 quota_show_check b u $TSTUSR
1685 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1686 error "set quota failed"
1688 $SETSTRIPE $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed"
1689 $SETSTRIPE $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed"
1690 chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed"
1691 chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed"
1693 echo "Write to ost0..."
1694 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1695 quota_error a $TSTUSR "dd failed"
1697 echo "Write to ost1..."
1698 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1699 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1701 echo "Free space from ost0..."
1703 wait_delete_completed
1704 sync_all_data || true
1706 echo "Write to ost1 after space freed from ost0..."
1707 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1708 quota_error a $TSTUSR "rebalancing failed"
1711 resetquota -u $TSTUSR
1713 run_test 12a "Block quota rebalancing"
1716 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
1718 local ilimit=$((1024 * 2)) # 2k inodes
1719 local TESTFILE0=$DIR/$tdir/$tfile
1720 local TESTFILE1=$DIR/${tdir}-1/$tfile
1722 setup_quota_test || error "setup quota failed with $?"
1723 trap cleanup_quota_test EXIT
1725 $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed"
1726 chmod 0777 $DIR/${tdir}-1
1728 set_mdt_qtype "u" || error "enable mdt quota failed"
1729 quota_show_check f u $TSTUSR
1731 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
1732 error "set quota failed"
1734 echo "Create $ilimit files on mdt0..."
1735 $RUNAS createmany -m $TESTFILE0 $ilimit ||
1736 quota_error u $TSTUSR "create failed, but expect success"
1738 echo "Create files on mdt1..."
1739 $RUNAS createmany -m $TESTFILE1 1 &&
1740 quota_error a $TSTUSR "create succeeded, expect EDQUOT"
1742 echo "Free space from mdt0..."
1743 $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed"
1744 wait_delete_completed
1745 sync_all_data || true
1747 echo "Create files on mdt1 after space freed from mdt0..."
1748 $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) ||
1749 quota_error a $TSTUSR "rebalancing failed"
1751 $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) ||
1752 error "unlink mdt1 files failed"
1753 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
1756 resetquota -u $TSTUSR
1758 run_test 12b "Inode quota rebalancing"
1761 local TESTFILE=$DIR/$tdir/$tfile
1762 # the name of lwp on ost1 name is MDT0000-lwp-OST0000
1763 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size"
1765 setup_quota_test || error "setup quota failed with $?"
1766 trap cleanup_quota_test EXIT
1768 set_ost_qtype "u" || error "enable ost quota failed"
1769 quota_show_check b u $TSTUSR
1771 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1772 error "set quota failed"
1773 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1774 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1776 # clear the locks in cache first
1777 do_facet ost1 $LCTL set_param -n $procf=clear
1778 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1779 [ $nlock -eq 0 ] || error "$nlock cached locks"
1781 # write to acquire the per-ID lock
1782 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1783 quota_error a $TSTUSR "dd failed"
1785 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1786 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1788 # clear quota doesn't trigger per-ID lock cancellation
1789 resetquota -u $TSTUSR
1790 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1791 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1793 # clear the per-ID lock
1794 do_facet ost1 $LCTL set_param -n $procf=clear
1795 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1796 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1798 # spare quota should be released
1799 local OSTUUID=$(ostuuid_from_index 0)
1800 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1801 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1802 [ $limit -le $space ] ||
1803 error "spare quota isn't released, limit:$limit, space:$space"
1807 run_test 13 "Cancel per-ID lock in the LRU list"
1810 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1812 wait_delete_completed
1813 sync_all_data || true
1816 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1817 error "set user quota failed"
1818 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1819 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1820 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1821 resetquota -u $TSTUSR
1824 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1825 error "set group quota failed"
1826 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1827 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1828 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1829 resetquota -g $TSTUSR
1831 run_test 15 "Set over 4T block quota"
1835 local BLKS=1 # 1M less than limit
1836 local TESTFILE=$DIR/$tdir/$tfile
1838 setup_quota_test || error "setup quota failed with $?"
1839 trap cleanup_quota_test EXIT
1841 # make sure the system is clean
1842 local USED=$(getquota -u $TSTUSR global curspace)
1843 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1845 set_ost_qtype "ug" || error "enable ost quota failed"
1846 # make sure no granted quota on ost
1847 resetquota -u $TSTUSR
1848 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1849 error "set quota failed"
1851 quota_show_check b u $TSTUSR
1853 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1854 lustre_fail mds 0xa04 $err_code
1856 # write in background
1857 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1861 # write should be blocked and never finished
1862 if ! ps -p $DDPID > /dev/null 2>&1; then
1864 quota_error u $TSTUSR "write finished incorrectly!"
1872 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1874 if [ $count -gt $timeout ]; then
1875 quota_error u $TSTUSR "dd is not finished!"
1880 sync; sync_all_data || true
1882 USED=$(getquota -u $TSTUSR global curspace)
1883 [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \
1884 "Used space(${USED}K) is less than ${BLKS}M"
1887 resetquota -u $TSTUSR
1890 # DQACQ return recoverable error
1892 echo "DQACQ return -ENOLCK"
1894 test_17sub 37 || error "Handle -ENOLCK failed"
1896 echo "DQACQ return -EAGAIN"
1898 test_17sub 11 || error "Handle -EAGAIN failed"
1900 echo "DQACQ return -ETIMEDOUT"
1901 #define ETIMEDOUT 110
1902 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1904 echo "DQACQ return -ENOTCONN"
1905 #define ENOTCONN 107
1906 test_17sub 107 || error "Handle -ENOTCONN failed"
1909 run_test 17 "DQACQ return recoverable error"
1913 local blimit="200m" # 200M
1914 local TESTFILE="$DIR/$tdir/$tfile"
1916 setup_quota_test || error "setup quota failed with $?"
1917 trap cleanup_quota_test EXIT
1919 set_ost_qtype "u" || error "enable ost quota failed"
1920 log "User quota (limit: $blimit)"
1921 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1922 error "set quota failed"
1923 quota_show_check b u $TSTUSR
1925 $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
1926 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1928 local timeout=$(sysctl -n lustre.timeout)
1930 if [ $io_type = "directio" ]; then
1931 log "Write 100M (directio) ..."
1932 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1934 log "Write 100M (buffered) ..."
1935 $RUNAS $DD of=$TESTFILE count=100 &
1939 replay_barrier $SINGLEMDS
1940 log "Fail mds for $((2 * timeout)) seconds"
1941 fail $SINGLEMDS $((2 * timeout))
1944 if at_is_enabled; then
1945 timeout=$(at_max_get mds)
1947 timeout=$(lctl get_param -n timeout)
1951 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1952 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1953 log "it took $count second"
1958 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1960 cancel_lru_locks mdc
1961 cancel_lru_locks osc
1964 local testfile_size=$(stat -c %s $TESTFILE)
1965 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1966 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \
1967 "got ${testfile_size}. Verifying file failed!"
1970 resetquota -u $TSTUSR
1973 # test when mds does failover, the ost still could work well
1974 # this test shouldn't trigger watchdog b=14840
1976 # Clear dmesg so watchdog is not triggered by previous
1978 do_facet ost1 dmesg -c > /dev/null
1981 test_18_sub directio
1983 # check if watchdog is triggered
1984 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1985 local watchdog=$(awk '/Service thread pid/ && /was inactive/ \
1986 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1987 [ -z "$watchdog" ] || error "$watchdog"
1988 rm -f $TMP/lustre-log-${TESTNAME}.log
1990 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1994 local TESTFILE=$DIR/$tdir/$tfile
1996 setup_quota_test || error "setup quota failed with $?"
1997 trap cleanup_quota_test EXIT
1999 set_ost_qtype $QTYPE || error "enable ost quota failed"
2001 # bind file to a single OST
2002 $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2003 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2005 echo "Set user quota (limit: ${blimit}M)"
2006 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2007 error "set user quota failed"
2008 quota_show_check b u $TSTUSR
2009 echo "Update quota limits"
2010 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2011 error "set group quota failed"
2012 quota_show_check b u $TSTUSR
2014 # first wirte might be cached
2015 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
2016 cancel_lru_locks osc
2018 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
2019 quota_error u $TSTUSR "Write success, expect failure"
2023 resetquota -u $TSTUSR
2025 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
2027 test_20() { # b15754
2028 local LSTR=(2g 1t 4k 3m) # limits strings
2030 local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \
2033 resetquota -u $TSTUSR
2035 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
2036 $MOUNT || error "could not set quota limits"
2037 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
2038 --inode-softlimit ${LSTR[2]} \
2039 --inode-hardlimit ${LSTR[3]} \
2040 $MOUNT || error "could not set quota limits"
2042 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
2043 error "bsoftlimit was not set properly"
2044 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
2045 error "bhardlimit was not set properly"
2046 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
2047 error "isoftlimit was not set properly"
2048 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
2049 error "ihardlimit was not set properly"
2051 resetquota -u $TSTUSR
2053 run_test 20 "Test if setquota specifiers work properly (b15754)"
2060 local time=$(($(date +%s) + seconds))
2061 while [ $(date +%s) -lt $time ]; do
2062 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
2066 # run for fixing bug16053, setquota shouldn't fail when writing and
2067 # deleting are happening
2069 local TESTFILE="$DIR/$tdir/$tfile"
2070 local BLIMIT=10 # 10G
2071 local ILIMIT=1000000
2073 setup_quota_test || error "setup quota failed with $?"
2074 trap cleanup_quota_test EXIT
2076 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2078 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
2079 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
2080 error "set user quota failed"
2081 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
2082 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
2083 error "set group quota failed"
2084 if is_project_quota_supported; then
2085 log "Set limit(block:${BLIMIT}G; file:$LIMIT) for " \
2086 "project: $TSTPRJID"
2087 $LFS setquota -p $TSTPRJID -b 0 -B $BLIMIT -i 0 -I $ILIMIT \
2088 $MOUNT || error "set project quota failed"
2091 # repeat writing on a 1M file
2092 test_21_sub ${TESTFILE}_1 1 30 &
2094 # repeat writing on a 128M file
2095 test_21_sub ${TESTFILE}_2 128 30 &
2098 local time=$(($(date +%s) + 30))
2100 while [ $(date +%s) -lt $time ]; do
2101 log "Set quota for $i times"
2102 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2103 -I $((ILIMIT + i)) $MOUNT ||
2104 error "Set user quota failed"
2105 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2106 -I $((ILIMIT + i)) $MOUNT ||
2107 error "Set group quota failed"
2108 if is_project_quota_supported; then
2109 $LFS setquota -p $TSTPRJID -b 0 -B \
2110 "$((BLIMIT + i))G" -i 0 -I $((ILIMIT + i)) $MOUNT ||
2111 error "Set project quota failed"
2119 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
2121 if [ $count -gt 60 ]; then
2122 quota_error a $TSTUSR "dd should be finished!"
2126 echo "(dd_pid=$DDPID1, time=$count)successful"
2130 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
2132 if [ $count -gt 60 ]; then
2133 quota_error a $TSTUSR "dd should be finished!"
2137 echo "(dd_pid=$DDPID2, time=$count)successful"
2140 resetquota -u $TSTUSR
2141 resetquota -g $TSTUSR
2142 resetquota -p $TSTPRJID
2144 run_test 21 "Setquota while writing & deleting (b16053)"
2146 # enable/disable quota enforcement permanently
2148 echo "Set both mdt & ost quota type as ug"
2150 is_project_quota_supported && qtype=$QTYPE
2151 set_mdt_qtype $qtype || error "enable mdt quota failed"
2152 set_ost_qtype $qtype || error "enable ost quota failed"
2155 stopall || error "failed to stopall (1)"
2159 echo "Verify if quota is enabled"
2160 local qtype1=$(mdt_quota_type)
2161 [ $qtype1 != $qtype] && error "mdt quota setting is lost"
2162 qtype=$(ost_quota_type)
2163 [ $qtype1 != $qtype ] && error "ost quota setting is lost"
2165 echo "Set both mdt & ost quota type as none"
2166 set_mdt_qtype "none" || error "disable mdt quota failed"
2167 set_ost_qtype "none" || error "disable ost quota failed"
2170 stopall || error "failed to stopall (2)"
2175 echo "Verify if quota is disabled"
2176 qtype=$(mdt_quota_type)
2177 [ $qtype != "none" ] && error "mdt quota setting is lost"
2178 qtype=$(ost_quota_type)
2179 [ $qtype != "none" ] && error "ost quota setting is lost"
2183 run_test 22 "enable/disable quota by 'lctl conf_param'"
2186 local TESTFILE="$DIR/$tdir/$tfile"
2189 setup_quota_test || error "setup quota failed with $?"
2190 trap cleanup_quota_test EXIT
2192 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2195 log "User quota (limit: $LIMIT MB)"
2196 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
2197 error "set quota failed"
2198 quota_show_check b u $TSTUSR
2200 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2201 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2203 log "Step1: trigger EDQUOT with O_DIRECT"
2204 log "Write half of file"
2205 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
2206 quota_error u $TSTUSR "(1) Write failure, expect success." \
2208 log "Write out of block quota ..."
2209 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
2210 oflag=direct conv=notrunc &&
2211 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
2215 log "Step2: rewrite should succeed"
2216 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
2217 quota_error u $TSTUSR "(3) Write failure, expect success." \
2223 local OST0_UUID=$(ostuuid_from_index 0)
2224 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
2225 [ $OST0_QUOTA_USED -ne 0 ] &&
2226 ($SHOW_QUOTA_USER; \
2227 quota_error u $TSTUSR "quota isn't released")
2229 resetquota -u $TSTUSR
2233 [ $(facet_fstype ost1) == "zfs" ] &&
2234 skip "Overwrite in place is not guaranteed to be " \
2235 "space neutral on ZFS" && return
2237 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
2238 check_whether_skip && return 0
2239 log "run for 4MB test file"
2242 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
2243 check_whether_skip && return 0
2244 log "run for 40MB test file"
2247 run_test 23 "Quota should be honored with directIO (b16125)"
2251 local TESTFILE="$DIR/$tdir/$tfile"
2253 setup_quota_test || error "setup quota failed with $?"
2254 trap cleanup_quota_test EXIT
2256 set_ost_qtype $QTYPE || error "enable ost quota failed"
2258 # bind file to a single OST
2259 $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2260 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2262 echo "Set user quota (limit: ${blimit}M)"
2263 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2264 error "set quota failed"
2266 # overrun quota by root user
2267 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
2268 error "write failure, expect success"
2269 cancel_lru_locks osc
2270 sync_all_data || true
2272 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
2275 resetquota -u $TSTUSR
2277 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
2279 test_27a() { # b19612
2280 $LFS quota $TSTUSR $DIR &&
2281 error "lfs succeeded with no type, but should have failed"
2282 $LFS setquota $TSTUSR $DIR &&
2283 error "lfs succeeded with no type, but should have failed"
2286 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
2288 test_27b() { # b20200
2289 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2290 error "lfs setquota failed with uid argument"
2291 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2292 error "lfs stequota failed with gid argument"
2293 if is_project_quota_supported; then
2294 $LFS setquota -p $TSTPRJID -b 1000 -B 1000 -i 1000 -I \
2295 1000 $DIR || error \
2296 "lfs stequota failed with projid argument"
2298 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
2299 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
2300 if is_project_quota_supported; then
2301 $SHOW_QUOTA_PROJID ||
2302 error "lfs quota failed with projid argument"
2304 resetquota -u $TSTUSR
2305 resetquota -g $TSTUSR
2306 resetquota -p $TSTPRJID
2309 run_test 27b "lfs quota/setquota should handle user/group/project ID (b20200)"
2314 $LFS setquota -u $TSTID -b 30M -B 3T $DIR ||
2315 error "lfs setquota failed"
2317 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
2318 [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
2319 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
2320 [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
2322 $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
2323 error "lfs setquota for $TSTID failed"
2325 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
2326 [ $limit != "1.465G" ] && error "wrong softlimit $limit"
2327 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
2328 [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
2330 $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
2331 error "total allocated inode/block limit not printed"
2333 resetquota -u $TSTUSR
2335 run_test 27c "lfs quota should support human-readable output"
2342 $LFS setquota -u $TSTID -b ${softlimit}p -B ${hardlimit}P $DIR ||
2343 error "set fraction block limit failed"
2344 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $3}')
2345 [ $limit == ${softlimit}P ] || error "get fraction softlimit failed"
2346 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $4}')
2347 [ $limit == ${hardlimit}P ] || error "get fraction hardlimit failed"
2349 resetquota -u $TSTUSR
2351 run_test 27d "lfs setquota should support fraction block limit"
2355 local TESTFILE="$DIR/$tdir/$tfile"
2358 setup_quota_test || error "setup quota failed with $?"
2359 trap cleanup_quota_test EXIT
2361 set_ost_qtype "u" || error "enable ost quota failed"
2363 $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
2364 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2366 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
2367 $MAX_IQ_TIME $DIR || error "set grace time failed"
2368 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
2369 error "set quota failed"
2370 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
2371 cancel_lru_locks osc
2373 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
2374 # over-quota flag has not yet settled since we do not trigger async
2375 # events based on grace time period expiration
2377 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
2378 cancel_lru_locks osc
2379 # now over-quota flag should be settled and further writes should fail
2381 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
2382 error "grace times were reset"
2385 resetquota -u $TSTUSR
2386 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
2387 $MAX_IQ_TIME $DIR || error "restore grace time failed"
2389 run_test 30 "Hard limit updates should not reset grace times"
2391 # basic usage tracking for user & group
2393 local INODES=10 # 10 files
2394 local BLK_CNT=2 # of 2M each
2395 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
2397 setup_quota_test || error "setup quota failed with $?"
2398 trap cleanup_quota_test EXIT
2400 # make sure the system is clean
2401 local USED=$(getquota -u $TSTID global curspace)
2403 error "Used space ($USED) for user $TSTID isn't 0."
2404 USED=$(getquota -g $TSTID global curspace)
2406 error "Used space ($USED) for group $TSTID isn't 0."
2407 if is_project_quota_supported; then
2408 USED=$(getquota -p $TSTPRJID global curspace)
2409 [ $USED -ne 0 ] && error \
2410 "Used space ($USED) for project $TSTPRJID isn't 0."
2413 echo "Write files..."
2414 for i in $(seq 0 $INODES); do
2415 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
2416 error "write failed"
2417 is_project_quota_supported &&
2418 change_project -p $TSTPRJID $DIR/$tdir/$tfile-$i
2419 echo "Iteration $i/$INODES completed"
2421 cancel_lru_locks osc
2423 echo "Wait for setattr on objects finished..."
2424 wait_delete_completed
2426 sync; sync_all_data || true
2428 echo "Verify disk usage after write"
2429 USED=$(getquota -u $TSTID global curspace)
2430 [ $USED -lt $TOTAL_BLKS ] &&
2431 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
2432 USED=$(getquota -g $TSTID global curspace)
2433 [ $USED -lt $TOTAL_BLKS ] &&
2434 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
2435 if is_project_quota_supported; then
2436 USED=$(getquota -p $TSTPRJID global curspace)
2437 [ $USED -lt $TOTAL_BLKS ] && error \
2438 "Used space for project $TSTPRJID:$USED, expected:$TOTAL_BLKS"
2441 echo "Verify inode usage after write"
2442 USED=$(getquota -u $TSTID global curinodes)
2443 [ $USED -lt $INODES ] &&
2444 error "Used inode for user $TSTID is $USED, expected $INODES"
2445 USED=$(getquota -g $TSTID global curinodes)
2446 [ $USED -lt $INODES ] &&
2447 error "Used inode for group $TSTID is $USED, expected $INODES"
2448 if is_project_quota_supported; then
2449 USED=$(getquota -p $TSTPRJID global curinodes)
2450 [ $USED -lt $INODES ] && error \
2451 "Used inode for project $TSTPRJID is $USED, expected $INODES"
2456 echo "Verify disk usage after delete"
2457 USED=$(getquota -u $TSTID global curspace)
2458 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
2459 USED=$(getquota -u $TSTID global curinodes)
2460 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
2461 USED=$(getquota -g $TSTID global curspace)
2462 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
2463 USED=$(getquota -g $TSTID global curinodes)
2464 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
2465 if is_project_quota_supported; then
2466 USED=$(getquota -p $TSTPRJID global curspace)
2468 error "Used space for project $TSTPRJID isn't 0. $USED"
2469 USED=$(getquota -p $TSTPRJID global curinodes)
2471 error "Used inodes for project $TSTPRJID isn't 0. $USED"
2474 run_test 33 "Basic usage tracking for user & group & project"
2476 # usage transfer test for user & group & project
2478 local BLK_CNT=2 # 2MB
2479 local project_supported="no"
2481 is_project_quota_supported && project_supported="yes"
2482 setup_quota_test || error "setup quota failed with $?"
2483 trap cleanup_quota_test EXIT
2485 # make sure the system is clean
2486 local USED=$(getquota -u $TSTID global curspace)
2487 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
2488 USED=$(getquota -g $TSTID global curspace)
2489 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
2491 local USED=$(getquota -u $TSTID2 global curspace)
2492 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID2 isn't 0."
2493 if [ $project_supported == "yes" ]; then
2494 USED=$(getquota -p $TSTPRJID global curspace)
2495 [ $USED -ne 0 ] && error \
2496 "Used space ($USED) for Project $TSTPRJID isn't 0."
2499 echo "Write file..."
2500 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2501 error "write failed"
2502 cancel_lru_locks osc
2503 sync; sync_all_data || true
2505 echo "chown the file to user $TSTID"
2506 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
2508 echo "Wait for setattr on objects finished..."
2509 wait_delete_completed
2511 BLK_CNT=$((BLK_CNT * 1024))
2513 echo "Verify disk usage for user $TSTID"
2514 USED=$(getquota -u $TSTID global curspace)
2515 [ $USED -lt $BLK_CNT ] &&
2516 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
2517 USED=$(getquota -u $TSTID global curinodes)
2519 error "Used inodes for user $TSTID is $USED, expected 1"
2521 echo "chgrp the file to group $TSTID"
2522 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
2524 echo "Wait for setattr on objects finished..."
2525 wait_delete_completed
2527 echo "Verify disk usage for group $TSTID"
2528 USED=$(getquota -g $TSTID global curspace)
2529 [ $USED -ge $BLK_CNT ] ||
2530 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2531 USED=$(getquota -g $TSTID global curinodes)
2533 error "Used inodes for group $TSTID is $USED, expected 1"
2535 # chown won't change the ost object group. LU-4345 */
2536 echo "chown the file to user $TSTID2"
2537 chown $TSTID2 $DIR/$tdir/$tfile || error "chown to $TSTID2 failed"
2539 echo "Wait for setattr on objects finished..."
2540 wait_delete_completed
2542 echo "change_project project id to $TSTPRJID"
2543 [ $project_supported == "yes" ] &&
2544 change_project -p $TSTPRJID $DIR/$tdir/$tfile
2545 echo "Wait for setattr on objects finished..."
2546 wait_delete_completed
2548 echo "Verify disk usage for user $TSTID2/$TSTID and group $TSTID"
2549 USED=$(getquota -u $TSTID2 global curspace)
2550 [ $USED -lt $BLK_CNT ] &&
2551 error "Used space for user $TSTID2 is $USED, expected $BLK_CNT"
2552 USED=$(getquota -u $TSTID global curspace)
2554 error "Used space for user $TSTID is $USED, expected 0"
2555 USED=$(getquota -g $TSTID global curspace)
2556 [ $USED -lt $BLK_CNT ] &&
2557 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2558 if [ $project_supported == "yes" ]; then
2559 USED=$(getquota -p $TSTPRJID global curspace)
2560 [ $USED -lt $BLK_CNT ] && error \
2561 "Used space for group $TSTPRJID is $USED, expected $BLK_CNT"
2566 run_test 34 "Usage transfer for user & group & project"
2568 # usage is still accessible across restart
2570 local BLK_CNT=2 # 2 MB
2572 setup_quota_test || error "setup quota failed with $?"
2573 trap cleanup_quota_test EXIT
2575 echo "Write file..."
2576 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2577 error "write failed"
2578 is_project_quota_supported &&
2579 change_project -p $TSTPRJID $DIR/$tdir/$tfile
2580 cancel_lru_locks osc
2582 echo "Wait for setattr on objects finished..."
2583 wait_delete_completed
2585 sync; sync_all_data || true
2587 echo "Save disk usage before restart"
2588 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2589 [ $ORIG_USR_SPACE -eq 0 ] &&
2590 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2591 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2592 [ $ORIG_USR_INODES -eq 0 ] &&
2593 error "Used inodes for user $TSTID is 0, expected 1"
2594 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2595 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2596 [ $ORIG_GRP_SPACE -eq 0 ] &&
2597 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2598 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2599 [ $ORIG_GRP_INODES -eq 0 ] &&
2600 error "Used inodes for group $TSTID is 0, expected 1"
2601 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2603 if is_project_quota_supported; then
2604 local ORIG_PRJ_SPACE=$(getquota -p $TSTPRJID global curspace)
2605 [ $ORIG_PRJ_SPACE -eq 0 ] && error \
2606 "Used space for project $TSTPRJID is 0, expected ${BLK_CNT}M"
2607 local ORIG_PRJ_INODES=$(getquota -p $TSTPRJID global curinodes)
2608 [ $ORIG_PRJ_INODES -eq 0 ] && error \
2609 "Used inodes for project $TSTPRJID is 0, expected 1"
2610 echo "Project $TSTPRJID: ${ORIG_PRJ_SPACE}KB $ORIG_PRJ_INODES inodes"
2618 echo "Verify disk usage after restart"
2619 local USED=$(getquota -u $TSTID global curspace)
2620 [ $USED -eq $ORIG_USR_SPACE ] ||
2621 error "Used space for user $TSTID changed from " \
2622 "$ORIG_USR_SPACE to $USED"
2623 USED=$(getquota -u $TSTID global curinodes)
2624 [ $USED -eq $ORIG_USR_INODES ] ||
2625 error "Used inodes for user $TSTID changed from " \
2626 "$ORIG_USR_INODES to $USED"
2627 USED=$(getquota -g $TSTID global curspace)
2628 [ $USED -eq $ORIG_GRP_SPACE ] ||
2629 error "Used space for group $TSTID changed from " \
2630 "$ORIG_GRP_SPACE to $USED"
2631 USED=$(getquota -g $TSTID global curinodes)
2632 [ $USED -eq $ORIG_GRP_INODES ] ||
2633 error "Used inodes for group $TSTID changed from " \
2634 "$ORIG_GRP_INODES to $USED"
2635 if [ $project_supported == "yes" ]; then
2636 USED=$(getquota -p $TSTPRJID global curinodes)
2637 [ $USED -eq $ORIG_PRJ_INODES ] ||
2638 error "Used inodes for project $TSTPRJID " \
2639 "changed from $ORIG_PRJ_INODES to $USED"
2640 USED=$(getquota -p $TSTPRJID global curspace)
2641 [ $USED -eq $ORIG_PRJ_SPACE ] ||
2642 error "Used space for project $TSTPRJID "\
2643 "changed from $ORIG_PRJ_SPACE to $USED"
2646 # check if the vfs_dq_init() is called before writing
2647 echo "Append to the same file..."
2648 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2649 error "write failed"
2650 cancel_lru_locks osc
2651 sync; sync_all_data || true
2653 echo "Verify space usage is increased"
2654 USED=$(getquota -u $TSTID global curspace)
2655 [ $USED -gt $ORIG_USR_SPACE ] ||
2656 error "Used space for user $TSTID isn't increased" \
2657 "orig:$ORIG_USR_SPACE, now:$USED"
2658 USED=$(getquota -g $TSTID global curspace)
2659 [ $USED -gt $ORIG_GRP_SPACE ] ||
2660 error "Used space for group $TSTID isn't increased" \
2661 "orig:$ORIG_GRP_SPACE, now:$USED"
2662 if [ $project_supported == "yes" ]; then
2663 USED=$(getquota -p $TSTPRJID global curspace)
2664 [ $USED -gt $ORIG_PRJ_SPACE ] ||
2665 error "Used space for project $TSTPRJID isn't " \
2666 "increased orig:$ORIG_PRJ_SPACE, now:$USED"
2671 run_test 35 "Usage is still accessible across reboot"
2673 # chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE
2676 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
2677 skip "Old server doesn't have LU-5006 fix." && return
2679 setup_quota_test || error "setup quota failed with $?"
2680 trap cleanup_quota_test EXIT
2682 # make sure the system is clean
2683 local USED=$(getquota -u $TSTID global curspace)
2685 error "Used space ($USED) for user $TSTID isn't 0."
2687 # create file with MDS_OPEN_DELAY_CREATE flag
2688 $SETSTRIPE -c 1 -i 0 $DIR/$tdir/$tfile ||
2689 error "Create file failed"
2691 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 conv=notrunc \
2692 oflag=sync || error "Write file failed"
2694 chown $TSTID $DIR/$tdir/$tfile || error "Chown to file failed"
2696 # wait for setattr on objects finished..."
2697 wait_delete_completed
2699 USED=$(getquota -u $TSTID global curspace)
2700 [ $USED -ne 0 ] || quota_error u $TSTUSR "Used space is 0"
2704 run_test 37 "Quota accounted properly for file created by 'lfs setstripe'"
2708 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.60) ] &&
2709 skip "Old server doesn't have LU-8801 fix." && return
2711 [ "$UID" != 0 ] && skip_env "must run as root" && return
2713 setup_quota_test || error "setup quota failed with $?"
2714 trap cleanup_quota_test EXIT
2716 # make sure the system is clean
2717 local USED=$(getquota -u $TSTID global curspace)
2719 error "Used space ($USED) for user $TSTID isn't 0."
2720 USED=$(getquota -u $TSTID2 global curspace)
2722 error "Used space ($USED) for user $TSTID2 isn't 0."
2724 local TESTFILE="$DIR/$tdir/$tfile"
2725 local file_cnt=10000
2727 # Generate id entries in accounting file
2728 echo "Create $file_cnt files..."
2729 for i in `seq $file_cnt`; do
2731 chown $((file_cnt - i)):$((file_cnt - i)) $TESTFILE-$i ||
2732 error "failed to chown $TESTFILE-$i"
2734 cancel_lru_locks osc
2735 sync; sync_all_data || true
2737 local procf="osd-$(facet_fstype $SINGLEMDS).$FSNAME-MDT0000"
2738 procf=${procf}.quota_slave.acct_user
2741 acct_cnt=$(do_facet mds1 $LCTL get_param $procf | grep "id:" | \
2742 awk '{if ($3 < 10000) {print $3}}' | wc -l)
2743 echo "Found $acct_cnt id entries"
2745 [ $file_cnt -eq $acct_cnt ] || {
2746 do_facet mds1 $LCTL get_param $procf
2747 error "skipped id entries"
2752 run_test 38 "Quota accounting iterator doesn't skip id entries"
2755 local TESTFILE="$DIR/$tdir/project"
2756 ! is_project_quota_supported &&
2757 skip "Project quota is not supported" && return 0
2759 setup_quota_test || error "setup quota failed with $?"
2762 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2763 [ $projectid -ne 0 ] &&
2764 error "Project id should be 0 not $projectid"
2765 change_project -p 1024 $TESTFILE
2766 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2767 [ $projectid -ne 1024 ] &&
2768 error "Project id should be 1024 not $projectid"
2770 stopall || error "failed to stopall (1)"
2773 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2774 [ $projectid -ne 1024 ] &&
2775 error "Project id should be 1024 not $projectid"
2779 run_test 39 "Project ID interface works correctly"
2782 ! is_project_quota_supported &&
2783 skip "Project quota is not supported" && return 0
2784 local dir1="$DIR/$tdir/dir1"
2785 local dir2="$DIR/$tdir/dir2"
2787 setup_quota_test || error "setup quota failed with $?"
2789 mkdir -p $dir1 $dir2
2790 change_project -sp 1 $dir1 && touch $dir1/1
2791 change_project -sp 2 $dir2
2793 ln $dir1/1 $dir2/1_link &&
2794 error "Hard link across different project quota should fail"
2799 run_test 40a "Hard link across different project ID"
2802 ! is_project_quota_supported &&
2803 skip "Project quota is not supported" && return 0
2804 local dir1="$DIR/$tdir/dir1"
2805 local dir2="$DIR/$tdir/dir2"
2807 setup_quota_test || error "setup quota failed with $?"
2808 mkdir -p $dir1 $dir2
2809 change_project -sp 1 $dir1 && touch $dir1/1
2810 change_project -sp 2 $dir2
2812 mv $dir1/1 $dir2/2 || error "mv failed $?"
2813 local projid=$(lfs project $dir2/2 | awk '{print $1}')
2814 if [ "$projid" != "2" ]; then
2815 error "project id expected 2 not $projid"
2820 run_test 40b "Mv across different project ID"
2823 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
2824 ! is_project_quota_supported &&
2825 skip "Project quota is not supported" && return 0
2827 setup_quota_test || error "setup quota failed with $?"
2828 local dir="$DIR/$tdir/dir"
2830 mkdir -p $dir && change_project -sp 1 $dir
2831 $LFS mkdir -i 1 $dir/remote_dir || error "create remote dir failed"
2832 local projid=$(lfs project -d $dir/remote_dir | awk '{print $1}')
2833 [ "$projid" != "1" ] && error "projid id expected 1 not $projid"
2834 touch $dir/remote_dir/file
2835 #verify inherit works file for remote dir.
2836 local projid=$(lfs project -d $dir/remote_dir/file | awk '{print $1}')
2837 [ "$projid" != "1" ] &&
2838 error "file under remote dir expected 1 not $projid"
2840 #Agent inode should be ignored for project quota
2841 USED=$(getquota -p 1 global curinodes)
2842 [ "$USED" != "3" ] &&
2843 error "file count expected 3 got $USED"
2849 run_test 40c "Remote child Dir inherit project quota properly"
2852 ! is_project_quota_supported &&
2853 skip "Project quota is not supported" && return 0
2855 setup_quota_test || error "setup quota failed with $?"
2856 local dir="$DIR/$tdir/dir"
2858 mkdir $dir && change_project -p 1 $dir
2859 count=$($LFS find --projid 1 $DIR | wc -l)
2860 [ "$count" != 1 ] && error "expected 1 but got $count"
2865 run_test 50 "Test if lfs find --projid works"
2868 ! is_project_quota_supported &&
2869 skip "Project quota is not supported" && return 0
2870 setup_quota_test || error "setup quota failed with $?"
2871 local dir="$DIR/$tdir/dir"
2873 mkdir $dir && change_project -sp 1 $dir
2874 local used=$(getquota -p 1 global curinodes)
2875 [ $used != "1" ] && error "expected 1 got $used"
2880 used=$(getquota -p 1 global curinodes)
2881 [ $used != "4" ] && error "expected 4 got $used"
2883 $DD if=/dev/zero of=$DIR/$tdir/6 bs=1M count=1
2885 cp $DIR/$tdir/6 $dir/6
2886 used=$(getquota -p 1 global curinodes)
2887 [ $used != "5" ] && error "expected 5 got $used"
2890 mv $DIR/$tdir/6 $dir/7
2891 used=$(getquota -p 1 global curinodes)
2892 [ $used != "6" ] && error "expected 6 got $used"
2897 run_test 51 "Test project accounting with mv/cp"
2900 ! is_project_quota_supported &&
2901 skip "Project quota is not supported" && return 0
2902 setup_quota_test || error "setup quota failed with $?"
2903 local dir="$DIR/$tdir/dir"
2904 mkdir $dir && change_project -sp 1 $dir
2906 touch $DIR/$tdir/file
2907 #Try renaming a file into the project. This should fail.
2908 for num in $(seq 1 2000); do
2909 mrename $DIR/$tdir/file $dir/file >&/dev/null &&
2910 error "rename should fail"
2915 run_test 52 "Rename across different project ID"
2918 ! is_project_quota_supported &&
2919 skip "Project quota is not supported" && return 0
2920 setup_quota_test || error "setup quota failed with $?"
2921 local dir="$DIR/$tdir/dir"
2922 mkdir $dir && change_project -s $dir
2923 lfs project -d $dir | grep P || error "inherit attribute should be set"
2925 change_project -C $dir
2926 lfs project -d $dir | grep P &&
2927 error "inherit attribute should be cleared"
2932 run_test 53 "Project inherit attribute could be cleared"
2935 ! is_project_quota_supported &&
2936 skip "Project quota is not supported" && return 0
2937 setup_quota_test || error "setup quota failed with $?"
2938 trap cleanup_quota_test EXIT
2939 local testfile="$DIR/$tdir/$tfile-0"
2941 #set project ID/inherit attribute
2942 change_project -sp $TSTPRJID $DIR/$tdir
2943 $RUNAS createmany -m ${testfile} 100 ||
2944 error "create many files failed"
2946 local proj_count=$(lfs project -r $DIR/$tdir | wc -l)
2947 # one more count for directory itself */
2951 local proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2952 [ $proj_count1 -eq 0 ] || error "c1: expected 0 got $proj_count1"
2954 proj_count1=$(lfs project -rcp $((TSTPRJID+1)) $DIR/$tdir | wc -l)
2955 [ $proj_count1 -eq $proj_count ] ||
2956 error "c2: expected $proj_count got $proj_count1"
2958 #clear project but with kept projid
2959 change_project -rCk $DIR/$tdir
2960 proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2961 [ $proj_count1 -eq $proj_count ] ||
2962 error "c3: expected $proj_count got $proj_count1"
2964 #verify projid untouched.
2965 proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
2967 [ $proj_count1 -eq $proj_count ] ||
2968 error "c4: expected $proj_count got $proj_count1"
2971 lfs project $DIR/$tdir -cr -0 | xargs -0 lfs project -s
2972 proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2973 [ $proj_count1 -eq 0 ] || error "c5: expected 0 got $proj_count1"
2975 #this time clear all
2976 change_project -rC $DIR/$tdir
2977 proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
2978 [ $proj_count1 -eq 0 ] ||
2979 error "c6: expected 0 got $proj_count1"
2981 unlinkmany ${testfile} 100 ||
2982 error "unlink many files failed"
2986 run_test 54 "basic lfs project interface test"
2989 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
2990 skip "Not supported before 2.10.58." && return
2991 setup_quota_test || error "setup quota failed with $?"
2993 set_ost_qtype $QTYPE || error "enable ost quota failed"
2996 #add second group to TSTUSR
2997 usermod -G $TSTUSR,$TSTUSR2 $TSTUSR
3000 $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1024 count=100000 ||
3001 error "failed to dd"
3003 cancel_lru_locks osc
3004 sync; sync_all_data || true
3006 $LFS setquota -g $TSTUSR2 -b 0 -B 50M $DIR ||
3007 error "failed to setquota on group $TSTUSR2"
3009 $LFS quota -v -g $TSTUSR2 $DIR
3011 runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile &&
3012 error "chgrp should failed with -EDQUOT"
3014 USED=$(getquota -g $TSTUSR2 global curspace)
3017 $LFS setquota -g $TSTUSR2 -b 0 -B 300M $DIR ||
3018 error "failed to setquota on group $TSTUSR2"
3020 $LFS quota -v -g $TSTUSR2 $DIR
3022 runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile ||
3023 error "chgrp should succeed"
3025 $LFS quota -v -g $TSTUSR2 $DIR
3027 resetquota -g $TSTUSR2
3030 run_test 55 "Chgrp should be affected by group quota"
3033 setup_quota_test || error "setup quota failed with $?"
3035 set_ost_qtype $QTYPE || error "enable ost quota failed"
3038 $LFS setquota -t -u -b 10 -i 10 $DIR ||
3039 erro "failed to set grace time for usr quota"
3040 grace_time=$($LFS quota -t -u $DIR | grep "Block grace time:" |
3041 awk '{print $4 $8}')
3042 if [ "x$grace_time" != "x10s;10s" ]; then
3043 $LFS quota -t -u $DIR
3044 error "expected grace time: 10s;10s, got:$grace_time"
3049 run_test 56 "lfs quota -t should work well"
3052 setup_quota_test || error "setup quota failed with $?"
3054 local dir="$DIR/$tdir/dir"
3057 #try to change pipe file should not hang and return failure
3058 wait_update_facet client "$LFS project -sp 1 $dir/pipe 2>&1 |
3059 awk -F ':' '{ print \\\$2 }'" \
3060 " failed to get xattr for '$dir/pipe'" || return 1
3061 #command can process further if it hit some errors
3062 touch $dir/aaa $dir/bbb
3063 #create one invalid link file
3064 ln -s $dir/not_exist_file $dir/ccc
3065 local cnt=$(lfs project -r $dir 2>/dev/null | wc -l)
3066 [ $cnt -eq 2 ] || error "expected 2 got $cnt"
3070 run_test 57 "lfs project could tolerate errors"
3073 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3074 skip "ldiskfs only test"
3077 disable_project_quota
3078 setup_quota_test || error "setup quota failed with $?"
3081 local testfile="$DIR/$tdir/$tfile-0"
3082 #make sure it did not crash kernel
3083 touch $testfile && lfs project -sp 1 $testfile
3085 enable_project_quota
3088 run_test 59 "lfs project dosen't crash kernel with project disabled"
3091 setup_quota_test || error "setup quota failed with $?"
3092 trap cleanup_quota_test EXIT
3093 local testfile=$DIR/$tdir/$tfile
3096 set_mdt_qtype "ug" || error "enable mdt quota failed"
3098 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $limit $DIR ||
3099 error "set quota failed"
3100 quota_show_check a g $TSTUSR
3102 chown $TSTUSR.$TSTUSR $DIR/$tdir || error "chown $DIR/$tdir failed"
3103 chmod g+s $DIR/$tdir || error "chmod g+s failed"
3104 $RUNAS createmany -m ${testfile} $((limit-1)) ||
3105 error "create many files failed"
3107 $RUNAS touch $DIR/$tdir/foo && error "regular user should fail"
3109 # root user can overrun quota
3110 runas -u 0 -g 0 touch $DIR/$tdir/foo ||
3111 error "root user should succeed"
3114 resetquota -g $TSTUSR
3116 run_test 60 "Test quota for root with setgid"
3118 # test default quota
3119 test_default_quota() {
3120 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.51) ] &&
3121 skip "Not supported before 2.11.51." && return
3126 local qprjid=$TSTPRJID
3130 local LIMIT=20480 #20M disk space
3131 local TESTFILE="$DIR/$tdir/$tfile-0"
3133 [ $qtype == "-p" ] && ! is_project_quota_supported &&
3134 echo "Project quota is not supported" && return 0
3136 [ $qtype == "-u" ] && qdtype="-U"
3137 [ $qtype == "-g" ] && qdtype="-G"
3138 [ $qtype == "-p" ] && {
3143 [ $qpool == "meta" ] && {
3144 LIMIT=10240 #10K inodes
3149 setup_quota_test || error "setup quota failed with $?"
3150 trap cleanup_quota_test EXIT
3154 # enable mdt/ost quota
3155 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
3156 set_ost_qtype $QTYPE || error "enable ost quota failed"
3158 log "set to use default quota"
3159 $LFS setquota $qtype $qid -d $DIR ||
3160 error "set $qid to use default quota failed"
3162 log "set default quota"
3163 $LFS setquota $qdtype $qs ${LIMIT} $qh ${LIMIT} $DIR ||
3164 error "set $qid default quota failed"
3166 log "get default quota"
3167 $LFS quota $qdtype $DIR || error "get default quota failed"
3169 if [ $qpool == "data" ]; then
3170 local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
3172 [ $SLIMIT -eq $LIMIT ] ||
3173 error "the returned default quota is wrong"
3175 local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
3177 [ $SLIMIT -eq $LIMIT ] ||
3178 error "the returned default quota is wrong"
3181 # make sure the system is clean
3182 local USED=$(getquota $qtype $qid global curspace)
3183 [ $USED -ne 0 ] && error "Used space for $qid isn't 0."
3185 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
3186 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
3188 [ $qtype == "-p" ] && change_project -sp $TSTPRJID $DIR/$tdir
3190 log "Test not out of quota"
3191 if [ $qpool == "data" ]; then
3192 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 >> 10)) oflag=sync ||
3193 quota_error $qtype $qid "write failed, expect succeed"
3195 $RUNAS createmany -m $TESTFILE $((LIMIT/2)) ||
3196 quota_error $qtype $qid "create failed, expect succeed"
3198 unlinkmany $TESTFILE $((LIMIT/2))
3201 log "Test out of quota"
3202 # flush cache, ensure noquota flag is set on client
3203 cancel_lru_locks osc
3204 cancel_lru_locks mdc
3205 sync; sync_all_data || true
3206 if [ $qpool == "data" ]; then
3207 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
3208 quota_error $qtype $qid "write succeed, expect EDQUOT"
3210 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
3211 quota_error $qtype $qid "create succeed, expect EDQUOT"
3213 unlinkmany $TESTFILE $((LIMIT*2))
3216 log "Increase default quota"
3217 # increase default quota
3218 $LFS setquota $qdtype $qs $((LIMIT*3)) $qh $((LIMIT*3)) $DIR ||
3219 error "set default quota failed"
3221 cancel_lru_locks osc
3222 cancel_lru_locks mdc
3223 sync; sync_all_data || true
3224 if [ $qpool == "data" ]; then
3225 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
3226 quota_error $qtype $qid "write failed, expect succeed"
3228 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
3229 quota_error $qtype $qid "create failed, expect succeed"
3231 unlinkmany $TESTFILE $((LIMIT*2))
3234 log "Set quota to override default quota"
3235 $LFS setquota $qtype $qid $qs ${LIMIT} $qh ${LIMIT} $DIR ||
3236 error "set $qid quota failed"
3238 cancel_lru_locks osc
3239 cancel_lru_locks mdc
3240 sync; sync_all_data || true
3241 if [ $qpool == "data" ]; then
3242 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync &&
3243 quota_error $qtype $qid "write succeed, expect EQUOT"
3245 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
3246 quota_error $qtype $qid "create succeed, expect EQUOT"
3248 unlinkmany $TESTFILE $((LIMIT*2))
3251 log "Set to use default quota again"
3252 $LFS setquota $qtype $qid -d $DIR ||
3253 error "set $qid to use default quota failed"
3255 cancel_lru_locks osc
3256 cancel_lru_locks mdc
3257 sync; sync_all_data || true
3258 if [ $qpool == "data" ]; then
3259 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) oflag=sync ||
3260 quota_error $qtype $qid "write failed, expect succeed"
3262 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
3263 quota_error $qtype $qid "create failed, expect succeed"
3265 unlinkmany $TESTFILE $((LIMIT*2))
3270 wait_delete_completed || error "wait_delete_completed failed"
3271 sync_all_data || true
3272 $LFS setquota $qdtype -b 0 -B 0 -i 0 -I 0 $DIR ||
3273 error "reset default quota failed"
3274 $LFS setquota $qtype $qid -b 0 -B 0 -i 0 -I 0 $DIR ||
3275 error "reset quota failed"
3281 test_default_quota "-u" "data"
3282 test_default_quota "-u" "meta"
3283 test_default_quota "-g" "data"
3284 test_default_quota "-g" "meta"
3285 test_default_quota "-p" "data"
3286 test_default_quota "-p" "meta"
3288 run_test 61 "default quota tests"
3292 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
3293 disable_project_quota
3295 reset_quota_settings
3300 check_and_cleanup_lustre
3301 export QUOTA_AUTO=$QUOTA_AUTO_OLD