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 ALWAYS_EXCEPT="$SANITY_QUOTA_EXCEPT"
14 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
16 [ "$ALWAYS_EXCEPT$EXCEPT" ] &&
17 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
23 TSTID2=${TSTID2:-60001}
24 TSTUSR=${TSTUSR:-"quota_usr"}
25 TSTUSR2=${TSTUSR2:-"quota_2usr"}
30 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
31 . $LUSTRE/tests/test-framework.sh
33 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
35 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
37 [ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0
39 require_dsh_mds || exit 0
40 require_dsh_ost || exit 0
42 # XXX Once we drop the interoperability with old server (< 2.3.50), the
43 # sanity-quota-old.sh should be removed.
44 if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.50) ]; then
45 exec $LUSTRE/tests/sanity-quota-old.sh
48 # if e2fsprogs support quota feature?
49 if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] && \
50 ! $DEBUGFS -c -R supported_features | grep -q 'quota'; then
51 skip "e2fsprogs doesn't support quota" && exit 0
54 [ "$SLOW" = "no" ] && EXCEPT_SLOW="9 18 21"
56 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
58 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
63 QUOTA_AUTO_OLD=$QUOTA_AUTO
66 check_and_setup_lustre
68 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
69 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
71 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
72 SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
73 SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR"
74 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
75 SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
76 SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR"
77 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
78 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
85 local fail_val=${3:-0}
87 if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
88 do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val"
89 do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc"
92 if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
93 for num in `seq $OSTCOUNT`; do
94 do_facet ost$num "lctl set_param fail_val=$fail_val"
95 do_facet ost$num "lctl set_param fail_loc=$fail_loc"
100 RUNAS="runas -u $TSTID -g $TSTID"
101 RUNAS2="runas -u $TSTID2 -g $TSTID2"
102 DD="dd if=/dev/zero bs=1M"
106 check_runas_id_ret $TSTUSR $TSTUSR $RUNAS ||
107 error "Please create user $TSTUSR($TSTID) and group $TSTUSR($TSTID)"
108 check_runas_id_ret $TSTUSR2 $TSTUSR2 $RUNAS2 ||
109 error "Please create user $TSTUSR2($TSTID2) and group $TSTUSR2($TSTID2)"
111 # clear quota limits for a user or a group
112 # usage: resetquota -u username
113 # resetquota -g groupname
116 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
117 [ "$1" != "-u" -a "$1" != "-g" ] &&
118 error "resetquota: wrong specifier $1 passed"
120 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT ||
121 error "clear quota for [type:$1 name:$2] failed"
122 # give a chance to slave to release space
130 if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "u" ]; then
131 $LFS quota -v -u $LOCAL_ID $DIR
132 log "Files for user ($LOCAL_ID):"
133 ($LFS find -user $LOCAL_ID $DIR | head -n 4 |
134 xargs stat 2>/dev/null)
137 if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "g" ]; then
138 $LFS quota -v -u $LOCAL_ID $DIR
139 log "Files for group ($LOCAL_ID):"
140 ($LFS find -group $LOCAL_ID $DIR | head -n 4 |
141 xargs stat 2>/dev/null)
157 # get quota for a user or a group
158 # usage: getquota -u|-g <username>|<groupname> global|<obd_uuid> \
159 # bhardlimit|bsoftlimit|bgrace|ihardlimit|isoftlimit|igrace
165 [ "$#" != 4 ] && error "getquota: wrong number of arguments: $#"
166 [ "$1" != "-u" -a "$1" != "-g" ] &&
167 error "getquota: wrong u/g specifier $1 passed"
180 *) error "unknown quota parameter $4";;
183 [ "$uuid" = "global" ] && uuid=$DIR
185 $LFS quota -v "$1" "$2" $DIR |
186 awk 'BEGIN { num='$spec' } { if ($1 == "'$uuid'") \
187 { if (NF == 1) { getline } else { num++ } ; print $num;} }' \
192 # usage: set_mdt_qtype ug|u|g|none
195 local varsvc=${SINGLEMDS}_svc
197 do_facet mgs $LCTL conf_param $FSNAME.quota.mdt=$qtype
198 if $(facet_up $SINGLEMDS); then
199 cmd="$LCTL get_param -n "
200 cmd=${cmd}osd-$(facet_fstype $SINGLEMDS).${!varsvc}
201 cmd=${cmd}.quota_slave.enabled
203 wait_update_facet $SINGLEMDS "$cmd" "$qtype" || return 1
209 # usage: set_ost_quota_type ug|u|g|none
213 local osts=$(get_facets OST)
215 do_facet mgs $LCTL conf_param $FSNAME.quota.ost=$qtype
216 # we have to make sure each OST received config changes
217 for ost in ${osts//,/ }; do
219 cmd="$LCTL get_param -n "
220 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
221 cmd=${cmd}.quota_slave.enabled
223 if $(facet_up $ost); then
224 wait_update_facet $ost "$cmd" "$qtype" || return 1
230 wait_reintegration() {
233 local result="glb[1],slv[1],reint[0]"
237 if [ $ntype == "mdt" ]; then
238 varsvc=${SINGLEMDS}_svc
239 cmd="$LCTL get_param -n "
240 cmd=${cmd}osd-$(facet_fstype $SINGLEMDS).${!varsvc}
241 cmd=${cmd}.quota_slave.info
243 if $(facet_up $SINGLEMDS); then
244 wait_update_facet $SINGLEMDS "$cmd |
245 grep "$qtype" | awk '{ print \\\$3 }'" "$result" ||
249 local osts=$(get_facets OST)
250 for ost in ${osts//,/ }; do
252 cmd="$LCTL get_param -n "
253 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
254 cmd=${cmd}.quota_slave.info
256 if $(facet_up $ost); then
257 wait_update_facet $ost "$cmd |
258 grep "$qtype" | awk '{ print \\\$3 }'" \
259 "$result" || return 1
269 if [ $qtype == "u" ] || [ $qtype == "ug" ]; then
270 wait_reintegration "mdt" "user" || return 1
273 if [ $qtype == "g" ] || [ $qtype == "ug" ]; then
274 wait_reintegration "mdt" "group" || return 1
282 if [ $qtype == "u" ] || [ $qtype == "ug" ]; then
283 wait_reintegration "ost" "user" || return 1
286 if [ $qtype == "g" ] || [ $qtype == "ug" ]; then
287 wait_reintegration "ost" "group" || return 1
294 wait_delete_completed
295 echo "Creating test directory"
298 # always clear fail_loc in case of fail_loc isn't cleared
299 # properly when previous test failed
300 lustre_fail mds_ost 0
303 cleanup_quota_test() {
305 echo "Delete files..."
307 echo "Wait for unlink objects finished..."
308 wait_delete_completed
309 sync_all_data || true
318 $LFS quota -v -$ug $qid $DIR
320 if [ "$bf" == "a" -o "$bf" == "b" ]; then
321 usage=$(getquota -$ug $qid global curspace)
322 if [ -z $usage ]; then
323 quota_error $ug $qid \
324 "Query block quota failed ($ug:$qid)."
326 [ $usage -ne 0 ] && quota_log $ug $qid \
327 "Block quota isn't 0 ($ug:$qid:$usage)."
331 if [ "$bf" == "a" -o "$bf" == "f" ]; then
332 usage=$(getquota -$ug $qid global curinodes)
333 if [ -z $usage ]; then
334 quota_error $ug $qid \
335 "Query file quota failed ($ug:$qid)."
337 [ $usage -ne 0 ] && quota_log $ug $qid \
338 "File quota isn't 0 ($ug:$qid:$usage)."
345 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
349 test_quota_performance() {
350 local TESTFILE="$DIR/$tdir/$tfile-0"
351 local size=$1 # in MB
352 local stime=$(date +%s)
353 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
354 quota_error u $TSTUSR "write failure"
355 local etime=$(date +%s)
356 delta=$((etime - stime))
357 if [ $delta -gt 0 ]; then
358 rate=$((size * 1024 / delta))
359 [ $rate -gt 1024 ] ||
360 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
365 # test basic quota performance b=21696
368 [ "$SLOW" = "no" ] && MB=10
370 local free_space=$(lfs df | grep "filesystem summary" | \
372 [ $free_space -le $((MB * 1024)) ] &&
373 skip "not enough space ${free_space} KB, " \
374 "required $((MB * 1024)) KB" && return
376 trap cleanup_quota_test EXIT
378 set_ost_qtype "none" || error "disable ost quota failed"
379 test_quota_performance $MB
381 set_ost_qtype "ug" || error "enable ost quota failed"
382 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
383 error "set quota failed"
384 test_quota_performance $MB
387 resetquota -u $TSTUSR
389 run_test 0 "Test basic quota performance"
391 # test block hardlimit
394 local TESTFILE="$DIR/$tdir/$tfile-0"
397 trap cleanup_quota_test EXIT
400 set_ost_qtype "ug" || "enable ost quota failed"
403 log "User quota (block hardlimit:$LIMIT MB)"
404 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
405 error "set user quota failed"
407 # make sure the system is clean
408 local USED=$(getquota -u $TSTUSR global curspace)
409 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
411 $LFS setstripe $TESTFILE -c 1
412 chown $TSTUSR.$TSTUSR $TESTFILE
415 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
416 quota_error u $TSTUSR "user write failure, but expect success"
417 log "Write out of block quota ..."
418 # this time maybe cache write, ignore it's failure
419 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
420 # flush cache, ensure noquota flag is set on client
422 $RUNAS $DD of=$TESTFILE count=1 seek=$LIMIT &&
423 quota_error u $TSTUSR "user write success, but expect EDQUOT"
426 wait_delete_completed
427 sync_all_data || true
428 USED=$(getquota -u $TSTUSR global curspace)
429 [ $USED -ne 0 ] && quota_error u $TSTUSR \
430 "user quota isn't released after deletion"
431 resetquota -u $TSTUSR
434 log "--------------------------------------"
435 log "Group quota (block hardlimit:$LIMIT MB)"
436 $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
437 error "set group quota failed"
439 TESTFILE="$DIR/$tdir/$tfile-1"
440 # make sure the system is clean
441 USED=$(getquota -g $TSTUSR global curspace)
442 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0"
444 $LFS setstripe $TESTFILE -c 1
445 chown $TSTUSR.$TSTUSR $TESTFILE
448 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
449 quota_error g $TSTUSR "group write failure, but expect success"
450 log "Write out of block quota ..."
451 # this time maybe cache write, ignore it's failure
452 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
454 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT &&
455 quota_error g $TSTUSR "group write success, but expect EDQUOT"
460 USED=$(getquota -g $TSTUSR global curspace)
461 [ $USED -ne 0 ] && quota_error g $TSTUSR \
462 "group quota isn't released after deletion"
464 resetquota -g $TSTUSR
466 run_test 1 "Block hard limit (normal use and out of quota)"
468 # test inode hardlimit
470 local LIMIT=$((1024 * 1024)) # 1M inodes
471 local TESTFILE="$DIR/$tdir/$tfile-0"
473 [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes
475 local FREE_INODES=$(lfs df -i | grep "filesystem summary" | \
477 [ $FREE_INODES -lt $LIMIT ] &&
478 skip "not enough free inodes $FREE_INODES required $LIMIT" &&
482 trap cleanup_quota_test EXIT
485 set_mdt_qtype "ug" || "enable mdt quota failed"
488 log "User quota (inode hardlimit:$LIMIT files)"
489 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
490 error "set user quota failed"
492 # make sure the system is clean
493 local USED=$(getquota -u $TSTUSR global curinodes)
494 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
496 log "Create $LIMIT files ..."
497 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
498 quota_error u $TSTUSR "user create failure, but expect success"
499 log "Create out of file quota ..."
500 $RUNAS touch ${TESTFILE}_xxx && \
501 quota_error u $TSTUSR "user create success, but expect EDQUOT"
504 unlinkmany ${TESTFILE} $LIMIT
505 rm -f ${TESTFILE}_xxx
506 wait_delete_completed
508 USED=$(getquota -u $TSTUSR global curinodes)
509 [ $USED -ne 0 ] && quota_error u $TSTUSR \
510 "user quota isn't released after deletion"
511 resetquota -u $TSTUSR
514 log "--------------------------------------"
515 log "Group quota (inode hardlimit:$LIMIT files)"
516 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
517 error "set group quota failed"
519 TESTFILE=$DIR/$tdir/$tfile-1
520 # make sure the system is clean
521 USED=$(getquota -g $TSTUSR global curinodes)
522 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
524 log "Create $LIMIT files ..."
525 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
526 quota_error g $TSTUSR "group create failure, but expect success"
527 log "Create out of file quota ..."
528 $RUNAS touch ${TESTFILE}_xxx && \
529 quota_error g $TSTUSR "group create success, but expect EDQUOT"
532 unlinkmany ${TESTFILE} $LIMIT
533 rm -f ${TESTFILE}_xxx
534 wait_delete_completed
536 USED=$(getquota -g $TSTUSR global curinodes)
537 [ $USED -ne 0 ] && quota_error g $TSTUSR \
538 "user quota isn't released after deletion"
541 resetquota -g $TSTUSR
543 run_test 2 "File hard limit (normal use and out of quota)"
547 local TIMER=$(($2 * 3 / 2))
552 trap cleanup_quota_test EXIT
554 $LFS setstripe $TESTFILE -c 1 -i 0
555 chown $TSTUSR.$TSTUSR $TESTFILE
557 echo "Write up to soft limit"
558 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
559 quota_error a $TSTUSR "write failure, but expect success"
560 OFFSET=$((LIMIT * 1024))
563 echo "Write to exceed soft limit"
564 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
565 quota_error a $TSTUSR "write failure, but expect success"
566 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
571 $SHOW_QUOTA_INFO_USER
572 $SHOW_QUOTA_INFO_GROUP
574 echo "Write before timer goes off"
575 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
576 quota_error a $TSTUSR "write failure, but expect success"
577 OFFSET=$((OFFSET + 1024))
580 echo "Sleep $TIMER seconds ..."
585 $SHOW_QUOTA_INFO_USER
586 $SHOW_QUOTA_INFO_GROUP
588 echo "Write after timer goes off"
589 # maybe cache write, ignore.
590 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET || true
591 OFFSET=$((OFFSET + 1024))
593 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET &&
594 quota_error a $TSTUSR "write success, but expect EDQUOT"
598 $SHOW_QUOTA_INFO_USER
599 $SHOW_QUOTA_INFO_GROUP
601 echo "Unlink file to stop timer"
603 wait_delete_completed
604 sync_all_data || true
608 $SHOW_QUOTA_INFO_USER
609 $SHOW_QUOTA_INFO_GROUP
611 $LFS setstripe $TESTFILE -c 1 -i 0
612 chown $TSTUSR.$TSTUSR $TESTFILE
615 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
616 quota_error a $TSTUSR "write failure, but expect success"
625 local TESTFILE=$DIR/$tdir/$tfile-0
627 set_ost_qtype "ug" || error "enable ost quota failed"
629 echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
630 # make sure the system is clean
631 local USED=$(getquota -u $TSTUSR global curspace)
632 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
634 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
635 $MAX_IQ_TIME $DIR || error "set user grace time failed"
636 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
637 error "set user quota failed"
639 test_block_soft $TESTFILE $GRACE $LIMIT
640 resetquota -u $TSTUSR
642 echo "Group quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
643 TESTFILE=$DIR/$tdir/$tfile-1
644 # make sure the system is clean
645 USED=$(getquota -g $TSTUSR global curspace)
646 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
648 $LFS setquota -t -g --block-grace $GRACE --inode-grace \
649 $MAX_IQ_TIME $DIR || error "set group grace time failed"
650 $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
651 error "set group quota failed"
653 test_block_soft $TESTFILE $GRACE $LIMIT
654 resetquota -g $TSTUSR
657 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
658 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
659 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
660 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
662 run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
667 local TIMER=$(($3 * 3 / 2))
670 trap cleanup_quota_test EXIT
672 echo "Create files to exceed soft limit"
673 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
674 quota_error a $TSTUSR "create failure, but expect success"
677 echo "Create file before timer goes off"
678 $RUNAS touch ${TESTFILE}_before ||
679 quota_error a $TSTUSR "failed create before timer expired," \
683 echo "Sleep $TIMER seconds ..."
688 $SHOW_QUOTA_INFO_USER
689 $SHOW_QUOTA_INFO_GROUP
691 echo "Create file after timer goes off"
692 # There is a window that space is accounted in the quota usage but
693 # hasn't been decreased from the pending write, if we acquire quota
694 # in this window, we'll acquire more than we needed.
695 $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
697 $RUNAS touch ${TESTFILE}_after_3 &&
698 quota_error a $TSTUSR "create after timer expired," \
704 $SHOW_QUOTA_INFO_USER
705 $SHOW_QUOTA_INFO_GROUP
707 echo "Unlink files to stop timer"
708 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
709 wait_delete_completed
712 $RUNAS touch ${TESTFILE}_xxx ||
713 quota_error a $TSTUSR "touch after timer stop failure," \
723 local LIMIT=10 # inodes
724 local TESTFILE=$DIR/$tdir/$tfile-0
727 set_mdt_qtype "ug" || error "enable mdt quota failed"
729 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
730 # make sure the system is clean
731 local USED=$(getquota -u $TSTUSR global curinodes)
732 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
734 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
735 $GRACE $DIR || error "set user grace time failed"
736 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
737 error "set user quota failed"
739 test_file_soft $TESTFILE $LIMIT $GRACE
740 resetquota -u $TSTUSR
742 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
743 # make sure the system is clean
744 USED=$(getquota -g $TSTUSR global curinodes)
745 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
747 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
748 $GRACE $DIR || error "set group grace time failed"
749 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
750 error "set group quota failed"
751 TESTFILE=$DIR/$tdir/$tfile-1
753 test_file_soft $TESTFILE $LIMIT $GRACE
754 resetquota -g $TSTUSR
757 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
758 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
759 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
760 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
762 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
766 local GR_STR2="1000s"
768 local GR_STR4="1w2d3h4m5s"
770 local GR_STR6="1111111111111111"
772 wait_delete_completed
774 # test of valid grace strings handling
775 echo "Valid grace strings test"
776 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
777 $GR_STR2 $DIR || error "set user grace time failed"
778 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
779 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
780 $GR_STR4 $DIR || error "set group grace time quota failed"
781 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
783 # test of invalid grace strings handling
784 echo " Invalid grace strings test"
785 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
786 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
789 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
790 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
791 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
792 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
794 run_test 4b "Grace time strings handling"
796 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
798 local BLIMIT=10 # 10M
799 local ILIMIT=10 # 10 inodes
802 trap cleanup_quota_test EXIT
804 set_mdt_qtype "ug" || error "enable mdt quota failed"
805 set_ost_qtype "ug" || error "enable ost quota failed"
807 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
808 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
809 error "set user quota failed"
810 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
811 error "set group quota failed"
813 # make sure the system is clean
814 local USED=$(getquota -u $TSTUSR global curinodes)
815 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
816 USED=$(getquota -g $TSTUSR global curinodes)
817 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
818 USED=$(getquota -u $TSTUSR global curspace)
819 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
820 USED=$(getquota -g $TSTUSR global curspace)
821 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
823 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
824 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
825 error "create failure, expect success"
826 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
827 error "write failure, expect success"
829 echo "Chown files to $TSTUSR.$TSTUSR ..."
830 for i in `seq 0 $ILIMIT`; do
831 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
832 quota_error a $TSTUSR "chown failure, expect success"
836 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
839 resetquota -u $TSTUSR
840 resetquota -g $TSTUSR
842 run_test 5 "Chown & chgrp successfully even out of block/file quota"
844 # test dropping acquire request on master
849 trap cleanup_quota_test EXIT
851 # make sure the system is clean
852 local USED=$(getquota -u $TSTUSR global curspace)
853 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
855 # make sure no granted quota on ost
856 set_ost_qtype "ug" || error "enable ost quota failed"
857 resetquota -u $TSTUSR
859 # create file for $TSTUSR
860 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
861 $LFS setstripe $TESTFILE -c 1 -i 0
862 chown $TSTUSR.$TSTUSR $TESTFILE
864 # create file for $TSTUSR2
865 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
866 $LFS setstripe $TESTFILE2 -c 1 -i 0
867 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
869 # cache per-ID lock for $TSTUSR on slave
870 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
871 error "set quota failed"
872 $RUNAS $DD of=$TESTFILE count=1 ||
873 error "write $TESTFILE failure, expect success"
874 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
875 error "write $TESTFILE2 failure, expect success"
877 sync_all_data || true
879 #define QUOTA_DQACQ 601
880 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
881 lustre_fail mds 0x513 601
883 # write to un-enforced ID ($TSTUSR2) should succeed
884 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
885 error "write failure, expect success"
887 # write to enforced ID ($TSTUSR) in background, exceeding limit
888 # to make sure DQACQ is sent
889 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
892 # watchdog timer uses a factor of 2
893 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
894 sleep $((TIMEOUT * 2 + 1))
896 # write should be blocked and never finished
897 if ! ps -p $DDPID > /dev/null 2>&1; then
899 error "write finished incorrectly!"
904 # no watchdog is triggered
905 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
906 watchdog=$(awk '/sanity-quota test 6/ {start = 1;}
907 /Service thread pid/ && /was inactive/ {
911 }' $TMP/lustre-log-${TESTNAME}.log)
912 [ -z "$watchdog" ] || error "$watchdog"
914 rm -f $TMP/lustre-log-${TESTNAME}.log
916 # write should continue & succeed
919 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
920 if [ $count -ge 120 ]; then
921 quota_error u $TSTUSR "dd not finished in $count secs"
924 [ $((count % 10)) -eq 0 ] && echo "Waiting $count secs"
929 resetquota -u $TSTUSR
931 run_test 6 "Test dropping acquire request on master"
933 # quota reintegration (global index)
935 local TESTFILE=$DIR/$tdir/$tfile
938 [ "$SLOW" = "no" ] && LIMIT=5
941 trap cleanup_quota_test EXIT
943 # make sure the system is clean
944 local USED=$(getquota -u $TSTUSR global curspace)
945 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
947 # make sure no granted quota on ost1
948 set_ost_qtype "ug" || error "enable ost quota failed"
949 resetquota -u $TSTUSR
950 set_ost_qtype "none" || error "disable ost quota failed"
952 local OSTUUID=$(ostuuid_from_index 0)
953 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
954 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
958 $LFS setstripe $TESTFILE -c 1 -i 0
959 chown $TSTUSR.$TSTUSR $TESTFILE
964 echo "Enable quota & set quota limit for $TSTUSR"
965 set_ost_qtype "ug" || error "enable ost quota failed"
966 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
967 error "set quota failed"
970 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
972 wait_ost_reint "ug" || error "reintegration failed"
974 # hardlimit should have been fetched by slave during global
975 # reintegration, write will exceed quota
976 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
977 quota_error u $TSTUSR "write success, but expect EDQUOT"
980 wait_delete_completed
981 sync_all_data || true
987 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
988 error "clear quota failed"
991 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
993 wait_ost_reint "ug" || error "reintegration failed"
995 # hardlimit should be cleared on slave during reintegration
996 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
997 quota_error u $TSTUSR "write error, but expect success"
1000 resetquota -u $TSTUSR
1002 run_test 7a "Quota reintegration (global index)"
1004 # quota reintegration (slave index)
1007 local TESTFILE=$DIR/$tdir/$tfile
1010 trap cleanup_quota_test EXIT
1012 # make sure the system is clean
1013 local USED=$(getquota -u $TSTUSR global curspace)
1014 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1016 # make sure no granted quota on ost1
1017 set_ost_qtype "ug" || error "enable ost quota failed"
1018 resetquota -u $TSTUSR
1019 set_ost_qtype "none" || error "disable ost quota failed"
1021 local OSTUUID=$(ostuuid_from_index 0)
1022 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1023 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
1027 $LFS setstripe $TESTFILE -c 1 -i 0
1028 chown $TSTUSR.$TSTUSR $TESTFILE
1030 # consume some space to make sure the granted space will not
1031 # be released during reconciliation
1032 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1033 error "consume space failure, expect success"
1035 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
1036 lustre_fail mds 0xa02
1038 set_ost_qtype "ug" || error "enable ost quota failed"
1039 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1040 error "set quota failed"
1042 # ignore the write error
1043 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
1045 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1049 echo "Restart ost to trigger reintegration..."
1051 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
1053 wait_ost_reint "ug" || error "reintegration failed"
1055 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1056 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1059 resetquota -u $TSTUSR
1062 run_test 7b "Quota reintegration (slave index)"
1064 # quota reintegration (restart mds during reintegration)
1066 local LIMIT=20 # 20M
1067 local TESTFILE=$DIR/$tdir/$tfile
1069 [ "$SLOW" = "no" ] && LIMIT=5
1072 trap cleanup_quota_test EXIT
1074 # make sure the system is clean
1075 local USED=$(getquota -u $TSTUSR global curspace)
1076 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1078 set_ost_qtype "none" || error "disable ost quota failed"
1079 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1080 error "set quota failed"
1082 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1083 lustre_fail ost 0xa03
1085 # enable ost quota to trigger reintegration
1086 set_ost_qtype "ug" || error "enable ost quota failed"
1094 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1096 wait_ost_reint "ug" || error "reintegration failed"
1098 # hardlimit should have been fetched by slave during global
1099 # reintegration, write will exceed quota
1100 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1101 quota_error u $TSTUSR "write success, but expect EDQUOT"
1104 resetquota -u $TSTUSR
1106 run_test 7c "Quota reintegration (restart mds during reintegration)"
1108 # Quota reintegration (Transfer index in multiple bulks)
1110 local TESTFILE=$DIR/$tdir/$tfile
1111 local TESTFILE1="$DIR/$tdir/$tfile"-1
1115 trap cleanup_quota_test EXIT
1117 set_ost_qtype "none" || error "disable ost quota failed"
1118 # LU-2284. Enable trace for debug log.
1119 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+trace"
1120 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1121 error "set quota for $TSTUSR failed"
1122 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1123 error "set quota for $TSTUSR2 failed"
1124 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-trace"
1126 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1127 lustre_fail mds 0x608 0
1129 # enable quota to tirgger reintegration
1130 set_ost_qtype "u" || error "enable ost quota failed"
1131 wait_ost_reint "u" || error "reintegration failed"
1135 # hardlimit should have been fetched by slave during global
1136 # reintegration, write will exceed quota
1137 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1138 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1140 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1141 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1144 resetquota -u $TSTUSR
1145 resetquota -u $TSTUSR2
1147 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1149 # run dbench with quota enabled
1151 local BLK_LIMIT="100g" #100G
1152 local FILE_LIMIT=1000000
1155 trap cleanup_quota_test EXIT
1157 set_mdt_qtype "ug" || error "enable mdt quota failed"
1158 set_ost_qtype "ug" || error "enable ost quota failed"
1160 echo "Set enough high limit for user: $TSTUSR"
1161 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1162 error "set user quota failed"
1163 echo "Set enough high limit for group: $TSTUSR"
1164 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1165 error "set group quota failed"
1168 [ "$SLOW" = "no" ] && duration=" -t 120"
1169 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1170 quota_error a $TSTUSR "dbench failed!"
1173 resetquota -u $TSTUSR
1174 resetquota -g $TSTUSR
1176 run_test 8 "Run dbench with quota enabled"
1178 # this check is just for test_9
1179 OST0_MIN=4900000 #4.67G
1181 check_whether_skip () {
1182 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1183 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1184 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1185 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1192 # run for fixing bug10707, it needs a big room. test for 64bit
1194 local filesize=$((1024 * 1024 * 1024 * 9 / 2)) # 4.5G
1196 check_whether_skip && return 0
1199 trap cleanup_quota_test EXIT
1201 set_ost_qtype "ug" || error "enable ost quota failed"
1203 local TESTFILE="$DIR/$tdir/$tfile-0"
1204 local BLK_LIMIT=100G #100G
1205 local FILE_LIMIT=1000000
1207 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1209 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1211 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1212 error "set user quota failed"
1214 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1215 "for group: $TSTUSR"
1216 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1217 error "set group quota failed"
1219 quota_show_check a u $TSTUSR
1220 quota_show_check a g $TSTUSR
1222 echo "Create test file"
1223 $LFS setstripe $TESTFILE -c 1 -i 0
1224 chown $TSTUSR.$TSTUSR $TESTFILE
1226 log "Write the big file of 4.5G ..."
1227 $RUNAS $DD of=$TESTFILE count=$filesize ||
1228 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1234 resetquota -u $TSTUSR
1235 resetquota -g $TSTUSR
1240 run_test 9 "Block limit larger than 4GB (b10707)"
1243 local TESTFILE=$DIR/$tdir/$tfile
1246 trap cleanup_quota_test EXIT
1248 # set limit to root user should fail
1249 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1250 error "set limit for root user successfully, expect failure"
1251 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1252 error "set limit for root group successfully, expect failure"
1254 # root user can overrun quota
1255 set_ost_qtype "ug" || "enable ost quota failed"
1257 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1258 error "set quota failed"
1259 quota_show_check b u $TSTUSR
1261 $LFS setstripe $TESTFILE -c 1
1262 chown $TSTUSR.$TSTUSR $TESTFILE
1264 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1265 error "write failure, expect success"
1268 resetquota -u $TSTUSR
1270 run_test 10 "Test quota for root user"
1273 local TESTFILE=$DIR/$tdir/$tfile
1275 trap cleanup_quota_test EXIT
1277 set_mdt_qtype "ug" || "enable mdt quota failed"
1278 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1279 error "set quota failed"
1284 chown $TSTUSR.$TSTUSR "$TESTFILE"-0
1285 chown $TSTUSR.$TSTUSR "$TESTFILE"-1
1288 local USED=$(getquota -u $TSTUSR global curinodes)
1289 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1292 resetquota -u $TSTUSR
1294 run_test 11 "Chown/chgrp ignores quota"
1297 [ "$OSTCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return
1299 local blimit=22 # 22M
1300 local blk_cnt=$((blimit - 5))
1301 local TESTFILE0="$DIR/$tdir/$tfile"-0
1302 local TESTFILE1="$DIR/$tdir/$tfile"-1
1305 trap cleanup_quota_test EXIT
1307 set_ost_qtype "u" || "enable ost quota failed"
1308 quota_show_check b u $TSTUSR
1310 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1311 error "set quota failed"
1313 $LFS setstripe $TESTFILE0 -c 1 -i 0
1314 $LFS setstripe $TESTFILE1 -c 1 -i 1
1315 chown $TSTUSR.$TSTUSR $TESTFILE0
1316 chown $TSTUSR.$TSTUSR $TESTFILE1
1318 echo "Write to ost0..."
1319 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1320 quota_error a $TSTUSR "dd failed"
1322 echo "Write to ost1..."
1323 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1324 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1326 echo "Free space from ost0..."
1328 wait_delete_completed
1329 sync_all_data || true
1331 echo "Write to ost1 after space freed from ost0..."
1332 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1333 quota_error a $TSTUSR "rebalancing failed"
1336 resetquota -u $TSTUSR
1338 run_test 12 "Block quota rebalancing"
1341 local TESTFILE=$DIR/$tdir/$tfile
1342 # the name of osp on ost1 name is MDT0000-osp-OST0000
1343 local procf="ldlm.namespaces.*MDT0000-osp-OST0000.lru_size"
1346 trap cleanup_quota_test EXIT
1348 set_ost_qtype "u" || "enable ost quota failed"
1349 quota_show_check b u $TSTUSR
1351 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1352 error "set quota failed"
1353 $LFS setstripe $TESTFILE -c 1 -i 0
1354 chown $TSTUSR.$TSTUSR $TESTFILE
1356 # clear the locks in cache first
1357 do_facet ost1 $LCTL set_param -n $procf=clear
1358 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1359 [ $nlock -eq 0 ] || error "$nlock cached locks"
1361 # write to acquire the per-ID lock
1362 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1363 quota_error a $TSTUSR "dd failed"
1365 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1366 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1368 # clear quota doesn't trigger per-ID lock cancellation
1369 resetquota -u $TSTUSR
1370 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1371 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1373 # clear the per-ID lock
1374 do_facet ost1 $LCTL set_param -n $procf=clear
1375 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1376 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1378 # spare quota should be released
1379 local OSTUUID=$(ostuuid_from_index 0)
1380 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1381 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1382 [ $limit -le $space ] ||
1383 error "spare quota isn't released, limit:$limit, space:$space"
1387 run_test 13 "Cancel per-ID lock in the LRU list"
1390 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1392 wait_delete_completed
1393 sync_all_data || true
1396 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1397 error "set user quota failed"
1398 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1399 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1400 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1401 resetquota -u $TSTUSR
1404 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1405 error "set group quota failed"
1406 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1407 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1408 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1409 resetquota -g $TSTUSR
1411 run_test 15 "Set over 4T block quota"
1415 local BLKS=1 # 1M less than limit
1416 local TESTFILE=$DIR/$tdir/$tfile
1419 trap cleanup_quota_test EXIT
1421 # make sure the system is clean
1422 local USED=$(getquota -u $TSTUSR global curspace)
1423 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1425 set_ost_qtype "ug" || error "enable ost quota failed"
1426 # make sure no granted quota on ost
1427 resetquota -u $TSTUSR
1428 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1429 error "set quota failed"
1431 quota_show_check b u $TSTUSR
1433 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1434 lustre_fail mds 0xa04 $err_code
1436 # write in background
1437 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1441 # write should be blocked and never finished
1442 if ! ps -p $DDPID > /dev/null 2>&1; then
1444 quota_error u $TSTUSR "write finished incorrectly!"
1452 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1454 if [ $count -gt $timeout ]; then
1455 quota_error u $TSTUSR "dd is not finished!"
1460 sync; sync_all_data || true
1462 USED=$(getquota -u $TSTUSR global curspace)
1463 [ $USED -ge $(($BLKS * 1024)) ] || quota_error u $TSTUSR \
1464 "Used space(${USED}K) is less than ${BLKS}M"
1467 resetquota -u $TSTUSR
1470 # DQACQ return recoverable error
1472 echo "DQACQ return -ENOLCK"
1474 test_17sub 37 || error "Handle -ENOLCK failed"
1476 echo "DQACQ return -EAGAIN"
1478 test_17sub 11 || error "Handle -EAGAIN failed"
1480 echo "DQACQ return -ETIMEDOUT"
1481 #define ETIMEDOUT 110
1482 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1484 echo "DQACQ return -ENOTCONN"
1485 #define ENOTCONN 107
1486 test_17sub 107 || error "Handle -ENOTCONN failed"
1489 run_test 17 "DQACQ return recoverable error"
1493 local blimit="200m" # 200M
1494 local TESTFILE="$DIR/$tdir/$tfile"
1497 trap cleanup_quota_test EXIT
1499 set_ost_qtype "u" || error "enable ost quota failed"
1500 log "User quota (limit: $blimit)"
1501 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1502 error "set quota failed"
1503 quota_show_check b u $TSTUSR
1505 $LFS setstripe $TESTFILE -i 0 -c 1
1506 chown $TSTUSR.$TSTUSR $TESTFILE
1508 local timeout=$(sysctl -n lustre.timeout)
1510 if [ $io_type = "directio" ]; then
1511 log "Write 100M (directio) ..."
1512 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1514 log "Write 100M (buffered) ..."
1515 $RUNAS $DD of=$TESTFILE count=100 &
1519 replay_barrier $SINGLEMDS
1520 log "Fail mds for $((2 * timeout)) seconds"
1521 fail $SINGLEMDS $((2 * timeout))
1524 if at_is_enabled; then
1525 timeout=$(at_max_get mds)
1527 timeout=$(lctl get_param -n timeout)
1531 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1532 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1533 log "it took $count second"
1538 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1540 cancel_lru_locks mdc
1541 cancel_lru_locks osc
1544 local testfile_size=$(stat -c %s $TESTFILE)
1545 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1546 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)),"
1547 "got ${testfile_size}. Verifying file failed!"
1550 resetquota -u $TSTUSR
1553 # test when mds does failover, the ost still could work well
1554 # this test shouldn't trigger watchdog b=14840
1557 test_18_sub directio
1559 # check if watchdog is triggered
1560 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1561 local watchdog=$(awk '/sanity-quota test 18/ {start = 1;}
1562 /Service thread pid/ && /was inactive/ {
1566 }' $TMP/lustre-log-${TESTNAME}.log)
1567 [ -z "$watchdog" ] || error "$watchdog"
1568 rm -f $TMP/lustre-log-${TESTNAME}.log
1570 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1574 local TESTFILE=$DIR/$tdir/$tfile
1577 trap cleanup_quota_test EXIT
1579 set_ost_qtype "ug" || error "enable ost quota failed"
1581 # bind file to a single OST
1582 $LFS setstripe -c 1 $TESTFILE
1583 chown $TSTUSR.$TSTUSR $TESTFILE
1585 echo "Set user quota (limit: "$blimit"M)"
1586 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1587 error "set user quota failed"
1588 quota_show_check b u $TSTUSR
1589 echo "Update quota limits"
1590 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1591 error "set group quota failed"
1592 quota_show_check b u $TSTUSR
1594 # first wirte might be cached
1595 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
1596 cancel_lru_locks osc
1598 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
1599 quota_error u $TSTUSR "Write success, expect failure"
1603 resetquota -u $TSTUSR
1605 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
1607 test_20() { # b15754
1608 local LSTR=(2g 1t 4k 3m) # limits strings
1610 local LVAL=($[2*1024*1024] $[1*1024*1024*1024] $[4*1024] $[3*1024*1024])
1612 resetquota -u $TSTUSR
1614 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1615 $MOUNT || error "could not set quota limits"
1616 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1617 --inode-softlimit ${LSTR[2]} \
1618 --inode-hardlimit ${LSTR[3]} \
1619 $MOUNT || error "could not set quota limits"
1621 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
1622 error "bsoftlimit was not set properly"
1623 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
1624 error "bhardlimit was not set properly"
1625 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
1626 error "isoftlimit was not set properly"
1627 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
1628 error "ihardlimit was not set properly"
1630 resetquota -u $TSTUSR
1632 run_test 20 "Test if setquota specifiers work properly (b15754)"
1639 local time=$(($(date +%s) + seconds))
1640 while [ $(date +%s) -lt $time ]; do
1641 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
1645 # run for fixing bug16053, setquota shouldn't fail when writing and
1646 # deleting are happening
1648 local TESTFILE="$DIR/$tdir/$tfile"
1649 local BLIMIT=10 # 10G
1650 local ILIMIT=1000000
1653 trap cleanup_quota_test EXIT
1655 set_ost_qtype "ug" || error "Enable ost quota failed"
1657 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
1658 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
1659 error "set user quota failed"
1660 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
1661 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
1662 error "set group quota failed"
1664 # repeat writing on a 1M file
1665 test_21_sub ${TESTFILE}_1 1 30 &
1667 # repeat writing on a 128M file
1668 test_21_sub ${TESTFILE}_2 128 30 &
1671 local time=$(($(date +%s) + 30))
1673 while [ $(date +%s) -lt $time ]; do
1674 log "Set quota for $i times"
1675 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1676 -I $((ILIMIT + i)) $MOUNT ||
1677 error "Set user quota failed"
1678 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1679 -I $((ILIMIT + i)) $MOUNT ||
1680 error "Set group quota failed"
1687 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1689 if [ $count -gt 60 ]; then
1690 quota_error a $TSTUSR "dd should be finished!"
1694 echo "(dd_pid=$DDPID1, time=$count)successful"
1698 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1700 if [ $count -gt 60 ]; then
1701 quota_error a $TSTUSR "dd should be finished!"
1705 echo "(dd_pid=$DDPID2, time=$count)successful"
1708 resetquota -u $TSTUSR
1709 resetquota -g $TSTUSR
1711 run_test 21 "Setquota while writing & deleting (b16053)"
1713 # enable/disable quota enforcement permanently
1715 echo "Set both mdt & ost quota type as ug"
1716 set_mdt_qtype "ug" || error "enable mdt quota failed"
1717 set_ost_qtype "ug" || error "enable ost quota failed"
1724 echo "Verify if quota is enabled"
1725 local qtype=$(mdt_quota_type)
1726 [ $qtype != "ug" ] && error "mdt quota setting is lost"
1727 qtype=$(ost_quota_type)
1728 [ $qtype != "ug" ] && error "ost quota setting is lost"
1730 echo "Set both mdt & ost quota type as none"
1731 set_mdt_qtype "none" || error "disable mdt quota failed"
1732 set_ost_qtype "none" || error "disable ost quota failed"
1739 echo "Verify if quota is disabled"
1740 qtype=$(mdt_quota_type)
1741 [ $qtype != "none" ] && error "mdt quota setting is lost"
1742 qtype=$(ost_quota_type)
1743 [ $qtype != "none" ] && error "ost quota setting is lost"
1747 run_test 22 "enable/disable quota by 'lctl conf_param'"
1750 local TESTFILE="$DIR/$tdir/$tfile"
1754 trap cleanup_quota_test EXIT
1756 set_ost_qtype "ug" || error "Enable ost quota failed"
1759 log "User quota (limit: $LIMIT MB)"
1760 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
1761 error "set quota failed"
1762 quota_show_check b u $TSTUSR
1764 $LFS setstripe $TESTFILE -c 1 -i 0
1765 chown $TSTUSR.$TSTUSR $TESTFILE
1767 log "Step1: trigger EDQUOT with O_DIRECT"
1768 log "Write half of file"
1769 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
1770 quota_error u $TSTUSR "(1) Write failure, expect success." \
1772 log "Write out of block quota ..."
1773 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
1774 oflag=direct conv=notrunc &&
1775 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
1779 log "Step2: rewrite should succeed"
1780 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
1781 quota_error u $TSTUSR "(3) Write failure, expect success." \
1787 local OST0_UUID=$(ostuuid_from_index 0)
1788 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
1789 [ $OST0_QUOTA_USED -ne 0 ] &&
1790 ($SHOW_QUOTA_USER; \
1791 quota_error u $TSTUSR "quota isn't released")
1793 resetquota -u $TSTUSR
1797 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
1798 check_whether_skip && return 0
1799 log "run for 4MB test file"
1802 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
1803 check_whether_skip && return 0
1804 log "run for 40MB test file"
1807 run_test 23 "Quota should be honored with directIO (b16125)"
1811 local TESTFILE="$DIR/$tdir/$tfile"
1814 trap cleanup_quota_test EXIT
1816 set_ost_qtype "ug" || error "enable ost quota failed"
1818 # bind file to a single OST
1819 $LFS setstripe -c 1 $TESTFILE
1820 chown $TSTUSR.$TSTUSR $TESTFILE
1822 echo "Set user quota (limit: "$blimit"M)"
1823 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1824 error "set quota failed"
1826 # overrun quota by root user
1827 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
1828 error "write failure, expect success"
1829 cancel_lru_locks osc
1830 sync_all_data || true
1832 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1835 resetquota -u $TSTUSR
1837 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
1839 test_27a() { # b19612
1840 $LFS quota $TSTUSR $DIR &&
1841 error "lfs succeeded with no type, but should have failed"
1842 $LFS setquota $TSTUSR $DIR &&
1843 error "lfs succeeded with no type, but should have failed"
1846 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
1848 test_27b() { # b20200
1849 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1850 error "lfs setquota failed with uid argument"
1851 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1852 error "lfs stequota failed with gid argument"
1853 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
1854 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
1855 resetquota -u $TSTUSR
1856 resetquota -g $TSTUSR
1859 run_test 27b "lfs quota/setquota should handle user/group ID (b20200)"
1864 local TESTFILE="$DIR/$tdir/$tfile"
1868 trap cleanup_quota_test EXIT
1870 set_ost_qtype "u" || error "enable ost quota failed"
1872 $LFS setstripe $TESTFILE -i 0 -c 1
1873 chown $TSTUSR.$TSTUSR $TESTFILE
1875 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
1876 $MAX_IQ_TIME $DIR || error "set grace time failed"
1877 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
1878 error "set quota failed"
1879 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
1880 cancel_lru_locks osc
1882 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
1883 # over-quota flag has not yet settled since we do not trigger async
1884 # events based on grace time period expiration
1886 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 || true
1887 cancel_lru_locks osc
1888 # now over-quota flag should be settled and further writes should fail
1890 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
1891 error "grace times were reset"
1894 resetquota -u $TSTUSR
1895 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1896 $MAX_IQ_TIME $DIR || error "restore grace time failed"
1898 run_test 30 "Hard limit updates should not reset grace times"
1900 # basic usage tracking for user & group
1902 local INODES=10 # 10 files
1903 local BLK_CNT=2 # of 2M each
1904 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
1907 trap cleanup_quota_test EXIT
1909 # make sure the system is clean
1910 local USED=$(getquota -u $TSTID global curspace)
1912 error "Used space ($USED) for user $TSTID isn't 0."
1913 USED=$(getquota -g $TSTID global curspace)
1915 error "Used space ($USED) for group $TSTID isn't 0."
1917 echo "Write files..."
1918 for i in `seq 0 $INODES`; do
1919 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
1920 error "write failed"
1921 echo "Iteration $i/$INODES completed"
1923 cancel_lru_locks osc
1924 sync; sync_all_data || true
1926 echo "Verify disk usage after write"
1927 USED=$(getquota -u $TSTID global curspace)
1928 [ $USED -lt $TOTAL_BLKS ] &&
1929 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
1930 USED=$(getquota -g $TSTID global curspace)
1931 [ $USED -lt $TOTAL_BLKS ] &&
1932 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
1934 echo "Verify inode usage after write"
1935 USED=$(getquota -u $TSTID global curinodes)
1936 [ $USED -lt $INODES ] &&
1937 error "Used inode for user $TSTID is $USED, expected $INODES"
1938 USED=$(getquota -g $TSTID global curinodes)
1939 [ $USED -lt $INODES ] &&
1940 error "Used inode for group $TSTID is $USED, expected $INODES"
1944 echo "Verify disk usage after delete"
1945 USED=$(getquota -u $TSTID global curspace)
1946 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
1947 USED=$(getquota -u $TSTID global curinodes)
1948 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
1949 USED=$(getquota -g $TSTID global curspace)
1950 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
1951 USED=$(getquota -g $TSTID global curinodes)
1952 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
1954 run_test 33 "Basic usage tracking for user & group"
1956 # usage transfer test for user & group
1958 local BLK_CNT=2 # 2MB
1961 trap cleanup_quota_test EXIT
1963 # make sure the system is clean
1964 local USED=$(getquota -u $TSTID global curspace)
1965 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
1966 USED=$(getquota -g $TSTID global curspace)
1967 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
1969 echo "Write file..."
1970 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
1971 error "write failed"
1972 cancel_lru_locks osc
1973 sync; sync_all_data || true
1975 echo "chown the file to user $TSTID"
1976 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
1978 echo "Wait for setattr on objects finished..."
1979 wait_delete_completed
1981 BLK_CNT=$((BLK_CNT * 1024))
1983 echo "Verify disk usage for user $TSTID"
1984 USED=$(getquota -u $TSTID global curspace)
1985 [ $USED -lt $BLK_CNT ] &&
1986 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
1987 USED=$(getquota -u $TSTID global curinodes)
1989 error "Used inodes for user $TSTID is $USED, expected 1"
1991 echo "chgrp the file to group $TSTID"
1992 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
1994 echo "Wait for setattr on objects finished..."
1995 wait_delete_completed
1997 echo "Verify disk usage for group $TSTID"
1998 USED=$(getquota -g $TSTID global curspace)
1999 [ $USED -ge $BLK_CNT ] ||
2000 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2001 USED=$(getquota -g $TSTID global curinodes)
2003 error "Used inodes for group $TSTID is $USED, expected 1"
2007 run_test 34 "Usage transfer for user & group"
2009 # usage is still accessible across restart
2011 local BLK_CNT=2 # 2 MB
2014 trap cleanup_quota_test EXIT
2016 echo "Write file..."
2017 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2018 error "write failed"
2019 cancel_lru_locks osc
2020 sync; sync_all_data || true
2022 echo "Save disk usage before restart"
2023 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2024 [ $ORIG_USR_SPACE -eq 0 ] &&
2025 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2026 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2027 [ $ORIG_USR_INODES -eq 0 ] &&
2028 error "Used inodes for user $TSTID is 0, expected 1"
2029 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2030 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2031 [ $ORIG_GRP_SPACE -eq 0 ] &&
2032 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2033 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2034 [ $ORIG_GRP_INODES -eq 0 ] &&
2035 error "Used inodes for group $TSTID is 0, expected 1"
2036 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2039 local ORIG_REFORMAT=$REFORMAT
2041 cleanup_and_setup_lustre
2042 REFORMAT=$ORIG_REFORMAT
2045 echo "Verify disk usage after restart"
2046 local USED=$(getquota -u $TSTID global curspace)
2047 [ $USED -eq $ORIG_USR_SPACE ] ||
2048 error "Used space for user $TSTID changed from " \
2049 "$ORIG_USR_SPACE to $USED"
2050 USED=$(getquota -u $TSTID global curinodes)
2051 [ $USED -eq $ORIG_USR_INODES ] ||
2052 error "Used inodes for user $TSTID changed from " \
2053 "$ORIG_USR_INODES to $USED"
2054 USED=$(getquota -g $TSTID global curspace)
2055 [ $USED -eq $ORIG_GRP_SPACE ] ||
2056 error "Used space for group $TSTID changed from " \
2057 "$ORIG_GRP_SPACE to $USED"
2058 USED=$(getquota -g $TSTID global curinodes)
2059 [ $USED -eq $ORIG_GRP_INODES ] ||
2060 error "Used inodes for group $TSTID changed from " \
2061 "$ORIG_GRP_INODES to $USED"
2063 # check if the vfs_dq_init() is called before writing
2064 echo "Append to the same file..."
2065 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2066 error "write failed"
2067 cancel_lru_locks osc
2068 sync; sync_all_data || true
2070 echo "Verify space usage is increased"
2071 USED=$(getquota -u $TSTID global curspace)
2072 [ $USED -gt $ORIG_USR_SPACE ] ||
2073 error "Used space for user $TSTID isn't increased" \
2074 "orig:$ORIG_USR_SPACE, now:$USED"
2075 USED=$(getquota -g $TSTID global curspace)
2076 [ $USED -gt $ORIG_GRP_SPACE ] ||
2077 error "Used space for group $TSTID isn't increased" \
2078 "orig:$ORIG_GRP_SPACE, now:$USED"
2082 run_test 35 "Usage is still accessible across reboot"
2084 # test migrating old amdin quota files (in Linux quota file format v2) into new
2085 # quota global index (in IAM format)
2087 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] && \
2088 skip "skipping migration test" && return
2090 # get the mdt0 device name
2091 local mdt0_node=$(facet_active_host $SINGLEMDS)
2092 local mdt0_dev=$(mdsdevname ${SINGLEMDS//mds/})
2097 echo "Copy admin quota files into MDT0..."
2098 local mntpt=$(facet_mntpt $SINGLEMDS)
2099 local mdt0_fstype=$(facet_fstype $SINGLEMDS)
2101 if ! do_node $mdt0_node test -b $mdt0_fstype; then
2104 echo "$mdt0_node, $mdt0_dev, $mntpt, $opt"
2105 do_node $mdt0_node mount -t $mdt0_fstype $opt $mdt0_dev $mntpt
2106 do_node $mdt0_node mkdir $mntpt/OBJECTS
2107 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.usr $mntpt/OBJECTS
2108 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.grp $mntpt/OBJECTS
2109 do_node $mdt0_node umount -f $mntpt
2114 echo "Verify global limits..."
2118 local proc="qmt.*.md-0x0.glb-usr"
2119 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2120 [ $id_cnt -eq 403 ] || error "Migrate inode user limit failed: $id_cnt"
2121 limit=$(getquota -u 1 global isoftlimit)
2122 [ $limit -eq 1024 ] || error "User inode softlimit: $limit"
2123 limit=$(getquota -u 1 global ihardlimit)
2124 [ $limit -eq 2048 ] || error "User inode hardlimit: $limit"
2126 proc="qmt.*.md-0x0.glb-grp"
2127 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2128 [ $id_cnt -eq 403 ] || error "Migrate inode group limit failed: $id_cnt"
2129 limit=$(getquota -g 1 global isoftlimit)
2130 [ $limit -eq 1024 ] || error "Group inode softlimit: $limit"
2131 limit=$(getquota -g 1 global ihardlimit)
2132 [ $limit -eq 2048 ] || error "Group inode hardlimit: $limit"
2134 proc=" qmt.*.dt-0x0.glb-usr"
2135 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2136 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2137 limit=$(getquota -u 60001 global bsoftlimit)
2138 [ $limit -eq 10485760 ] || error "User block softlimit: $limit"
2139 limit=$(getquota -u 60001 global bhardlimit)
2140 [ $limit -eq 20971520 ] || error "User block hardlimit: $limit"
2142 proc="qmt.*.dt-0x0.glb-grp"
2143 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2144 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2145 limit=$(getquota -g 60001 global bsoftlimit)
2146 [ $limit -eq 10485760 ] || error "Group block softlimit: $limit"
2147 limit=$(getquota -g 60001 global bhardlimit)
2148 [ $limit -eq 20971520 ] || error "Group block hardlimit: $limit"
2154 run_test 36 "Migrate old admin files into new global indexes"
2158 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
2164 check_and_cleanup_lustre
2165 export QUOTA_AUTO=$QUOTA_AUTO_OLD