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"
53 # bug number for skipped test: LU-5638
54 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 11 33"
60 [ "$SLOW" = "no" ] && EXCEPT_SLOW="$ZFS_SLOW"
62 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
64 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
69 QUOTA_AUTO_OLD=$QUOTA_AUTO
72 check_and_setup_lustre
74 ENABLE_PROJECT_QUOTAS=${ENABLE_PROJECT_QUOTAS:-true}
75 is_project_quota_supported() {
76 $ENABLE_PROJECT_QUOTAS || return 1
77 [ "$(facet_fstype $SINGLEMDS)" == "ldiskfs" ] &&
78 [ $(lustre_version_code $SINGLEMDS) -gt \
79 $(version_code 2.9.55) ] &&
80 lfs --help | grep project >&/dev/null &&
81 egrep -q "7." /etc/redhat-release && return 0
83 if [ "$(facet_fstype $SINGLEMDS)" == "zfs" ]; then
84 [ $(lustre_version_code $SINGLEMDS) -le \
85 $(version_code 2.10.53) ] && return 1
87 $ZPOOL upgrade -v | grep project_quota && return 0
93 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
94 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
95 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
96 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
97 SHOW_QUOTA_PROJID="eval is_project_quota_supported && $LFS quota -v -p $TSTPRJID $DIR"
98 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
99 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
100 SHOW_QUOTA_INFO_PROJID="eval is_project_quota_supported && $LFS quota -t -p $DIR"
107 local fail_val=${3:-0}
111 mds_ost|mdt_ost) NODES="$(comma_list $(mdts_nodes) $(osts_nodes))";;
112 mds|mdt) NODES="$(comma_list $(mdts_nodes))";;
113 ost) NODES="$(comma_list $(osts_nodes))";;
116 do_nodes $NODES "lctl set_param fail_val=$fail_val fail_loc=$fail_loc"
121 echo "lfs project $*"
122 lfs project $* || error "lfs project $* failed"
125 RUNAS="runas -u $TSTID -g $TSTID"
126 RUNAS2="runas -u $TSTID2 -g $TSTID2"
127 DD="dd if=/dev/zero bs=1M"
131 # clear quota limits for a user or a group
132 # usage: resetquota -u username
133 # resetquota -g groupname
134 # resetquota -p projid
137 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
138 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
139 error "resetquota: wrong specifier $1 passed"
141 if [ $1 == "-p" ]; then
142 is_project_quota_supported || return 0
145 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
146 error "clear quota for [type:$1 name:$2] failed"
147 # give a chance to slave to release space
155 if [ "$local_ugp" == "a" -o "$local_ugp" == "u" ]; then
156 $LFS quota -v -u $local_id $DIR
157 log "Files for user ($local_id):"
158 ($LFS find --user $local_id $DIR | head -n 4 |
159 xargs stat 2>/dev/null)
162 if [ "$local_ugp" == "a" -o "$local_ugp" == "g" ]; then
163 $LFS quota -v -g $local_id $DIR
164 log "Files for group ($local_id):"
165 ($LFS find --group $local_id $DIR | head -n 4 |
166 xargs stat 2>/dev/null)
169 if [ "$local_ugp" == "a" -o "$local_ugp" == "p" ]; then
170 $LFS quota -v -p $TSTPRJID $DIR
171 log "Files for project ($TSTPRJID):"
172 ($LFS find --projid $TSTPRJID $DIR | head -n 4 |
173 xargs stat 2>/dev/null)
189 # get quota for a user or a group
190 # usage: getquota -u|-g|-p <username>|<groupname>|<projid> global|<obd_uuid> \
191 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace
196 sync_all_data > /dev/null 2>&1 || true
198 [ "$#" != 4 ] && error "getquota: wrong number of arguments: $#"
199 [ "$1" != "-u" -a "$1" != "-g" -a "$1" != "-p" ] &&
200 error "getquota: wrong u/g/p specifier $1 passed"
213 *) error "unknown quota parameter $4";;
216 [ "$uuid" = "global" ] && uuid=$DIR
218 $LFS quota -v "$1" "$2" $DIR |
219 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
220 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
225 # usage: set_mdt_qtype ugp|u|g|p|none
229 local mdts=$(get_facets MDS)
231 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
232 qtype=$(tr -d 'p' <<<$qtype)
233 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$qtype
234 # we have to make sure each MDT received config changes
235 for mdt in ${mdts//,/ }; do
237 cmd="$LCTL get_param -n "
238 cmd=${cmd}osd-$(facet_fstype $mdt).${!varsvc}
239 cmd=${cmd}.quota_slave.enabled
241 if $(facet_up $mdt); then
242 wait_update_facet $mdt "$cmd" "$qtype" || return 1
249 # usage: set_ost_qtype ugp|u|g|p|none
253 local osts=$(get_facets OST)
255 [[ "$qtype" =~ "p" ]] && ! is_project_quota_supported &&
256 qtype=$(tr -d 'p' <<<$qtype)
257 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$qtype
258 # we have to make sure each OST received config changes
259 for ost in ${osts//,/ }; do
261 cmd="$LCTL get_param -n "
262 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
263 cmd=${cmd}.quota_slave.enabled
265 if $(facet_up $ost); then
266 wait_update_facet $ost "$cmd" "$qtype" || return 1
272 wait_reintegration() {
276 local result="glb[1],slv[1],reint[0]"
281 if [ $ntype == "mdt" ]; then
282 tgts=$(get_facets MDS)
284 tgts=$(get_facets OST)
287 for tgt in ${tgts//,/ }; do
289 cmd="$LCTL get_param -n "
290 cmd=${cmd}osd-$(facet_fstype $tgt).${!varsvc}
291 cmd=${cmd}.quota_slave.info
293 if $(facet_up $tgt); then
294 wait_update_facet $tgt "$cmd |
295 grep "$qtype" | awk '{ print \\\$3 }'" \
296 "$result" $max || return 1
306 if [[ "$qtype" =~ "u" ]]; then
307 wait_reintegration "mdt" "user" $max || return 1
310 if [[ "$qtype" =~ "g" ]]; then
311 wait_reintegration "mdt" "group" $max || return 1
314 if [[ "$qtype" =~ "p" ]]; then
315 ! is_project_quota_supported && return 0
316 wait_reintegration "mdt" "project" $max || return 1
325 if [[ "$qtype" =~ "u" ]]; then
326 wait_reintegration "ost" "user" $max || return 1
329 if [[ "$qtype" =~ "g" ]]; then
330 wait_reintegration "ost" "group" $max || return 1
333 if [[ "$qtype" =~ "p" ]]; then
334 ! is_project_quota_supported && return 0
335 wait_reintegration "ost" "project" $max || return 1
340 disable_project_quota() {
341 is_project_quota_supported || return 0
342 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
343 stopall || error "failed to stopall (1)"
345 for num in $(seq $MDSCOUNT); do
346 do_facet mds$num $TUNE2FS -Q ^prj $(mdsdevname $num) ||
347 error "tune2fs $(mdsdevname $num) failed"
350 for num in $(seq $OSTCOUNT); do
351 do_facet ost$num $TUNE2FS -Q ^prj $(ostdevname $num) ||
352 error "tune2fs $(ostdevname $num) failed"
360 wait_delete_completed
361 echo "Creating test directory"
362 mkdir $DIR/$tdir || return 1
363 chmod 0777 $DIR/$tdir || return 2
364 # always clear fail_loc in case of fail_loc isn't cleared
365 # properly when previous test failed
366 lustre_fail mds_ost 0
369 cleanup_quota_test() {
371 echo "Delete files..."
373 echo "Wait for unlink objects finished..."
374 wait_delete_completed
375 sync_all_data || true
384 $LFS quota -v -$ugp $qid $DIR
386 if [ "$bf" == "a" -o "$bf" == "b" ]; then
387 usage=$(getquota -$ugp $qid global curspace)
388 if [ -z $usage ]; then
389 quota_error $ugp $qid \
390 "Query block quota failed ($ugp:$qid)."
392 [ $usage -ne 0 ] && quota_log $ugp $qid \
393 "Block quota isn't 0 ($ugp:$qid:$usage)."
397 if [ "$bf" == "a" -o "$bf" == "f" ]; then
398 usage=$(getquota -$ugp $qid global curinodes)
399 if [ -z $usage ]; then
400 quota_error $ugp $qid \
401 "Query file quota failed ($ugp:$qid)."
403 [ $usage -ne 0 ] && quota_log $ugp $qid \
404 "File quota isn't 0 ($ugp:$qid:$usage)."
409 enable_project_quota() {
410 is_project_quota_supported || return 0
411 [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] && return 0
412 stopall || error "failed to stopall (1)"
414 for num in $(seq $MDSCOUNT); do
415 do_facet mds$num $TUNE2FS -O project $(mdsdevname $num) ||
416 error "tune2fs $(mdsdevname $num) failed"
419 for num in $(seq $OSTCOUNT); do
420 do_facet ost$num $TUNE2FS -O project $(ostdevname $num) ||
421 error "tune2fs $(ostdevname $num) failed"
429 reset_quota_settings() {
430 resetquota -u $TSTUSR
431 resetquota -g $TSTUSR
432 resetquota -u $TSTUSR2
433 resetquota -g $TSTUSR2
434 resetquota -p $TSTPRJID
439 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
444 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
445 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
446 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
447 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
449 test_quota_performance() {
450 local TESTFILE="$DIR/$tdir/$tfile-0"
451 local size=$1 # in MB
452 local stime=$(date +%s)
453 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
454 quota_error u $TSTUSR "write failure"
455 local etime=$(date +%s)
456 delta=$((etime - stime))
457 if [ $delta -gt 0 ]; then
458 rate=$((size * 1024 / delta))
459 if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
460 # LU-2872 - see LU-2887 for fix
462 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
464 [ $rate -gt 1024 ] ||
465 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
471 # test basic quota performance b=21696
474 [ "$SLOW" = "no" ] && MB=10
476 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
477 [ $free_space -le $((MB * 1024)) ] &&
478 skip "not enough space ${free_space} KB, " \
479 "required $((MB * 1024)) KB" && return
480 setup_quota_test || error "setup quota failed with $?"
481 trap cleanup_quota_test EXIT
483 set_ost_qtype "none" || error "disable ost quota failed"
484 test_quota_performance $MB
486 set_ost_qtype $QTYPE || error "enable ost quota failed"
487 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
488 error "set quota failed"
489 test_quota_performance $MB
492 resetquota -u $TSTUSR
494 run_test 0 "Test basic quota performance"
496 # test block hardlimit
499 local TESTFILE="$DIR/$tdir/$tfile-0"
501 setup_quota_test || error "setup quota failed with $?"
502 trap cleanup_quota_test EXIT
505 set_ost_qtype $QTYPE || error "enable ost quota failed"
508 log "User quota (block hardlimit:$LIMIT MB)"
509 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
510 error "set user quota failed"
512 # make sure the system is clean
513 local USED=$(getquota -u $TSTUSR global curspace)
514 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
516 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
517 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
520 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
521 quota_error u $TSTUSR "user write failure, but expect success"
522 log "Write out of block quota ..."
523 # this time maybe cache write, ignore it's failure
524 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
525 # flush cache, ensure noquota flag is set on client
527 sync; sync_all_data || true
528 $RUNAS $DD of=$TESTFILE count=1 seek=$LIMIT &&
529 quota_error u $TSTUSR "user write success, but expect EDQUOT"
532 wait_delete_completed || error "wait_delete_completed failed"
533 sync_all_data || true
534 USED=$(getquota -u $TSTUSR global curspace)
535 [ $USED -ne 0 ] && quota_error u $TSTUSR \
536 "user quota isn't released after deletion"
537 resetquota -u $TSTUSR
540 log "--------------------------------------"
541 log "Group quota (block hardlimit:$LIMIT MB)"
542 $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
543 error "set group quota failed"
545 TESTFILE="$DIR/$tdir/$tfile-1"
546 # make sure the system is clean
547 USED=$(getquota -g $TSTUSR global curspace)
548 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTUSR isn't 0"
550 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
551 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
554 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
555 quota_error g $TSTUSR "Group write failure, but expect success"
556 log "Write out of block quota ..."
557 # this time maybe cache write, ignore it's failure
558 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
560 sync; sync_all_data || true
561 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT &&
562 quota_error g $TSTUSR "Group write success, but expect EDQUOT"
564 wait_delete_completed || error "wait_delete_completed failed"
565 sync_all_data || true
566 USED=$(getquota -g $TSTUSR global curspace)
567 [ $USED -ne 0 ] && quota_error g $TSTUSR \
568 "Group quota isn't released after deletion"
569 resetquota -g $TSTUSR
571 if ! is_project_quota_supported; then
572 echo "Project quota is not supported"
577 TESTFILE="$DIR/$tdir/$tfile-2"
578 # make sure the system is clean
579 USED=$(getquota -p $TSTPRJID global curspace)
581 error "used space($USED) for project $TSTPRJID isn't 0"
584 log "--------------------------------------"
585 log "Project quota (block hardlimit:$LIMIT mb)"
586 $LFS setquota -p $TSTPRJID -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
587 error "set project quota failed"
589 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
590 chown $TSTUSR:$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
591 change_project -p $TSTPRJID $TESTFILE
594 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) || quota_error p $TSTPRJID \
595 "project write failure, but expect success"
596 log "write out of block quota ..."
597 # this time maybe cache write, ignore it's failure
598 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
600 sync; sync_all_data || true
601 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT && quota_error p \
602 $TSTPRJID "project write success, but expect EDQUOT"
607 USED=$(getquota -p $TSTPRJID global curspace)
608 [ $USED -ne 0 ] && quota_error p $TSTPRJID \
609 "project quota isn't released after deletion"
611 resetquota -p $TSTPRJID
613 run_test 1 "Block hard limit (normal use and out of quota)"
615 # test inode hardlimit
617 local LIMIT=$((1024 * 1024)) # 1M inodes
618 local TESTFILE="$DIR/$tdir/$tfile-0"
620 [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes
622 local FREE_INODES=$(mdt_free_inodes 0)
623 echo "$FREE_INODES free inodes on master MDT"
624 [ $FREE_INODES -lt $LIMIT ] &&
625 skip "not enough free inodes $FREE_INODES required $LIMIT" &&
628 setup_quota_test || error "setup quota failed with $?"
629 trap cleanup_quota_test EXIT
632 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
635 log "User quota (inode hardlimit:$LIMIT files)"
636 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
637 error "set user quota failed"
639 # make sure the system is clean
640 local USED=$(getquota -u $TSTUSR global curinodes)
641 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
643 log "Create $LIMIT files ..."
644 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
645 quota_error u $TSTUSR "user create failure, but expect success"
646 log "Create out of file quota ..."
647 $RUNAS touch ${TESTFILE}_xxx &&
648 quota_error u $TSTUSR "user create success, but expect EDQUOT"
651 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
652 rm -f ${TESTFILE}_xxx
653 wait_delete_completed
655 USED=$(getquota -u $TSTUSR global curinodes)
656 [ $USED -ne 0 ] && quota_error u $TSTUSR \
657 "user quota isn't released after deletion"
658 resetquota -u $TSTUSR
661 log "--------------------------------------"
662 log "Group quota (inode hardlimit:$LIMIT files)"
663 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
664 error "set group quota failed"
666 TESTFILE=$DIR/$tdir/$tfile-1
667 # make sure the system is clean
668 USED=$(getquota -g $TSTUSR global curinodes)
669 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
671 log "Create $LIMIT files ..."
672 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
673 quota_error g $TSTUSR "group create failure, but expect success"
674 log "Create out of file quota ..."
675 $RUNAS touch ${TESTFILE}_xxx &&
676 quota_error g $TSTUSR "group create success, but expect EDQUOT"
679 unlinkmany ${TESTFILE} $LIMIT || error "unlinkmany $TESTFILE failed"
680 rm -f ${TESTFILE}_xxx
681 wait_delete_completed
683 USED=$(getquota -g $TSTUSR global curinodes)
684 [ $USED -ne 0 ] && quota_error g $TSTUSR \
685 "user quota isn't released after deletion"
687 resetquota -g $TSTUSR
688 ! is_project_quota_supported && cleanup_quota_test &&
689 echo "Skip project quota is not supported" && return 0
692 log "--------------------------------------"
693 log "Project quota (inode hardlimit:$LIMIT files)"
694 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
695 error "set project quota failed"
697 TESTFILE=$DIR/$tdir/$tfile-1
698 # make sure the system is clean
699 USED=$(getquota -p $TSTPRJID global curinodes)
701 error "Used inodes($USED) for project $TSTPRJID isn't 0"
703 change_project -sp $TSTPRJID $DIR/$tdir
704 log "Create $LIMIT files ..."
705 $RUNAS createmany -m ${TESTFILE} $((LIMIT-1)) || quota_error p \
706 $TSTPRJID "project create fail, but expect success"
707 log "Create out of file quota ..."
708 $RUNAS touch ${TESTFILE}_xxx && quota_error p $TSTPRJID \
709 "project create success, but expect EDQUOT"
710 change_project -C $DIR/$tdir
713 USED=$(getquota -p $TSTPRJID global curinodes)
714 [ $USED -ne 0 ] && quota_error p $TSTPRJID \
715 "project quota isn't released after deletion"
717 resetquota -p $TSTPRJID
720 run_test 2 "File hard limit (normal use and out of quota)"
724 local TIMER=$(($2 * 3 / 2))
730 trap cleanup_quota_test EXIT
732 $SETSTRIPE $TESTFILE -c 1 -i 0
733 chown $TSTUSR.$TSTUSR $TESTFILE
734 [ "$qtype" == "p" ] && is_project_quota_supported &&
735 change_project -p $TSTPRJID $TESTFILE
737 echo "Write up to soft limit"
738 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
739 quota_error a $TSTUSR "write failure, but expect success"
740 OFFSET=$((LIMIT * 1024))
743 echo "Write to exceed soft limit"
744 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
745 quota_error a $TSTUSR "write failure, but expect success"
746 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
752 $SHOW_QUOTA_INFO_USER
753 $SHOW_QUOTA_INFO_GROUP
754 $SHOW_QUOTA_INFO_PROJID
756 echo "Write before timer goes off"
757 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
758 quota_error a $TSTUSR "write failure, but expect success"
759 OFFSET=$((OFFSET + 1024))
762 echo "Sleep $TIMER seconds ..."
768 $SHOW_QUOTA_INFO_USER
769 $SHOW_QUOTA_INFO_GROUP
770 $SHOW_QUOTA_INFO_PROJID
772 echo "Write after timer goes off"
773 # maybe cache write, ignore.
774 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET || true
775 OFFSET=$((OFFSET + 1024))
777 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET &&
778 quota_error a $TSTUSR "write success, but expect EDQUOT"
783 $SHOW_QUOTA_INFO_USER
784 $SHOW_QUOTA_INFO_GROUP
785 $SHOW_QUOTA_INFO_PROJID
787 echo "Unlink file to stop timer"
789 wait_delete_completed
790 sync_all_data || true
795 $SHOW_QUOTA_INFO_USER
796 $SHOW_QUOTA_INFO_GROUP
797 $SHOW_QUOTA_INFO_PROJID
799 $SETSTRIPE $TESTFILE -c 1 -i 0
800 chown $TSTUSR.$TSTUSR $TESTFILE
801 [ "$qtype" == "p" ] && change_project -p $TSTPRJID $TESTFILE
804 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
805 quota_error a $TSTUSR "write failure, but expect success"
814 local TESTFILE=$DIR/$tdir/$tfile-0
816 set_ost_qtype $QTYPE || error "enable ost quota failed"
818 echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
819 # make sure the system is clean
820 local USED=$(getquota -u $TSTUSR global curspace)
821 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
823 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
824 $MAX_IQ_TIME $DIR || error "set user grace time failed"
825 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
826 error "set user quota failed"
828 test_block_soft $TESTFILE $GRACE $LIMIT "u"
829 resetquota -u $TSTUSR
831 echo "Group quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
832 TESTFILE=$DIR/$tdir/$tfile-1
833 # make sure the system is clean
834 USED=$(getquota -g $TSTUSR global curspace)
835 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
837 $LFS setquota -t -g --block-grace $GRACE --inode-grace \
838 $MAX_IQ_TIME $DIR || error "set group grace time failed"
839 $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
840 error "set group quota failed"
842 test_block_soft $TESTFILE $GRACE $LIMIT "g"
843 resetquota -g $TSTUSR
845 if is_project_quota_supported; then
846 echo "Project quota (soft limit:$LIMIT MB grace:$GRACE sec)"
847 TESTFILE=$DIR/$tdir/$tfile-2
848 # make sure the system is clean
849 USED=$(getquota -p $TSTPRJID global curspace)
850 [ $USED -ne 0 ] && error \
851 "Used space($USED) for project $TSTPRJID isn't 0."
853 $LFS setquota -t -p --block-grace $GRACE --inode-grace \
855 error "set project grace time failed"
856 $LFS setquota -p $TSTPRJID -b ${LIMIT}M -B 0 -i 0 -I 0 \
857 $DIR || error "set project quota failed"
859 test_block_soft $TESTFILE $GRACE $LIMIT "p"
860 resetquota -p $TSTPRJID
861 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
863 error "restore project grace time failed"
867 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
868 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
869 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
870 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
872 run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
878 local TIMER=$(($grace * 3 / 2))
881 trap cleanup_quota_test EXIT
882 is_project_quota_supported && change_project -sp $TSTPRJID $DIR/$tdir
884 echo "Create files to exceed soft limit"
885 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
886 quota_error a $TSTUSR "create failure, but expect success"
887 local trigger_time=$(date +%s)
889 sync_all_data || true
891 local cur_time=$(date +%s)
892 [ $(($cur_time - $trigger_time)) -ge $grace ] &&
893 error "Passed grace time $grace, $trigger_time, $cur_time"
895 echo "Create file before timer goes off"
896 $RUNAS touch ${TESTFILE}_before ||
897 quota_error a $TSTUSR "failed create before timer expired," \
898 "but expect success. $trigger_time, $cur_time"
899 sync_all_data || true
901 echo "Sleep $TIMER seconds ..."
907 $SHOW_QUOTA_INFO_USER
908 $SHOW_QUOTA_INFO_GROUP
909 $SHOW_QUOTA_INFO_PROJID
911 echo "Create file after timer goes off"
912 # There is a window that space is accounted in the quota usage but
913 # hasn't been decreased from the pending write, if we acquire quota
914 # in this window, we'll acquire more than we needed.
915 $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
916 sync_all_data || true
917 $RUNAS touch ${TESTFILE}_after_3 &&
918 quota_error a $TSTUSR "create after timer expired," \
920 sync_all_data || true
925 $SHOW_QUOTA_INFO_USER
926 $SHOW_QUOTA_INFO_GROUP
927 $SHOW_QUOTA_INFO_PROJID
929 echo "Unlink files to stop timer"
930 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
931 wait_delete_completed
934 $RUNAS touch ${TESTFILE}_xxx ||
935 quota_error a $TSTUSR "touch after timer stop failure," \
937 sync_all_data || true
945 local LIMIT=10 # inodes
946 local TESTFILE=$DIR/$tdir/$tfile-0
949 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
951 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
952 # make sure the system is clean
953 local USED=$(getquota -u $TSTUSR global curinodes)
954 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
956 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
957 $GRACE $DIR || error "set user grace time failed"
958 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
959 error "set user quota failed"
961 test_file_soft $TESTFILE $LIMIT $GRACE
962 resetquota -u $TSTUSR
964 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
965 # make sure the system is clean
966 USED=$(getquota -g $TSTUSR global curinodes)
967 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
969 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
970 $GRACE $DIR || error "set group grace time failed"
971 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
972 error "set group quota failed"
973 TESTFILE=$DIR/$tdir/$tfile-1
975 test_file_soft $TESTFILE $LIMIT $GRACE
976 resetquota -g $TSTUSR
978 if is_project_quota_supported; then
979 echo "Project quota (soft limit:$LIMIT files grace:$GRACE sec)"
980 # make sure the system is clean
981 USED=$(getquota -p $TSTPRJID global curinodes)
982 [ $USED -ne 0 ] && error \
983 "Used space($USED) for project $TSTPRJID isn't 0."
985 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
986 $GRACE $DIR || error "set project grace time failed"
987 $LFS setquota -p $TSTPRJID -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
988 error "set project quota failed"
990 TESTFILE=$DIR/$tdir/$tfile-1
991 # one less than limit, because of parent directory included.
992 test_file_soft $TESTFILE $((LIMIT-1)) $GRACE
993 resetquota -p $TSTPRJID
994 $LFS setquota -t -p --block-grace $MAX_DQ_TIME --inode-grace \
996 error "restore project grace time failed"
1000 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1001 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1002 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1003 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1005 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
1008 local GR_STR1="1w3d"
1009 local GR_STR2="1000s"
1011 local GR_STR4="1w2d3h4m5s"
1013 local GR_STR6="18446744073709551615"
1016 wait_delete_completed
1018 # test of valid grace strings handling
1019 echo "Valid grace strings test"
1020 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
1021 $GR_STR2 $DIR || error "set user grace time failed"
1022 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
1023 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
1024 $GR_STR4 $DIR || error "set group grace time quota failed"
1025 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
1027 # test of invalid grace strings handling
1028 echo " Invalid grace strings test"
1029 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
1030 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
1031 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace \
1035 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1036 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
1037 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
1038 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
1040 run_test 4b "Grace time strings handling"
1042 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
1044 local BLIMIT=10 # 10M
1045 local ILIMIT=10 # 10 inodes
1047 setup_quota_test || error "setup quota failed with $?"
1048 trap cleanup_quota_test EXIT
1050 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1051 set_ost_qtype $QTYPE || error "enable ost quota failed"
1053 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
1054 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1055 error "set user quota failed"
1056 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
1057 if is_project_quota_supported; then
1058 error "set group quota failed"
1059 $LFS setquota -p $TSTPRJID -b 0 -B ${BLIMIT}M -i 0 \
1060 -I $ILIMIT $DIR || error "set project quota failed"
1063 # make sure the system is clean
1064 local USED=$(getquota -u $TSTUSR global curinodes)
1065 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1066 USED=$(getquota -g $TSTUSR global curinodes)
1067 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
1068 USED=$(getquota -u $TSTUSR global curspace)
1069 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
1070 USED=$(getquota -g $TSTUSR global curspace)
1071 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
1072 if is_project_quota_supported; then
1073 USED=$(getquota -p $TSTPRJID global curinodes)
1075 error "Used inode($USED) for project $TSTPRJID isn't 0."
1076 USED=$(getquota -p $TSTPRJID global curspace)
1078 error "Used block($USED) for project $TSTPRJID isn't 0."
1081 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
1082 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1083 error "create failure, expect success"
1084 if is_project_quota_supported; then
1085 touch $DIR/$tdir/$tfile-0_1
1086 change_project -p $TSTPRJID $DIR/$tdir/$tfile-0_1
1088 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
1089 error "write failure, expect success"
1091 echo "Chown files to $TSTUSR.$TSTUSR ..."
1092 for i in $(seq 0 $ILIMIT); do
1093 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
1094 quota_error a $TSTUSR "chown failure, expect success"
1098 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
1099 error "unlinkmany $DIR/$tdir/$tfile-0_ failed"
1102 resetquota -u $TSTUSR
1103 resetquota -g $TSTUSR
1104 resetquota -p $TSTPRJID
1106 run_test 5 "Chown & chgrp successfully even out of block/file quota"
1108 # test dropping acquire request on master
1112 # Clear dmesg so watchdog is not triggered by previous
1114 do_facet ost1 dmesg -c > /dev/null
1116 setup_quota_test || error "setup quota failed with $?"
1117 trap cleanup_quota_test EXIT
1119 # make sure the system is clean
1120 local USED=$(getquota -u $TSTUSR global curspace)
1121 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1123 # make sure no granted quota on ost
1124 set_ost_qtype $QTYPE || error "enable ost quota failed"
1125 resetquota -u $TSTUSR
1127 # create file for $TSTUSR
1128 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
1129 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1130 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1132 # create file for $TSTUSR2
1133 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
1134 $SETSTRIPE $TESTFILE2 -c 1 -i 0 || error "setstripe $TESTFILE2 failed"
1135 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 || error "chown $TESTFILE2 failed"
1137 # cache per-ID lock for $TSTUSR on slave
1138 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1139 error "set quota failed"
1140 $RUNAS $DD of=$TESTFILE count=1 ||
1141 error "write $TESTFILE failure, expect success"
1142 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
1143 error "write $TESTFILE2 failure, expect success"
1145 sync_all_data || true
1147 #define QUOTA_DQACQ 601
1148 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
1149 lustre_fail mds 0x513 601
1151 # write to un-enforced ID ($TSTUSR2) should succeed
1152 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
1153 error "write failure, expect success"
1155 # write to enforced ID ($TSTUSR) in background, exceeding limit
1156 # to make sure DQACQ is sent
1157 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
1160 # watchdog timer uses a factor of 2
1161 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
1162 sleep $((TIMEOUT * 2 + 1))
1164 # write should be blocked and never finished
1165 if ! ps -p $DDPID > /dev/null 2>&1; then
1167 error "write finished incorrectly!"
1172 # no watchdog is triggered
1173 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1174 watchdog=$(awk '/Service thread pid/ && /was inactive/ \
1175 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1176 [ -z "$watchdog" ] || error "$watchdog"
1178 rm -f $TMP/lustre-log-${TESTNAME}.log
1180 # write should continue then fail with EDQUOT
1184 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1185 if [ $count -ge 240 ]; then
1186 quota_error u $TSTUSR "dd not finished in $count secs"
1188 count=$((count + 1))
1189 if [ $((count % 30)) -eq 0 ]; then
1190 c_size=$(stat -c %s $TESTFILE)
1191 echo "Waiting $count secs. $c_size"
1198 resetquota -u $TSTUSR
1200 run_test 6 "Test dropping acquire request on master"
1202 # quota reintegration (global index)
1204 local TESTFILE=$DIR/$tdir/$tfile
1205 local LIMIT=20 # 20M
1207 [ "$SLOW" = "no" ] && LIMIT=5
1209 setup_quota_test || error "setup quota failed with $?"
1210 trap cleanup_quota_test EXIT
1212 # make sure the system is clean
1213 local USED=$(getquota -u $TSTUSR global curspace)
1214 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1216 # make sure no granted quota on ost1
1217 set_ost_qtype $QTYPE || error "enable ost quota failed"
1218 resetquota -u $TSTUSR
1219 set_ost_qtype "none" || error "disable ost quota failed"
1221 local OSTUUID=$(ostuuid_from_index 0)
1222 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1224 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1227 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1228 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1233 echo "Enable quota & set quota limit for $TSTUSR"
1234 set_ost_qtype $QTYPE || error "enable ost quota failed"
1235 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1236 error "set quota failed"
1238 echo "Start ost1..."
1239 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1242 wait_ost_reint $QTYPE || error "reintegration failed"
1244 # hardlimit should have been fetched by slave during global
1245 # reintegration, write will exceed quota
1246 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1247 quota_error u $TSTUSR "write success, but expect EDQUOT"
1250 wait_delete_completed
1251 sync_all_data || true
1257 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1258 error "clear quota failed"
1260 echo "Start ost1..."
1261 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1264 wait_ost_reint $QTYPE || error "reintegration failed"
1266 # hardlimit should be cleared on slave during reintegration
1267 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
1268 quota_error u $TSTUSR "write error, but expect success"
1271 resetquota -u $TSTUSR
1273 run_test 7a "Quota reintegration (global index)"
1275 # quota reintegration (slave index)
1278 local TESTFILE=$DIR/$tdir/$tfile
1280 setup_quota_test || error "setup quota failed with $?"
1281 trap cleanup_quota_test EXIT
1283 # make sure the system is clean
1284 local USED=$(getquota -u $TSTUSR global curspace)
1285 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1287 # make sure no granted quota on ost1
1288 set_ost_qtype $QTYPE || error "enable ost quota failed"
1289 resetquota -u $TSTUSR
1290 set_ost_qtype "none" || error "disable ost quota failed"
1292 local OSTUUID=$(ostuuid_from_index 0)
1293 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1295 error "limit($USED) on $OSTUUID for user $TSTUSR isn't 0"
1298 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1299 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1301 # consume some space to make sure the granted space will not
1302 # be released during reconciliation
1303 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1304 error "consume space failure, expect success"
1306 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
1307 lustre_fail mds 0xa02
1309 set_ost_qtype $QTYPE || error "enable ost quota failed"
1310 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1311 error "set quota failed"
1313 # ignore the write error
1314 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
1316 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1320 echo "Restart ost to trigger reintegration..."
1322 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "start ost1 failed"
1325 wait_ost_reint $QTYPE || error "reintegration failed"
1327 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1328 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1331 resetquota -u $TSTUSR
1334 run_test 7b "Quota reintegration (slave index)"
1336 # quota reintegration (restart mds during reintegration)
1338 local LIMIT=20 # 20M
1339 local TESTFILE=$DIR/$tdir/$tfile
1341 [ "$SLOW" = "no" ] && LIMIT=5
1343 setup_quota_test || error "setup quota failed with $?"
1344 trap cleanup_quota_test EXIT
1346 # make sure the system is clean
1347 local USED=$(getquota -u $TSTUSR global curspace)
1348 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1350 set_ost_qtype "none" || error "disable ost quota failed"
1351 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1352 error "set quota failed"
1354 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1355 lustre_fail ost 0xa03
1358 set_ost_qtype $QTYPE || error "enable ost quota failed"
1359 # trigger reintegration
1360 local procf="osd-$(facet_fstype ost1).$FSNAME-OST*."
1361 procf=${procf}quota_slave.force_reint
1362 do_facet ost1 $LCTL set_param $procf=1 ||
1363 error "force reintegration failed"
1371 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1374 # wait longer than usual to make sure the reintegration
1375 # is triggered by quota wb thread.
1376 wait_ost_reint $QTYPE 200 || error "reintegration failed"
1378 # hardlimit should have been fetched by slave during global
1379 # reintegration, write will exceed quota
1380 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1381 quota_error u $TSTUSR "write success, but expect EDQUOT"
1384 resetquota -u $TSTUSR
1386 run_test 7c "Quota reintegration (restart mds during reintegration)"
1388 # Quota reintegration (Transfer index in multiple bulks)
1390 local TESTFILE=$DIR/$tdir/$tfile
1391 local TESTFILE1="$DIR/$tdir/$tfile"-1
1394 setup_quota_test || error "setup quota failed with $?"
1395 trap cleanup_quota_test EXIT
1397 set_ost_qtype "none" || error "disable ost quota failed"
1398 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1399 error "set quota for $TSTUSR failed"
1400 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1401 error "set quota for $TSTUSR2 failed"
1403 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1404 lustre_fail mds 0x608 0
1406 # enable quota to tirgger reintegration
1407 set_ost_qtype "u" || error "enable ost quota failed"
1408 wait_ost_reint "u" || error "reintegration failed"
1412 # hardlimit should have been fetched by slave during global
1413 # reintegration, write will exceed quota
1414 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1415 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1417 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1418 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1421 resetquota -u $TSTUSR
1422 resetquota -u $TSTUSR2
1424 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1426 # quota reintegration (inode limits)
1428 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
1430 # LU-2435: skip this quota test if underlying zfs version has not
1431 # supported native dnode accounting
1432 [ "$(facet_fstype mds1)" == "zfs" ] && {
1433 local F="feature@userobj_accounting"
1434 local pool=$(zpool_name mds1)
1435 local feature=$(do_facet mds1 $ZPOOL get -H $F $pool)
1437 [[ "$feature" != *" active "* ]] &&
1438 skip "requires zpool with active userobj_accounting" &&
1442 local ilimit=$((1024 * 2)) # 2k inodes
1443 local TESTFILE=$DIR/${tdir}-1/$tfile
1445 setup_quota_test || error "setup quota failed with $?"
1446 trap cleanup_quota_test EXIT
1448 # make sure the system is clean
1449 local USED=$(getquota -u $TSTUSR global curinodes)
1450 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
1452 # make sure no granted quota on mdt1
1453 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1454 resetquota -u $TSTUSR
1455 set_mdt_qtype "none" || error "disable mdt quota failed"
1457 local MDTUUID=$(mdtuuid_from_index $((MDSCOUNT - 1)))
1458 USED=$(getquota -u $TSTUSR $MDTUUID ihardlimit)
1459 [ $USED -ne 0 ] && error "limit($USED) on $MDTUUID for user" \
1462 echo "Stop mds${MDSCOUNT}..."
1465 echo "Enable quota & set quota limit for $TSTUSR"
1466 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1467 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
1468 error "set quota failed"
1470 echo "Start mds${MDSCOUNT}..."
1471 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
1474 wait_mdt_reint $QTYPE || error "reintegration failed"
1476 echo "create remote dir"
1477 $LFS mkdir -i $((MDSCOUNT - 1)) $DIR/${tdir}-1 ||
1478 error "create remote dir failed"
1479 chmod 0777 $DIR/${tdir}-1
1481 # hardlimit should have been fetched by slave during global
1482 # reintegration, create will exceed quota
1483 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) &&
1484 quota_error u $TSTUSR "create succeeded, expect EDQUOT"
1486 $RUNAS unlinkmany $TESTFILE $ilimit || error "unlink files failed"
1487 wait_delete_completed
1488 sync_all_data || true
1490 echo "Stop mds${MDSCOUNT}..."
1493 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
1494 error "clear quota failed"
1496 echo "Start mds${MDSCOUNT}..."
1497 start mds${MDSCOUNT} $(mdsdevname $MDSCOUNT) $MDS_MOUNT_OPTS
1500 wait_mdt_reint $QTYPE || error "reintegration failed"
1502 # hardlimit should be cleared on slave during reintegration
1503 $RUNAS createmany -m $TESTFILE $((ilimit + 1)) ||
1504 quota_error u $TSTUSR "create failed, expect success"
1506 $RUNAS unlinkmany $TESTFILE $((ilimit + 1)) || error "unlink failed"
1507 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
1510 resetquota -u $TSTUSR
1512 run_test 7e "Quota reintegration (inode limits)"
1514 # run dbench with quota enabled
1516 local BLK_LIMIT="100g" #100G
1517 local FILE_LIMIT=1000000
1519 setup_quota_test || error "setup quota failed with $?"
1520 trap cleanup_quota_test EXIT
1522 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
1523 set_ost_qtype $QTYPE || error "enable ost quota failed"
1525 echo "Set enough high limit for user: $TSTUSR"
1526 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1527 error "set user quota failed"
1528 echo "Set enough high limit for group: $TSTUSR"
1529 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1530 error "set group quota failed"
1531 if is_project_quota_supported; then
1532 change_project -sp $TSTPRJID $DIR/$tdir
1533 echo "Set enough high limit for project: $TSTPRJID"
1534 $LFS setquota -p $TSTPRJID -b 0 \
1535 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1536 error "set project quota failed"
1540 [ "$SLOW" = "no" ] && duration=" -t 120"
1541 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1542 quota_error a $TSTUSR "dbench failed!"
1544 is_project_quota_supported && change_project -C $DIR/$tdir
1546 resetquota -u $TSTUSR
1547 resetquota -g $TSTUSR
1548 resetquota -p $TSTPRJID
1550 run_test 8 "Run dbench with quota enabled"
1552 # this check is just for test_9
1553 OST0_MIN=4900000 #4.67G
1555 check_whether_skip () {
1556 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1557 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1558 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1559 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1566 # run for fixing bug10707, it needs a big room. test for 64bit
1568 local filesize=$((1024 * 9 / 2)) # 4.5G
1570 check_whether_skip && return 0
1572 setup_quota_test || error "setup quota failed with $?"
1573 trap cleanup_quota_test EXIT
1575 set_ost_qtype "ug" || error "enable ost quota failed"
1577 local TESTFILE="$DIR/$tdir/$tfile-0"
1578 local BLK_LIMIT=100G #100G
1579 local FILE_LIMIT=1000000
1581 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1583 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1585 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1586 error "set user quota failed"
1588 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1589 "for group: $TSTUSR"
1590 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1591 error "set group quota failed"
1593 quota_show_check a u $TSTUSR
1594 quota_show_check a g $TSTUSR
1596 echo "Create test file"
1597 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1598 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1600 log "Write the big file of 4.5G ..."
1601 $RUNAS $DD of=$TESTFILE count=$filesize ||
1602 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1608 resetquota -u $TSTUSR
1609 resetquota -g $TSTUSR
1614 run_test 9 "Block limit larger than 4GB (b10707)"
1617 local TESTFILE=$DIR/$tdir/$tfile
1619 setup_quota_test || error "setup quota failed with $?"
1620 trap cleanup_quota_test EXIT
1622 # set limit to root user should fail
1623 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1624 error "set limit for root user successfully, expect failure"
1625 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1626 error "set limit for root group successfully, expect failure"
1627 $LFS setquota -p 0 -b 1T -B 10T -i 5K -I 100M $DIR &&
1628 error "set limit for project 0 successfully, expect failure"
1630 # root user can overrun quota
1631 set_ost_qtype "ug" || error "enable ost quota failed"
1633 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1634 error "set quota failed"
1635 quota_show_check b u $TSTUSR
1637 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
1638 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1640 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1641 error "write failure, expect success"
1644 resetquota -u $TSTUSR
1646 run_test 10 "Test quota for root user"
1649 local TESTFILE=$DIR/$tdir/$tfile
1650 setup_quota_test || error "setup quota failed with $?"
1651 trap cleanup_quota_test EXIT
1653 set_mdt_qtype "ug" || error "enable mdt quota failed"
1654 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1655 error "set quota failed"
1657 touch "$TESTFILE"-0 || error "touch $TESTFILE-0 failed"
1658 touch "$TESTFILE"-1 || error "touch $TESTFILE-0 failed"
1660 chown $TSTUSR.$TSTUSR "$TESTFILE"-0 || error "chown $TESTFILE-0 failed"
1661 chown $TSTUSR.$TSTUSR "$TESTFILE"-1 || error "chown $TESTFILE-1 failed"
1664 local USED=$(getquota -u $TSTUSR global curinodes)
1665 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1668 resetquota -u $TSTUSR
1670 run_test 11 "Chown/chgrp ignores quota"
1673 [ "$OSTCOUNT" -lt "2" ] && skip "needs >= 2 OSTs" && return
1675 local blimit=22 # 22M
1676 local blk_cnt=$((blimit - 5))
1677 local TESTFILE0="$DIR/$tdir/$tfile"-0
1678 local TESTFILE1="$DIR/$tdir/$tfile"-1
1680 setup_quota_test || error "setup quota failed with $?"
1681 trap cleanup_quota_test EXIT
1683 set_ost_qtype "u" || error "enable ost quota failed"
1684 quota_show_check b u $TSTUSR
1686 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1687 error "set quota failed"
1689 $SETSTRIPE $TESTFILE0 -c 1 -i 0 || error "setstripe $TESTFILE0 failed"
1690 $SETSTRIPE $TESTFILE1 -c 1 -i 1 || error "setstripe $TESTFILE1 failed"
1691 chown $TSTUSR.$TSTUSR $TESTFILE0 || error "chown $TESTFILE0 failed"
1692 chown $TSTUSR.$TSTUSR $TESTFILE1 || error "chown $TESTFILE1 failed"
1694 echo "Write to ost0..."
1695 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1696 quota_error a $TSTUSR "dd failed"
1698 echo "Write to ost1..."
1699 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1700 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1702 echo "Free space from ost0..."
1704 wait_delete_completed
1705 sync_all_data || true
1707 echo "Write to ost1 after space freed from ost0..."
1708 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1709 quota_error a $TSTUSR "rebalancing failed"
1712 resetquota -u $TSTUSR
1714 run_test 12a "Block quota rebalancing"
1717 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
1719 local ilimit=$((1024 * 2)) # 2k inodes
1720 local TESTFILE0=$DIR/$tdir/$tfile
1721 local TESTFILE1=$DIR/${tdir}-1/$tfile
1723 setup_quota_test || error "setup quota failed with $?"
1724 trap cleanup_quota_test EXIT
1726 $LFS mkdir -i 1 $DIR/${tdir}-1 || error "create remote dir failed"
1727 chmod 0777 $DIR/${tdir}-1
1729 set_mdt_qtype "u" || error "enable mdt quota failed"
1730 quota_show_check f u $TSTUSR
1732 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $ilimit $DIR ||
1733 error "set quota failed"
1735 echo "Create $ilimit files on mdt0..."
1736 $RUNAS createmany -m $TESTFILE0 $ilimit ||
1737 quota_error u $TSTUSR "create failed, but expect success"
1739 echo "Create files on mdt1..."
1740 $RUNAS createmany -m $TESTFILE1 1 &&
1741 quota_error a $TSTUSR "create succeeded, expect EDQUOT"
1743 echo "Free space from mdt0..."
1744 $RUNAS unlinkmany $TESTFILE0 $ilimit || error "unlink mdt0 files failed"
1745 wait_delete_completed
1746 sync_all_data || true
1748 echo "Create files on mdt1 after space freed from mdt0..."
1749 $RUNAS createmany -m $TESTFILE1 $((ilimit / 2)) ||
1750 quota_error a $TSTUSR "rebalancing failed"
1752 $RUNAS unlinkmany $TESTFILE1 $((ilimit / 2)) ||
1753 error "unlink mdt1 files failed"
1754 rmdir $DIR/${tdir}-1 || error "unlink remote dir failed"
1757 resetquota -u $TSTUSR
1759 run_test 12b "Inode quota rebalancing"
1762 local TESTFILE=$DIR/$tdir/$tfile
1763 # the name of lwp on ost1 name is MDT0000-lwp-OST0000
1764 local procf="ldlm.namespaces.*MDT0000-lwp-OST0000.lru_size"
1766 setup_quota_test || error "setup quota failed with $?"
1767 trap cleanup_quota_test EXIT
1769 set_ost_qtype "u" || error "enable ost quota failed"
1770 quota_show_check b u $TSTUSR
1772 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1773 error "set quota failed"
1774 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
1775 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1777 # clear the locks in cache first
1778 do_facet ost1 $LCTL set_param -n $procf=clear
1779 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1780 [ $nlock -eq 0 ] || error "$nlock cached locks"
1782 # write to acquire the per-ID lock
1783 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1784 quota_error a $TSTUSR "dd failed"
1786 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1787 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1789 # clear quota doesn't trigger per-ID lock cancellation
1790 resetquota -u $TSTUSR
1791 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1792 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1794 # clear the per-ID lock
1795 do_facet ost1 $LCTL set_param -n $procf=clear
1796 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1797 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1799 # spare quota should be released
1800 local OSTUUID=$(ostuuid_from_index 0)
1801 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1802 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1803 [ $limit -le $space ] ||
1804 error "spare quota isn't released, limit:$limit, space:$space"
1808 run_test 13 "Cancel per-ID lock in the LRU list"
1811 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1813 wait_delete_completed
1814 sync_all_data || true
1817 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1818 error "set user quota failed"
1819 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1820 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1821 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1822 resetquota -u $TSTUSR
1825 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1826 error "set group quota failed"
1827 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1828 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1829 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1830 resetquota -g $TSTUSR
1832 run_test 15 "Set over 4T block quota"
1836 local BLKS=1 # 1M less than limit
1837 local TESTFILE=$DIR/$tdir/$tfile
1839 setup_quota_test || error "setup quota failed with $?"
1840 trap cleanup_quota_test EXIT
1842 # make sure the system is clean
1843 local USED=$(getquota -u $TSTUSR global curspace)
1844 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1846 set_ost_qtype "ug" || error "enable ost quota failed"
1847 # make sure no granted quota on ost
1848 resetquota -u $TSTUSR
1849 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1850 error "set quota failed"
1852 quota_show_check b u $TSTUSR
1854 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1855 lustre_fail mds 0xa04 $err_code
1857 # write in background
1858 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1862 # write should be blocked and never finished
1863 if ! ps -p $DDPID > /dev/null 2>&1; then
1865 quota_error u $TSTUSR "write finished incorrectly!"
1873 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1875 if [ $count -gt $timeout ]; then
1876 quota_error u $TSTUSR "dd is not finished!"
1881 sync; sync_all_data || true
1883 USED=$(getquota -u $TSTUSR global curspace)
1884 [ $USED -ge $((BLKS * 1024)) ] || quota_error u $TSTUSR \
1885 "Used space(${USED}K) is less than ${BLKS}M"
1888 resetquota -u $TSTUSR
1891 # DQACQ return recoverable error
1893 echo "DQACQ return -ENOLCK"
1895 test_17sub 37 || error "Handle -ENOLCK failed"
1897 echo "DQACQ return -EAGAIN"
1899 test_17sub 11 || error "Handle -EAGAIN failed"
1901 echo "DQACQ return -ETIMEDOUT"
1902 #define ETIMEDOUT 110
1903 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1905 echo "DQACQ return -ENOTCONN"
1906 #define ENOTCONN 107
1907 test_17sub 107 || error "Handle -ENOTCONN failed"
1910 run_test 17 "DQACQ return recoverable error"
1914 local blimit="200m" # 200M
1915 local TESTFILE="$DIR/$tdir/$tfile"
1917 setup_quota_test || error "setup quota failed with $?"
1918 trap cleanup_quota_test EXIT
1920 set_ost_qtype "u" || error "enable ost quota failed"
1921 log "User quota (limit: $blimit)"
1922 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1923 error "set quota failed"
1924 quota_show_check b u $TSTUSR
1926 $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
1927 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
1929 local timeout=$(sysctl -n lustre.timeout)
1931 if [ $io_type = "directio" ]; then
1932 log "Write 100M (directio) ..."
1933 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1935 log "Write 100M (buffered) ..."
1936 $RUNAS $DD of=$TESTFILE count=100 &
1940 replay_barrier $SINGLEMDS
1941 log "Fail mds for $((2 * timeout)) seconds"
1942 fail $SINGLEMDS $((2 * timeout))
1945 if at_is_enabled; then
1946 timeout=$(at_max_get mds)
1948 timeout=$(lctl get_param -n timeout)
1952 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1953 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1954 log "it took $count second"
1959 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1961 cancel_lru_locks mdc
1962 cancel_lru_locks osc
1965 local testfile_size=$(stat -c %s $TESTFILE)
1966 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1967 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100))," \
1968 "got ${testfile_size}. Verifying file failed!"
1971 resetquota -u $TSTUSR
1974 # test when mds does failover, the ost still could work well
1975 # this test shouldn't trigger watchdog b=14840
1977 # Clear dmesg so watchdog is not triggered by previous
1979 do_facet ost1 dmesg -c > /dev/null
1982 test_18_sub directio
1984 # check if watchdog is triggered
1985 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1986 local watchdog=$(awk '/Service thread pid/ && /was inactive/ \
1987 { print; }' $TMP/lustre-log-${TESTNAME}.log)
1988 [ -z "$watchdog" ] || error "$watchdog"
1989 rm -f $TMP/lustre-log-${TESTNAME}.log
1991 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1995 local TESTFILE=$DIR/$tdir/$tfile
1997 setup_quota_test || error "setup quota failed with $?"
1998 trap cleanup_quota_test EXIT
2000 set_ost_qtype $QTYPE || error "enable ost quota failed"
2002 # bind file to a single OST
2003 $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2004 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2006 echo "Set user quota (limit: ${blimit}M)"
2007 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2008 error "set user quota failed"
2009 quota_show_check b u $TSTUSR
2010 echo "Update quota limits"
2011 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2012 error "set group quota failed"
2013 quota_show_check b u $TSTUSR
2015 # first wirte might be cached
2016 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
2017 cancel_lru_locks osc
2019 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
2020 quota_error u $TSTUSR "Write success, expect failure"
2024 resetquota -u $TSTUSR
2026 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
2028 test_20() { # b15754
2029 local LSTR=(2g 1t 4k 3m) # limits strings
2031 local LVAL=($((2*1024*1024)) $((1*1024*1024*1024)) $((4*1024)) \
2034 resetquota -u $TSTUSR
2036 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
2037 $MOUNT || error "could not set quota limits"
2038 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
2039 --inode-softlimit ${LSTR[2]} \
2040 --inode-hardlimit ${LSTR[3]} \
2041 $MOUNT || error "could not set quota limits"
2043 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
2044 error "bsoftlimit was not set properly"
2045 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
2046 error "bhardlimit was not set properly"
2047 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
2048 error "isoftlimit was not set properly"
2049 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
2050 error "ihardlimit was not set properly"
2052 resetquota -u $TSTUSR
2054 run_test 20 "Test if setquota specifiers work properly (b15754)"
2061 local time=$(($(date +%s) + seconds))
2062 while [ $(date +%s) -lt $time ]; do
2063 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
2067 # run for fixing bug16053, setquota shouldn't fail when writing and
2068 # deleting are happening
2070 local TESTFILE="$DIR/$tdir/$tfile"
2071 local BLIMIT=10 # 10G
2072 local ILIMIT=1000000
2074 setup_quota_test || error "setup quota failed with $?"
2075 trap cleanup_quota_test EXIT
2077 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2079 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
2080 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
2081 error "set user quota failed"
2082 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
2083 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
2084 error "set group quota failed"
2085 if is_project_quota_supported; then
2086 log "Set limit(block:${BLIMIT}G; file:$LIMIT) for " \
2087 "project: $TSTPRJID"
2088 $LFS setquota -p $TSTPRJID -b 0 -B $BLIMIT -i 0 -I $ILIMIT \
2089 $MOUNT || error "set project quota failed"
2092 # repeat writing on a 1M file
2093 test_21_sub ${TESTFILE}_1 1 30 &
2095 # repeat writing on a 128M file
2096 test_21_sub ${TESTFILE}_2 128 30 &
2099 local time=$(($(date +%s) + 30))
2101 while [ $(date +%s) -lt $time ]; do
2102 log "Set quota for $i times"
2103 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2104 -I $((ILIMIT + i)) $MOUNT ||
2105 error "Set user quota failed"
2106 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
2107 -I $((ILIMIT + i)) $MOUNT ||
2108 error "Set group quota failed"
2109 if is_project_quota_supported; then
2110 $LFS setquota -p $TSTPRJID -b 0 -B \
2111 "$((BLIMIT + i))G" -i 0 -I $((ILIMIT + i)) $MOUNT ||
2112 error "Set project quota failed"
2120 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
2122 if [ $count -gt 60 ]; then
2123 quota_error a $TSTUSR "dd should be finished!"
2127 echo "(dd_pid=$DDPID1, time=$count)successful"
2131 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
2133 if [ $count -gt 60 ]; then
2134 quota_error a $TSTUSR "dd should be finished!"
2138 echo "(dd_pid=$DDPID2, time=$count)successful"
2141 resetquota -u $TSTUSR
2142 resetquota -g $TSTUSR
2143 resetquota -p $TSTPRJID
2145 run_test 21 "Setquota while writing & deleting (b16053)"
2147 # enable/disable quota enforcement permanently
2149 echo "Set both mdt & ost quota type as ug"
2151 is_project_quota_supported && qtype=$QTYPE
2152 set_mdt_qtype $qtype || error "enable mdt quota failed"
2153 set_ost_qtype $qtype || error "enable ost quota failed"
2156 stopall || error "failed to stopall (1)"
2160 echo "Verify if quota is enabled"
2161 local qtype1=$(mdt_quota_type)
2162 [ $qtype1 != $qtype] && error "mdt quota setting is lost"
2163 qtype=$(ost_quota_type)
2164 [ $qtype1 != $qtype ] && error "ost quota setting is lost"
2166 echo "Set both mdt & ost quota type as none"
2167 set_mdt_qtype "none" || error "disable mdt quota failed"
2168 set_ost_qtype "none" || error "disable ost quota failed"
2171 stopall || error "failed to stopall (2)"
2176 echo "Verify if quota is disabled"
2177 qtype=$(mdt_quota_type)
2178 [ $qtype != "none" ] && error "mdt quota setting is lost"
2179 qtype=$(ost_quota_type)
2180 [ $qtype != "none" ] && error "ost quota setting is lost"
2184 run_test 22 "enable/disable quota by 'lctl conf_param'"
2187 local TESTFILE="$DIR/$tdir/$tfile"
2190 setup_quota_test || error "setup quota failed with $?"
2191 trap cleanup_quota_test EXIT
2193 set_ost_qtype $QTYPE || error "Enable ost quota failed"
2196 log "User quota (limit: $LIMIT MB)"
2197 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
2198 error "set quota failed"
2199 quota_show_check b u $TSTUSR
2201 $SETSTRIPE $TESTFILE -c 1 -i 0 || error "setstripe $TESTFILE failed"
2202 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2204 log "Step1: trigger EDQUOT with O_DIRECT"
2205 log "Write half of file"
2206 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
2207 quota_error u $TSTUSR "(1) Write failure, expect success." \
2209 log "Write out of block quota ..."
2210 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
2211 oflag=direct conv=notrunc &&
2212 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
2216 log "Step2: rewrite should succeed"
2217 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
2218 quota_error u $TSTUSR "(3) Write failure, expect success." \
2224 local OST0_UUID=$(ostuuid_from_index 0)
2225 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
2226 [ $OST0_QUOTA_USED -ne 0 ] &&
2227 ($SHOW_QUOTA_USER; \
2228 quota_error u $TSTUSR "quota isn't released")
2230 resetquota -u $TSTUSR
2234 [ $(facet_fstype ost1) == "zfs" ] &&
2235 skip "Overwrite in place is not guaranteed to be " \
2236 "space neutral on ZFS" && return
2238 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
2239 check_whether_skip && return 0
2240 log "run for 4MB test file"
2243 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
2244 check_whether_skip && return 0
2245 log "run for 40MB test file"
2248 run_test 23 "Quota should be honored with directIO (b16125)"
2252 local TESTFILE="$DIR/$tdir/$tfile"
2254 setup_quota_test || error "setup quota failed with $?"
2255 trap cleanup_quota_test EXIT
2257 set_ost_qtype $QTYPE || error "enable ost quota failed"
2259 # bind file to a single OST
2260 $SETSTRIPE -c 1 $TESTFILE || error "setstripe $TESTFILE failed"
2261 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2263 echo "Set user quota (limit: ${blimit}M)"
2264 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
2265 error "set quota failed"
2267 # overrun quota by root user
2268 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
2269 error "write failure, expect success"
2270 cancel_lru_locks osc
2271 sync_all_data || true
2273 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
2276 resetquota -u $TSTUSR
2278 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
2280 test_27a() { # b19612
2281 $LFS quota $TSTUSR $DIR &&
2282 error "lfs succeeded with no type, but should have failed"
2283 $LFS setquota $TSTUSR $DIR &&
2284 error "lfs succeeded with no type, but should have failed"
2287 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
2289 test_27b() { # b20200
2290 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2291 error "lfs setquota failed with uid argument"
2292 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
2293 error "lfs stequota failed with gid argument"
2294 if is_project_quota_supported; then
2295 $LFS setquota -p $TSTPRJID -b 1000 -B 1000 -i 1000 -I \
2296 1000 $DIR || error \
2297 "lfs stequota failed with projid argument"
2299 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
2300 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
2301 if is_project_quota_supported; then
2302 $SHOW_QUOTA_PROJID ||
2303 error "lfs quota failed with projid argument"
2305 resetquota -u $TSTUSR
2306 resetquota -g $TSTUSR
2307 resetquota -p $TSTPRJID
2310 run_test 27b "lfs quota/setquota should handle user/group/project ID (b20200)"
2315 $LFS setquota -u $TSTID -b 30M -B 3T $DIR ||
2316 error "lfs setquota failed"
2318 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
2319 [ $limit != "30M" ] && error "softlimit $limit isn't human-readable"
2320 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
2321 [ $limit != "3T" ] && error "hardlimit $limit isn't human-readable"
2323 $LFS setquota -u $TSTID -b 1500M -B 18500G $DIR ||
2324 error "lfs setquota for $TSTID failed"
2326 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $3}')
2327 [ $limit != "1.465G" ] && error "wrong softlimit $limit"
2328 limit=$($LFS quota -u $TSTID -v -h $DIR | grep $DIR | awk '{print $4}')
2329 [ $limit != "18.07T" ] && error "wrong hardlimit $limit"
2331 $LFS quota -u $TSTID -v -h $DIR | grep -q "Total allocated" ||
2332 error "total allocated inode/block limit not printed"
2334 resetquota -u $TSTUSR
2336 run_test 27c "lfs quota should support human-readable output"
2343 $LFS setquota -u $TSTID -b ${softlimit}p -B ${hardlimit}P $DIR ||
2344 error "set fraction block limit failed"
2345 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $3}')
2346 [ $limit == ${softlimit}P ] || error "get fraction softlimit failed"
2347 limit=$($LFS quota -u $TSTID -h $DIR | grep $DIR | awk '{print $4}')
2348 [ $limit == ${hardlimit}P ] || error "get fraction hardlimit failed"
2350 resetquota -u $TSTUSR
2352 run_test 27d "lfs setquota should support fraction block limit"
2356 local TESTFILE="$DIR/$tdir/$tfile"
2359 setup_quota_test || error "setup quota failed with $?"
2360 trap cleanup_quota_test EXIT
2362 set_ost_qtype "u" || error "enable ost quota failed"
2364 $SETSTRIPE $TESTFILE -i 0 -c 1 || error "setstripe $TESTFILE failed"
2365 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
2367 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
2368 $MAX_IQ_TIME $DIR || error "set grace time failed"
2369 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
2370 error "set quota failed"
2371 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
2372 cancel_lru_locks osc
2374 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
2375 # over-quota flag has not yet settled since we do not trigger async
2376 # events based on grace time period expiration
2378 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 || true
2379 cancel_lru_locks osc
2380 # now over-quota flag should be settled and further writes should fail
2382 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=4 &&
2383 error "grace times were reset"
2386 resetquota -u $TSTUSR
2387 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
2388 $MAX_IQ_TIME $DIR || error "restore grace time failed"
2390 run_test 30 "Hard limit updates should not reset grace times"
2392 # basic usage tracking for user & group
2394 local INODES=10 # 10 files
2395 local BLK_CNT=2 # of 2M each
2396 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
2398 setup_quota_test || error "setup quota failed with $?"
2399 trap cleanup_quota_test EXIT
2401 # make sure the system is clean
2402 local USED=$(getquota -u $TSTID global curspace)
2404 error "Used space ($USED) for user $TSTID isn't 0."
2405 USED=$(getquota -g $TSTID global curspace)
2407 error "Used space ($USED) for group $TSTID isn't 0."
2408 if is_project_quota_supported; then
2409 USED=$(getquota -p $TSTPRJID global curspace)
2410 [ $USED -ne 0 ] && error \
2411 "Used space ($USED) for project $TSTPRJID isn't 0."
2414 echo "Write files..."
2415 for i in $(seq 0 $INODES); do
2416 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
2417 error "write failed"
2418 is_project_quota_supported &&
2419 change_project -p $TSTPRJID $DIR/$tdir/$tfile-$i
2420 echo "Iteration $i/$INODES completed"
2422 cancel_lru_locks osc
2424 echo "Wait for setattr on objects finished..."
2425 wait_delete_completed
2427 sync; sync_all_data || true
2429 echo "Verify disk usage after write"
2430 USED=$(getquota -u $TSTID global curspace)
2431 [ $USED -lt $TOTAL_BLKS ] &&
2432 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
2433 USED=$(getquota -g $TSTID global curspace)
2434 [ $USED -lt $TOTAL_BLKS ] &&
2435 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
2436 if is_project_quota_supported; then
2437 USED=$(getquota -p $TSTPRJID global curspace)
2438 [ $USED -lt $TOTAL_BLKS ] && error \
2439 "Used space for project $TSTPRJID:$USED, expected:$TOTAL_BLKS"
2442 echo "Verify inode usage after write"
2443 USED=$(getquota -u $TSTID global curinodes)
2444 [ $USED -lt $INODES ] &&
2445 error "Used inode for user $TSTID is $USED, expected $INODES"
2446 USED=$(getquota -g $TSTID global curinodes)
2447 [ $USED -lt $INODES ] &&
2448 error "Used inode for group $TSTID is $USED, expected $INODES"
2449 if is_project_quota_supported; then
2450 USED=$(getquota -p $TSTPRJID global curinodes)
2451 [ $USED -lt $INODES ] && error \
2452 "Used inode for project $TSTPRJID is $USED, expected $INODES"
2457 echo "Verify disk usage after delete"
2458 USED=$(getquota -u $TSTID global curspace)
2459 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
2460 USED=$(getquota -u $TSTID global curinodes)
2461 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
2462 USED=$(getquota -g $TSTID global curspace)
2463 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
2464 USED=$(getquota -g $TSTID global curinodes)
2465 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
2466 if is_project_quota_supported; then
2467 USED=$(getquota -p $TSTPRJID global curspace)
2469 error "Used space for project $TSTPRJID isn't 0. $USED"
2470 USED=$(getquota -p $TSTPRJID global curinodes)
2472 error "Used inodes for project $TSTPRJID isn't 0. $USED"
2475 run_test 33 "Basic usage tracking for user & group & project"
2477 # usage transfer test for user & group & project
2479 local BLK_CNT=2 # 2MB
2480 local project_supported="no"
2482 is_project_quota_supported && project_supported="yes"
2483 setup_quota_test || error "setup quota failed with $?"
2484 trap cleanup_quota_test EXIT
2486 # make sure the system is clean
2487 local USED=$(getquota -u $TSTID global curspace)
2488 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
2489 USED=$(getquota -g $TSTID global curspace)
2490 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
2492 local USED=$(getquota -u $TSTID2 global curspace)
2493 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID2 isn't 0."
2494 if [ $project_supported == "yes" ]; then
2495 USED=$(getquota -p $TSTPRJID global curspace)
2496 [ $USED -ne 0 ] && error \
2497 "Used space ($USED) for Project $TSTPRJID isn't 0."
2500 echo "Write file..."
2501 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2502 error "write failed"
2503 cancel_lru_locks osc
2504 sync; sync_all_data || true
2506 echo "chown the file to user $TSTID"
2507 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
2509 echo "Wait for setattr on objects finished..."
2510 wait_delete_completed
2512 BLK_CNT=$((BLK_CNT * 1024))
2514 echo "Verify disk usage for user $TSTID"
2515 USED=$(getquota -u $TSTID global curspace)
2516 [ $USED -lt $BLK_CNT ] &&
2517 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
2518 USED=$(getquota -u $TSTID global curinodes)
2520 error "Used inodes for user $TSTID is $USED, expected 1"
2522 echo "chgrp the file to group $TSTID"
2523 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
2525 echo "Wait for setattr on objects finished..."
2526 wait_delete_completed
2528 echo "Verify disk usage for group $TSTID"
2529 USED=$(getquota -g $TSTID global curspace)
2530 [ $USED -ge $BLK_CNT ] ||
2531 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2532 USED=$(getquota -g $TSTID global curinodes)
2534 error "Used inodes for group $TSTID is $USED, expected 1"
2536 # chown won't change the ost object group. LU-4345 */
2537 echo "chown the file to user $TSTID2"
2538 chown $TSTID2 $DIR/$tdir/$tfile || error "chown to $TSTID2 failed"
2540 echo "Wait for setattr on objects finished..."
2541 wait_delete_completed
2543 echo "change_project project id to $TSTPRJID"
2544 [ $project_supported == "yes" ] &&
2545 change_project -p $TSTPRJID $DIR/$tdir/$tfile
2546 echo "Wait for setattr on objects finished..."
2547 wait_delete_completed
2549 echo "Verify disk usage for user $TSTID2/$TSTID and group $TSTID"
2550 USED=$(getquota -u $TSTID2 global curspace)
2551 [ $USED -lt $BLK_CNT ] &&
2552 error "Used space for user $TSTID2 is $USED, expected $BLK_CNT"
2553 USED=$(getquota -u $TSTID global curspace)
2555 error "Used space for user $TSTID is $USED, expected 0"
2556 USED=$(getquota -g $TSTID global curspace)
2557 [ $USED -lt $BLK_CNT ] &&
2558 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2559 if [ $project_supported == "yes" ]; then
2560 USED=$(getquota -p $TSTPRJID global curspace)
2561 [ $USED -lt $BLK_CNT ] && error \
2562 "Used space for group $TSTPRJID is $USED, expected $BLK_CNT"
2567 run_test 34 "Usage transfer for user & group & project"
2569 # usage is still accessible across restart
2571 local BLK_CNT=2 # 2 MB
2573 setup_quota_test || error "setup quota failed with $?"
2574 trap cleanup_quota_test EXIT
2576 echo "Write file..."
2577 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2578 error "write failed"
2579 is_project_quota_supported &&
2580 change_project -p $TSTPRJID $DIR/$tdir/$tfile
2581 cancel_lru_locks osc
2583 echo "Wait for setattr on objects finished..."
2584 wait_delete_completed
2586 sync; sync_all_data || true
2588 echo "Save disk usage before restart"
2589 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2590 [ $ORIG_USR_SPACE -eq 0 ] &&
2591 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2592 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2593 [ $ORIG_USR_INODES -eq 0 ] &&
2594 error "Used inodes for user $TSTID is 0, expected 1"
2595 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2596 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2597 [ $ORIG_GRP_SPACE -eq 0 ] &&
2598 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2599 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2600 [ $ORIG_GRP_INODES -eq 0 ] &&
2601 error "Used inodes for group $TSTID is 0, expected 1"
2602 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2604 if is_project_quota_supported; then
2605 local ORIG_PRJ_SPACE=$(getquota -p $TSTPRJID global curspace)
2606 [ $ORIG_PRJ_SPACE -eq 0 ] && error \
2607 "Used space for project $TSTPRJID is 0, expected ${BLK_CNT}M"
2608 local ORIG_PRJ_INODES=$(getquota -p $TSTPRJID global curinodes)
2609 [ $ORIG_PRJ_INODES -eq 0 ] && error \
2610 "Used inodes for project $TSTPRJID is 0, expected 1"
2611 echo "Project $TSTPRJID: ${ORIG_PRJ_SPACE}KB $ORIG_PRJ_INODES inodes"
2619 echo "Verify disk usage after restart"
2620 local USED=$(getquota -u $TSTID global curspace)
2621 [ $USED -eq $ORIG_USR_SPACE ] ||
2622 error "Used space for user $TSTID changed from " \
2623 "$ORIG_USR_SPACE to $USED"
2624 USED=$(getquota -u $TSTID global curinodes)
2625 [ $USED -eq $ORIG_USR_INODES ] ||
2626 error "Used inodes for user $TSTID changed from " \
2627 "$ORIG_USR_INODES to $USED"
2628 USED=$(getquota -g $TSTID global curspace)
2629 [ $USED -eq $ORIG_GRP_SPACE ] ||
2630 error "Used space for group $TSTID changed from " \
2631 "$ORIG_GRP_SPACE to $USED"
2632 USED=$(getquota -g $TSTID global curinodes)
2633 [ $USED -eq $ORIG_GRP_INODES ] ||
2634 error "Used inodes for group $TSTID changed from " \
2635 "$ORIG_GRP_INODES to $USED"
2636 if [ $project_supported == "yes" ]; then
2637 USED=$(getquota -p $TSTPRJID global curinodes)
2638 [ $USED -eq $ORIG_PRJ_INODES ] ||
2639 error "Used inodes for project $TSTPRJID " \
2640 "changed from $ORIG_PRJ_INODES to $USED"
2641 USED=$(getquota -p $TSTPRJID global curspace)
2642 [ $USED -eq $ORIG_PRJ_SPACE ] ||
2643 error "Used space for project $TSTPRJID "\
2644 "changed from $ORIG_PRJ_SPACE to $USED"
2647 # check if the vfs_dq_init() is called before writing
2648 echo "Append to the same file..."
2649 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2650 error "write failed"
2651 cancel_lru_locks osc
2652 sync; sync_all_data || true
2654 echo "Verify space usage is increased"
2655 USED=$(getquota -u $TSTID global curspace)
2656 [ $USED -gt $ORIG_USR_SPACE ] ||
2657 error "Used space for user $TSTID isn't increased" \
2658 "orig:$ORIG_USR_SPACE, now:$USED"
2659 USED=$(getquota -g $TSTID global curspace)
2660 [ $USED -gt $ORIG_GRP_SPACE ] ||
2661 error "Used space for group $TSTID isn't increased" \
2662 "orig:$ORIG_GRP_SPACE, now:$USED"
2663 if [ $project_supported == "yes" ]; then
2664 USED=$(getquota -p $TSTPRJID global curspace)
2665 [ $USED -gt $ORIG_PRJ_SPACE ] ||
2666 error "Used space for project $TSTPRJID isn't " \
2667 "increased orig:$ORIG_PRJ_SPACE, now:$USED"
2672 run_test 35 "Usage is still accessible across reboot"
2674 # chown/chgrp to the file created with MDS_OPEN_DELAY_CREATE
2677 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
2678 skip "Old server doesn't have LU-5006 fix." && return
2680 setup_quota_test || error "setup quota failed with $?"
2681 trap cleanup_quota_test EXIT
2683 # make sure the system is clean
2684 local USED=$(getquota -u $TSTID global curspace)
2686 error "Used space ($USED) for user $TSTID isn't 0."
2688 # create file with MDS_OPEN_DELAY_CREATE flag
2689 $SETSTRIPE -c 1 -i 0 $DIR/$tdir/$tfile ||
2690 error "Create file failed"
2692 dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1 conv=notrunc \
2693 oflag=sync || error "Write file failed"
2695 chown $TSTID $DIR/$tdir/$tfile || error "Chown to file failed"
2697 # wait for setattr on objects finished..."
2698 wait_delete_completed
2700 USED=$(getquota -u $TSTID global curspace)
2701 [ $USED -ne 0 ] || quota_error u $TSTUSR "Used space is 0"
2705 run_test 37 "Quota accounted properly for file created by 'lfs setstripe'"
2709 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.60) ] &&
2710 skip "Old server doesn't have LU-8801 fix." && return
2712 [ "$UID" != 0 ] && skip_env "must run as root" && return
2714 setup_quota_test || error "setup quota failed with $?"
2715 trap cleanup_quota_test EXIT
2717 # make sure the system is clean
2718 local USED=$(getquota -u $TSTID global curspace)
2720 error "Used space ($USED) for user $TSTID isn't 0."
2721 USED=$(getquota -u $TSTID2 global curspace)
2723 error "Used space ($USED) for user $TSTID2 isn't 0."
2725 local TESTFILE="$DIR/$tdir/$tfile"
2726 local file_cnt=10000
2728 # Generate id entries in accounting file
2729 echo "Create $file_cnt files..."
2730 for i in `seq $file_cnt`; do
2732 chown $((file_cnt - i)):$((file_cnt - i)) $TESTFILE-$i ||
2733 error "failed to chown $TESTFILE-$i"
2735 cancel_lru_locks osc
2736 sync; sync_all_data || true
2738 local procf="osd-$(facet_fstype $SINGLEMDS).$FSNAME-MDT0000"
2739 procf=${procf}.quota_slave.acct_user
2742 acct_cnt=$(do_facet mds1 $LCTL get_param $procf | grep "id:" | \
2743 awk '{if ($3 < 10000) {print $3}}' | wc -l)
2744 echo "Found $acct_cnt id entries"
2746 [ $file_cnt -eq $acct_cnt ] || {
2747 do_facet mds1 $LCTL get_param $procf
2748 error "skipped id entries"
2753 run_test 38 "Quota accounting iterator doesn't skip id entries"
2756 local TESTFILE="$DIR/$tdir/project"
2757 ! is_project_quota_supported &&
2758 skip "Project quota is not supported" && return 0
2760 setup_quota_test || error "setup quota failed with $?"
2763 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2764 [ $projectid -ne 0 ] &&
2765 error "Project id should be 0 not $projectid"
2766 change_project -p 1024 $TESTFILE
2767 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2768 [ $projectid -ne 1024 ] &&
2769 error "Project id should be 1024 not $projectid"
2771 stopall || error "failed to stopall (1)"
2774 projectid=$(lfs project $TESTFILE | awk '{print $1}')
2775 [ $projectid -ne 1024 ] &&
2776 error "Project id should be 1024 not $projectid"
2780 run_test 39 "Project ID interface works correctly"
2783 ! is_project_quota_supported &&
2784 skip "Project quota is not supported" && return 0
2785 local dir1="$DIR/$tdir/dir1"
2786 local dir2="$DIR/$tdir/dir2"
2788 setup_quota_test || error "setup quota failed with $?"
2790 mkdir -p $dir1 $dir2
2791 change_project -sp 1 $dir1 && touch $dir1/1
2792 change_project -sp 2 $dir2
2794 ln $dir1/1 $dir2/1_link &&
2795 error "Hard link across different project quota should fail"
2800 run_test 40a "Hard link across different project ID"
2803 ! is_project_quota_supported &&
2804 skip "Project quota is not supported" && return 0
2805 local dir1="$DIR/$tdir/dir1"
2806 local dir2="$DIR/$tdir/dir2"
2808 setup_quota_test || error "setup quota failed with $?"
2809 mkdir -p $dir1 $dir2
2810 change_project -sp 1 $dir1 && touch $dir1/1
2811 change_project -sp 2 $dir2
2813 mv $dir1/1 $dir2/2 || error "mv failed $?"
2814 local projid=$(lfs project $dir2/2 | awk '{print $1}')
2815 if [ "$projid" != "2" ]; then
2816 error "project id expected 2 not $projid"
2821 run_test 40b "Mv across different project ID"
2824 [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs" && return
2825 ! is_project_quota_supported &&
2826 skip "Project quota is not supported" && return 0
2828 setup_quota_test || error "setup quota failed with $?"
2829 local dir="$DIR/$tdir/dir"
2831 mkdir -p $dir && change_project -sp 1 $dir
2832 $LFS mkdir -i 1 $dir/remote_dir || error "create remote dir failed"
2833 local projid=$(lfs project -d $dir/remote_dir | awk '{print $1}')
2834 [ "$projid" != "1" ] && error "projid id expected 1 not $projid"
2835 touch $dir/remote_dir/file
2836 #verify inherit works file for remote dir.
2837 local projid=$(lfs project -d $dir/remote_dir/file | awk '{print $1}')
2838 [ "$projid" != "1" ] &&
2839 error "file under remote dir expected 1 not $projid"
2841 #Agent inode should be ignored for project quota
2842 USED=$(getquota -p 1 global curinodes)
2843 [ "$USED" != "3" ] &&
2844 error "file count expected 3 got $USED"
2850 run_test 40c "Remote child Dir inherit project quota properly"
2853 ! is_project_quota_supported &&
2854 skip "Project quota is not supported" && return 0
2856 setup_quota_test || error "setup quota failed with $?"
2857 local dir="$DIR/$tdir/dir"
2859 mkdir $dir && change_project -p 1 $dir
2860 count=$($LFS find --projid 1 $DIR | wc -l)
2861 [ "$count" != 1 ] && error "expected 1 but got $count"
2866 run_test 50 "Test if lfs find --projid works"
2869 ! is_project_quota_supported &&
2870 skip "Project quota is not supported" && return 0
2871 setup_quota_test || error "setup quota failed with $?"
2872 local dir="$DIR/$tdir/dir"
2874 mkdir $dir && change_project -sp 1 $dir
2875 local used=$(getquota -p 1 global curinodes)
2876 [ $used != "1" ] && error "expected 1 got $used"
2881 used=$(getquota -p 1 global curinodes)
2882 [ $used != "4" ] && error "expected 4 got $used"
2884 $DD if=/dev/zero of=$DIR/$tdir/6 bs=1M count=1
2886 cp $DIR/$tdir/6 $dir/6
2887 used=$(getquota -p 1 global curinodes)
2888 [ $used != "5" ] && error "expected 5 got $used"
2891 mv $DIR/$tdir/6 $dir/7
2892 used=$(getquota -p 1 global curinodes)
2893 [ $used != "6" ] && error "expected 6 got $used"
2898 run_test 51 "Test project accounting with mv/cp"
2901 ! is_project_quota_supported &&
2902 skip "Project quota is not supported" && return 0
2903 setup_quota_test || error "setup quota failed with $?"
2904 local dir="$DIR/$tdir/dir"
2905 mkdir $dir && change_project -sp 1 $dir
2907 touch $DIR/$tdir/file
2908 #Try renaming a file into the project. This should fail.
2909 for num in $(seq 1 2000); do
2910 mrename $DIR/$tdir/file $dir/file >&/dev/null &&
2911 error "rename should fail"
2916 run_test 52 "Rename across different project ID"
2919 ! is_project_quota_supported &&
2920 skip "Project quota is not supported" && return 0
2921 setup_quota_test || error "setup quota failed with $?"
2922 local dir="$DIR/$tdir/dir"
2923 mkdir $dir && change_project -s $dir
2924 lfs project -d $dir | grep P || error "inherit attribute should be set"
2926 change_project -C $dir
2927 lfs project -d $dir | grep P &&
2928 error "inherit attribute should be cleared"
2933 run_test 53 "Project inherit attribute could be cleared"
2936 ! is_project_quota_supported &&
2937 skip "Project quota is not supported" && return 0
2938 setup_quota_test || error "setup quota failed with $?"
2939 trap cleanup_quota_test EXIT
2940 local testfile="$DIR/$tdir/$tfile-0"
2942 #set project ID/inherit attribute
2943 change_project -sp $TSTPRJID $DIR/$tdir
2944 $RUNAS createmany -m ${testfile} 100 ||
2945 error "create many files failed"
2947 local proj_count=$(lfs project -r $DIR/$tdir | wc -l)
2948 # one more count for directory itself */
2952 local proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2953 [ $proj_count1 -eq 0 ] || error "c1: expected 0 got $proj_count1"
2955 proj_count1=$(lfs project -rcp $((TSTPRJID+1)) $DIR/$tdir | wc -l)
2956 [ $proj_count1 -eq $proj_count ] ||
2957 error "c2: expected $proj_count got $proj_count1"
2959 #clear project but with kept projid
2960 change_project -rCk $DIR/$tdir
2961 proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2962 [ $proj_count1 -eq $proj_count ] ||
2963 error "c3: expected $proj_count got $proj_count1"
2965 #verify projid untouched.
2966 proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
2968 [ $proj_count1 -eq $proj_count ] ||
2969 error "c4: expected $proj_count got $proj_count1"
2972 lfs project $DIR/$tdir -cr -0 | xargs -0 lfs project -s
2973 proj_count1=$(lfs project -rcp $TSTPRJID $DIR/$tdir | wc -l)
2974 [ $proj_count1 -eq 0 ] || error "c5: expected 0 got $proj_count1"
2976 #this time clear all
2977 change_project -rC $DIR/$tdir
2978 proj_count1=$(lfs project -r $DIR/$tdir | grep -c $TSTPRJID)
2979 [ $proj_count1 -eq 0 ] ||
2980 error "c6: expected 0 got $proj_count1"
2982 unlinkmany ${testfile} 100 ||
2983 error "unlink many files failed"
2987 run_test 54 "basic lfs project interface test"
2990 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
2991 skip "Not supported before 2.10.58." && return
2992 setup_quota_test || error "setup quota failed with $?"
2994 set_ost_qtype $QTYPE || error "enable ost quota failed"
2997 #add second group to TSTUSR
2998 usermod -G $TSTUSR,$TSTUSR2 $TSTUSR
3001 $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1024 count=100000 ||
3002 error "failed to dd"
3004 cancel_lru_locks osc
3005 sync; sync_all_data || true
3007 $LFS setquota -g $TSTUSR2 -b 0 -B 50M $DIR ||
3008 error "failed to setquota on group $TSTUSR2"
3010 $LFS quota -v -g $TSTUSR2 $DIR
3012 runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile &&
3013 error "chgrp should failed with -EDQUOT"
3015 USED=$(getquota -g $TSTUSR2 global curspace)
3018 $LFS setquota -g $TSTUSR2 -b 0 -B 300M $DIR ||
3019 error "failed to setquota on group $TSTUSR2"
3021 $LFS quota -v -g $TSTUSR2 $DIR
3023 runas -u $TSTUSR -g $TSTUSR2 chgrp $TSTUSR2 $DIR/$tdir/$tfile ||
3024 error "chgrp should succeed"
3026 $LFS quota -v -g $TSTUSR2 $DIR
3028 resetquota -g $TSTUSR2
3031 run_test 55 "Chgrp should be affected by group quota"
3034 setup_quota_test || error "setup quota failed with $?"
3036 set_ost_qtype $QTYPE || error "enable ost quota failed"
3039 $LFS setquota -t -u -b 10 -i 10 $DIR ||
3040 erro "failed to set grace time for usr quota"
3041 grace_time=$($LFS quota -t -u $DIR | grep "Block grace time:" |
3042 awk '{print $4 $8}')
3043 if [ "x$grace_time" != "x10s;10s" ]; then
3044 $LFS quota -t -u $DIR
3045 error "expected grace time: 10s;10s, got:$grace_time"
3050 run_test 56 "lfs quota -t should work well"
3053 setup_quota_test || error "setup quota failed with $?"
3055 local dir="$DIR/$tdir/dir"
3058 #try to change pipe file should not hang and return failure
3059 wait_update_facet client "$LFS project -sp 1 $dir/pipe 2>&1 |
3060 awk -F ':' '{ print \\\$2 }'" \
3061 " failed to get xattr for '$dir/pipe'" || return 1
3062 #command can process further if it hit some errors
3063 touch $dir/aaa $dir/bbb
3064 #create one invalid link file
3065 ln -s $dir/not_exist_file $dir/ccc
3066 local cnt=$(lfs project -r $dir 2>/dev/null | wc -l)
3067 [ $cnt -eq 2 ] || error "expected 2 got $cnt"
3071 run_test 57 "lfs project could tolerate errors"
3074 if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
3075 skip "ldiskfs only test"
3078 disable_project_quota
3079 setup_quota_test || error "setup quota failed with $?"
3082 local testfile="$DIR/$tdir/$tfile-0"
3083 #make sure it did not crash kernel
3084 touch $testfile && lfs project -sp 1 $testfile
3086 enable_project_quota
3089 run_test 59 "lfs project dosen't crash kernel with project disabled"
3092 setup_quota_test || error "setup quota failed with $?"
3093 trap cleanup_quota_test EXIT
3094 local testfile=$DIR/$tdir/$tfile
3097 set_mdt_qtype "ug" || error "enable mdt quota failed"
3099 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $limit $DIR ||
3100 error "set quota failed"
3101 quota_show_check a g $TSTUSR
3103 chown $TSTUSR.$TSTUSR $DIR/$tdir || error "chown $DIR/$tdir failed"
3104 chmod g+s $DIR/$tdir || error "chmod g+s failed"
3105 $RUNAS createmany -m ${testfile} $((limit-1)) ||
3106 error "create many files failed"
3108 $RUNAS touch $DIR/$tdir/foo && error "regular user should fail"
3110 # root user can overrun quota
3111 runas -u 0 -g 0 touch $DIR/$tdir/foo ||
3112 error "root user should succeed"
3115 resetquota -g $TSTUSR
3117 run_test 60 "Test quota for root with setgid"
3119 # test default quota
3120 test_default_quota() {
3121 [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.51) ] &&
3122 skip "Not supported before 2.11.51." && return
3127 local qprjid=$TSTPRJID
3131 local LIMIT=102400 #100M disk space
3132 local TESTFILE="$DIR/$tdir/$tfile-0"
3134 [ $qtype == "-p" ] && ! is_project_quota_supported &&
3135 echo "Project quota is not supported" && return 0
3137 [ $qtype == "-u" ] && qdtype="-U"
3138 [ $qtype == "-g" ] && qdtype="-G"
3139 [ $qtype == "-p" ] && {
3144 [ $qpool == "meta" ] && {
3145 LIMIT=10240 #10K inodes
3150 setup_quota_test || error "setup quota failed with $?"
3151 trap cleanup_quota_test EXIT
3155 # enable mdt/ost quota
3156 set_mdt_qtype $QTYPE || error "enable mdt quota failed"
3157 set_ost_qtype $QTYPE || error "enable ost quota failed"
3159 log "set to use default quota"
3160 $LFS setquota $qtype $qid -d $DIR ||
3161 error "set $qid to use default quota failed"
3163 log "set default quota"
3164 $LFS setquota $qdtype $qs ${LIMIT} $qh ${LIMIT} $DIR ||
3165 error "set $qid default quota failed"
3167 log "get default quota"
3168 $LFS quota $qdtype $DIR || error "get default quota failed"
3170 if [ $qpool == "data" ]; then
3171 local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
3173 [ $SLIMIT -eq $LIMIT ] ||
3174 error "the returned default quota is wrong"
3176 local SLIMIT=$($LFS quota $qdtype $DIR | grep "$MOUNT" | \
3178 [ $SLIMIT -eq $LIMIT ] ||
3179 error "the returned default quota is wrong"
3182 # make sure the system is clean
3183 local USED=$(getquota $qtype $qid global curspace)
3184 [ $USED -ne 0 ] && error "Used space for $qid isn't 0."
3186 $SETSTRIPE $TESTFILE -c 1 || error "setstripe $TESTFILE failed"
3187 chown $TSTUSR.$TSTUSR $TESTFILE || error "chown $TESTFILE failed"
3189 [ $qtype == "-p" ] && change_project -sp $TSTPRJID $DIR/$tdir
3191 log "Test not out of quota"
3192 if [ $qpool == "data" ]; then
3193 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 >> 10)) ||
3194 quota_error $qtype $qid "write failed, expect succeed"
3196 $RUNAS createmany -m $TESTFILE $((LIMIT/2)) ||
3197 quota_error $qtype $qid "create failed, expect succeed"
3199 unlinkmany $TESTFILE $((LIMIT/2))
3202 log "Test out of quota"
3203 # flush cache, ensure noquota flag is set on client
3204 cancel_lru_locks osc
3205 cancel_lru_locks mdc
3206 sync; sync_all_data || true
3207 if [ $qpool == "data" ]; then
3208 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) &&
3209 quota_error $qtype $qid "write succeed, expect EDQUOT"
3211 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
3212 quota_error $qtype $qid "create succeed, expect EDQUOT"
3214 unlinkmany $TESTFILE $((LIMIT*2))
3217 log "Increase default quota"
3218 # increase default quota
3219 $LFS setquota $qdtype $qs $((LIMIT*3)) $qh $((LIMIT*3)) $DIR ||
3220 error "set default quota failed"
3222 cancel_lru_locks osc
3223 cancel_lru_locks mdc
3224 sync; sync_all_data || true
3225 if [ $qpool == "data" ]; then
3226 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) ||
3227 quota_error $qtype $qid "write failed, expect succeed"
3229 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
3230 quota_error $qtype $qid "create failed, expect succeed"
3232 unlinkmany $TESTFILE $((LIMIT*2))
3235 log "Set quota to override default quota"
3236 $LFS setquota $qtype $qid $qs ${LIMIT} $qh ${LIMIT} $DIR ||
3237 error "set $qid quota failed"
3239 cancel_lru_locks osc
3240 cancel_lru_locks mdc
3241 sync; sync_all_data || true
3242 if [ $qpool == "data" ]; then
3243 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) &&
3244 quota_error $qtype $qid "write succeed, expect EQUOT"
3246 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) &&
3247 quota_error $qtype $qid "create succeed, expect EQUOT"
3249 unlinkmany $TESTFILE $((LIMIT*2))
3252 log "Set to use default quota again"
3253 $LFS setquota $qtype $qid -d $DIR ||
3254 error "set $qid to use default quota failed"
3256 cancel_lru_locks osc
3257 cancel_lru_locks mdc
3258 sync; sync_all_data || true
3259 if [ $qpool == "data" ]; then
3260 $RUNAS $DD of=$TESTFILE count=$((LIMIT*2 >> 10)) ||
3261 quota_error $qtype $qid "write failed, expect succeed"
3263 $RUNAS createmany -m $TESTFILE $((LIMIT*2)) ||
3264 quota_error $qtype $qid "create failed, expect succeed"
3266 unlinkmany $TESTFILE $((LIMIT*2))
3271 wait_delete_completed || error "wait_delete_completed failed"
3272 sync_all_data || true
3273 $LFS setquota $qdtype -b 0 -B 0 -i 0 -I 0 $DIR ||
3274 error "reset default quota failed"
3275 $LFS setquota $qtype $qid -b 0 -B 0 -i 0 -I 0 $DIR ||
3276 error "reset quota failed"
3282 test_default_quota "-u" "data"
3283 test_default_quota "-u" "meta"
3284 test_default_quota "-g" "data"
3285 test_default_quota "-g" "meta"
3286 test_default_quota "-p" "data"
3287 test_default_quota "-p" "meta"
3289 run_test 61 "default quota tests"
3293 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
3294 disable_project_quota
3296 reset_quota_settings
3301 check_and_cleanup_lustre
3302 export QUOTA_AUTO=$QUOTA_AUTO_OLD