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() {
234 local result="glb[1],slv[1],reint[0]"
238 if [ $ntype == "mdt" ]; then
239 varsvc=${SINGLEMDS}_svc
240 cmd="$LCTL get_param -n "
241 cmd=${cmd}osd-$(facet_fstype $SINGLEMDS).${!varsvc}
242 cmd=${cmd}.quota_slave.info
244 if $(facet_up $SINGLEMDS); then
245 wait_update_facet $SINGLEMDS "$cmd |
246 grep "$qtype" | awk '{ print \\\$3 }'" \
247 "$result" $max || return 1
250 local osts=$(get_facets OST)
251 for ost in ${osts//,/ }; do
253 cmd="$LCTL get_param -n "
254 cmd=${cmd}osd-$(facet_fstype $ost).${!varsvc}
255 cmd=${cmd}.quota_slave.info
257 if $(facet_up $ost); then
258 wait_update_facet $ost "$cmd |
259 grep "$qtype" | awk '{ print \\\$3 }'" \
260 "$result" $max || return 1
271 if [ $qtype == "u" ] || [ $qtype == "ug" ]; then
272 wait_reintegration "mdt" "user" $max || return 1
275 if [ $qtype == "g" ] || [ $qtype == "ug" ]; then
276 wait_reintegration "mdt" "group" $max || return 1
285 if [ $qtype == "u" ] || [ $qtype == "ug" ]; then
286 wait_reintegration "ost" "user" $max || return 1
289 if [ $qtype == "g" ] || [ $qtype == "ug" ]; then
290 wait_reintegration "ost" "group" $max || return 1
297 wait_delete_completed
298 echo "Creating test directory"
301 # always clear fail_loc in case of fail_loc isn't cleared
302 # properly when previous test failed
303 lustre_fail mds_ost 0
306 cleanup_quota_test() {
308 echo "Delete files..."
310 echo "Wait for unlink objects finished..."
311 wait_delete_completed
312 sync_all_data || true
321 $LFS quota -v -$ug $qid $DIR
323 if [ "$bf" == "a" -o "$bf" == "b" ]; then
324 usage=$(getquota -$ug $qid global curspace)
325 if [ -z $usage ]; then
326 quota_error $ug $qid \
327 "Query block quota failed ($ug:$qid)."
329 [ $usage -ne 0 ] && quota_log $ug $qid \
330 "Block quota isn't 0 ($ug:$qid:$usage)."
334 if [ "$bf" == "a" -o "$bf" == "f" ]; then
335 usage=$(getquota -$ug $qid global curinodes)
336 if [ -z $usage ]; then
337 quota_error $ug $qid \
338 "Query file quota failed ($ug:$qid)."
340 [ $usage -ne 0 ] && quota_log $ug $qid \
341 "File quota isn't 0 ($ug:$qid:$usage)."
348 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
352 resetquota -u $TSTUSR
353 resetquota -g $TSTUSR
354 resetquota -u $TSTUSR2
355 resetquota -g $TSTUSR2
357 test_quota_performance() {
358 local TESTFILE="$DIR/$tdir/$tfile-0"
359 local size=$1 # in MB
360 local stime=$(date +%s)
361 $RUNAS $DD of=$TESTFILE count=$size conv=fsync ||
362 quota_error u $TSTUSR "write failure"
363 local etime=$(date +%s)
364 delta=$((etime - stime))
365 if [ $delta -gt 0 ]; then
366 rate=$((size * 1024 / delta))
367 [ $rate -gt 1024 ] ||
368 error "SLOW IO for $TSTUSR (user): $rate KB/sec"
373 # test basic quota performance b=21696
376 [ "$SLOW" = "no" ] && MB=10
378 local free_space=$(lfs_df | grep "summary" | awk '{print $4}')
379 [ $free_space -le $((MB * 1024)) ] &&
380 skip "not enough space ${free_space} KB, " \
381 "required $((MB * 1024)) KB" && return
383 trap cleanup_quota_test EXIT
385 set_ost_qtype "none" || error "disable ost quota failed"
386 test_quota_performance $MB
388 set_ost_qtype "ug" || error "enable ost quota failed"
389 $LFS setquota -u $TSTUSR -b 0 -B 10G -i 0 -I 0 $DIR ||
390 error "set quota failed"
391 test_quota_performance $MB
394 resetquota -u $TSTUSR
396 run_test 0 "Test basic quota performance"
398 # test block hardlimit
401 local TESTFILE="$DIR/$tdir/$tfile-0"
404 trap cleanup_quota_test EXIT
407 set_ost_qtype "ug" || "enable ost quota failed"
410 log "User quota (block hardlimit:$LIMIT MB)"
411 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
412 error "set user quota failed"
414 # make sure the system is clean
415 local USED=$(getquota -u $TSTUSR global curspace)
416 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
418 $LFS setstripe $TESTFILE -c 1
419 chown $TSTUSR.$TSTUSR $TESTFILE
422 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
423 quota_error u $TSTUSR "user write failure, but expect success"
424 log "Write out of block quota ..."
425 # this time maybe cache write, ignore it's failure
426 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
427 # flush cache, ensure noquota flag is set on client
429 $RUNAS $DD of=$TESTFILE count=1 seek=$LIMIT &&
430 quota_error u $TSTUSR "user write success, but expect EDQUOT"
433 wait_delete_completed
434 sync_all_data || true
435 USED=$(getquota -u $TSTUSR global curspace)
436 [ $USED -ne 0 ] && quota_error u $TSTUSR \
437 "user quota isn't released after deletion"
438 resetquota -u $TSTUSR
441 log "--------------------------------------"
442 log "Group quota (block hardlimit:$LIMIT MB)"
443 $LFS setquota -g $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
444 error "set group quota failed"
446 TESTFILE="$DIR/$tdir/$tfile-1"
447 # make sure the system is clean
448 USED=$(getquota -g $TSTUSR global curspace)
449 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0"
451 $LFS setstripe $TESTFILE -c 1
452 chown $TSTUSR.$TSTUSR $TESTFILE
455 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) ||
456 quota_error g $TSTUSR "group write failure, but expect success"
457 log "Write out of block quota ..."
458 # this time maybe cache write, ignore it's failure
459 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) seek=$((LIMIT/2)) || true
461 $RUNAS $DD of=$TESTFILE count=10 seek=$LIMIT &&
462 quota_error g $TSTUSR "group write success, but expect EDQUOT"
467 USED=$(getquota -g $TSTUSR global curspace)
468 [ $USED -ne 0 ] && quota_error g $TSTUSR \
469 "group quota isn't released after deletion"
471 resetquota -g $TSTUSR
473 run_test 1 "Block hard limit (normal use and out of quota)"
475 # test inode hardlimit
477 local LIMIT=$((1024 * 1024)) # 1M inodes
478 local TESTFILE="$DIR/$tdir/$tfile-0"
480 [ "$SLOW" = "no" ] && LIMIT=1024 # 1k inodes
482 local FREE_INODES=$(lfs_df -i | grep "summary" | awk '{print $4}')
483 [ $FREE_INODES -lt $LIMIT ] &&
484 skip "not enough free inodes $FREE_INODES required $LIMIT" &&
488 trap cleanup_quota_test EXIT
491 set_mdt_qtype "ug" || "enable mdt quota failed"
494 log "User quota (inode hardlimit:$LIMIT files)"
495 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
496 error "set user quota failed"
498 # make sure the system is clean
499 local USED=$(getquota -u $TSTUSR global curinodes)
500 [ $USED -ne 0 ] && error "Used inodes($USED) for user $TSTUSR isn't 0."
502 log "Create $LIMIT files ..."
503 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
504 quota_error u $TSTUSR "user create failure, but expect success"
505 log "Create out of file quota ..."
506 $RUNAS touch ${TESTFILE}_xxx && \
507 quota_error u $TSTUSR "user create success, but expect EDQUOT"
510 unlinkmany ${TESTFILE} $LIMIT
511 rm -f ${TESTFILE}_xxx
512 wait_delete_completed
514 USED=$(getquota -u $TSTUSR global curinodes)
515 [ $USED -ne 0 ] && quota_error u $TSTUSR \
516 "user quota isn't released after deletion"
517 resetquota -u $TSTUSR
520 log "--------------------------------------"
521 log "Group quota (inode hardlimit:$LIMIT files)"
522 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR ||
523 error "set group quota failed"
525 TESTFILE=$DIR/$tdir/$tfile-1
526 # make sure the system is clean
527 USED=$(getquota -g $TSTUSR global curinodes)
528 [ $USED -ne 0 ] && error "Used inodes($USED) for group $TSTUSR isn't 0."
530 log "Create $LIMIT files ..."
531 $RUNAS createmany -m ${TESTFILE} $LIMIT ||
532 quota_error g $TSTUSR "group create failure, but expect success"
533 log "Create out of file quota ..."
534 $RUNAS touch ${TESTFILE}_xxx && \
535 quota_error g $TSTUSR "group create success, but expect EDQUOT"
538 unlinkmany ${TESTFILE} $LIMIT
539 rm -f ${TESTFILE}_xxx
540 wait_delete_completed
542 USED=$(getquota -g $TSTUSR global curinodes)
543 [ $USED -ne 0 ] && quota_error g $TSTUSR \
544 "user quota isn't released after deletion"
547 resetquota -g $TSTUSR
549 run_test 2 "File hard limit (normal use and out of quota)"
553 local TIMER=$(($2 * 3 / 2))
558 trap cleanup_quota_test EXIT
560 $LFS setstripe $TESTFILE -c 1 -i 0
561 chown $TSTUSR.$TSTUSR $TESTFILE
563 echo "Write up to soft limit"
564 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
565 quota_error a $TSTUSR "write failure, but expect success"
566 OFFSET=$((LIMIT * 1024))
569 echo "Write to exceed soft limit"
570 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
571 quota_error a $TSTUSR "write failure, but expect success"
572 OFFSET=$((OFFSET + 1024)) # make sure we don't write to same block
577 $SHOW_QUOTA_INFO_USER
578 $SHOW_QUOTA_INFO_GROUP
580 echo "Write before timer goes off"
581 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET ||
582 quota_error a $TSTUSR "write failure, but expect success"
583 OFFSET=$((OFFSET + 1024))
586 echo "Sleep $TIMER seconds ..."
591 $SHOW_QUOTA_INFO_USER
592 $SHOW_QUOTA_INFO_GROUP
594 echo "Write after timer goes off"
595 # maybe cache write, ignore.
596 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET || true
597 OFFSET=$((OFFSET + 1024))
599 $RUNAS dd if=/dev/zero of=$TESTFILE bs=1K count=10 seek=$OFFSET &&
600 quota_error a $TSTUSR "write success, but expect EDQUOT"
604 $SHOW_QUOTA_INFO_USER
605 $SHOW_QUOTA_INFO_GROUP
607 echo "Unlink file to stop timer"
609 wait_delete_completed
610 sync_all_data || true
614 $SHOW_QUOTA_INFO_USER
615 $SHOW_QUOTA_INFO_GROUP
617 $LFS setstripe $TESTFILE -c 1 -i 0
618 chown $TSTUSR.$TSTUSR $TESTFILE
621 $RUNAS $DD of=$TESTFILE count=$LIMIT ||
622 quota_error a $TSTUSR "write failure, but expect success"
631 local TESTFILE=$DIR/$tdir/$tfile-0
633 set_ost_qtype "ug" || error "enable ost quota failed"
635 echo "User quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
636 # make sure the system is clean
637 local USED=$(getquota -u $TSTUSR global curspace)
638 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
640 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
641 $MAX_IQ_TIME $DIR || error "set user grace time failed"
642 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
643 error "set user quota failed"
645 test_block_soft $TESTFILE $GRACE $LIMIT
646 resetquota -u $TSTUSR
648 echo "Group quota (soft limit:$LIMIT MB grace:$GRACE seconds)"
649 TESTFILE=$DIR/$tdir/$tfile-1
650 # make sure the system is clean
651 USED=$(getquota -g $TSTUSR global curspace)
652 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
654 $LFS setquota -t -g --block-grace $GRACE --inode-grace \
655 $MAX_IQ_TIME $DIR || error "set group grace time failed"
656 $LFS setquota -g $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
657 error "set group quota failed"
659 test_block_soft $TESTFILE $GRACE $LIMIT
660 resetquota -g $TSTUSR
663 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
664 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
665 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
666 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
668 run_test 3 "Block soft limit (start timer, timer goes off, stop timer)"
673 local TIMER=$(($3 * 3 / 2))
676 trap cleanup_quota_test EXIT
678 echo "Create files to exceed soft limit"
679 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) ||
680 quota_error a $TSTUSR "create failure, but expect success"
683 echo "Create file before timer goes off"
684 $RUNAS touch ${TESTFILE}_before ||
685 quota_error a $TSTUSR "failed create before timer expired," \
689 echo "Sleep $TIMER seconds ..."
694 $SHOW_QUOTA_INFO_USER
695 $SHOW_QUOTA_INFO_GROUP
697 echo "Create file after timer goes off"
698 # There is a window that space is accounted in the quota usage but
699 # hasn't been decreased from the pending write, if we acquire quota
700 # in this window, we'll acquire more than we needed.
701 $RUNAS touch ${TESTFILE}_after_1 ${TESTFILE}_after_2 || true
703 $RUNAS touch ${TESTFILE}_after_3 &&
704 quota_error a $TSTUSR "create after timer expired," \
710 $SHOW_QUOTA_INFO_USER
711 $SHOW_QUOTA_INFO_GROUP
713 echo "Unlink files to stop timer"
714 find $(dirname $TESTFILE) -name "$(basename ${TESTFILE})*" | xargs rm -f
715 wait_delete_completed
718 $RUNAS touch ${TESTFILE}_xxx ||
719 quota_error a $TSTUSR "touch after timer stop failure," \
729 local LIMIT=10 # inodes
730 local TESTFILE=$DIR/$tdir/$tfile-0
733 set_mdt_qtype "ug" || error "enable mdt quota failed"
735 echo "User quota (soft limit:$LIMIT files grace:$GRACE seconds)"
736 # make sure the system is clean
737 local USED=$(getquota -u $TSTUSR global curinodes)
738 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
740 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
741 $GRACE $DIR || error "set user grace time failed"
742 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
743 error "set user quota failed"
745 test_file_soft $TESTFILE $LIMIT $GRACE
746 resetquota -u $TSTUSR
748 echo "Group quota (soft limit:$LIMIT files grace:$GRACE seconds)"
749 # make sure the system is clean
750 USED=$(getquota -g $TSTUSR global curinodes)
751 [ $USED -ne 0 ] && error "Used space($USED) for group $TSTUSR isn't 0."
753 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
754 $GRACE $DIR || error "set group grace time failed"
755 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR ||
756 error "set group quota failed"
757 TESTFILE=$DIR/$tdir/$tfile-1
759 test_file_soft $TESTFILE $LIMIT $GRACE
760 resetquota -g $TSTUSR
763 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
764 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
765 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
766 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
768 run_test 4a "File soft limit (start timer, timer goes off, stop timer)"
772 local GR_STR2="1000s"
774 local GR_STR4="1w2d3h4m5s"
776 local GR_STR6="1111111111111111"
778 wait_delete_completed
780 # test of valid grace strings handling
781 echo "Valid grace strings test"
782 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace \
783 $GR_STR2 $DIR || error "set user grace time failed"
784 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
785 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace \
786 $GR_STR4 $DIR || error "set group grace time quota failed"
787 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
789 # test of invalid grace strings handling
790 echo " Invalid grace strings test"
791 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
792 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
795 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
796 $MAX_IQ_TIME $DIR || error "restore user grace time failed"
797 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace \
798 $MAX_IQ_TIME $DIR || error "restore group grace time failed"
800 run_test 4b "Grace time strings handling"
802 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
804 local BLIMIT=10 # 10M
805 local ILIMIT=10 # 10 inodes
808 trap cleanup_quota_test EXIT
810 set_mdt_qtype "ug" || error "enable mdt quota failed"
811 set_ost_qtype "ug" || error "enable ost quota failed"
813 echo "Set quota limit (0 ${BLIMIT}M 0 $ILIMIT) for $TSTUSR.$TSTUSR"
814 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
815 error "set user quota failed"
816 $LFS setquota -g $TSTUSR -b 0 -B ${BLIMIT}M -i 0 -I $ILIMIT $DIR ||
817 error "set group quota failed"
819 # make sure the system is clean
820 local USED=$(getquota -u $TSTUSR global curinodes)
821 [ $USED -ne 0 ] && error "Used inode($USED) for user $TSTUSR isn't 0."
822 USED=$(getquota -g $TSTUSR global curinodes)
823 [ $USED -ne 0 ] && error "Used inode($USED) for group $TSTUSR isn't 0."
824 USED=$(getquota -u $TSTUSR global curspace)
825 [ $USED -ne 0 ] && error "Used block($USED) for user $TSTUSR isn't 0."
826 USED=$(getquota -g $TSTUSR global curspace)
827 [ $USED -ne 0 ] && error "Used block($USED) for group $TSTUSR isn't 0."
829 echo "Create more than $ILIMIT files and more than $BLIMIT MB ..."
830 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) ||
831 error "create failure, expect success"
832 $DD of=$DIR/$tdir/$tfile-0_1 count=$((BLIMIT+1)) ||
833 error "write failure, expect success"
835 echo "Chown files to $TSTUSR.$TSTUSR ..."
836 for i in `seq 0 $ILIMIT`; do
837 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i ||
838 quota_error a $TSTUSR "chown failure, expect success"
842 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
845 resetquota -u $TSTUSR
846 resetquota -g $TSTUSR
848 run_test 5 "Chown & chgrp successfully even out of block/file quota"
850 # test dropping acquire request on master
855 trap cleanup_quota_test EXIT
857 # make sure the system is clean
858 local USED=$(getquota -u $TSTUSR global curspace)
859 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
861 # make sure no granted quota on ost
862 set_ost_qtype "ug" || error "enable ost quota failed"
863 resetquota -u $TSTUSR
865 # create file for $TSTUSR
866 local TESTFILE=$DIR/$tdir/$tfile-$TSTUSR
867 $LFS setstripe $TESTFILE -c 1 -i 0
868 chown $TSTUSR.$TSTUSR $TESTFILE
870 # create file for $TSTUSR2
871 local TESTFILE2=$DIR/$tdir/$tfile-$TSTUSR2
872 $LFS setstripe $TESTFILE2 -c 1 -i 0
873 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
875 # cache per-ID lock for $TSTUSR on slave
876 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
877 error "set quota failed"
878 $RUNAS $DD of=$TESTFILE count=1 ||
879 error "write $TESTFILE failure, expect success"
880 $RUNAS2 $DD of=$TESTFILE2 count=1 ||
881 error "write $TESTFILE2 failure, expect success"
883 sync_all_data || true
885 #define QUOTA_DQACQ 601
886 #define OBD_FAIL_PTLRPC_DROP_REQ_OPC 0x513
887 lustre_fail mds 0x513 601
889 # write to un-enforced ID ($TSTUSR2) should succeed
890 $RUNAS2 $DD of=$TESTFILE2 count=$LIMIT seek=1 oflag=sync conv=notrunc ||
891 error "write failure, expect success"
893 # write to enforced ID ($TSTUSR) in background, exceeding limit
894 # to make sure DQACQ is sent
895 $RUNAS $DD of=$TESTFILE count=$LIMIT seek=1 oflag=sync conv=notrunc &
898 # watchdog timer uses a factor of 2
899 echo "Sleep for $((TIMEOUT * 2 + 1)) seconds ..."
900 sleep $((TIMEOUT * 2 + 1))
902 # write should be blocked and never finished
903 if ! ps -p $DDPID > /dev/null 2>&1; then
905 error "write finished incorrectly!"
910 # no watchdog is triggered
911 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
912 watchdog=$(awk '/sanity-quota test 6/ {start = 1;}
913 /Service thread pid/ && /was inactive/ {
917 }' $TMP/lustre-log-${TESTNAME}.log)
918 [ -z "$watchdog" ] || error "$watchdog"
920 rm -f $TMP/lustre-log-${TESTNAME}.log
922 # write should continue & succeed
925 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
926 if [ $count -ge 120 ]; then
927 quota_error u $TSTUSR "dd not finished in $count secs"
930 [ $((count % 10)) -eq 0 ] && echo "Waiting $count secs"
935 resetquota -u $TSTUSR
937 run_test 6 "Test dropping acquire request on master"
939 # quota reintegration (global index)
941 local TESTFILE=$DIR/$tdir/$tfile
944 [ "$SLOW" = "no" ] && LIMIT=5
947 trap cleanup_quota_test EXIT
949 # make sure the system is clean
950 local USED=$(getquota -u $TSTUSR global curspace)
951 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
953 # make sure no granted quota on ost1
954 set_ost_qtype "ug" || error "enable ost quota failed"
955 resetquota -u $TSTUSR
956 set_ost_qtype "none" || error "disable ost quota failed"
958 local OSTUUID=$(ostuuid_from_index 0)
959 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
960 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
964 $LFS setstripe $TESTFILE -c 1 -i 0
965 chown $TSTUSR.$TSTUSR $TESTFILE
970 echo "Enable quota & set quota limit for $TSTUSR"
971 set_ost_qtype "ug" || error "enable ost quota failed"
972 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
973 error "set quota failed"
976 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
979 wait_ost_reint "ug" || error "reintegration failed"
981 # hardlimit should have been fetched by slave during global
982 # reintegration, write will exceed quota
983 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
984 quota_error u $TSTUSR "write success, but expect EDQUOT"
987 wait_delete_completed
988 sync_all_data || true
994 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 0 $DIR ||
995 error "clear quota failed"
998 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
1001 wait_ost_reint "ug" || error "reintegration failed"
1003 # hardlimit should be cleared on slave during reintegration
1004 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync ||
1005 quota_error u $TSTUSR "write error, but expect success"
1008 resetquota -u $TSTUSR
1010 run_test 7a "Quota reintegration (global index)"
1012 # quota reintegration (slave index)
1015 local TESTFILE=$DIR/$tdir/$tfile
1018 trap cleanup_quota_test EXIT
1020 # make sure the system is clean
1021 local USED=$(getquota -u $TSTUSR global curspace)
1022 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1024 # make sure no granted quota on ost1
1025 set_ost_qtype "ug" || error "enable ost quota failed"
1026 resetquota -u $TSTUSR
1027 set_ost_qtype "none" || error "disable ost quota failed"
1029 local OSTUUID=$(ostuuid_from_index 0)
1030 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1031 [ $USED -ne 0 ] && error "limit($USED) on $OSTUUID for user" \
1035 $LFS setstripe $TESTFILE -c 1 -i 0
1036 chown $TSTUSR.$TSTUSR $TESTFILE
1038 # consume some space to make sure the granted space will not
1039 # be released during reconciliation
1040 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1041 error "consume space failure, expect success"
1043 # define OBD_FAIL_QUOTA_EDQUOT 0xa02
1044 lustre_fail mds 0xa02
1046 set_ost_qtype "ug" || error "enable ost quota failed"
1047 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1048 error "set quota failed"
1050 # ignore the write error
1051 $RUNAS $DD of=$TESTFILE count=1 seek=1 oflag=sync conv=notrunc
1053 local old_used=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1057 echo "Restart ost to trigger reintegration..."
1059 start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
1062 wait_ost_reint "ug" || error "reintegration failed"
1064 USED=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1065 [ $USED -gt $old_used ] || error "limit on $OSTUUID $USED <= $old_used"
1068 resetquota -u $TSTUSR
1071 run_test 7b "Quota reintegration (slave index)"
1073 # quota reintegration (restart mds during reintegration)
1075 local LIMIT=20 # 20M
1076 local TESTFILE=$DIR/$tdir/$tfile
1078 [ "$SLOW" = "no" ] && LIMIT=5
1081 trap cleanup_quota_test EXIT
1083 # make sure the system is clean
1084 local USED=$(getquota -u $TSTUSR global curspace)
1085 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1087 set_ost_qtype "none" || error "disable ost quota failed"
1088 $LFS setquota -u $TSTUSR -b 0 -B ${LIMIT}M -i 0 -I 0 $DIR ||
1089 error "set quota failed"
1091 # define OBD_FAIL_QUOTA_DELAY_REINT 0xa03
1092 lustre_fail ost 0xa03
1095 set_ost_qtype "ug" || error "enable ost quota failed"
1096 # trigger reintegration
1097 local procf="osd-$(facet_fstype ost1).$FSNAME-OST*."
1098 procf=${procf}quota_slave.force_reint
1099 $LCTL set_param $procf=1 || "force reintegration failed"
1107 start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
1110 # wait longer than usual to make sure the reintegration
1111 # is triggered by quota wb thread.
1112 wait_ost_reint "ug" 200 || error "reintegration failed"
1114 # hardlimit should have been fetched by slave during global
1115 # reintegration, write will exceed quota
1116 $RUNAS $DD of=$TESTFILE count=$((LIMIT + 1)) oflag=sync &&
1117 quota_error u $TSTUSR "write success, but expect EDQUOT"
1120 resetquota -u $TSTUSR
1122 run_test 7c "Quota reintegration (restart mds during reintegration)"
1124 # Quota reintegration (Transfer index in multiple bulks)
1126 local TESTFILE=$DIR/$tdir/$tfile
1127 local TESTFILE1="$DIR/$tdir/$tfile"-1
1131 trap cleanup_quota_test EXIT
1133 set_ost_qtype "none" || error "disable ost quota failed"
1134 $LFS setquota -u $TSTUSR -B ${limit}M $DIR ||
1135 error "set quota for $TSTUSR failed"
1136 $LFS setquota -u $TSTUSR2 -B ${limit}M $DIR ||
1137 error "set quota for $TSTUSR2 failed"
1139 #define OBD_FAIL_OBD_IDX_READ_BREAK 0x608
1140 lustre_fail mds 0x608 0
1142 # enable quota to tirgger reintegration
1143 set_ost_qtype "u" || error "enable ost quota failed"
1144 wait_ost_reint "u" || error "reintegration failed"
1148 # hardlimit should have been fetched by slave during global
1149 # reintegration, write will exceed quota
1150 $RUNAS $DD of=$TESTFILE count=$((limit + 1)) oflag=sync &&
1151 quota_error u $TSTUSR "$TSTUSR write success, expect EDQUOT"
1153 $RUNAS2 $DD of=$TESTFILE1 count=$((limit + 1)) oflag=sync &&
1154 quota_error u $TSTUSR2 "$TSTUSR2 write success, expect EDQUOT"
1157 resetquota -u $TSTUSR
1158 resetquota -u $TSTUSR2
1160 run_test 7d "Quota reintegration (Transfer index in multiple bulks)"
1162 # run dbench with quota enabled
1164 local BLK_LIMIT="100g" #100G
1165 local FILE_LIMIT=1000000
1168 trap cleanup_quota_test EXIT
1170 set_mdt_qtype "ug" || error "enable mdt quota failed"
1171 set_ost_qtype "ug" || error "enable ost quota failed"
1173 echo "Set enough high limit for user: $TSTUSR"
1174 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1175 error "set user quota failed"
1176 echo "Set enough high limit for group: $TSTUSR"
1177 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1178 error "set group quota failed"
1181 [ "$SLOW" = "no" ] && duration=" -t 120"
1182 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration ||
1183 quota_error a $TSTUSR "dbench failed!"
1186 resetquota -u $TSTUSR
1187 resetquota -g $TSTUSR
1189 run_test 8 "Run dbench with quota enabled"
1191 # this check is just for test_9
1192 OST0_MIN=4900000 #4.67G
1194 check_whether_skip () {
1195 local OST0_SIZE=$($LFS df $DIR | awk '/\[OST:0\]/ {print $4}')
1196 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
1197 if [ $OST0_SIZE -lt $OST0_MIN ]; then
1198 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
1205 # run for fixing bug10707, it needs a big room. test for 64bit
1207 local filesize=$((1024 * 9 / 2)) # 4.5G
1209 check_whether_skip && return 0
1212 trap cleanup_quota_test EXIT
1214 set_ost_qtype "ug" || error "enable ost quota failed"
1216 local TESTFILE="$DIR/$tdir/$tfile-0"
1217 local BLK_LIMIT=100G #100G
1218 local FILE_LIMIT=1000000
1220 echo "Set block limit $BLK_LIMIT bytes to $TSTUSR.$TSTUSR"
1222 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1224 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1225 error "set user quota failed"
1227 log "Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT)" \
1228 "for group: $TSTUSR"
1229 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR ||
1230 error "set group quota failed"
1232 quota_show_check a u $TSTUSR
1233 quota_show_check a g $TSTUSR
1235 echo "Create test file"
1236 $LFS setstripe $TESTFILE -c 1 -i 0
1237 chown $TSTUSR.$TSTUSR $TESTFILE
1239 log "Write the big file of 4.5G ..."
1240 $RUNAS $DD of=$TESTFILE count=$filesize ||
1241 quota_error a $TSTUSR "write 4.5G file failure, expect success"
1247 resetquota -u $TSTUSR
1248 resetquota -g $TSTUSR
1253 run_test 9 "Block limit larger than 4GB (b10707)"
1256 local TESTFILE=$DIR/$tdir/$tfile
1259 trap cleanup_quota_test EXIT
1261 # set limit to root user should fail
1262 $LFS setquota -u root -b 100G -B 500G -i 1K -I 1M $DIR &&
1263 error "set limit for root user successfully, expect failure"
1264 $LFS setquota -g root -b 1T -B 10T -i 5K -I 100M $DIR &&
1265 error "set limit for root group successfully, expect failure"
1267 # root user can overrun quota
1268 set_ost_qtype "ug" || "enable ost quota failed"
1270 $LFS setquota -u $TSTUSR -b 0 -B 2M -i 0 -I 0 $DIR ||
1271 error "set quota failed"
1272 quota_show_check b u $TSTUSR
1274 $LFS setstripe $TESTFILE -c 1
1275 chown $TSTUSR.$TSTUSR $TESTFILE
1277 runas -u 0 -g 0 $DD of=$TESTFILE count=3 oflag=sync ||
1278 error "write failure, expect success"
1281 resetquota -u $TSTUSR
1283 run_test 10 "Test quota for root user"
1286 local TESTFILE=$DIR/$tdir/$tfile
1288 trap cleanup_quota_test EXIT
1290 set_mdt_qtype "ug" || "enable mdt quota failed"
1291 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I 1 $DIR ||
1292 error "set quota failed"
1297 chown $TSTUSR.$TSTUSR "$TESTFILE"-0
1298 chown $TSTUSR.$TSTUSR "$TESTFILE"-1
1301 local USED=$(getquota -u $TSTUSR global curinodes)
1302 [ $USED -ge 2 ] || error "Used inodes($USED) is less than 2"
1305 resetquota -u $TSTUSR
1307 run_test 11 "Chown/chgrp ignores quota"
1310 [ "$OSTCOUNT" -lt "2" ] && skip "skipping rebalancing test" && return
1312 local blimit=22 # 22M
1313 local blk_cnt=$((blimit - 5))
1314 local TESTFILE0="$DIR/$tdir/$tfile"-0
1315 local TESTFILE1="$DIR/$tdir/$tfile"-1
1318 trap cleanup_quota_test EXIT
1320 set_ost_qtype "u" || "enable ost quota failed"
1321 quota_show_check b u $TSTUSR
1323 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $DIR ||
1324 error "set quota failed"
1326 $LFS setstripe $TESTFILE0 -c 1 -i 0
1327 $LFS setstripe $TESTFILE1 -c 1 -i 1
1328 chown $TSTUSR.$TSTUSR $TESTFILE0
1329 chown $TSTUSR.$TSTUSR $TESTFILE1
1331 echo "Write to ost0..."
1332 $RUNAS $DD of=$TESTFILE0 count=$blk_cnt oflag=sync ||
1333 quota_error a $TSTUSR "dd failed"
1335 echo "Write to ost1..."
1336 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync &&
1337 quota_error a $TSTUSR "dd succeed, expect EDQUOT"
1339 echo "Free space from ost0..."
1341 wait_delete_completed
1342 sync_all_data || true
1344 echo "Write to ost1 after space freed from ost0..."
1345 $RUNAS $DD of=$TESTFILE1 count=$blk_cnt oflag=sync ||
1346 quota_error a $TSTUSR "rebalancing failed"
1349 resetquota -u $TSTUSR
1351 run_test 12 "Block quota rebalancing"
1354 local TESTFILE=$DIR/$tdir/$tfile
1355 # the name of osp on ost1 name is MDT0000-osp-OST0000
1356 local procf="ldlm.namespaces.*MDT0000-osp-OST0000.lru_size"
1359 trap cleanup_quota_test EXIT
1361 set_ost_qtype "u" || "enable ost quota failed"
1362 quota_show_check b u $TSTUSR
1364 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1365 error "set quota failed"
1366 $LFS setstripe $TESTFILE -c 1 -i 0
1367 chown $TSTUSR.$TSTUSR $TESTFILE
1369 # clear the locks in cache first
1370 do_facet ost1 $LCTL set_param -n $procf=clear
1371 local nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1372 [ $nlock -eq 0 ] || error "$nlock cached locks"
1374 # write to acquire the per-ID lock
1375 $RUNAS $DD of=$TESTFILE count=1 oflag=sync ||
1376 quota_error a $TSTUSR "dd failed"
1378 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1379 [ $nlock -eq 1 ] || error "lock count($nlock) isn't 1"
1381 # clear quota doesn't trigger per-ID lock cancellation
1382 resetquota -u $TSTUSR
1383 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1384 [ $nlock -eq 1 ] || error "per-ID lock is lost on quota clear"
1386 # clear the per-ID lock
1387 do_facet ost1 $LCTL set_param -n $procf=clear
1388 nlock=$(do_facet ost1 $LCTL get_param -n $procf)
1389 [ $nlock -eq 0 ] || error "per-ID lock isn't cleared"
1391 # spare quota should be released
1392 local OSTUUID=$(ostuuid_from_index 0)
1393 local limit=$(getquota -u $TSTUSR $OSTUUID bhardlimit)
1394 local space=$(getquota -u $TSTUSR $OSTUUID curspace)
1395 [ $limit -le $space ] ||
1396 error "spare quota isn't released, limit:$limit, space:$space"
1400 run_test 13 "Cancel per-ID lock in the LRU list"
1403 local LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1405 wait_delete_completed
1406 sync_all_data || true
1409 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1410 error "set user quota failed"
1411 local TOTAL_LIMIT=$(getquota -u $TSTUSR global bhardlimit)
1412 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1413 error "(user) limit:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1414 resetquota -u $TSTUSR
1417 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR ||
1418 error "set group quota failed"
1419 TOTAL_LIMIT=$(getquota -g $TSTUSR global bhardlimit)
1420 [ $TOTAL_LIMIT -eq $LIMIT ] ||
1421 error "(group) limits:$TOTAL_LIMIT, expect:$LIMIT, failed!"
1422 resetquota -g $TSTUSR
1424 run_test 15 "Set over 4T block quota"
1428 local BLKS=1 # 1M less than limit
1429 local TESTFILE=$DIR/$tdir/$tfile
1432 trap cleanup_quota_test EXIT
1434 # make sure the system is clean
1435 local USED=$(getquota -u $TSTUSR global curspace)
1436 [ $USED -ne 0 ] && error "Used space($USED) for user $TSTUSR isn't 0."
1438 set_ost_qtype "ug" || error "enable ost quota failed"
1439 # make sure no granted quota on ost
1440 resetquota -u $TSTUSR
1441 $LFS setquota -u $TSTUSR -b 0 -B 10M -i 0 -I 0 $DIR ||
1442 error "set quota failed"
1444 quota_show_check b u $TSTUSR
1446 #define OBD_FAIL_QUOTA_RECOVERABLE_ERR 0xa04
1447 lustre_fail mds 0xa04 $err_code
1449 # write in background
1450 $RUNAS $DD of=$TESTFILE count=$BLKS oflag=direct &
1454 # write should be blocked and never finished
1455 if ! ps -p $DDPID > /dev/null 2>&1; then
1457 quota_error u $TSTUSR "write finished incorrectly!"
1465 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1467 if [ $count -gt $timeout ]; then
1468 quota_error u $TSTUSR "dd is not finished!"
1473 sync; sync_all_data || true
1475 USED=$(getquota -u $TSTUSR global curspace)
1476 [ $USED -ge $(($BLKS * 1024)) ] || quota_error u $TSTUSR \
1477 "Used space(${USED}K) is less than ${BLKS}M"
1480 resetquota -u $TSTUSR
1483 # DQACQ return recoverable error
1485 echo "DQACQ return -ENOLCK"
1487 test_17sub 37 || error "Handle -ENOLCK failed"
1489 echo "DQACQ return -EAGAIN"
1491 test_17sub 11 || error "Handle -EAGAIN failed"
1493 echo "DQACQ return -ETIMEDOUT"
1494 #define ETIMEDOUT 110
1495 test_17sub 110 || error "Handle -ETIMEDOUT failed"
1497 echo "DQACQ return -ENOTCONN"
1498 #define ENOTCONN 107
1499 test_17sub 107 || error "Handle -ENOTCONN failed"
1502 run_test 17 "DQACQ return recoverable error"
1506 local blimit="200m" # 200M
1507 local TESTFILE="$DIR/$tdir/$tfile"
1510 trap cleanup_quota_test EXIT
1512 set_ost_qtype "u" || error "enable ost quota failed"
1513 log "User quota (limit: $blimit)"
1514 $LFS setquota -u $TSTUSR -b 0 -B $blimit -i 0 -I 0 $MOUNT ||
1515 error "set quota failed"
1516 quota_show_check b u $TSTUSR
1518 $LFS setstripe $TESTFILE -i 0 -c 1
1519 chown $TSTUSR.$TSTUSR $TESTFILE
1521 local timeout=$(sysctl -n lustre.timeout)
1523 if [ $io_type = "directio" ]; then
1524 log "Write 100M (directio) ..."
1525 $RUNAS $DD of=$TESTFILE count=100 oflag=direct &
1527 log "Write 100M (buffered) ..."
1528 $RUNAS $DD of=$TESTFILE count=100 &
1532 replay_barrier $SINGLEMDS
1533 log "Fail mds for $((2 * timeout)) seconds"
1534 fail $SINGLEMDS $((2 * timeout))
1537 if at_is_enabled; then
1538 timeout=$(at_max_get mds)
1540 timeout=$(lctl get_param -n timeout)
1544 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1545 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1546 log "it took $count second"
1551 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1553 cancel_lru_locks mdc
1554 cancel_lru_locks osc
1557 local testfile_size=$(stat -c %s $TESTFILE)
1558 if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
1559 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)),"
1560 "got ${testfile_size}. Verifying file failed!"
1563 resetquota -u $TSTUSR
1566 # test when mds does failover, the ost still could work well
1567 # this test shouldn't trigger watchdog b=14840
1570 test_18_sub directio
1572 # check if watchdog is triggered
1573 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1574 local watchdog=$(awk '/sanity-quota test 18/ {start = 1;}
1575 /Service thread pid/ && /was inactive/ {
1579 }' $TMP/lustre-log-${TESTNAME}.log)
1580 [ -z "$watchdog" ] || error "$watchdog"
1581 rm -f $TMP/lustre-log-${TESTNAME}.log
1583 run_test 18 "MDS failover while writing, no watchdog triggered (b14840)"
1587 local TESTFILE=$DIR/$tdir/$tfile
1590 trap cleanup_quota_test EXIT
1592 set_ost_qtype "ug" || error "enable ost quota failed"
1594 # bind file to a single OST
1595 $LFS setstripe -c 1 $TESTFILE
1596 chown $TSTUSR.$TSTUSR $TESTFILE
1598 echo "Set user quota (limit: "$blimit"M)"
1599 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1600 error "set user quota failed"
1601 quota_show_check b u $TSTUSR
1602 echo "Update quota limits"
1603 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1604 error "set group quota failed"
1605 quota_show_check b u $TSTUSR
1607 # first wirte might be cached
1608 $RUNAS $DD of=$TESTFILE count=$((blimit + 1))
1609 cancel_lru_locks osc
1611 $RUNAS $DD of=$TESTFILE count=$((blimit + 1)) seek=$((blimit + 1)) &&
1612 quota_error u $TSTUSR "Write success, expect failure"
1616 resetquota -u $TSTUSR
1618 run_test 19 "Updating admin limits doesn't zero operational limits(b14790)"
1620 test_20() { # b15754
1621 local LSTR=(2g 1t 4k 3m) # limits strings
1623 local LVAL=($[2*1024*1024] $[1*1024*1024*1024] $[4*1024] $[3*1024*1024])
1625 resetquota -u $TSTUSR
1627 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1628 $MOUNT || error "could not set quota limits"
1629 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1630 --inode-softlimit ${LSTR[2]} \
1631 --inode-hardlimit ${LSTR[3]} \
1632 $MOUNT || error "could not set quota limits"
1634 [ "$(getquota -u $TSTUSR global bsoftlimit)" = "${LVAL[0]}" ] ||
1635 error "bsoftlimit was not set properly"
1636 [ "$(getquota -u $TSTUSR global bhardlimit)" = "${LVAL[1]}" ] ||
1637 error "bhardlimit was not set properly"
1638 [ "$(getquota -u $TSTUSR global isoftlimit)" = "${LVAL[2]}" ] ||
1639 error "isoftlimit was not set properly"
1640 [ "$(getquota -u $TSTUSR global ihardlimit)" = "${LVAL[3]}" ] ||
1641 error "ihardlimit was not set properly"
1643 resetquota -u $TSTUSR
1645 run_test 20 "Test if setquota specifiers work properly (b15754)"
1652 local time=$(($(date +%s) + seconds))
1653 while [ $(date +%s) -lt $time ]; do
1654 $RUNAS $DD of=$testfile count=$blk_number > /dev/null 2>&1
1658 # run for fixing bug16053, setquota shouldn't fail when writing and
1659 # deleting are happening
1661 local TESTFILE="$DIR/$tdir/$tfile"
1662 local BLIMIT=10 # 10G
1663 local ILIMIT=1000000
1666 trap cleanup_quota_test EXIT
1668 set_ost_qtype "ug" || error "Enable ost quota failed"
1670 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for user: $TSTUSR"
1671 $LFS setquota -u $TSTUSR -b 0 -B ${BLIMIT}G -i 0 -I $ILIMIT $MOUNT ||
1672 error "set user quota failed"
1673 log "Set limit(block:${BLIMIT}G; file:$ILIMIT) for group: $TSTUSR"
1674 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $MOUNT ||
1675 error "set group quota failed"
1677 # repeat writing on a 1M file
1678 test_21_sub ${TESTFILE}_1 1 30 &
1680 # repeat writing on a 128M file
1681 test_21_sub ${TESTFILE}_2 128 30 &
1684 local time=$(($(date +%s) + 30))
1686 while [ $(date +%s) -lt $time ]; do
1687 log "Set quota for $i times"
1688 $LFS setquota -u $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1689 -I $((ILIMIT + i)) $MOUNT ||
1690 error "Set user quota failed"
1691 $LFS setquota -g $TSTUSR -b 0 -B "$((BLIMIT + i))G" -i 0 \
1692 -I $((ILIMIT + i)) $MOUNT ||
1693 error "Set group quota failed"
1700 if ! ps -p ${DDPID1} > /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=$DDPID1, time=$count)successful"
1711 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1713 if [ $count -gt 60 ]; then
1714 quota_error a $TSTUSR "dd should be finished!"
1718 echo "(dd_pid=$DDPID2, time=$count)successful"
1721 resetquota -u $TSTUSR
1722 resetquota -g $TSTUSR
1724 run_test 21 "Setquota while writing & deleting (b16053)"
1726 # enable/disable quota enforcement permanently
1728 echo "Set both mdt & ost quota type as ug"
1729 set_mdt_qtype "ug" || error "enable mdt quota failed"
1730 set_ost_qtype "ug" || error "enable ost quota failed"
1737 echo "Verify if quota is enabled"
1738 local qtype=$(mdt_quota_type)
1739 [ $qtype != "ug" ] && error "mdt quota setting is lost"
1740 qtype=$(ost_quota_type)
1741 [ $qtype != "ug" ] && error "ost quota setting is lost"
1743 echo "Set both mdt & ost quota type as none"
1744 set_mdt_qtype "none" || error "disable mdt quota failed"
1745 set_ost_qtype "none" || error "disable ost quota failed"
1753 echo "Verify if quota is disabled"
1754 qtype=$(mdt_quota_type)
1755 [ $qtype != "none" ] && error "mdt quota setting is lost"
1756 qtype=$(ost_quota_type)
1757 [ $qtype != "none" ] && error "ost quota setting is lost"
1761 run_test 22 "enable/disable quota by 'lctl conf_param'"
1764 local TESTFILE="$DIR/$tdir/$tfile"
1768 trap cleanup_quota_test EXIT
1770 set_ost_qtype "ug" || error "Enable ost quota failed"
1773 log "User quota (limit: $LIMIT MB)"
1774 $LFS setquota -u $TSTUSR -b 0 -B "$LIMIT"M -i 0 -I 0 $DIR ||
1775 error "set quota failed"
1776 quota_show_check b u $TSTUSR
1778 $LFS setstripe $TESTFILE -c 1 -i 0
1779 chown $TSTUSR.$TSTUSR $TESTFILE
1781 log "Step1: trigger EDQUOT with O_DIRECT"
1782 log "Write half of file"
1783 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2)) oflag=direct ||
1784 quota_error u $TSTUSR "(1) Write failure, expect success." \
1786 log "Write out of block quota ..."
1787 $RUNAS $DD of=$TESTFILE count=$((LIMIT/2 + 1)) seek=$((LIMIT/2)) \
1788 oflag=direct conv=notrunc &&
1789 quota_error u $TSTUSR "(2) Write success, expect EDQUOT." \
1793 log "Step2: rewrite should succeed"
1794 $RUNAS $DD of=$TESTFILE count=1 oflag=direct conv=notrunc||
1795 quota_error u $TSTUSR "(3) Write failure, expect success." \
1801 local OST0_UUID=$(ostuuid_from_index 0)
1802 local OST0_QUOTA_USED=$(getquota -u $TSTUSR $OST0_UUID curspace)
1803 [ $OST0_QUOTA_USED -ne 0 ] &&
1804 ($SHOW_QUOTA_USER; \
1805 quota_error u $TSTUSR "quota isn't released")
1807 resetquota -u $TSTUSR
1811 local OST0_MIN=$((6 * 1024)) # 6MB, extra space for meta blocks.
1812 check_whether_skip && return 0
1813 log "run for 4MB test file"
1816 OST0_MIN=$((60 * 1024)) # 60MB, extra space for meta blocks.
1817 check_whether_skip && return 0
1818 log "run for 40MB test file"
1821 run_test 23 "Quota should be honored with directIO (b16125)"
1825 local TESTFILE="$DIR/$tdir/$tfile"
1828 trap cleanup_quota_test EXIT
1830 set_ost_qtype "ug" || error "enable ost quota failed"
1832 # bind file to a single OST
1833 $LFS setstripe -c 1 $TESTFILE
1834 chown $TSTUSR.$TSTUSR $TESTFILE
1836 echo "Set user quota (limit: "$blimit"M)"
1837 $LFS setquota -u $TSTUSR -b 0 -B "$blimit"M -i 0 -I 0 $MOUNT ||
1838 error "set quota failed"
1840 # overrun quota by root user
1841 runas -u 0 -g 0 $DD of=$TESTFILE count=$((blimit + 1)) ||
1842 error "write failure, expect success"
1843 cancel_lru_locks osc
1844 sync_all_data || true
1846 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1849 resetquota -u $TSTUSR
1851 run_test 24 "lfs draws an asterix when limit is reached (b16646)"
1853 test_27a() { # b19612
1854 $LFS quota $TSTUSR $DIR &&
1855 error "lfs succeeded with no type, but should have failed"
1856 $LFS setquota $TSTUSR $DIR &&
1857 error "lfs succeeded with no type, but should have failed"
1860 run_test 27a "lfs quota/setquota should handle wrong arguments (b19612)"
1862 test_27b() { # b20200
1863 $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1864 error "lfs setquota failed with uid argument"
1865 $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR ||
1866 error "lfs stequota failed with gid argument"
1867 $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
1868 $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
1869 resetquota -u $TSTUSR
1870 resetquota -g $TSTUSR
1873 run_test 27b "lfs quota/setquota should handle user/group ID (b20200)"
1878 local TESTFILE="$DIR/$tdir/$tfile"
1882 trap cleanup_quota_test EXIT
1884 set_ost_qtype "u" || error "enable ost quota failed"
1886 $LFS setstripe $TESTFILE -i 0 -c 1
1887 chown $TSTUSR.$TSTUSR $TESTFILE
1889 $LFS setquota -t -u --block-grace $GRACE --inode-grace \
1890 $MAX_IQ_TIME $DIR || error "set grace time failed"
1891 $LFS setquota -u $TSTUSR -b ${LIMIT}M -B 0 -i 0 -I 0 $DIR ||
1892 error "set quota failed"
1893 $RUNAS $DD of=$TESTFILE count=$((LIMIT * 2)) || true
1894 cancel_lru_locks osc
1896 $LFS setquota -u $TSTUSR -B 0 $DIR || error "clear quota failed"
1897 # over-quota flag has not yet settled since we do not trigger async
1898 # events based on grace time period expiration
1900 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 || true
1901 cancel_lru_locks osc
1902 # now over-quota flag should be settled and further writes should fail
1904 $RUNAS $DD of=$TESTFILE conv=notrunc oflag=append count=1 &&
1905 error "grace times were reset"
1908 resetquota -u $TSTUSR
1909 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace \
1910 $MAX_IQ_TIME $DIR || error "restore grace time failed"
1912 run_test 30 "Hard limit updates should not reset grace times"
1914 # basic usage tracking for user & group
1916 local INODES=10 # 10 files
1917 local BLK_CNT=2 # of 2M each
1918 local TOTAL_BLKS=$((INODES * BLK_CNT * 1024))
1921 trap cleanup_quota_test EXIT
1923 # make sure the system is clean
1924 local USED=$(getquota -u $TSTID global curspace)
1926 error "Used space ($USED) for user $TSTID isn't 0."
1927 USED=$(getquota -g $TSTID global curspace)
1929 error "Used space ($USED) for group $TSTID isn't 0."
1931 echo "Write files..."
1932 for i in `seq 0 $INODES`; do
1933 $RUNAS $DD of=$DIR/$tdir/$tfile-$i count=$BLK_CNT 2>/dev/null ||
1934 error "write failed"
1935 echo "Iteration $i/$INODES completed"
1937 cancel_lru_locks osc
1938 sync; sync_all_data || true
1940 echo "Verify disk usage after write"
1941 USED=$(getquota -u $TSTID global curspace)
1942 [ $USED -lt $TOTAL_BLKS ] &&
1943 error "Used space for user $TSTID:$USED, expected:$TOTAL_BLKS"
1944 USED=$(getquota -g $TSTID global curspace)
1945 [ $USED -lt $TOTAL_BLKS ] &&
1946 error "Used space for group $TSTID:$USED, expected:$TOTAL_BLKS"
1948 echo "Verify inode usage after write"
1949 USED=$(getquota -u $TSTID global curinodes)
1950 [ $USED -lt $INODES ] &&
1951 error "Used inode for user $TSTID is $USED, expected $INODES"
1952 USED=$(getquota -g $TSTID global curinodes)
1953 [ $USED -lt $INODES ] &&
1954 error "Used inode for group $TSTID is $USED, expected $INODES"
1958 echo "Verify disk usage after delete"
1959 USED=$(getquota -u $TSTID global curspace)
1960 [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
1961 USED=$(getquota -u $TSTID global curinodes)
1962 [ $USED -eq 0 ] || error "Used inodes for user $TSTID isn't 0. $USED"
1963 USED=$(getquota -g $TSTID global curspace)
1964 [ $USED -eq 0 ] || error "Used space for group $TSTID isn't 0. $USED"
1965 USED=$(getquota -g $TSTID global curinodes)
1966 [ $USED -eq 0 ] || error "Used inodes for group $TSTID isn't 0. $USED"
1968 run_test 33 "Basic usage tracking for user & group"
1970 # usage transfer test for user & group
1972 local BLK_CNT=2 # 2MB
1975 trap cleanup_quota_test EXIT
1977 # make sure the system is clean
1978 local USED=$(getquota -u $TSTID global curspace)
1979 [ $USED -ne 0 ] && error "Used space ($USED) for user $TSTID isn't 0."
1980 USED=$(getquota -g $TSTID global curspace)
1981 [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
1983 echo "Write file..."
1984 $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
1985 error "write failed"
1986 cancel_lru_locks osc
1987 sync; sync_all_data || true
1989 echo "chown the file to user $TSTID"
1990 chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
1992 echo "Wait for setattr on objects finished..."
1993 wait_delete_completed
1995 BLK_CNT=$((BLK_CNT * 1024))
1997 echo "Verify disk usage for user $TSTID"
1998 USED=$(getquota -u $TSTID global curspace)
1999 [ $USED -lt $BLK_CNT ] &&
2000 error "Used space for user $TSTID is ${USED}, expected $BLK_CNT"
2001 USED=$(getquota -u $TSTID global curinodes)
2003 error "Used inodes for user $TSTID is $USED, expected 1"
2005 echo "chgrp the file to group $TSTID"
2006 chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
2008 echo "Wait for setattr on objects finished..."
2009 wait_delete_completed
2011 echo "Verify disk usage for group $TSTID"
2012 USED=$(getquota -g $TSTID global curspace)
2013 [ $USED -ge $BLK_CNT ] ||
2014 error "Used space for group $TSTID is $USED, expected $BLK_CNT"
2015 USED=$(getquota -g $TSTID global curinodes)
2017 error "Used inodes for group $TSTID is $USED, expected 1"
2021 run_test 34 "Usage transfer for user & group"
2023 # usage is still accessible across restart
2025 local BLK_CNT=2 # 2 MB
2028 trap cleanup_quota_test EXIT
2030 echo "Write file..."
2031 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT 2>/dev/null ||
2032 error "write failed"
2033 cancel_lru_locks osc
2034 sync; sync_all_data || true
2036 echo "Save disk usage before restart"
2037 local ORIG_USR_SPACE=$(getquota -u $TSTID global curspace)
2038 [ $ORIG_USR_SPACE -eq 0 ] &&
2039 error "Used space for user $TSTID is 0, expected ${BLK_CNT}M"
2040 local ORIG_USR_INODES=$(getquota -u $TSTID global curinodes)
2041 [ $ORIG_USR_INODES -eq 0 ] &&
2042 error "Used inodes for user $TSTID is 0, expected 1"
2043 echo "User $TSTID: ${ORIG_USR_SPACE}KB $ORIG_USR_INODES inodes"
2044 local ORIG_GRP_SPACE=$(getquota -g $TSTID global curspace)
2045 [ $ORIG_GRP_SPACE -eq 0 ] &&
2046 error "Used space for group $TSTID is 0, expected ${BLK_CNT}M"
2047 local ORIG_GRP_INODES=$(getquota -g $TSTID global curinodes)
2048 [ $ORIG_GRP_INODES -eq 0 ] &&
2049 error "Used inodes for group $TSTID is 0, expected 1"
2050 echo "Group $TSTID: ${ORIG_GRP_SPACE}KB $ORIG_GRP_INODES inodes"
2053 local ORIG_REFORMAT=$REFORMAT
2055 cleanup_and_setup_lustre
2056 REFORMAT=$ORIG_REFORMAT
2059 echo "Verify disk usage after restart"
2060 local USED=$(getquota -u $TSTID global curspace)
2061 [ $USED -eq $ORIG_USR_SPACE ] ||
2062 error "Used space for user $TSTID changed from " \
2063 "$ORIG_USR_SPACE to $USED"
2064 USED=$(getquota -u $TSTID global curinodes)
2065 [ $USED -eq $ORIG_USR_INODES ] ||
2066 error "Used inodes for user $TSTID changed from " \
2067 "$ORIG_USR_INODES to $USED"
2068 USED=$(getquota -g $TSTID global curspace)
2069 [ $USED -eq $ORIG_GRP_SPACE ] ||
2070 error "Used space for group $TSTID changed from " \
2071 "$ORIG_GRP_SPACE to $USED"
2072 USED=$(getquota -g $TSTID global curinodes)
2073 [ $USED -eq $ORIG_GRP_INODES ] ||
2074 error "Used inodes for group $TSTID changed from " \
2075 "$ORIG_GRP_INODES to $USED"
2077 # check if the vfs_dq_init() is called before writing
2078 echo "Append to the same file..."
2079 $RUNAS $DD of=$DIR/$tdir/$tfile count=$BLK_CNT seek=1 2>/dev/null ||
2080 error "write failed"
2081 cancel_lru_locks osc
2082 sync; sync_all_data || true
2084 echo "Verify space usage is increased"
2085 USED=$(getquota -u $TSTID global curspace)
2086 [ $USED -gt $ORIG_USR_SPACE ] ||
2087 error "Used space for user $TSTID isn't increased" \
2088 "orig:$ORIG_USR_SPACE, now:$USED"
2089 USED=$(getquota -g $TSTID global curspace)
2090 [ $USED -gt $ORIG_GRP_SPACE ] ||
2091 error "Used space for group $TSTID isn't increased" \
2092 "orig:$ORIG_GRP_SPACE, now:$USED"
2096 run_test 35 "Usage is still accessible across reboot"
2098 # test migrating old amdin quota files (in Linux quota file format v2) into new
2099 # quota global index (in IAM format)
2101 [ $(facet_fstype $SINGLEMDS) != ldiskfs ] && \
2102 skip "skipping migration test" && return
2104 # get the mdt0 device name
2105 local mdt0_node=$(facet_active_host $SINGLEMDS)
2106 local mdt0_dev=$(mdsdevname ${SINGLEMDS//mds/})
2111 echo "Copy admin quota files into MDT0..."
2112 local mntpt=$(facet_mntpt $SINGLEMDS)
2113 local mdt0_fstype=$(facet_fstype $SINGLEMDS)
2115 if ! do_node $mdt0_node test -b $mdt0_fstype; then
2118 echo "$mdt0_node, $mdt0_dev, $mntpt, $opt"
2119 do_node $mdt0_node mount -t $mdt0_fstype $opt $mdt0_dev $mntpt
2120 do_node $mdt0_node mkdir $mntpt/OBJECTS
2121 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.usr $mntpt/OBJECTS
2122 do_node $mdt0_node cp $LUSTRE/tests/admin_quotafile_v2.grp $mntpt/OBJECTS
2123 do_node $mdt0_node umount -f $mntpt
2128 echo "Verify global limits..."
2132 local proc="qmt.*.md-0x0.glb-usr"
2133 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2134 [ $id_cnt -eq 403 ] || error "Migrate inode user limit failed: $id_cnt"
2135 limit=$(getquota -u 1 global isoftlimit)
2136 [ $limit -eq 1024 ] || error "User inode softlimit: $limit"
2137 limit=$(getquota -u 1 global ihardlimit)
2138 [ $limit -eq 2048 ] || error "User inode hardlimit: $limit"
2140 proc="qmt.*.md-0x0.glb-grp"
2141 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2142 [ $id_cnt -eq 403 ] || error "Migrate inode group limit failed: $id_cnt"
2143 limit=$(getquota -g 1 global isoftlimit)
2144 [ $limit -eq 1024 ] || error "Group inode softlimit: $limit"
2145 limit=$(getquota -g 1 global ihardlimit)
2146 [ $limit -eq 2048 ] || error "Group inode hardlimit: $limit"
2148 proc=" qmt.*.dt-0x0.glb-usr"
2149 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2150 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2151 limit=$(getquota -u 60001 global bsoftlimit)
2152 [ $limit -eq 10485760 ] || error "User block softlimit: $limit"
2153 limit=$(getquota -u 60001 global bhardlimit)
2154 [ $limit -eq 20971520 ] || error "User block hardlimit: $limit"
2156 proc="qmt.*.dt-0x0.glb-grp"
2157 id_cnt=$(do_node $mdt0_node $LCTL get_param -n $proc | wc -l)
2158 [ $id_cnt -eq 403 ] || error "Migrate block user limit failed: $id_cnt"
2159 limit=$(getquota -g 60001 global bsoftlimit)
2160 [ $limit -eq 10485760 ] || error "Group block softlimit: $limit"
2161 limit=$(getquota -g 60001 global bhardlimit)
2162 [ $limit -eq 20971520 ] || error "Group block hardlimit: $limit"
2168 run_test 36 "Migrate old admin files into new global indexes"
2172 do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=-quota"
2178 check_and_cleanup_lustre
2179 export QUOTA_AUTO=$QUOTA_AUTO_OLD