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
973 wait_ost_reint "ug" || error "reintegration failed"
975 # hardlimit should have been fetched by slave during global
976 # reintegration, write will exceed quota
977 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
978 quota_error u $TSTUSR "write success, but expect EDQUOT"
981 wait_delete_completed
982 sync_all_data || true
988 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
989 error "clear quota failed"
992 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
995 wait_ost_reint "ug" || error "reintegration failed"
997 # hardlimit should be cleared on slave during reintegration
998 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
999 quota_error u $TSTUSR "write error, but expect success"
1002 resetquota -u $TSTUSR
1004 run_test 7a "Quota reintegration (global index)"
1006 # quota reintegration (slave index)
1009 local TESTFILE=$DIR/$tdir/$tfile
1012 trap cleanup_quota_test EXIT
1014 # make sure the system is clean
1015 local USED=$(getquota -u $TSTUSR global curspace)
1016 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1018 # make sure no granted quota on ost1
1019 set_ost_qtype "ug" || error "enable ost quota failed"
1020 resetquota -u $TSTUSR
1021 set_ost_qtype "none" || error "disable ost quota failed"
1023 local OSTUUID=$(ostuuid_from_index 0)
1024 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1025 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
1029 $LFS setstripe $TESTFILE -c 1 -i 0
1030 chown $TSTUSR.$TSTUSR $TESTFILE
1032 # consume some space to make sure the granted space will not
1033 # be released during reconciliation
1034 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1035 error "consume space failure, expect success"
1037 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
1038 lustre_fail mds 0xa02
1040 set_ost_qtype "ug" || error "enable ost quota failed"
1041 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1042 error "set quota failed"
1044 # ignore the write error
1045 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
1047 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1051 echo "Restart ost to trigger reintegration..."
1053 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
1056 wait_ost_reint "ug" || error "reintegration failed"
1058 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1059 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1062 resetquota -u $TSTUSR
1065 run_test 7b "Quota reintegration (slave index)"
1067 # quota reintegration (restart mds during reintegration)
1069 local LIMIT=20 # 20M
1070 local TESTFILE=$DIR/$tdir/$tfile
1072 [ "$SLOW" = "no" ] && LIMIT=5
1075 trap cleanup_quota_test EXIT
1077 # make sure the system is clean
1078 local USED=$(getquota -u $TSTUSR global curspace)
1079 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1081 set_ost_qtype "none" || error "disable ost quota failed"
1082 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1083 error "set quota failed"
1085 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1086 lustre_fail ost 0xa03
1088 # enable ost quota to trigger reintegration
1089 set_ost_qtype "ug" || error "enable ost quota failed"
1097 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1100 wait_ost_reint "ug" || error "reintegration failed"
1102 # hardlimit should have been fetched by slave during global
1103 # reintegration, write will exceed quota
1104 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1105 quota_error u $TSTUSR "write success, but expect EDQUOT"
1108 resetquota -u $TSTUSR
1110 run_test 7c "Quota reintegration (restart mds during reintegration)"
1112 # Quota reintegration (Transfer index in multiple bulks)
1114 local TESTFILE=$DIR/$tdir/$tfile
1115 local TESTFILE1="$DIR/$tdir/$tfile"-1
1119 trap cleanup_quota_test EXIT
1121 set_ost_qtype "none" || error "disable ost quota failed"
1122 # LU-2284. Enable trace for debug log.
1123 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+trace"
1124 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1125 error "set quota for $TSTUSR failed"
1126 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1127 error "set quota for $TSTUSR2 failed"
1128 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-trace"
1130 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1131 lustre_fail mds 0x608 0
1133 # enable quota to tirgger reintegration
1134 set_ost_qtype "u" || error "enable ost quota failed"
1135 wait_ost_reint "u" || error "reintegration failed"
1139 # hardlimit should have been fetched by slave during global
1140 # reintegration, write will exceed quota
1141 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1142 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1144 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1145 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1148 resetquota -u $TSTUSR
1149 resetquota -u $TSTUSR2
1151 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1153 # run dbench with quota enabled
1155 local BLK_LIMIT="100g" #100G
1156 local FILE_LIMIT=1000000
1159 trap cleanup_quota_test EXIT
1161 set_mdt_qtype "ug" || error "enable mdt quota failed"
1162 set_ost_qtype "ug" || error "enable ost quota failed"
1164 echo "Set enough high limit for user: $TSTUSR"
1165 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1166 error "set user quota failed"
1167 echo "Set enough high limit for group: $TSTUSR"
1168 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1169 error "set group quota failed"
1172 [ "$SLOW" = "no" ] && duration=" -t 120"
1173 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1174 quota_error a $TSTUSR "dbench failed!"
1177 resetquota -u $TSTUSR
1178 resetquota -g $TSTUSR
1180 run_test 8 "Run dbench with quota enabled"
1182 # this check is just for test_9
1183 OST0_MIN=4900000 #4.67G
1185 check_whether_skip () {
1186 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1187 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1188 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1189 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1196 # run for fixing bug10707, it needs a big room. test for 64bit
1198 local filesize=$((1024 * 1024 * 1024 * 9 / 2)) # 4.5G
1200 check_whether_skip && return 0
1203 trap cleanup_quota_test EXIT
1205 set_ost_qtype "ug" || error "enable ost quota failed"
1207 local TESTFILE="$DIR/$tdir/$tfile-0"
1208 local BLK_LIMIT=100G #100G
1209 local FILE_LIMIT=1000000
1211 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1213 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1215 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1216 error "set user quota failed"
1218 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1219 "for group: $TSTUSR"
1220 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1221 error "set group quota failed"
1223 quota_show_check a u $TSTUSR
1224 quota_show_check a g $TSTUSR
1226 echo "Create test file"
1227 $LFS setstripe $TESTFILE -c 1 -i 0
1228 chown $TSTUSR.$TSTUSR $TESTFILE
1230 log "Write the big file of 4.5G ..."
1231 $RUNAS $DD of=$TESTFILE count=$filesize ||
1232 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1238 resetquota -u $TSTUSR
1239 resetquota -g $TSTUSR
1244 run_test 9 "Block limit larger than 4GB (b10707)"
1247 local TESTFILE=$DIR/$tdir/$tfile
1250 trap cleanup_quota_test EXIT
1252 # set limit to root user should fail
1253 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1254 error "set limit for root user successfully, expect failure"
1255 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1256 error "set limit for root group successfully, expect failure"
1258 # root user can overrun quota
1259 set_ost_qtype "ug" || "enable ost quota failed"
1261 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1262 error "set quota failed"
1263 quota_show_check b u $TSTUSR
1265 $LFS setstripe $TESTFILE -c 1
1266 chown $TSTUSR.$TSTUSR $TESTFILE
1268 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1269 error "write failure, expect success"
1272 resetquota -u $TSTUSR
1274 run_test 10 "Test quota for root user"
1277 local TESTFILE=$DIR/$tdir/$tfile
1279 trap cleanup_quota_test EXIT
1281 set_mdt_qtype "ug" || "enable mdt quota failed"
1282 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1283 error "set quota failed"
1288 chown $TSTUSR.$TSTUSR "$TESTFILE"-0
1289 chown $TSTUSR.$TSTUSR "$TESTFILE"-1
1292 local USED=$(getquota -u $TSTUSR global curinodes)
1293 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1296 resetquota -u $TSTUSR
1298 run_test 11 "Chown/chgrp ignores quota"
1301 [ "$OSTCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return
1303 local blimit=22 # 22M
1304 local blk_cnt=$((blimit - 5))
1305 local TESTFILE0="$DIR/$tdir/$tfile"-0
1306 local TESTFILE1="$DIR/$tdir/$tfile"-1
1309 trap cleanup_quota_test EXIT
1311 set_ost_qtype "u" || "enable ost quota failed"
1312 quota_show_check b u $TSTUSR
1314 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1315 error "set quota failed"
1317 $LFS setstripe $TESTFILE0 -c 1 -i 0
1318 $LFS setstripe $TESTFILE1 -c 1 -i 1
1319 chown $TSTUSR.$TSTUSR $TESTFILE0
1320 chown $TSTUSR.$TSTUSR $TESTFILE1
1322 echo "Write to ost0..."
1323 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1324 quota_error a $TSTUSR "dd failed"
1326 echo "Write to ost1..."
1327 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1328 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1330 echo "Free space from ost0..."
1332 wait_delete_completed
1333 sync_all_data || true
1335 echo "Write to ost1 after space freed from ost0..."
1336 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1337 quota_error a $TSTUSR "rebalancing failed"
1340 resetquota -u $TSTUSR
1342 run_test 12 "Block quota rebalancing"
1345 local TESTFILE=$DIR/$tdir/$tfile
1346 # the name of osp on ost1 name is MDT0000-osp-OST0000
1347 local procf="ldlm.namespaces.*MDT0000-osp-OST0000.lru_size"
1350 trap cleanup_quota_test EXIT
1352 set_ost_qtype "u" || "enable ost quota failed"
1353 quota_show_check b u $TSTUSR
1355 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1356 error "set quota failed"
1357 $LFS setstripe $TESTFILE -c 1 -i 0
1358 chown $TSTUSR.$TSTUSR $TESTFILE
1360 # clear the locks in cache first
1361 do_facet ost1 $LCTL set_param -n $procf=clear
1362 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1363 [ $nlock -eq 0 ] || error "$nlock cached locks"
1365 # write to acquire the per-ID lock
1366 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1367 quota_error a $TSTUSR "dd failed"
1369 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1370 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1372 # clear quota doesn't trigger per-ID lock cancellation
1373 resetquota -u $TSTUSR
1374 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1375 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1377 # clear the per-ID lock
1378 do_facet ost1 $LCTL set_param -n $procf=clear
1379 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1380 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1382 # spare quota should be released
1383 local OSTUUID=$(ostuuid_from_index 0)
1384 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1385 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1386 [ $limit -le $space ] ||
1387 error "spare quota isn't released, limit:$limit, space:$space"
1391 run_test 13 "Cancel per-ID lock in the LRU list"
1394 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1396 wait_delete_completed
1397 sync_all_data || true
1400 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1401 error "set user quota failed"
1402 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1403 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1404 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1405 resetquota -u $TSTUSR
1408 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1409 error "set group quota failed"
1410 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1411 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1412 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1413 resetquota -g $TSTUSR
1415 run_test 15 "Set over 4T block quota"
1419 local BLKS=1 # 1M less than limit
1420 local TESTFILE=$DIR/$tdir/$tfile
1423 trap cleanup_quota_test EXIT
1425 # make sure the system is clean
1426 local USED=$(getquota -u $TSTUSR global curspace)
1427 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1429 set_ost_qtype "ug" || error "enable ost quota failed"
1430 # make sure no granted quota on ost
1431 resetquota -u $TSTUSR
1432 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1433 error "set quota failed"
1435 quota_show_check b u $TSTUSR
1437 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1438 lustre_fail mds 0xa04 $err_code
1440 # write in background
1441 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1445 # write should be blocked and never finished
1446 if ! ps -p $DDPID > /dev/null 2>&1; then
1448 quota_error u $TSTUSR "write finished incorrectly!"
1456 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1458 if [ $count -gt $timeout ]; then
1459 quota_error u $TSTUSR "dd is not finished!"
1464 sync; sync_all_data || true
1466 USED=$(getquota -u $TSTUSR global curspace)
1467 [ $USED -ge $(($BLKS * 1024)) ] || quota_error u $TSTUSR \
1468 "Used space(${USED}K) is less than ${BLKS}M"
1471 resetquota -u $TSTUSR
1474 # DQACQ return recoverable error
1476 echo "DQACQ return -ENOLCK"
1478 test_17sub 37 || error "Handle -ENOLCK failed"
1480 echo "DQACQ return -EAGAIN"
1482 test_17sub 11 || error "Handle -EAGAIN failed"
1484 echo "DQACQ return -ETIMEDOUT"
1485 #define ETIMEDOUT 110
1486 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1488 echo "DQACQ return -ENOTCONN"
1489 #define ENOTCONN 107
1490 test_17sub 107 || error "Handle -ENOTCONN failed"
1493 run_test 17 "DQACQ return recoverable error"
1497 local blimit="200m" # 200M
1498 local TESTFILE="$DIR/$tdir/$tfile"
1501 trap cleanup_quota_test EXIT
1503 set_ost_qtype "u" || error "enable ost quota failed"
1504 log "User quota (limit: $blimit)"
1505 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1506 error "set quota failed"
1507 quota_show_check b u $TSTUSR
1509 $LFS setstripe $TESTFILE -i 0 -c 1
1510 chown $TSTUSR.$TSTUSR $TESTFILE
1512 local timeout=$(sysctl -n lustre.timeout)
1514 if [ $io_type = "directio" ]; then
1515 log "Write 100M (directio) ..."
1516 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1518 log "Write 100M (buffered) ..."
1519 $RUNAS $DD of=$TESTFILE count=100 &
1523 replay_barrier $SINGLEMDS
1524 log "Fail mds for $((2 * timeout)) seconds"
1525 fail $SINGLEMDS $((2 * timeout))
1528 if at_is_enabled; then
1529 timeout=$(at_max_get mds)
1531 timeout=$(lctl get_param -n timeout)
1535 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1536 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1537 log "it took $count second"
1542 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1544 cancel_lru_locks mdc
1545 cancel_lru_locks osc
1548 local testfile_size=$(stat -c %s $TESTFILE)
1549 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1550 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)),"
1551 "got ${testfile_size}. Verifying file failed!"
1554 resetquota -u $TSTUSR
1557 # test when mds does failover, the ost still could work well
1558 # this test shouldn't trigger watchdog b=14840
1561 test_18_sub directio
1563 # check if watchdog is triggered
1564 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1565 local watchdog=$(awk '/sanity-quota test 18/ {start = 1;}
1566 /Service thread pid/ && /was inactive/ {
1570 }' $TMP/lustre-log-${TESTNAME}.log)
1571 [ -z "$watchdog" ] || error "$watchdog"
1572 rm -f $TMP/lustre-log-${TESTNAME}.log
1574 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1578 local TESTFILE=$DIR/$tdir/$tfile
1581 trap cleanup_quota_test EXIT
1583 set_ost_qtype "ug" || error "enable ost quota failed"
1585 # bind file to a single OST
1586 $LFS setstripe -c 1 $TESTFILE
1587 chown $TSTUSR.$TSTUSR $TESTFILE
1589 echo "Set user quota (limit: "$blimit"M)"
1590 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1591 error "set user quota failed"
1592 quota_show_check b u $TSTUSR
1593 echo "Update quota limits"
1594 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1595 error "set group quota failed"
1596 quota_show_check b u $TSTUSR
1598 # first wirte might be cached
1599 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
1600 cancel_lru_locks osc
1602 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
1603 quota_error u $TSTUSR "Write success, expect failure"
1607 resetquota -u $TSTUSR
1609 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
1611 test_20() { # b15754
1612 local LSTR=(2g 1t 4k 3m) # limits strings
1614 local LVAL=($[2*1024*1024] $[1*1024*1024*1024] $[4*1024] $[3*1024*1024])
1616 resetquota -u $TSTUSR
1618 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1619 $MOUNT || error "could not set quota limits"
1620 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1621 --inode-softlimit ${LSTR[2]} \
1622 --inode-hardlimit ${LSTR[3]} \
1623 $MOUNT || error "could not set quota limits"
1625 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
1626 error "bsoftlimit was not set properly"
1627 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
1628 error "bhardlimit was not set properly"
1629 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
1630 error "isoftlimit was not set properly"
1631 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
1632 error "ihardlimit was not set properly"
1634 resetquota -u $TSTUSR
1636 run_test 20 "Test if setquota specifiers work properly (b15754)"
1643 local time=$(($(date +%s) + seconds))
1644 while [ $(date +%s) -lt $time ]; do
1645 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
1649 # run for fixing bug16053, setquota shouldn't fail when writing and
1650 # deleting are happening
1652 local TESTFILE="$DIR/$tdir/$tfile"
1653 local BLIMIT=10 # 10G
1654 local ILIMIT=1000000
1657 trap cleanup_quota_test EXIT
1659 set_ost_qtype "ug" || error "Enable ost quota failed"
1661 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
1662 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
1663 error "set user quota failed"
1664 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
1665 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
1666 error "set group quota failed"
1668 # repeat writing on a 1M file
1669 test_21_sub ${TESTFILE}_1 1 30 &
1671 # repeat writing on a 128M file
1672 test_21_sub ${TESTFILE}_2 128 30 &
1675 local time=$(($(date +%s) + 30))
1677 while [ $(date +%s) -lt $time ]; do
1678 log "Set quota for $i times"
1679 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1680 -I $((ILIMIT + i)) $MOUNT ||
1681 error "Set user quota failed"
1682 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1683 -I $((ILIMIT + i)) $MOUNT ||
1684 error "Set group quota failed"
1691 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1693 if [ $count -gt 60 ]; then
1694 quota_error a $TSTUSR "dd should be finished!"
1698 echo "(dd_pid=$DDPID1, time=$count)successful"
1702 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1704 if [ $count -gt 60 ]; then
1705 quota_error a $TSTUSR "dd should be finished!"
1709 echo "(dd_pid=$DDPID2, time=$count)successful"
1712 resetquota -u $TSTUSR
1713 resetquota -g $TSTUSR
1715 run_test 21 "Setquota while writing & deleting (b16053)"
1717 # enable/disable quota enforcement permanently
1719 echo "Set both mdt & ost quota type as ug"
1720 set_mdt_qtype "ug" || error "enable mdt quota failed"
1721 set_ost_qtype "ug" || error "enable ost quota failed"
1728 echo "Verify if quota is enabled"
1729 local qtype=$(mdt_quota_type)
1730 [ $qtype != "ug" ] && error "mdt quota setting is lost"
1731 qtype=$(ost_quota_type)
1732 [ $qtype != "ug" ] && error "ost quota setting is lost"
1734 echo "Set both mdt & ost quota type as none"
1735 set_mdt_qtype "none" || error "disable mdt quota failed"
1736 set_ost_qtype "none" || error "disable ost quota failed"
1744 echo "Verify if quota is disabled"
1745 qtype=$(mdt_quota_type)
1746 [ $qtype != "none" ] && error "mdt quota setting is lost"
1747 qtype=$(ost_quota_type)
1748 [ $qtype != "none" ] && error "ost quota setting is lost"
1752 run_test 22 "enable/disable quota by 'lctl conf_param'"
1755 local TESTFILE="$DIR/$tdir/$tfile"
1759 trap cleanup_quota_test EXIT
1761 set_ost_qtype "ug" || error "Enable ost quota failed"
1764 log "User quota (limit: $LIMIT MB)"
1765 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
1766 error "set quota failed"
1767 quota_show_check b u $TSTUSR
1769 $LFS setstripe $TESTFILE -c 1 -i 0
1770 chown $TSTUSR.$TSTUSR $TESTFILE
1772 log "Step1: trigger EDQUOT with O_DIRECT"
1773 log "Write half of file"
1774 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
1775 quota_error u $TSTUSR "(1) Write failure, expect success." \
1777 log "Write out of block quota ..."
1778 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
1779 oflag=direct conv=notrunc &&
1780 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
1784 log "Step2: rewrite should succeed"
1785 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
1786 quota_error u $TSTUSR "(3) Write failure, expect success." \
1792 local OST0_UUID=$(ostuuid_from_index 0)
1793 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
1794 [ $OST0_QUOTA_USED -ne 0 ] &&
1795 ($SHOW_QUOTA_USER; \
1796 quota_error u $TSTUSR "quota isn't released")
1798 resetquota -u $TSTUSR
1802 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
1803 check_whether_skip && return 0
1804 log "run for 4MB test file"
1807 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
1808 check_whether_skip && return 0
1809 log "run for 40MB test file"
1812 run_test 23 "Quota should be honored with directIO (b16125)"
1816 local TESTFILE="$DIR/$tdir/$tfile"
1819 trap cleanup_quota_test EXIT
1821 set_ost_qtype "ug" || error "enable ost quota failed"
1823 # bind file to a single OST
1824 $LFS setstripe -c 1 $TESTFILE
1825 chown $TSTUSR.$TSTUSR $TESTFILE
1827 echo "Set user quota (limit: "$blimit"M)"
1828 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1829 error "set quota failed"
1831 # overrun quota by root user
1832 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
1833 error "write failure, expect success"
1834 cancel_lru_locks osc
1835 sync_all_data || true
1837 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1840 resetquota -u $TSTUSR
1842 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
1844 test_27a() { # b19612
1845 $LFS quota $TSTUSR $DIR &&
1846 error "lfs succeeded with no type, but should have failed"
1847 $LFS setquota $TSTUSR $DIR &&
1848 error "lfs succeeded with no type, but should have failed"
1851 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
1853 test_27b() { # b20200
1854 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1855 error "lfs setquota failed with uid argument"
1856 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1857 error "lfs stequota failed with gid argument"
1858 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
1859 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
1860 resetquota -u $TSTUSR
1861 resetquota -g $TSTUSR
1864 run_test 27b "lfs quota/setquota should handle user/group ID (b20200)"
1869 local TESTFILE="$DIR/$tdir/$tfile"
1873 trap cleanup_quota_test EXIT
1875 set_ost_qtype "u" || error "enable ost quota failed"
1877 $LFS setstripe $TESTFILE -i 0 -c 1
1878 chown $TSTUSR.$TSTUSR $TESTFILE
1880 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
1881 $MAX_IQ_TIME $DIR || error "set grace time failed"
1882 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
1883 error "set quota failed"
1884 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
1885 cancel_lru_locks osc
1887 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
1888 # over-quota flag has not yet settled since we do not trigger async
1889 # events based on grace time period expiration
1891 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 || true
1892 cancel_lru_locks osc
1893 # now over-quota flag should be settled and further writes should fail
1895 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
1896 error "grace times were reset"
1899 resetquota -u $TSTUSR
1900 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1901 $MAX_IQ_TIME $DIR || error "restore grace time failed"
1903 run_test 30 "Hard limit updates should not reset grace times"
1905 # basic usage tracking for user & group
1907 local INODES=10 # 10 files
1908 local BLK_CNT=2 # of 2M each
1909 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
1912 trap cleanup_quota_test EXIT
1914 # make sure the system is clean
1915 local USED=$(getquota -u $TSTID global curspace)
1917 error "Used space ($USED) for user $TSTID isn't 0."
1918 USED=$(getquota -g $TSTID global curspace)
1920 error "Used space ($USED) for group $TSTID isn't 0."
1922 echo "Write files..."
1923 for i in `seq 0 $INODES`; do
1924 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
1925 error "write failed"
1926 echo "Iteration $i/$INODES completed"
1928 cancel_lru_locks osc
1929 sync; sync_all_data || true
1931 echo "Verify disk usage after write"
1932 USED=$(getquota -u $TSTID global curspace)
1933 [ $USED -lt $TOTAL_BLKS ] &&
1934 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
1935 USED=$(getquota -g $TSTID global curspace)
1936 [ $USED -lt $TOTAL_BLKS ] &&
1937 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
1939 echo "Verify inode usage after write"
1940 USED=$(getquota -u $TSTID global curinodes)
1941 [ $USED -lt $INODES ] &&
1942 error "Used inode for user $TSTID is $USED, expected $INODES"
1943 USED=$(getquota -g $TSTID global curinodes)
1944 [ $USED -lt $INODES ] &&
1945 error "Used inode for group $TSTID is $USED, expected $INODES"
1949 echo "Verify disk usage after delete"
1950 USED=$(getquota -u $TSTID global curspace)
1951 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
1952 USED=$(getquota -u $TSTID global curinodes)
1953 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
1954 USED=$(getquota -g $TSTID global curspace)
1955 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
1956 USED=$(getquota -g $TSTID global curinodes)
1957 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
1959 run_test 33 "Basic usage tracking for user & group"
1961 # usage transfer test for user & group
1963 local BLK_CNT=2 # 2MB
1966 trap cleanup_quota_test EXIT
1968 # make sure the system is clean
1969 local USED=$(getquota -u $TSTID global curspace)
1970 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
1971 USED=$(getquota -g $TSTID global curspace)
1972 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
1974 echo "Write file..."
1975 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
1976 error "write failed"
1977 cancel_lru_locks osc
1978 sync; sync_all_data || true
1980 echo "chown the file to user $TSTID"
1981 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
1983 echo "Wait for setattr on objects finished..."
1984 wait_delete_completed
1986 BLK_CNT=$((BLK_CNT * 1024))
1988 echo "Verify disk usage for user $TSTID"
1989 USED=$(getquota -u $TSTID global curspace)
1990 [ $USED -lt $BLK_CNT ] &&
1991 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
1992 USED=$(getquota -u $TSTID global curinodes)
1994 error "Used inodes for user $TSTID is $USED, expected 1"
1996 echo "chgrp the file to group $TSTID"
1997 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
1999 echo "Wait for setattr on objects finished..."
2000 wait_delete_completed
2002 echo "Verify disk usage for group $TSTID"
2003 USED=$(getquota -g $TSTID global curspace)
2004 [ $USED -ge $BLK_CNT ] ||
2005 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2006 USED=$(getquota -g $TSTID global curinodes)
2008 error "Used inodes for group $TSTID is $USED, expected 1"
2012 run_test 34 "Usage transfer for user & group"
2014 # usage is still accessible across restart
2016 local BLK_CNT=2 # 2 MB
2019 trap cleanup_quota_test EXIT
2021 echo "Write file..."
2022 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2023 error "write failed"
2024 cancel_lru_locks osc
2025 sync; sync_all_data || true
2027 echo "Save disk usage before restart"
2028 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2029 [ $ORIG_USR_SPACE -eq 0 ] &&
2030 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2031 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2032 [ $ORIG_USR_INODES -eq 0 ] &&
2033 error "Used inodes for user $TSTID is 0, expected 1"
2034 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2035 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2036 [ $ORIG_GRP_SPACE -eq 0 ] &&
2037 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2038 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2039 [ $ORIG_GRP_INODES -eq 0 ] &&
2040 error "Used inodes for group $TSTID is 0, expected 1"
2041 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2044 local ORIG_REFORMAT=$REFORMAT
2046 cleanup_and_setup_lustre
2047 REFORMAT=$ORIG_REFORMAT
2050 echo "Verify disk usage after restart"
2051 local USED=$(getquota -u $TSTID global curspace)
2052 [ $USED -eq $ORIG_USR_SPACE ] ||
2053 error "Used space for user $TSTID changed from " \
2054 "$ORIG_USR_SPACE to $USED"
2055 USED=$(getquota -u $TSTID global curinodes)
2056 [ $USED -eq $ORIG_USR_INODES ] ||
2057 error "Used inodes for user $TSTID changed from " \
2058 "$ORIG_USR_INODES to $USED"
2059 USED=$(getquota -g $TSTID global curspace)
2060 [ $USED -eq $ORIG_GRP_SPACE ] ||
2061 error "Used space for group $TSTID changed from " \
2062 "$ORIG_GRP_SPACE to $USED"
2063 USED=$(getquota -g $TSTID global curinodes)
2064 [ $USED -eq $ORIG_GRP_INODES ] ||
2065 error "Used inodes for group $TSTID changed from " \
2066 "$ORIG_GRP_INODES to $USED"
2068 # check if the vfs_dq_init() is called before writing
2069 echo "Append to the same file..."
2070 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2071 error "write failed"
2072 cancel_lru_locks osc
2073 sync; sync_all_data || true
2075 echo "Verify space usage is increased"
2076 USED=$(getquota -u $TSTID global curspace)
2077 [ $USED -gt $ORIG_USR_SPACE ] ||
2078 error "Used space for user $TSTID isn't increased" \
2079 "orig:$ORIG_USR_SPACE, now:$USED"
2080 USED=$(getquota -g $TSTID global curspace)
2081 [ $USED -gt $ORIG_GRP_SPACE ] ||
2082 error "Used space for group $TSTID isn't increased" \
2083 "orig:$ORIG_GRP_SPACE, now:$USED"
2087 run_test 35 "Usage is still accessible across reboot"
2089 # test migrating old amdin quota files (in Linux quota file format v2) into new
2090 # quota global index (in IAM format)
2092 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] && \
2093 skip "skipping migration test" && return
2095 # get the mdt0 device name
2096 local mdt0_node=$(facet_active_host $SINGLEMDS)
2097 local mdt0_dev=$(mdsdevname ${SINGLEMDS//mds/})
2102 echo "Copy admin quota files into MDT0..."
2103 local mntpt=$(facet_mntpt $SINGLEMDS)
2104 local mdt0_fstype=$(facet_fstype $SINGLEMDS)
2106 if ! do_node $mdt0_node test -b $mdt0_fstype; then
2109 echo "$mdt0_node, $mdt0_dev, $mntpt, $opt"
2110 do_node $mdt0_node mount -t $mdt0_fstype $opt $mdt0_dev $mntpt
2111 do_node $mdt0_node mkdir $mntpt/OBJECTS
2112 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.usr $mntpt/OBJECTS
2113 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.grp $mntpt/OBJECTS
2114 do_node $mdt0_node umount -f $mntpt
2119 echo "Verify global limits..."
2123 local proc="qmt.*.md-0x0.glb-usr"
2124 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2125 [ $id_cnt -eq 403 ] || error "Migrate inode user limit failed: $id_cnt"
2126 limit=$(getquota -u 1 global isoftlimit)
2127 [ $limit -eq 1024 ] || error "User inode softlimit: $limit"
2128 limit=$(getquota -u 1 global ihardlimit)
2129 [ $limit -eq 2048 ] || error "User inode hardlimit: $limit"
2131 proc="qmt.*.md-0x0.glb-grp"
2132 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2133 [ $id_cnt -eq 403 ] || error "Migrate inode group limit failed: $id_cnt"
2134 limit=$(getquota -g 1 global isoftlimit)
2135 [ $limit -eq 1024 ] || error "Group inode softlimit: $limit"
2136 limit=$(getquota -g 1 global ihardlimit)
2137 [ $limit -eq 2048 ] || error "Group inode hardlimit: $limit"
2139 proc=" qmt.*.dt-0x0.glb-usr"
2140 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2141 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2142 limit=$(getquota -u 60001 global bsoftlimit)
2143 [ $limit -eq 10485760 ] || error "User block softlimit: $limit"
2144 limit=$(getquota -u 60001 global bhardlimit)
2145 [ $limit -eq 20971520 ] || error "User block hardlimit: $limit"
2147 proc="qmt.*.dt-0x0.glb-grp"
2148 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2149 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2150 limit=$(getquota -g 60001 global bsoftlimit)
2151 [ $limit -eq 10485760 ] || error "Group block softlimit: $limit"
2152 limit=$(getquota -g 60001 global bhardlimit)
2153 [ $limit -eq 20971520 ] || error "Group block hardlimit: $limit"
2159 run_test 36 "Migrate old admin files into new global indexes"
2163 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
2169 check_and_cleanup_lustre
2170 export QUOTA_AUTO=$QUOTA_AUTO_OLD