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 "summary" | awk '{print $4}')
371 [ $free_space -le $((MB * 1024)) ] &&
372 skip "not enough space ${free_space} KB, " \
373 "required $((MB * 1024)) KB" && return
375 trap cleanup_quota_test EXIT
377 set_ost_qtype "none" || error "disable ost quota failed"
378 test_quota_performance $MB
380 set_ost_qtype "ug" || error "enable ost quota failed"
381 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
382 error "set quota failed"
383 test_quota_performance $MB
386 resetquota -u $TSTUSR
388 run_test 0 "Test basic quota performance"
390 # test block hardlimit
393 local TESTFILE="$DIR/$tdir/$tfile-0"
396 trap cleanup_quota_test EXIT
399 set_ost_qtype "ug" || "enable ost quota failed"
402 log "User quota (block hardlimit:$LIMIT MB)"
403 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
404 error "set user quota failed"
406 # make sure the system is clean
407 local USED=$(getquota -u $TSTUSR global curspace)
408 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
410 $LFS setstripe $TESTFILE -c 1
411 chown $TSTUSR.$TSTUSR $TESTFILE
414 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
415 quota_error u $TSTUSR "user write failure, but expect success"
416 log "Write out of block quota ..."
417 # this time maybe cache write, ignore it's failure
418 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
419 # flush cache, ensure noquota flag is set on client
421 $RUNAS $DD of=$TESTFILE count=1 seek=$LIMIT &&
422 quota_error u $TSTUSR "user write success, but expect EDQUOT"
425 wait_delete_completed
426 sync_all_data || true
427 USED=$(getquota -u $TSTUSR global curspace)
428 [ $USED -ne 0 ] && quota_error u $TSTUSR \
429 "user quota isn't released after deletion"
430 resetquota -u $TSTUSR
433 log "--------------------------------------"
434 log "Group quota (block hardlimit:$LIMIT MB)"
435 $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
436 error "set group quota failed"
438 TESTFILE="$DIR/$tdir/$tfile-1"
439 # make sure the system is clean
440 USED=$(getquota -g $TSTUSR global curspace)
441 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0"
443 $LFS setstripe $TESTFILE -c 1
444 chown $TSTUSR.$TSTUSR $TESTFILE
447 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
448 quota_error g $TSTUSR "group write failure, but expect success"
449 log "Write out of block quota ..."
450 # this time maybe cache write, ignore it's failure
451 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
453 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT &&
454 quota_error g $TSTUSR "group write success, but expect EDQUOT"
459 USED=$(getquota -g $TSTUSR global curspace)
460 [ $USED -ne 0 ] && quota_error g $TSTUSR \
461 "group quota isn't released after deletion"
463 resetquota -g $TSTUSR
465 run_test 1 "Block hard limit (normal use and out of quota)"
467 # test inode hardlimit
469 local LIMIT=$((1024 * 1024)) # 1M inodes
470 local TESTFILE="$DIR/$tdir/$tfile-0"
472 [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes
474 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
475 [ $FREE_INODES -lt $LIMIT ] &&
476 skip "not enough free inodes $FREE_INODES required $LIMIT" &&
480 trap cleanup_quota_test EXIT
483 set_mdt_qtype "ug" || "enable mdt quota failed"
486 log "User quota (inode hardlimit:$LIMIT files)"
487 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
488 error "set user quota failed"
490 # make sure the system is clean
491 local USED=$(getquota -u $TSTUSR global curinodes)
492 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
494 log "Create $LIMIT files ..."
495 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
496 quota_error u $TSTUSR "user create failure, but expect success"
497 log "Create out of file quota ..."
498 $RUNAS touch ${TESTFILE}_xxx && \
499 quota_error u $TSTUSR "user create success, but expect EDQUOT"
502 unlinkmany ${TESTFILE} $LIMIT
503 rm -f ${TESTFILE}_xxx
504 wait_delete_completed
506 USED=$(getquota -u $TSTUSR global curinodes)
507 [ $USED -ne 0 ] && quota_error u $TSTUSR \
508 "user quota isn't released after deletion"
509 resetquota -u $TSTUSR
512 log "--------------------------------------"
513 log "Group quota (inode hardlimit:$LIMIT files)"
514 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
515 error "set group quota failed"
517 TESTFILE=$DIR/$tdir/$tfile-1
518 # make sure the system is clean
519 USED=$(getquota -g $TSTUSR global curinodes)
520 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
522 log "Create $LIMIT files ..."
523 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
524 quota_error g $TSTUSR "group create failure, but expect success"
525 log "Create out of file quota ..."
526 $RUNAS touch ${TESTFILE}_xxx && \
527 quota_error g $TSTUSR "group create success, but expect EDQUOT"
530 unlinkmany ${TESTFILE} $LIMIT
531 rm -f ${TESTFILE}_xxx
532 wait_delete_completed
534 USED=$(getquota -g $TSTUSR global curinodes)
535 [ $USED -ne 0 ] && quota_error g $TSTUSR \
536 "user quota isn't released after deletion"
539 resetquota -g $TSTUSR
541 run_test 2 "File hard limit (normal use and out of quota)"
545 local TIMER=$(($2 * 3 / 2))
550 trap cleanup_quota_test EXIT
552 $LFS setstripe $TESTFILE -c 1 -i 0
553 chown $TSTUSR.$TSTUSR $TESTFILE
555 echo "Write up to soft limit"
556 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
557 quota_error a $TSTUSR "write failure, but expect success"
558 OFFSET=$((LIMIT * 1024))
561 echo "Write to exceed soft limit"
562 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
563 quota_error a $TSTUSR "write failure, but expect success"
564 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
569 $SHOW_QUOTA_INFO_USER
570 $SHOW_QUOTA_INFO_GROUP
572 echo "Write before timer goes off"
573 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
574 quota_error a $TSTUSR "write failure, but expect success"
575 OFFSET=$((OFFSET + 1024))
578 echo "Sleep $TIMER seconds ..."
583 $SHOW_QUOTA_INFO_USER
584 $SHOW_QUOTA_INFO_GROUP
586 echo "Write after timer goes off"
587 # maybe cache write, ignore.
588 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET || true
589 OFFSET=$((OFFSET + 1024))
591 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET &&
592 quota_error a $TSTUSR "write success, but expect EDQUOT"
596 $SHOW_QUOTA_INFO_USER
597 $SHOW_QUOTA_INFO_GROUP
599 echo "Unlink file to stop timer"
601 wait_delete_completed
602 sync_all_data || true
606 $SHOW_QUOTA_INFO_USER
607 $SHOW_QUOTA_INFO_GROUP
609 $LFS setstripe $TESTFILE -c 1 -i 0
610 chown $TSTUSR.$TSTUSR $TESTFILE
613 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
614 quota_error a $TSTUSR "write failure, but expect success"
623 local TESTFILE=$DIR/$tdir/$tfile-0
625 set_ost_qtype "ug" || error "enable ost quota failed"
627 echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
628 # make sure the system is clean
629 local USED=$(getquota -u $TSTUSR global curspace)
630 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
632 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
633 $MAX_IQ_TIME $DIR || error "set user grace time failed"
634 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
635 error "set user quota failed"
637 test_block_soft $TESTFILE $GRACE $LIMIT
638 resetquota -u $TSTUSR
640 echo "Group quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
641 TESTFILE=$DIR/$tdir/$tfile-1
642 # make sure the system is clean
643 USED=$(getquota -g $TSTUSR global curspace)
644 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
646 $LFS setquota -t -g --block-grace $GRACE --inode-grace \
647 $MAX_IQ_TIME $DIR || error "set group grace time failed"
648 $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
649 error "set group quota failed"
651 test_block_soft $TESTFILE $GRACE $LIMIT
652 resetquota -g $TSTUSR
655 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
656 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
657 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
658 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
660 run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
665 local TIMER=$(($3 * 3 / 2))
668 trap cleanup_quota_test EXIT
670 echo "Create files to exceed soft limit"
671 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
672 quota_error a $TSTUSR "create failure, but expect success"
675 echo "Create file before timer goes off"
676 $RUNAS touch ${TESTFILE}_before ||
677 quota_error a $TSTUSR "failed create before timer expired," \
681 echo "Sleep $TIMER seconds ..."
686 $SHOW_QUOTA_INFO_USER
687 $SHOW_QUOTA_INFO_GROUP
689 echo "Create file after timer goes off"
690 # There is a window that space is accounted in the quota usage but
691 # hasn't been decreased from the pending write, if we acquire quota
692 # in this window, we'll acquire more than we needed.
693 $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
695 $RUNAS touch ${TESTFILE}_after_3 &&
696 quota_error a $TSTUSR "create after timer expired," \
702 $SHOW_QUOTA_INFO_USER
703 $SHOW_QUOTA_INFO_GROUP
705 echo "Unlink files to stop timer"
706 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
707 wait_delete_completed
710 $RUNAS touch ${TESTFILE}_xxx ||
711 quota_error a $TSTUSR "touch after timer stop failure," \
721 local LIMIT=10 # inodes
722 local TESTFILE=$DIR/$tdir/$tfile-0
725 set_mdt_qtype "ug" || error "enable mdt quota failed"
727 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
728 # make sure the system is clean
729 local USED=$(getquota -u $TSTUSR global curinodes)
730 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
732 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
733 $GRACE $DIR || error "set user grace time failed"
734 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
735 error "set user quota failed"
737 test_file_soft $TESTFILE $LIMIT $GRACE
738 resetquota -u $TSTUSR
740 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
741 # make sure the system is clean
742 USED=$(getquota -g $TSTUSR global curinodes)
743 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
745 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
746 $GRACE $DIR || error "set group grace time failed"
747 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
748 error "set group quota failed"
749 TESTFILE=$DIR/$tdir/$tfile-1
751 test_file_soft $TESTFILE $LIMIT $GRACE
752 resetquota -g $TSTUSR
755 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
756 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
757 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
758 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
760 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
764 local GR_STR2="1000s"
766 local GR_STR4="1w2d3h4m5s"
768 local GR_STR6="1111111111111111"
770 wait_delete_completed
772 # test of valid grace strings handling
773 echo "Valid grace strings test"
774 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
775 $GR_STR2 $DIR || error "set user grace time failed"
776 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
777 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
778 $GR_STR4 $DIR || error "set group grace time quota failed"
779 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
781 # test of invalid grace strings handling
782 echo " Invalid grace strings test"
783 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
784 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
787 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
788 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
789 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
790 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
792 run_test 4b "Grace time strings handling"
794 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
796 local BLIMIT=10 # 10M
797 local ILIMIT=10 # 10 inodes
800 trap cleanup_quota_test EXIT
802 set_mdt_qtype "ug" || error "enable mdt quota failed"
803 set_ost_qtype "ug" || error "enable ost quota failed"
805 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
806 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
807 error "set user quota failed"
808 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
809 error "set group quota failed"
811 # make sure the system is clean
812 local USED=$(getquota -u $TSTUSR global curinodes)
813 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
814 USED=$(getquota -g $TSTUSR global curinodes)
815 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
816 USED=$(getquota -u $TSTUSR global curspace)
817 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
818 USED=$(getquota -g $TSTUSR global curspace)
819 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
821 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
822 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
823 error "create failure, expect success"
824 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
825 error "write failure, expect success"
827 echo "Chown files to $TSTUSR.$TSTUSR ..."
828 for i in `seq 0 $ILIMIT`; do
829 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
830 quota_error a $TSTUSR "chown failure, expect success"
834 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
837 resetquota -u $TSTUSR
838 resetquota -g $TSTUSR
840 run_test 5 "Chown & chgrp successfully even out of block/file quota"
842 # test dropping acquire request on master
847 trap cleanup_quota_test EXIT
849 # make sure the system is clean
850 local USED=$(getquota -u $TSTUSR global curspace)
851 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
853 # make sure no granted quota on ost
854 set_ost_qtype "ug" || error "enable ost quota failed"
855 resetquota -u $TSTUSR
857 # create file for $TSTUSR
858 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
859 $LFS setstripe $TESTFILE -c 1 -i 0
860 chown $TSTUSR.$TSTUSR $TESTFILE
862 # create file for $TSTUSR2
863 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
864 $LFS setstripe $TESTFILE2 -c 1 -i 0
865 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
867 # cache per-ID lock for $TSTUSR on slave
868 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
869 error "set quota failed"
870 $RUNAS $DD of=$TESTFILE count=1 ||
871 error "write $TESTFILE failure, expect success"
872 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
873 error "write $TESTFILE2 failure, expect success"
875 sync_all_data || true
877 #define QUOTA_DQACQ 601
878 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
879 lustre_fail mds 0x513 601
881 # write to un-enforced ID ($TSTUSR2) should succeed
882 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
883 error "write failure, expect success"
885 # write to enforced ID ($TSTUSR) in background, exceeding limit
886 # to make sure DQACQ is sent
887 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
890 # watchdog timer uses a factor of 2
891 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
892 sleep $((TIMEOUT * 2 + 1))
894 # write should be blocked and never finished
895 if ! ps -p $DDPID > /dev/null 2>&1; then
897 error "write finished incorrectly!"
902 # no watchdog is triggered
903 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
904 watchdog=$(awk '/sanity-quota test 6/ {start = 1;}
905 /Service thread pid/ && /was inactive/ {
909 }' $TMP/lustre-log-${TESTNAME}.log)
910 [ -z "$watchdog" ] || error "$watchdog"
912 rm -f $TMP/lustre-log-${TESTNAME}.log
914 # write should continue & succeed
917 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
918 if [ $count -ge 120 ]; then
919 quota_error u $TSTUSR "dd not finished in $count secs"
922 [ $((count % 10)) -eq 0 ] && echo "Waiting $count secs"
927 resetquota -u $TSTUSR
929 run_test 6 "Test dropping acquire request on master"
931 # quota reintegration (global index)
933 local TESTFILE=$DIR/$tdir/$tfile
936 [ "$SLOW" = "no" ] && LIMIT=5
939 trap cleanup_quota_test EXIT
941 # make sure the system is clean
942 local USED=$(getquota -u $TSTUSR global curspace)
943 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
945 # make sure no granted quota on ost1
946 set_ost_qtype "ug" || error "enable ost quota failed"
947 resetquota -u $TSTUSR
948 set_ost_qtype "none" || error "disable ost quota failed"
950 local OSTUUID=$(ostuuid_from_index 0)
951 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
952 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
956 $LFS setstripe $TESTFILE -c 1 -i 0
957 chown $TSTUSR.$TSTUSR $TESTFILE
962 echo "Enable quota & set quota limit for $TSTUSR"
963 set_ost_qtype "ug" || error "enable ost quota failed"
964 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
965 error "set quota failed"
968 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
971 wait_ost_reint "ug" || error "reintegration failed"
973 # hardlimit should have been fetched by slave during global
974 # reintegration, write will exceed quota
975 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
976 quota_error u $TSTUSR "write success, but expect EDQUOT"
979 wait_delete_completed
980 sync_all_data || true
986 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
987 error "clear quota failed"
990 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
1054 wait_ost_reint "ug" || error "reintegration failed"
1056 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1057 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1060 resetquota -u $TSTUSR
1063 run_test 7b "Quota reintegration (slave index)"
1065 # quota reintegration (restart mds during reintegration)
1067 local LIMIT=20 # 20M
1068 local TESTFILE=$DIR/$tdir/$tfile
1070 [ "$SLOW" = "no" ] && LIMIT=5
1073 trap cleanup_quota_test EXIT
1075 # make sure the system is clean
1076 local USED=$(getquota -u $TSTUSR global curspace)
1077 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1079 set_ost_qtype "none" || error "disable ost quota failed"
1080 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1081 error "set quota failed"
1083 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1084 lustre_fail ost 0xa03
1086 # enable ost quota to trigger reintegration
1087 set_ost_qtype "ug" || error "enable ost quota failed"
1095 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1098 wait_ost_reint "ug" || error "reintegration failed"
1100 # hardlimit should have been fetched by slave during global
1101 # reintegration, write will exceed quota
1102 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1103 quota_error u $TSTUSR "write success, but expect EDQUOT"
1106 resetquota -u $TSTUSR
1108 run_test 7c "Quota reintegration (restart mds during reintegration)"
1110 # Quota reintegration (Transfer index in multiple bulks)
1112 local TESTFILE=$DIR/$tdir/$tfile
1113 local TESTFILE1="$DIR/$tdir/$tfile"-1
1117 trap cleanup_quota_test EXIT
1119 set_ost_qtype "none" || error "disable ost quota failed"
1120 # LU-2284. Enable trace for debug log.
1121 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+trace"
1122 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1123 error "set quota for $TSTUSR failed"
1124 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1125 error "set quota for $TSTUSR2 failed"
1126 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-trace"
1128 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1129 lustre_fail mds 0x608 0
1131 # enable quota to tirgger reintegration
1132 set_ost_qtype "u" || error "enable ost quota failed"
1133 wait_ost_reint "u" || error "reintegration failed"
1137 # hardlimit should have been fetched by slave during global
1138 # reintegration, write will exceed quota
1139 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1140 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1142 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1143 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1146 resetquota -u $TSTUSR
1147 resetquota -u $TSTUSR2
1149 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1151 # run dbench with quota enabled
1153 local BLK_LIMIT="100g" #100G
1154 local FILE_LIMIT=1000000
1157 trap cleanup_quota_test EXIT
1159 set_mdt_qtype "ug" || error "enable mdt quota failed"
1160 set_ost_qtype "ug" || error "enable ost quota failed"
1162 echo "Set enough high limit for user: $TSTUSR"
1163 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1164 error "set user quota failed"
1165 echo "Set enough high limit for group: $TSTUSR"
1166 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1167 error "set group quota failed"
1170 [ "$SLOW" = "no" ] && duration=" -t 120"
1171 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1172 quota_error a $TSTUSR "dbench failed!"
1175 resetquota -u $TSTUSR
1176 resetquota -g $TSTUSR
1178 run_test 8 "Run dbench with quota enabled"
1180 # this check is just for test_9
1181 OST0_MIN=4900000 #4.67G
1183 check_whether_skip () {
1184 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1185 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1186 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1187 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1194 # run for fixing bug10707, it needs a big room. test for 64bit
1196 local filesize=$((1024 * 1024 * 1024 * 9 / 2)) # 4.5G
1198 check_whether_skip && return 0
1201 trap cleanup_quota_test EXIT
1203 set_ost_qtype "ug" || error "enable ost quota failed"
1205 local TESTFILE="$DIR/$tdir/$tfile-0"
1206 local BLK_LIMIT=100G #100G
1207 local FILE_LIMIT=1000000
1209 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1211 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1213 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1214 error "set user quota failed"
1216 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1217 "for group: $TSTUSR"
1218 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1219 error "set group quota failed"
1221 quota_show_check a u $TSTUSR
1222 quota_show_check a g $TSTUSR
1224 echo "Create test file"
1225 $LFS setstripe $TESTFILE -c 1 -i 0
1226 chown $TSTUSR.$TSTUSR $TESTFILE
1228 log "Write the big file of 4.5G ..."
1229 $RUNAS $DD of=$TESTFILE count=$filesize ||
1230 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1236 resetquota -u $TSTUSR
1237 resetquota -g $TSTUSR
1242 run_test 9 "Block limit larger than 4GB (b10707)"
1245 local TESTFILE=$DIR/$tdir/$tfile
1248 trap cleanup_quota_test EXIT
1250 # set limit to root user should fail
1251 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1252 error "set limit for root user successfully, expect failure"
1253 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1254 error "set limit for root group successfully, expect failure"
1256 # root user can overrun quota
1257 set_ost_qtype "ug" || "enable ost quota failed"
1259 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1260 error "set quota failed"
1261 quota_show_check b u $TSTUSR
1263 $LFS setstripe $TESTFILE -c 1
1264 chown $TSTUSR.$TSTUSR $TESTFILE
1266 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1267 error "write failure, expect success"
1270 resetquota -u $TSTUSR
1272 run_test 10 "Test quota for root user"
1275 local TESTFILE=$DIR/$tdir/$tfile
1277 trap cleanup_quota_test EXIT
1279 set_mdt_qtype "ug" || "enable mdt quota failed"
1280 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1281 error "set quota failed"
1286 chown $TSTUSR.$TSTUSR "$TESTFILE"-0
1287 chown $TSTUSR.$TSTUSR "$TESTFILE"-1
1290 local USED=$(getquota -u $TSTUSR global curinodes)
1291 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1294 resetquota -u $TSTUSR
1296 run_test 11 "Chown/chgrp ignores quota"
1299 [ "$OSTCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return
1301 local blimit=22 # 22M
1302 local blk_cnt=$((blimit - 5))
1303 local TESTFILE0="$DIR/$tdir/$tfile"-0
1304 local TESTFILE1="$DIR/$tdir/$tfile"-1
1307 trap cleanup_quota_test EXIT
1309 set_ost_qtype "u" || "enable ost quota failed"
1310 quota_show_check b u $TSTUSR
1312 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1313 error "set quota failed"
1315 $LFS setstripe $TESTFILE0 -c 1 -i 0
1316 $LFS setstripe $TESTFILE1 -c 1 -i 1
1317 chown $TSTUSR.$TSTUSR $TESTFILE0
1318 chown $TSTUSR.$TSTUSR $TESTFILE1
1320 echo "Write to ost0..."
1321 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1322 quota_error a $TSTUSR "dd failed"
1324 echo "Write to ost1..."
1325 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1326 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1328 echo "Free space from ost0..."
1330 wait_delete_completed
1331 sync_all_data || true
1333 echo "Write to ost1 after space freed from ost0..."
1334 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1335 quota_error a $TSTUSR "rebalancing failed"
1338 resetquota -u $TSTUSR
1340 run_test 12 "Block quota rebalancing"
1343 local TESTFILE=$DIR/$tdir/$tfile
1344 # the name of osp on ost1 name is MDT0000-osp-OST0000
1345 local procf="ldlm.namespaces.*MDT0000-osp-OST0000.lru_size"
1348 trap cleanup_quota_test EXIT
1350 set_ost_qtype "u" || "enable ost quota failed"
1351 quota_show_check b u $TSTUSR
1353 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1354 error "set quota failed"
1355 $LFS setstripe $TESTFILE -c 1 -i 0
1356 chown $TSTUSR.$TSTUSR $TESTFILE
1358 # clear the locks in cache first
1359 do_facet ost1 $LCTL set_param -n $procf=clear
1360 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1361 [ $nlock -eq 0 ] || error "$nlock cached locks"
1363 # write to acquire the per-ID lock
1364 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1365 quota_error a $TSTUSR "dd failed"
1367 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1368 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1370 # clear quota doesn't trigger per-ID lock cancellation
1371 resetquota -u $TSTUSR
1372 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1373 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1375 # clear the per-ID lock
1376 do_facet ost1 $LCTL set_param -n $procf=clear
1377 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1378 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1380 # spare quota should be released
1381 local OSTUUID=$(ostuuid_from_index 0)
1382 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1383 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1384 [ $limit -le $space ] ||
1385 error "spare quota isn't released, limit:$limit, space:$space"
1389 run_test 13 "Cancel per-ID lock in the LRU list"
1392 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1394 wait_delete_completed
1395 sync_all_data || true
1398 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1399 error "set user quota failed"
1400 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1401 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1402 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1403 resetquota -u $TSTUSR
1406 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1407 error "set group quota failed"
1408 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1409 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1410 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1411 resetquota -g $TSTUSR
1413 run_test 15 "Set over 4T block quota"
1417 local BLKS=1 # 1M less than limit
1418 local TESTFILE=$DIR/$tdir/$tfile
1421 trap cleanup_quota_test EXIT
1423 # make sure the system is clean
1424 local USED=$(getquota -u $TSTUSR global curspace)
1425 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1427 set_ost_qtype "ug" || error "enable ost quota failed"
1428 # make sure no granted quota on ost
1429 resetquota -u $TSTUSR
1430 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1431 error "set quota failed"
1433 quota_show_check b u $TSTUSR
1435 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1436 lustre_fail mds 0xa04 $err_code
1438 # write in background
1439 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1443 # write should be blocked and never finished
1444 if ! ps -p $DDPID > /dev/null 2>&1; then
1446 quota_error u $TSTUSR "write finished incorrectly!"
1454 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1456 if [ $count -gt $timeout ]; then
1457 quota_error u $TSTUSR "dd is not finished!"
1462 sync; sync_all_data || true
1464 USED=$(getquota -u $TSTUSR global curspace)
1465 [ $USED -ge $(($BLKS * 1024)) ] || quota_error u $TSTUSR \
1466 "Used space(${USED}K) is less than ${BLKS}M"
1469 resetquota -u $TSTUSR
1472 # DQACQ return recoverable error
1474 echo "DQACQ return -ENOLCK"
1476 test_17sub 37 || error "Handle -ENOLCK failed"
1478 echo "DQACQ return -EAGAIN"
1480 test_17sub 11 || error "Handle -EAGAIN failed"
1482 echo "DQACQ return -ETIMEDOUT"
1483 #define ETIMEDOUT 110
1484 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1486 echo "DQACQ return -ENOTCONN"
1487 #define ENOTCONN 107
1488 test_17sub 107 || error "Handle -ENOTCONN failed"
1491 run_test 17 "DQACQ return recoverable error"
1495 local blimit="200m" # 200M
1496 local TESTFILE="$DIR/$tdir/$tfile"
1499 trap cleanup_quota_test EXIT
1501 set_ost_qtype "u" || error "enable ost quota failed"
1502 log "User quota (limit: $blimit)"
1503 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1504 error "set quota failed"
1505 quota_show_check b u $TSTUSR
1507 $LFS setstripe $TESTFILE -i 0 -c 1
1508 chown $TSTUSR.$TSTUSR $TESTFILE
1510 local timeout=$(sysctl -n lustre.timeout)
1512 if [ $io_type = "directio" ]; then
1513 log "Write 100M (directio) ..."
1514 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1516 log "Write 100M (buffered) ..."
1517 $RUNAS $DD of=$TESTFILE count=100 &
1521 replay_barrier $SINGLEMDS
1522 log "Fail mds for $((2 * timeout)) seconds"
1523 fail $SINGLEMDS $((2 * timeout))
1526 if at_is_enabled; then
1527 timeout=$(at_max_get mds)
1529 timeout=$(lctl get_param -n timeout)
1533 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1534 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1535 log "it took $count second"
1540 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1542 cancel_lru_locks mdc
1543 cancel_lru_locks osc
1546 local testfile_size=$(stat -c %s $TESTFILE)
1547 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1548 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)),"
1549 "got ${testfile_size}. Verifying file failed!"
1552 resetquota -u $TSTUSR
1555 # test when mds does failover, the ost still could work well
1556 # this test shouldn't trigger watchdog b=14840
1559 test_18_sub directio
1561 # check if watchdog is triggered
1562 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1563 local watchdog=$(awk '/sanity-quota test 18/ {start = 1;}
1564 /Service thread pid/ && /was inactive/ {
1568 }' $TMP/lustre-log-${TESTNAME}.log)
1569 [ -z "$watchdog" ] || error "$watchdog"
1570 rm -f $TMP/lustre-log-${TESTNAME}.log
1572 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1576 local TESTFILE=$DIR/$tdir/$tfile
1579 trap cleanup_quota_test EXIT
1581 set_ost_qtype "ug" || error "enable ost quota failed"
1583 # bind file to a single OST
1584 $LFS setstripe -c 1 $TESTFILE
1585 chown $TSTUSR.$TSTUSR $TESTFILE
1587 echo "Set user quota (limit: "$blimit"M)"
1588 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1589 error "set user quota failed"
1590 quota_show_check b u $TSTUSR
1591 echo "Update quota limits"
1592 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1593 error "set group quota failed"
1594 quota_show_check b u $TSTUSR
1596 # first wirte might be cached
1597 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
1598 cancel_lru_locks osc
1600 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
1601 quota_error u $TSTUSR "Write success, expect failure"
1605 resetquota -u $TSTUSR
1607 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
1609 test_20() { # b15754
1610 local LSTR=(2g 1t 4k 3m) # limits strings
1612 local LVAL=($[2*1024*1024] $[1*1024*1024*1024] $[4*1024] $[3*1024*1024])
1614 resetquota -u $TSTUSR
1616 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1617 $MOUNT || error "could not set quota limits"
1618 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1619 --inode-softlimit ${LSTR[2]} \
1620 --inode-hardlimit ${LSTR[3]} \
1621 $MOUNT || error "could not set quota limits"
1623 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
1624 error "bsoftlimit was not set properly"
1625 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
1626 error "bhardlimit was not set properly"
1627 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
1628 error "isoftlimit was not set properly"
1629 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
1630 error "ihardlimit was not set properly"
1632 resetquota -u $TSTUSR
1634 run_test 20 "Test if setquota specifiers work properly (b15754)"
1641 local time=$(($(date +%s) + seconds))
1642 while [ $(date +%s) -lt $time ]; do
1643 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
1647 # run for fixing bug16053, setquota shouldn't fail when writing and
1648 # deleting are happening
1650 local TESTFILE="$DIR/$tdir/$tfile"
1651 local BLIMIT=10 # 10G
1652 local ILIMIT=1000000
1655 trap cleanup_quota_test EXIT
1657 set_ost_qtype "ug" || error "Enable ost quota failed"
1659 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
1660 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
1661 error "set user quota failed"
1662 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
1663 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
1664 error "set group quota failed"
1666 # repeat writing on a 1M file
1667 test_21_sub ${TESTFILE}_1 1 30 &
1669 # repeat writing on a 128M file
1670 test_21_sub ${TESTFILE}_2 128 30 &
1673 local time=$(($(date +%s) + 30))
1675 while [ $(date +%s) -lt $time ]; do
1676 log "Set quota for $i times"
1677 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1678 -I $((ILIMIT + i)) $MOUNT ||
1679 error "Set user quota failed"
1680 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1681 -I $((ILIMIT + i)) $MOUNT ||
1682 error "Set group quota failed"
1689 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1691 if [ $count -gt 60 ]; then
1692 quota_error a $TSTUSR "dd should be finished!"
1696 echo "(dd_pid=$DDPID1, time=$count)successful"
1700 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1702 if [ $count -gt 60 ]; then
1703 quota_error a $TSTUSR "dd should be finished!"
1707 echo "(dd_pid=$DDPID2, time=$count)successful"
1710 resetquota -u $TSTUSR
1711 resetquota -g $TSTUSR
1713 run_test 21 "Setquota while writing & deleting (b16053)"
1715 # enable/disable quota enforcement permanently
1717 echo "Set both mdt & ost quota type as ug"
1718 set_mdt_qtype "ug" || error "enable mdt quota failed"
1719 set_ost_qtype "ug" || error "enable ost quota failed"
1726 echo "Verify if quota is enabled"
1727 local qtype=$(mdt_quota_type)
1728 [ $qtype != "ug" ] && error "mdt quota setting is lost"
1729 qtype=$(ost_quota_type)
1730 [ $qtype != "ug" ] && error "ost quota setting is lost"
1732 echo "Set both mdt & ost quota type as none"
1733 set_mdt_qtype "none" || error "disable mdt quota failed"
1734 set_ost_qtype "none" || error "disable ost quota failed"
1742 echo "Verify if quota is disabled"
1743 qtype=$(mdt_quota_type)
1744 [ $qtype != "none" ] && error "mdt quota setting is lost"
1745 qtype=$(ost_quota_type)
1746 [ $qtype != "none" ] && error "ost quota setting is lost"
1750 run_test 22 "enable/disable quota by 'lctl conf_param'"
1753 local TESTFILE="$DIR/$tdir/$tfile"
1757 trap cleanup_quota_test EXIT
1759 set_ost_qtype "ug" || error "Enable ost quota failed"
1762 log "User quota (limit: $LIMIT MB)"
1763 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
1764 error "set quota failed"
1765 quota_show_check b u $TSTUSR
1767 $LFS setstripe $TESTFILE -c 1 -i 0
1768 chown $TSTUSR.$TSTUSR $TESTFILE
1770 log "Step1: trigger EDQUOT with O_DIRECT"
1771 log "Write half of file"
1772 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
1773 quota_error u $TSTUSR "(1) Write failure, expect success." \
1775 log "Write out of block quota ..."
1776 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
1777 oflag=direct conv=notrunc &&
1778 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
1782 log "Step2: rewrite should succeed"
1783 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
1784 quota_error u $TSTUSR "(3) Write failure, expect success." \
1790 local OST0_UUID=$(ostuuid_from_index 0)
1791 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
1792 [ $OST0_QUOTA_USED -ne 0 ] &&
1793 ($SHOW_QUOTA_USER; \
1794 quota_error u $TSTUSR "quota isn't released")
1796 resetquota -u $TSTUSR
1800 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
1801 check_whether_skip && return 0
1802 log "run for 4MB test file"
1805 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
1806 check_whether_skip && return 0
1807 log "run for 40MB test file"
1810 run_test 23 "Quota should be honored with directIO (b16125)"
1814 local TESTFILE="$DIR/$tdir/$tfile"
1817 trap cleanup_quota_test EXIT
1819 set_ost_qtype "ug" || error "enable ost quota failed"
1821 # bind file to a single OST
1822 $LFS setstripe -c 1 $TESTFILE
1823 chown $TSTUSR.$TSTUSR $TESTFILE
1825 echo "Set user quota (limit: "$blimit"M)"
1826 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1827 error "set quota failed"
1829 # overrun quota by root user
1830 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
1831 error "write failure, expect success"
1832 cancel_lru_locks osc
1833 sync_all_data || true
1835 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1838 resetquota -u $TSTUSR
1840 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
1842 test_27a() { # b19612
1843 $LFS quota $TSTUSR $DIR &&
1844 error "lfs succeeded with no type, but should have failed"
1845 $LFS setquota $TSTUSR $DIR &&
1846 error "lfs succeeded with no type, but should have failed"
1849 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
1851 test_27b() { # b20200
1852 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1853 error "lfs setquota failed with uid argument"
1854 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1855 error "lfs stequota failed with gid argument"
1856 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
1857 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
1858 resetquota -u $TSTUSR
1859 resetquota -g $TSTUSR
1862 run_test 27b "lfs quota/setquota should handle user/group ID (b20200)"
1867 local TESTFILE="$DIR/$tdir/$tfile"
1871 trap cleanup_quota_test EXIT
1873 set_ost_qtype "u" || error "enable ost quota failed"
1875 $LFS setstripe $TESTFILE -i 0 -c 1
1876 chown $TSTUSR.$TSTUSR $TESTFILE
1878 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
1879 $MAX_IQ_TIME $DIR || error "set grace time failed"
1880 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
1881 error "set quota failed"
1882 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
1883 cancel_lru_locks osc
1885 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
1886 # over-quota flag has not yet settled since we do not trigger async
1887 # events based on grace time period expiration
1889 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 || true
1890 cancel_lru_locks osc
1891 # now over-quota flag should be settled and further writes should fail
1893 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
1894 error "grace times were reset"
1897 resetquota -u $TSTUSR
1898 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1899 $MAX_IQ_TIME $DIR || error "restore grace time failed"
1901 run_test 30 "Hard limit updates should not reset grace times"
1903 # basic usage tracking for user & group
1905 local INODES=10 # 10 files
1906 local BLK_CNT=2 # of 2M each
1907 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
1910 trap cleanup_quota_test EXIT
1912 # make sure the system is clean
1913 local USED=$(getquota -u $TSTID global curspace)
1915 error "Used space ($USED) for user $TSTID isn't 0."
1916 USED=$(getquota -g $TSTID global curspace)
1918 error "Used space ($USED) for group $TSTID isn't 0."
1920 echo "Write files..."
1921 for i in `seq 0 $INODES`; do
1922 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
1923 error "write failed"
1924 echo "Iteration $i/$INODES completed"
1926 cancel_lru_locks osc
1927 sync; sync_all_data || true
1929 echo "Verify disk usage after write"
1930 USED=$(getquota -u $TSTID global curspace)
1931 [ $USED -lt $TOTAL_BLKS ] &&
1932 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
1933 USED=$(getquota -g $TSTID global curspace)
1934 [ $USED -lt $TOTAL_BLKS ] &&
1935 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
1937 echo "Verify inode usage after write"
1938 USED=$(getquota -u $TSTID global curinodes)
1939 [ $USED -lt $INODES ] &&
1940 error "Used inode for user $TSTID is $USED, expected $INODES"
1941 USED=$(getquota -g $TSTID global curinodes)
1942 [ $USED -lt $INODES ] &&
1943 error "Used inode for group $TSTID is $USED, expected $INODES"
1947 echo "Verify disk usage after delete"
1948 USED=$(getquota -u $TSTID global curspace)
1949 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
1950 USED=$(getquota -u $TSTID global curinodes)
1951 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
1952 USED=$(getquota -g $TSTID global curspace)
1953 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
1954 USED=$(getquota -g $TSTID global curinodes)
1955 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
1957 run_test 33 "Basic usage tracking for user & group"
1959 # usage transfer test for user & group
1961 local BLK_CNT=2 # 2MB
1964 trap cleanup_quota_test EXIT
1966 # make sure the system is clean
1967 local USED=$(getquota -u $TSTID global curspace)
1968 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
1969 USED=$(getquota -g $TSTID global curspace)
1970 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
1972 echo "Write file..."
1973 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
1974 error "write failed"
1975 cancel_lru_locks osc
1976 sync; sync_all_data || true
1978 echo "chown the file to user $TSTID"
1979 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
1981 echo "Wait for setattr on objects finished..."
1982 wait_delete_completed
1984 BLK_CNT=$((BLK_CNT * 1024))
1986 echo "Verify disk usage for user $TSTID"
1987 USED=$(getquota -u $TSTID global curspace)
1988 [ $USED -lt $BLK_CNT ] &&
1989 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
1990 USED=$(getquota -u $TSTID global curinodes)
1992 error "Used inodes for user $TSTID is $USED, expected 1"
1994 echo "chgrp the file to group $TSTID"
1995 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
1997 echo "Wait for setattr on objects finished..."
1998 wait_delete_completed
2000 echo "Verify disk usage for group $TSTID"
2001 USED=$(getquota -g $TSTID global curspace)
2002 [ $USED -ge $BLK_CNT ] ||
2003 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2004 USED=$(getquota -g $TSTID global curinodes)
2006 error "Used inodes for group $TSTID is $USED, expected 1"
2010 run_test 34 "Usage transfer for user & group"
2012 # usage is still accessible across restart
2014 local BLK_CNT=2 # 2 MB
2017 trap cleanup_quota_test EXIT
2019 echo "Write file..."
2020 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2021 error "write failed"
2022 cancel_lru_locks osc
2023 sync; sync_all_data || true
2025 echo "Save disk usage before restart"
2026 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2027 [ $ORIG_USR_SPACE -eq 0 ] &&
2028 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2029 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2030 [ $ORIG_USR_INODES -eq 0 ] &&
2031 error "Used inodes for user $TSTID is 0, expected 1"
2032 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2033 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2034 [ $ORIG_GRP_SPACE -eq 0 ] &&
2035 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2036 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2037 [ $ORIG_GRP_INODES -eq 0 ] &&
2038 error "Used inodes for group $TSTID is 0, expected 1"
2039 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2042 local ORIG_REFORMAT=$REFORMAT
2044 cleanup_and_setup_lustre
2045 REFORMAT=$ORIG_REFORMAT
2048 echo "Verify disk usage after restart"
2049 local USED=$(getquota -u $TSTID global curspace)
2050 [ $USED -eq $ORIG_USR_SPACE ] ||
2051 error "Used space for user $TSTID changed from " \
2052 "$ORIG_USR_SPACE to $USED"
2053 USED=$(getquota -u $TSTID global curinodes)
2054 [ $USED -eq $ORIG_USR_INODES ] ||
2055 error "Used inodes for user $TSTID changed from " \
2056 "$ORIG_USR_INODES to $USED"
2057 USED=$(getquota -g $TSTID global curspace)
2058 [ $USED -eq $ORIG_GRP_SPACE ] ||
2059 error "Used space for group $TSTID changed from " \
2060 "$ORIG_GRP_SPACE to $USED"
2061 USED=$(getquota -g $TSTID global curinodes)
2062 [ $USED -eq $ORIG_GRP_INODES ] ||
2063 error "Used inodes for group $TSTID changed from " \
2064 "$ORIG_GRP_INODES to $USED"
2066 # check if the vfs_dq_init() is called before writing
2067 echo "Append to the same file..."
2068 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2069 error "write failed"
2070 cancel_lru_locks osc
2071 sync; sync_all_data || true
2073 echo "Verify space usage is increased"
2074 USED=$(getquota -u $TSTID global curspace)
2075 [ $USED -gt $ORIG_USR_SPACE ] ||
2076 error "Used space for user $TSTID isn't increased" \
2077 "orig:$ORIG_USR_SPACE, now:$USED"
2078 USED=$(getquota -g $TSTID global curspace)
2079 [ $USED -gt $ORIG_GRP_SPACE ] ||
2080 error "Used space for group $TSTID isn't increased" \
2081 "orig:$ORIG_GRP_SPACE, now:$USED"
2085 run_test 35 "Usage is still accessible across reboot"
2087 # test migrating old amdin quota files (in Linux quota file format v2) into new
2088 # quota global index (in IAM format)
2090 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] && \
2091 skip "skipping migration test" && return
2093 # get the mdt0 device name
2094 local mdt0_node=$(facet_active_host $SINGLEMDS)
2095 local mdt0_dev=$(mdsdevname ${SINGLEMDS//mds/})
2100 echo "Copy admin quota files into MDT0..."
2101 local mntpt=$(facet_mntpt $SINGLEMDS)
2102 local mdt0_fstype=$(facet_fstype $SINGLEMDS)
2104 if ! do_node $mdt0_node test -b $mdt0_fstype; then
2107 echo "$mdt0_node, $mdt0_dev, $mntpt, $opt"
2108 do_node $mdt0_node mount -t $mdt0_fstype $opt $mdt0_dev $mntpt
2109 do_node $mdt0_node mkdir $mntpt/OBJECTS
2110 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.usr $mntpt/OBJECTS
2111 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.grp $mntpt/OBJECTS
2112 do_node $mdt0_node umount -f $mntpt
2117 echo "Verify global limits..."
2121 local proc="qmt.*.md-0x0.glb-usr"
2122 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2123 [ $id_cnt -eq 403 ] || error "Migrate inode user limit failed: $id_cnt"
2124 limit=$(getquota -u 1 global isoftlimit)
2125 [ $limit -eq 1024 ] || error "User inode softlimit: $limit"
2126 limit=$(getquota -u 1 global ihardlimit)
2127 [ $limit -eq 2048 ] || error "User inode hardlimit: $limit"
2129 proc="qmt.*.md-0x0.glb-grp"
2130 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2131 [ $id_cnt -eq 403 ] || error "Migrate inode group limit failed: $id_cnt"
2132 limit=$(getquota -g 1 global isoftlimit)
2133 [ $limit -eq 1024 ] || error "Group inode softlimit: $limit"
2134 limit=$(getquota -g 1 global ihardlimit)
2135 [ $limit -eq 2048 ] || error "Group inode hardlimit: $limit"
2137 proc=" qmt.*.dt-0x0.glb-usr"
2138 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2139 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2140 limit=$(getquota -u 60001 global bsoftlimit)
2141 [ $limit -eq 10485760 ] || error "User block softlimit: $limit"
2142 limit=$(getquota -u 60001 global bhardlimit)
2143 [ $limit -eq 20971520 ] || error "User block hardlimit: $limit"
2145 proc="qmt.*.dt-0x0.glb-grp"
2146 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2147 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2148 limit=$(getquota -g 60001 global bsoftlimit)
2149 [ $limit -eq 10485760 ] || error "Group block softlimit: $limit"
2150 limit=$(getquota -g 60001 global bhardlimit)
2151 [ $limit -eq 20971520 ] || error "Group block hardlimit: $limit"
2157 run_test 36 "Migrate old admin files into new global indexes"
2161 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
2167 check_and_cleanup_lustre
2168 export QUOTA_AUTO=$QUOTA_AUTO_OLD