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
9 #kernel 2.4.x doesn't support quota
10 K_VER=`uname --kernel-release | cut -b 1-3`
11 if [ $K_VER = "2.4" ]; then
12 echo "Kernel 2.4 doesn't support quota"
17 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
20 ALWAYS_EXCEPT="10 $SANITY_QUOTA_EXCEPT"
21 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
24 2.6*) FSTYPE=${FSTYPE:-ldiskfs};;
25 *) error "unsupported kernel" ;;
28 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
29 echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
35 TSTID2=${TSTID2:-60001}
36 TSTUSR=${TSTUSR:-"quota_usr"}
37 TSTUSR2=${TSTUSR2:-"quota_2usr"}
39 BUNIT_SZ=${BUNIT_SZ:-1024} # min block quota unit(kB)
40 IUNIT_SZ=${IUNIT_SZ:-10} # min inode quota unit
45 LUSTRE=${LUSTRE:-`dirname $0`/..}
46 . $LUSTRE/tests/test-framework.sh
48 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
49 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
51 [ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0
52 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
53 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
55 [ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11 18b 21"
57 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
59 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
64 check_and_setup_lustre
66 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
67 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
69 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
70 SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR"
71 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
72 SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR"
73 SHOW_QUOTA_INFO="$LFS quota -t $DIR"
75 # control the time of tests
77 [ "$SLOW" = "no" ] && cycle=10
84 # set_blk_tunables(btune_sz)
86 local btune=$(($1 * BLK_SZ))
87 # set btune size on all obdfilters
88 do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_btune_sz=$btune"
89 # set btune size on mds
90 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_btune_sz=$btune"
93 # set_blk_unitsz(bunit_sz)
95 local bunit=$(($1 * BLK_SZ))
96 # set bunit size on all obdfilters
97 do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_bunit_sz=$bunit"
98 # set bunit size on mds
99 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_bunit_sz=$bunit"
102 # set_file_tunesz(itune_sz)
105 # set itune size on all obdfilters
106 do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_itune_sz=$itune"
107 # set itune size on mds
108 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_itune_sz=$itune"
111 # set_file_unitsz(iunit_sz)
114 # set iunit size on all obdfilters
115 do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_iunit_sz=$iunit"
116 # set iunit size on mds
117 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_iunit_sz=$iunit"
123 local fail_val=${3:-0}
125 if [ $fail_node == "mds" ] || [ $fail_node == "mds_ost" ]; then
126 if [ $((fail_loc & 0x10000000)) -ne 0 -a $fail_val -gt 0 ] || \
127 [ $((fail_loc)) -eq 0 ]; then
128 do_facet $SINGLEMDS "lctl set_param fail_val=$fail_val"
130 do_facet $SINGLEMDS "lctl set_param fail_loc=$fail_loc"
132 if [ $fail_node == "ost" ] || [ $fail_node == "mds_ost" ]; then
133 for num in `seq $OSTCOUNT`; do
134 if [ $((fail_loc & 0x10000000)) -ne 0 -a $fail_val -gt 0 ] || \
135 [ $((fail_loc)) -eq 0 ]; then
136 do_facet ost$num "lctl set_param fail_val=$fail_val"
138 do_facet ost$num "lctl set_param fail_loc=$fail_loc"
143 RUNAS="runas -u $TSTID -g $TSTID"
144 RUNAS2="runas -u $TSTID2 -g $TSTID2"
145 FAIL_ON_ERROR=true check_runas_id $TSTID $TSTID $RUNAS
146 FAIL_ON_ERROR=true check_runas_id $TSTID2 $TSTID2 $RUNAS2
150 run_test_with_stat() {
151 (($# != 2)) && error "the number of arguments is wrong"
153 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.stats=0" > /dev/null
154 for j in `seq $OSTCOUNT`; do
155 do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.stats=0" > /dev/null
158 if [ ${STAT:-"yes"} != "no" -a -z "$LAST_SKIPPED" ]; then
159 echo "statistics info begin ***************************************"
160 do_facet $SINGLEMDS "lctl get_param lquota.mdd_obd-${FSNAME}-MDT*.stats"
161 for j in `seq $OSTCOUNT`; do
162 do_facet ost$j "lctl get_param lquota.${FSNAME}-OST*.stats"
164 echo "statistics info end ***************************************"
169 # clear quota limits for a user or a group
170 # usage: resetquota -u username
171 # resetquota -g groupname
174 [ "$#" != 2 ] && error "resetquota: wrong number of arguments: $#"
175 [ "$1" != "-u" -a "$1" != "-g" ] && error "resetquota: wrong specifier $1 passed"
176 $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT || error "resetquota failed"
183 if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "u" ]; then
184 log "Files for user ($LOCAL_ID):"
185 ($LFS find -user $LOCAL_ID $DIR | xargs stat 2>/dev/null)
188 if [ "$LOCAL_UG" == "a" -o "$LOCAL_UG" == "g" ]; then
189 log "Files for group ($LOCAL_ID):"
190 ($LFS find -group $LOCAL_ID $DIR | xargs stat 2>/dev/null)
210 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
212 $LFS quota -v -$LOCAL_UG $LOCAL_ID $DIR
214 if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then
215 USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`"
216 [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
219 if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then
220 USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`"
221 [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
227 $LFS quotaoff -ug $DIR
228 $LFS quotacheck -ug $DIR
230 resetquota -u $TSTUSR
231 resetquota -g $TSTUSR
233 lctl set_param debug="+quota"
234 do_facet $SINGLEMDS "lctl set_param debug=+quota"
235 for num in `seq $OSTCOUNT`; do
236 do_facet ost$num "lctl set_param debug=+quota"
239 run_test_with_stat 0 "Set quota ============================="
241 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
245 chmod 0777 $DIR/$tdir
246 TESTFILE="$DIR/$tdir/$tfile-0"
248 wait_delete_completed
251 log " User quota (limit: $LIMIT kbytes)"
252 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
254 quota_show_check b u $TSTUSR
256 $LFS setstripe $TESTFILE -c 1
257 chown $TSTUSR.$TSTUSR $TESTFILE
260 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error u $TSTUSR "(usr) write failure, but expect success"
262 log " Write out of block quota ..."
263 # this time maybe cache write, ignore it's failure
264 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
265 # flush cache, ensure noquota flag is setted on client
267 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error u $TSTUSR "(usr) write success, but expect EDQUOT"
271 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
272 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
273 echo $OST0_QUOTA_USED
274 [ $OST0_QUOTA_USED -ne 0 ] && \
275 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
277 resetquota -u $TSTUSR
280 log "--------------------------------------"
281 log " Group quota (limit: $LIMIT kbytes)"
282 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
284 quota_show_check b g $TSTUSR
285 TESTFILE="$DIR/$tdir/$tfile-1"
287 $LFS setstripe $TESTFILE -c 1
288 chown $TSTUSR.$TSTUSR $TESTFILE
291 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error g $TSTUSR "(grp) write failure, but expect success"
293 log " Write out of block quota ..."
294 # this time maybe cache write, ignore it's failure
295 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
297 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && quota_error g $TSTUSR "(grp) write success, but expect EDQUOT"
302 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
303 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
304 echo $OST0_QUOTA_USED
305 [ $OST0_QUOTA_USED -ne 0 ] && \
306 ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
308 resetquota -g $TSTUSR
311 # block hard limit (normal use and out of quota)
313 for i in `seq 1 $cycle`; do
314 # define blk_qunit is between 1M and 4M
315 blk_qunit=$(( $RANDOM % 3072 + 1024 ))
316 blk_qtune=$(( $RANDOM % $blk_qunit ))
317 # other osts and mds will occupy at 1M blk quota
318 b_limit=$(( ($RANDOM - 16384) / 8 + $OSTCOUNT * $blk_qunit * 4 ))
319 set_blk_tunesz $blk_qtune
320 set_blk_unitsz $blk_qunit
321 echo "cycle: $i(total $cycle) bunit:$blk_qunit, btune:$blk_qtune, blimit:$b_limit"
323 echo "=================================================="
324 set_blk_unitsz $((128 * 1024))
325 set_blk_tunesz $((128 * 1024 / 2))
328 run_test_with_stat 1 "Block hard limit (normal use and out of quota) ==="
330 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
334 chmod 0777 $DIR/$tdir
335 TESTFILE="$DIR/$tdir/$tfile-0"
337 wait_delete_completed
340 log " User quota (limit: $LIMIT files)"
341 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
343 quota_show_check f u $TSTUSR
345 log " Create $LIMIT files ..."
346 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
347 quota_error u $TSTUSR "(usr) create failure, but expect success"
349 log " Create out of file quota ..."
350 $RUNAS touch ${TESTFILE}_xxx && \
351 quota_error u $TSTUSR "(usr) touch success, but expect EDQUOT"
353 unlinkmany ${TESTFILE} $LIMIT
354 rm -f ${TESTFILE}_xxx
357 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
358 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
360 [ $MDS_QUOTA_USED -ne 0 ] && \
361 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
363 resetquota -u $TSTUSR
366 log "--------------------------------------"
367 log " Group quota (limit: $LIMIT FILE)"
368 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
370 quota_show_check f g $TSTUSR
371 TESTFILE=$DIR/$tdir/$tfile-1
373 log " Create $LIMIT files ..."
374 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
375 quota_error g $TSTUSR "(grp) create failure, but expect success"
377 log " Create out of file quota ..."
378 $RUNAS touch ${TESTFILE}_xxx && \
379 quota_error g $TSTUSR "(grp) touch success, but expect EDQUOT"
381 unlinkmany ${TESTFILE} $LIMIT
382 rm -f ${TESTFILE}_xxx
385 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
386 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
388 [ $MDS_QUOTA_USED -ne 0 ] && \
389 ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
391 resetquota -g $TSTUSR
394 # file hard limit (normal use and out of quota)
396 for i in `seq 1 $cycle`; do
397 if [ $i -eq 1 ]; then
402 # define ino_qunit is between 10 and 100
403 ino_qunit=$(( $RANDOM % 90 + 10 ))
404 ino_qtune=$(( $RANDOM % $ino_qunit ))
405 # RANDOM's maxium is 32767
406 i_limit=$(( $RANDOM % 990 + 10 ))
409 set_file_tunesz $ino_qtune
410 set_file_unitsz $ino_qunit
411 echo "cycle: $i(total $cycle) iunit:$ino_qunit, itune:$ino_qtune, ilimit:$i_limit"
413 echo "=================================================="
418 run_test_with_stat 2 "File hard limit (normal use and out of quota) ==="
422 TIMER=$(($2 * 3 / 2))
425 wait_delete_completed
427 echo " Write to exceed soft limit"
428 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
429 $RUNDD count=$((BUNIT_SZ+1)) || \
430 quota_error a $TSTUSR "write failure, but expect success"
431 OFFSET=$((OFFSET + BUNIT_SZ + 1))
438 echo " Write before timer goes off"
439 $RUNDD count=$BUNIT_SZ seek=$OFFSET || \
440 quota_error a $TSTUSR "write failure, but expect success"
441 OFFSET=$((OFFSET + BUNIT_SZ))
445 echo " Sleep $TIMER seconds ..."
452 echo " Write after timer goes off"
453 # maybe cache write, ignore.
454 $RUNDD count=$BUNIT_SZ seek=$OFFSET || true
455 OFFSET=$((OFFSET + BUNIT_SZ))
457 $RUNDD count=$BUNIT_SZ seek=$OFFSET && \
458 quota_error a $TSTUSR "write success, but expect EDQUOT"
464 echo " Unlink file to stop timer"
474 $RUNDD count=$BUNIT_SZ || quota_error a $TSTUSR "write failure, but expect success"
482 # block soft limit (start timer, timer goes off, stop timer)
485 chmod 0777 $DIR/$tdir
487 # 1 bunit on mds and 1 bunit on every ost
488 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) ))
491 echo " User quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
492 TESTFILE=$DIR/$tdir/$tfile-0
494 $LFS setstripe $TESTFILE -c 1
495 chown $TSTUSR.$TSTUSR $TESTFILE
497 $LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
498 $LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
500 test_block_soft $TESTFILE $GRACE
501 resetquota -u $TSTUSR
503 echo " Group quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
504 TESTFILE=$DIR/$tdir/$tfile-1
506 $LFS setstripe $TESTFILE -c 1
507 chown $TSTUSR.$TSTUSR $TESTFILE
509 $LFS setquota -t -g --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
510 $LFS setquota -g $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
512 test_block_soft $TESTFILE $GRACE
513 resetquota -g $TSTUSR
515 run_test_with_stat 3 "Block soft limit (start timer, timer goes off, stop timer) ==="
520 TIMER=$(($3 * 3 / 2))
522 wait_delete_completed
524 echo " Create files to exceed soft limit"
525 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) || \
526 quota_error a $TSTUSR "create failure, but expect success"
530 echo " Create file before timer goes off"
531 $RUNAS touch ${TESTFILE}_before || \
532 quota_error a $TSTUSR "failed create before timer expired, but expect success"
536 echo " Sleep $TIMER seconds ..."
543 echo " Create file after timer goes off"
544 # the least of inode qunit is 2, so there are at most 3(qunit:2+qtune:1)
545 # inode quota left here
546 $RUNAS touch ${TESTFILE}_after ${TESTFILE}_after1 ${TESTFILE}_after2 || true
548 $RUNAS touch ${TESTFILE}_after3 && \
549 quota_error a $TSTUSR "create after timer expired, but expect EDQUOT"
556 echo " Unlink files to stop timer"
557 find `dirname $TESTFILE` -name "`basename ${TESTFILE}`*" | xargs rm -f
561 $RUNAS touch ${TESTFILE}_xxx || \
562 quota_error a $TSTUSR "touch after timer stop failure, but expect success"
567 rm -f ${TESTFILE}_xxx
571 # file soft limit (start timer, timer goes off, stop timer)
572 test_4a() { # was test_4
574 chmod 0777 $DIR/$tdir
575 LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds
576 TESTFILE=$DIR/$tdir/$tfile-0
580 echo " User quota (soft limit: $LIMIT files grace: $GRACE seconds)"
581 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
582 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
583 quota_show_check f u $TSTUSR
585 test_file_soft $TESTFILE $LIMIT $GRACE
586 resetquota -u $TSTUSR
588 echo " Group quota (soft limit: $LIMIT files grace: $GRACE seconds)"
589 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
590 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
591 quota_show_check f g $TSTUSR
592 TESTFILE=$DIR/$tdir/$tfile-1
594 test_file_soft $TESTFILE $LIMIT $GRACE
595 resetquota -g $TSTUSR
598 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
599 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
601 run_test_with_stat 4a "File soft limit (start timer, timer goes off, stop timer) ==="
603 test_4b() { # was test_4a
609 GR_STR6="1111111111111111"
611 wait_delete_completed
613 # test of valid grace strings handling
614 echo " Valid grace strings test"
615 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace $GR_STR2 $DIR
616 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
617 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace $GR_STR4 $DIR
618 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
620 # test of invalid grace strings handling
621 echo " Invalid grace strings test"
622 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
623 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
626 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
627 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
629 run_test_with_stat 4b "Grace time strings handling ==="
631 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
634 BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server
635 ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds
637 wait_delete_completed
639 echo " Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR"
640 $LFS setquota -u $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
641 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
642 quota_show_check a u $TSTUSR
643 quota_show_check a g $TSTUSR
645 echo " Create more than $ILIMIT files and more than $BLIMIT kbytes ..."
646 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \
647 error "touch failure, expect success"
648 dd if=/dev/zero of=$DIR/$tdir/$tfile-0_1 bs=$BLK_SZ count=$((BLIMIT+1)) || error "write failure, expect success"
650 echo " Chown files to $TSTUSR.$TSTUSR ..."
651 for i in `seq 0 $ILIMIT`; do
652 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \
653 quota_error a $TSTUSR "chown failure, but expect success"
657 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
660 resetquota -u $TSTUSR
661 resetquota -g $TSTUSR
663 run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota ==="
665 # block quota acquire & release
667 if [ $OSTCOUNT -lt 2 ]; then
668 skip "$OSTCOUNT < 2, too few osts"
672 wait_delete_completed
675 chmod 0777 $DIR/$tdir
677 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server
678 FILEA="$DIR/$tdir/$tfile-0_a"
679 FILEB="$DIR/$tdir/$tfile-0_b"
681 echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
682 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
683 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
684 quota_show_check b u $TSTUSR
685 quota_show_check b g $TSTUSR
687 echo " Create filea on OST0 and fileb on OST1"
688 $LFS setstripe $FILEA -i 0 -c 1
689 $LFS setstripe $FILEB -i 1 -c 1
690 chown $TSTUSR.$TSTUSR $FILEA
691 chown $TSTUSR.$TSTUSR $FILEB
693 echo " Exceed quota limit ..."
694 RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
695 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
696 quota_error a $TSTUSR "write fileb failure, but expect success"
701 $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
702 quota_error a $TSTUSR "write fileb success, but expect EDQUOT"
704 echo " Write to OST0 return EDQUOT"
705 # this write maybe cache write, ignore it's failure
706 RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
707 $RUNDD count=$(($BUNIT_SZ * 2)) || true
711 $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
712 quota_error a $TSTUSR "write filea success, but expect EDQUOT"
714 echo " Remove fileb to let OST1 release quota"
716 sync; sleep 10; sync; # need to allow journal commit for small fs
718 echo " Write to OST0"
719 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
720 quota_error a $TSTUSR "write filea failure, expect success"
727 resetquota -u $TSTUSR
728 resetquota -g $TSTUSR
731 run_test_with_stat 6 "Block quota acquire & release ========="
733 # quota recovery (block quota only by now)
737 chmod 0777 $DIR/$tdir
739 wait_delete_completed
741 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) ))
742 TESTFILE="$DIR/$tdir/$tfile-0"
744 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
746 $LFS setstripe $TESTFILE -c 1
747 chown $TSTUSR.$TSTUSR $TESTFILE
749 echo " Write to OST0..."
750 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \
751 quota_error u $TSTUSR "write failure, but expect success"
753 #define OBD_FAIL_OBD_DQACQ 0x604
754 lustre_fail mds 0x604
755 echo " Remove files on OST0"
759 echo " Trigger recovery..."
760 OSC0_UUID="`$LCTL dl | awk '$3 ~ /osc/ { print $1 }'`"
761 for i in $OSC0_UUID; do
762 $LCTL --device $i activate || error "activate osc failed!"
765 # sleep a while to wait for recovery done
769 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
770 TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
771 [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!"
772 echo " total limits = $TOTAL_LIMIT"
774 OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
775 [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
776 OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`"
777 [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!"
778 echo " limits on $OST0_UUID = $OST0_LIMIT"
781 resetquota -u $TSTUSR
783 run_test_with_stat 7 "Quota recovery (only block limit) ======"
785 # run dbench with quota enabled
788 BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
791 wait_delete_completed
793 echo " Set enough high limit for user: $TSTUSR"
794 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
795 echo " Set enough high limit for group: $TSTUSR"
796 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
798 chmod 0777 $DIR/$tdir
800 [ "$SLOW" = "no" ] && duration=" -t 120"
801 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration || quota_error a $TSTUSR "dbench failed!"
808 run_test_with_stat 8 "Run dbench with quota enabled ==========="
810 # run for fixing bug10707, it needs a big room. test for 64bit
812 GB=$((KB * 1024 * 1024))
813 # Use this as dd bs to decrease time
814 # inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS);
815 blksize=$((1 << 21)) # 2Mb
816 size_file=$((GB * 9 / 2))
817 # this check is just for test9 and test10
818 OST0_MIN=4900000 #4.67G
819 check_whether_skip () {
820 OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'`
821 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
822 if [ $OST0_SIZE -lt $OST0_MIN ]; then
823 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
831 check_whether_skip && return 0
833 wait_delete_completed
839 chmod 0777 $DIR/$tdir
840 TESTFILE="$DIR/$tdir/$tfile-0"
842 BLK_LIMIT=$((100 * KB * KB)) # 100G
844 echo " Set block limit $BLK_LIMIT kbytes to $TSTUSR.$TSTUSR"
846 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
847 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
848 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
849 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
851 quota_show_check a u $TSTUSR
852 quota_show_check a g $TSTUSR
855 $LFS setstripe $TESTFILE -c 1
857 chown $TSTUSR.$TSTUSR $TESTFILE
859 log " Write the big file of 4.5G ..."
860 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
861 quota_error a $TSTUSR "(usr) write 4.5G file failure, but expect success"
866 log " delete the big file of 4.5G..."
867 $RUNAS rm -f $TESTFILE
875 set_blk_unitsz $((128 * 1024))
876 set_blk_tunesz $((128 * 1024 / 2))
880 run_test_with_stat 9 "run for fixing bug10707(64bit) ==========="
882 # run for fixing bug10707, it need a big room. test for 32bit
883 # 2.0 version does not support 32 bit qd_count, so such test is obsolete.
886 chmod 0777 $DIR/$tdir
887 check_whether_skip && return 0
889 wait_delete_completed
894 # make qd_count 32 bit
895 lustre_fail mds_ost 0xA00
897 TESTFILE="$DIR/$tdir/$tfile-0"
899 BLK_LIMIT=$((100 * KB * KB)) # 100G
902 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
903 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
904 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
905 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
907 quota_show_check a u $TSTUSR
908 quota_show_check a g $TSTUSR
911 $LFS setstripe $TESTFILE -c 1
913 chown $TSTUSR.$TSTUSR $TESTFILE
915 log " Write the big file of 4.5 G ..."
916 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
917 quota_error a $TSTUSR "(usr) write 4.5 G file failure, but expect success"
922 log " delete the big file of 4.5 G..."
923 $RUNAS rm -f $TESTFILE
931 # make qd_count 64 bit
932 lustre_fail mds_ost 0
934 set_blk_unitsz $((128 * 1024))
935 set_blk_tunesz $((128 * 1024 / 2))
939 #run_test_with_stat 10 "run for fixing bug10707(32bit) ==========="
942 wait_delete_completed
945 block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1`
947 orig_dbr=`sysctl -n vm.dirty_background_ratio`
948 orig_dec=`sysctl -n vm.dirty_expire_centisecs`
949 orig_dr=`sysctl -n vm.dirty_ratio`
950 orig_dwc=`sysctl -n vm.dirty_writeback_centisecs`
951 sysctl -w vm.dirty_background_ratio=1
952 sysctl -w vm.dirty_expire_centisecs=30
953 sysctl -w vm.dirty_ratio=1
954 sysctl -w vm.dirty_writeback_centisecs=50
961 [ "$SLOW" = no ] && REPS=1
964 while [ $i -le $REPS ]; do
965 echo "test: cycle($i of $REPS) start at $(date)"
966 mkdir -p $TESTDIR && chmod 777 $TESTDIR
967 echo -n " create a file for uid "
968 for j in `seq 1 30`; do
970 # 30MB per dd for a total of 900MB (if space even permits)
971 runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile bs=$blksize count=15 > /dev/null 2>&1 &
974 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
976 while [ $PROCS -gt 0 ]; do
978 SECS=$((SECS + sleep))
979 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
980 USED=$(du -s $TESTDIR | awk '{print $1}')
981 PCT=$(($USED * 100 / $block_limit))
982 echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} "
983 if [ $USED -le $LAST_USED ]; then
984 kill -9 $(ps -ef | grep "dd if /dev/zero of $TESTDIR" | grep -v grep | awk '{ print $2 }')
991 echo " removing the test files..."
992 rm -f $TESTDIR/$tfile
993 echo "cycle $i done at $(date)"
996 echo "Test took $SECS sec"
999 sysctl -w vm.dirty_background_ratio=$orig_dbr
1000 sysctl -w vm.dirty_expire_centisecs=$orig_dec
1001 sysctl -w vm.dirty_ratio=$orig_dr
1002 sysctl -w vm.dirty_writeback_centisecs=$orig_dwc
1003 if [ $RV -ne 0 ]; then
1004 error "Nothing was written for $SECS sec ... aborting"
1008 run_test_with_stat 11 "run for fixing bug10912 ==========="
1011 # test a deadlock between quota and journal b=11693
1014 chmod 0777 $DIR/$tdir
1016 [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
1017 { skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
1019 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
1020 TESTFILE="$DIR/$tdir/$tfile-0"
1021 TESTFILE2="$DIR2/$tdir/$tfile-1"
1023 wait_delete_completed
1025 echo " User quota (limit: $LIMIT kbytes)"
1026 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1028 $LFS setstripe $TESTFILE -i 0 -c 1
1029 chown $TSTUSR.$TSTUSR $TESTFILE
1030 $LFS setstripe $TESTFILE2 -i 0 -c 1
1031 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
1033 #define OBD_FAIL_OST_HOLD_WRITE_RPC 0x21f
1034 #define OBD_FAIL_SOME 0x10000000 /* fail N times */
1035 lustre_fail ost $((0x0000021f | 0x10000000)) 1
1037 echo " step1: write out of block quota ..."
1038 $RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 &
1040 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT*2)) &
1043 echo " step2: testing ......"
1046 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1048 if [ $count -gt 64 ]; then
1050 quota_error u $TSTUSR2 "dd should be finished!"
1054 echo "(dd_pid=$DDPID1, time=$count)successful"
1056 #Recover fail_loc and dd will finish soon
1059 echo " step3: testing ......"
1062 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1064 if [ $count -gt 150 ]; then
1065 quota_error u $TSTUSR "dd should be finished!"
1069 echo "(dd_pid=$DDPID, time=$count)successful"
1071 rm -f $TESTFILE $TESTFILE2
1072 sync; sleep 3; sync;
1074 resetquota -u $TSTUSR
1076 run_test_with_stat 12 "test a deadlock between quota and journal ==="
1078 # test multiple clients write block quota b=11693
1081 wait_delete_completed
1083 # one OST * 10 + (mds + other OSTs)
1084 LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT)))
1085 TESTFILE="$DIR/$tdir/$tfile"
1087 echo " User quota (limit: $LIMIT kbytes)"
1088 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1089 quota_show_check b u $TSTUSR
1091 $LFS setstripe $TESTFILE -i 0 -c 1
1092 chown $TSTUSR.$TSTUSR $TESTFILE
1093 $LFS setstripe $TESTFILE.2 -i 0 -c 1
1094 chown $TSTUSR.$TSTUSR $TESTFILE.2
1096 echo " step1: write out of block quota ..."
1097 # one bunit will give mds
1098 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1100 $RUNAS dd if=/dev/zero of=$TESTFILE.2 bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1103 echo " step2: testing ......"
1106 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1108 if [ $count -gt 64 ]; then
1109 quota_error u $TSTUSR "dd should be finished!"
1113 echo "(dd_pid=$DDPID, time=$count)successful"
1117 if ! ps -p ${DDPID1} > /dev/null 2>&1 ; then break; fi
1119 if [ $count -gt 64 ]; then
1120 quota_error u $TSTUSR "dd should be finished!"
1124 echo "(dd_pid=$DDPID1, time=$count)successful"
1126 sync; sleep 5; sync;
1128 echo " step3: checking ......"
1129 fz=`stat -c %s $TESTFILE`
1130 fz2=`stat -c %s $TESTFILE.2`
1132 [ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
1133 quota_error u $TSTUSR "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
1135 rm -f $TESTFILE $TESTFILE.2
1136 sync; sleep 3; sync;
1138 resetquota -u $TSTUSR
1140 run_test_with_stat 13 "test multiple clients write block quota ==="
1142 check_if_quota_zero(){
1143 line=`$LFS quota -v -$1 $2 $DIR | wc -l`
1144 for i in `seq 3 $line`; do
1145 if [ $i -eq 3 ]; then
1151 tmp=`$LFS quota -v -$1 $2 $DIR | sed -n ${i}p |
1152 awk '{print $'"$j"'}'`
1153 [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -v -$1 $2 $DIR && \
1154 error "quota on $2 isn't clean"
1157 echo "pass check_if_quota_zero"
1160 test_14a() { # was test_14 b=12223 -- setting quota on root
1161 TESTFILE="$DIR/$tdir/$tfile"
1165 cleanup_and_setup_lustre
1170 # out of root's file and block quota
1171 $LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR
1172 createmany -m ${TESTFILE} 20 || \
1173 quota_error u root "unexpected: user(root) create files failly!"
1174 dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
1175 quota_error u root "unexpected: user(root) write files failly!"
1177 $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
1178 quota_error u root "unexpected: user(quota_usr) write a file successfully!"
1182 for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done
1183 for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done
1186 dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
1188 #check_if_quota_zero u root
1191 unlinkmany ${TESTFILE} 15
1193 sync; sleep 3; sync;
1195 run_test_with_stat 14a "test setting quota on root ==="
1197 # save quota version (both administrative and operational quotas)
1198 quota_save_version() {
1199 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1"
1201 local osts=$(get_facets OST)
1202 for ost in ${osts//,/ }; do
1204 do_facet mgs "lctl conf_param ${!varsvc}.ost.quota_type=$1"
1209 LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1210 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
1212 wait_delete_completed
1215 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1216 TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1217 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1218 echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1219 resetquota -u $TSTUSR
1222 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1223 TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1224 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1225 echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1226 resetquota -g $TSTUSR
1227 $LFS quotaoff -ug $DIR
1228 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
1229 error "fail to set version for $SINGLEMDS"
1230 for j in `seq $OSTCOUNT`; do
1231 do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=ug" | grep "error writing" && \
1232 error "fail to set version for ost$j"
1235 echo "invalidating quota files"
1236 $LFS quotainv -ug $DIR
1237 $LFS quotainv -ugf $DIR
1238 $LFS quotacheck -ug $DIR
1240 run_test_with_stat 15 "set block quota more than 4T ==="
1242 # $1=u/g $2=with qunit adjust or not
1244 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4))
1245 TESTFILE="$DIR/$tdir/$tfile"
1248 wait_delete_completed
1250 echo " User quota (limit: $LIMIT kbytes)"
1251 if [ $1 == "u" ]; then
1252 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1253 quota_show_check b u $TSTUSR
1255 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1256 quota_show_check b g $TSTUSR
1259 $LFS setstripe $TESTFILE -c 1
1260 chown $TSTUSR.$TSTUSR $TESTFILE
1263 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
1264 quota_error a $TSTUSR "(usr) write failure, but expect success"
1266 echo " Write out of block quota ..."
1267 # this time maybe cache write, ignore it's failure
1268 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true
1269 # flush cache, ensure noquota flag is setted on client
1270 cancel_lru_locks osc
1271 if [ $2 -eq 1 ]; then
1272 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
1273 quota_error a $TSTUSR "(write failure, but expect success"
1275 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
1276 quota_error a $TSTUSR "(write success, but expect EDQUOT"
1280 sync; sleep 3; sync;
1281 resetquota -$1 $TSTUSR
1284 # test without adjusting qunit
1285 # 2.0 version does not support WITHOUT_CHANGE_QS, so such test is obsolete
1287 set_blk_tunesz $((BUNIT_SZ * 2))
1288 set_blk_unitsz $((BUNIT_SZ * 4))
1291 # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS 0xA01
1292 echo " grp/usr: $i, adjust qunit: $j"
1293 echo "-------------------------------"
1294 [ $j -eq 1 ] && lustre_fail mds_ost 0
1295 [ $j -eq 0 ] && lustre_fail mds_ost 0xA01
1299 set_blk_unitsz $((128 * 1024))
1300 set_blk_tunesz $((128 * 1024 / 2))
1302 #run_test_with_stat 16 "test without adjusting qunit"
1304 # run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre.
1309 wait_delete_completed
1311 #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
1312 lustre_fail ost 0x80000A02
1314 TESTFILE="$DIR/$tdir/$tfile-a"
1315 TESTFILE2="$DIR/$tdir/$tfile-b"
1318 BLK_LIMIT=$((100 * 1024)) # 100M
1320 log " Set enough high limit(block:$BLK_LIMIT) for user: $TSTUSR"
1321 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1322 log " Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
1323 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1325 quota_show_check b u $TSTUSR
1326 quota_show_check b g $TSTUSR
1329 chown $TSTUSR.$TSTUSR $TESTFILE
1331 chown $TSTUSR.$TSTUSR $TESTFILE2
1333 log " Write the test file1 ..."
1334 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(( 10 * 1024 )) \
1335 || quota_error a $TSTUSR "write 10M file failure"
1340 log " write the test file2 ..."
1341 $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=$(( 10 * 1024 )) \
1342 || quota_error a $TSTUSR "write 10M file failure"
1347 rm -f $TESTFILE $TESTFILE2
1349 sync; sleep 3; sync;
1351 # make qd_count 64 bit
1354 set_blk_unitsz $((128 * 1024))
1355 set_blk_tunesz $((128 * 1024 / 2))
1357 resetquota -u $TSTUSR
1358 resetquota -g $TSTUSR
1362 run_test_with_stat 17 "run for fixing bug14526 ==========="
1364 # test when mds takes a long time to handle a quota req so that
1365 # the ost has dropped it, the ost still could work well b=14840
1367 LIMIT=$((100 * 1024 * 1024)) # 100G
1368 TESTFILE="$DIR/$tdir/$tfile"
1371 wait_delete_completed
1376 log " User quota (limit: $LIMIT kbytes)"
1377 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1378 quota_show_check b u $TSTUSR
1380 $LFS setstripe $TESTFILE -i 0 -c 1
1381 chown $TSTUSR.$TSTUSR $TESTFILE
1383 #define OBD_FAIL_MDS_BLOCK_QUOTA_REQ 0x13c
1384 lustre_fail mds 0x13c
1386 log " step1: write 100M block ..."
1387 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1393 echo " step2: testing ......"
1395 if at_is_valid && at_is_enabled; then
1396 timeout=$(at_max_get mds)
1398 timeout=$(lctl get_param -n timeout)
1401 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1403 if [ $count -gt $((4 * $timeout)) ]; then
1404 quota_error u $TSTUSR "count=$count dd should be finished!"
1408 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1410 testfile_size=$(stat -c %s $TESTFILE)
1411 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1412 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1414 sync; sleep 3; sync;
1416 resetquota -u $TSTUSR
1418 set_blk_unitsz $((128 * 1024))
1419 set_blk_tunesz $((128 * 1024 / 2))
1421 run_test_with_stat 18 "run for fixing bug14840 ==========="
1423 # test when mds drops a quota req, the ost still could work well b=14840
1425 LIMIT=$((100 * 1024 * 1024)) # 100G
1426 TESTFILE="$DIR/$tdir/$tfile-a"
1429 wait_delete_completed
1434 log " User quota (limit: $LIMIT kbytes)"
1435 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1436 quota_show_check b u $TSTUSR
1438 $LFS setstripe $TESTFILE -i 0 -c 1
1439 chown $TSTUSR.$TSTUSR $TESTFILE
1441 #define OBD_FAIL_MDS_DROP_QUOTA_REQ | OBD_FAIL_ONCE 0x8000013d
1442 lustre_fail mds 0x8000013d
1444 log " step1: write 100M block ..."
1445 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1448 echo " step2: testing ......"
1450 if at_is_valid && at_is_enabled; then
1451 timeout=$(at_max_get mds)
1453 timeout=$(lctl get_param -n timeout)
1456 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1458 if [ $count -gt $((6 * $timeout)) ]; then
1460 quota_error u $TSTUSR "count=$count dd should be finished!"
1464 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1469 sync; sleep 3; sync;
1471 resetquota -u $TSTUSR
1473 set_blk_unitsz $((128 * 1024))
1474 set_blk_tunesz $((128 * 1024 / 2))
1476 run_test_with_stat 18a "run for fixing bug14840 ==========="
1478 # test when mds do failover, the ost still could work well without trigger
1483 LIMIT=$((110 * 1024 )) # 110M
1484 TESTFILE="$DIR/$tdir/$tfile"
1487 wait_delete_completed
1492 log " User quota (limit: $LIMIT kbytes)"
1493 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1494 quota_show_check b u $TSTUSR
1496 $LFS setstripe $TESTFILE -i 0 -c 1
1497 chown $TSTUSR.$TSTUSR $TESTFILE
1499 timeout=$(sysctl -n lustre.timeout)
1501 if [ $type = "directio" ]; then
1502 log " write 100M block(directio) ..."
1503 $RUNAS $DIRECTIO write $TESTFILE 0 100 $((BLK_SZ * 1024)) &
1505 log " write 100M block(normal) ..."
1506 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$((BLK_SZ * 1024)) count=100 &
1510 do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
1512 log "failing mds for $((2 * timeout)) seconds"
1513 fail $SINGLEMDS $((2 * timeout))
1515 # check if quotaon successful
1516 $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
1517 if [ $? -eq 0 ]; then
1518 error "quotaon failed!"
1524 if at_is_valid && at_is_enabled; then
1525 timeout=$(at_max_get mds)
1527 timeout=$(lctl get_param -n timeout)
1530 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1531 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1532 log "it took $count second"
1536 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1539 testfile_size=$(stat -c %s $TESTFILE)
1540 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1541 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1543 resetquota -u $TSTUSR
1548 # test when mds does failover, the ost still could work well
1549 # this test shouldn't trigger watchdog b=14840
1551 test_18bc_sub normal
1552 test_18bc_sub directio
1553 # check if watchdog is triggered
1554 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1555 watchdog=`awk '/test 18b/ {start = 1;}
1556 /Watchdog triggered/ {
1560 }' $TMP/lustre-log-${TESTNAME}.log`
1561 [ `echo "$watchdog" | wc -l` -ge 3 ] && error "$watchdog"
1562 rm -f $TMP/lustre-log-${TESTNAME}.log
1564 run_test_with_stat 18b "run for fixing bug14840(mds failover, no watchdog) ==========="
1566 # test when mds does failover, the ost still could work well
1567 # this test will prevent OST_DISCONNET from happening b=14840
1569 # define OBD_FAIL_OST_DISCONNECT_NET 0x202(disable ost_disconnect for osts)
1570 lustre_fail ost 0x202
1571 test_18bc_sub normal
1572 test_18bc_sub directio
1575 run_test_with_stat 18c "run for fixing bug14840(mds failover, OST_DISCONNECT is disabled) ==========="
1577 run_to_block_limit() {
1578 local LIMIT=$((($OSTCOUNT + 1) * $BUNIT_SZ))
1580 wait_delete_completed
1582 # set 1 Mb quota unit size
1586 # bind file to a single OST
1587 $LFS setstripe -c 1 $TESTFILE
1588 chown $TSTUSR.$TSTUSR $TESTFILE
1590 echo " User quota (limit: $LIMIT kbytes)"
1591 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1592 quota_show_check b u $TSTUSR
1593 echo " Updating quota limits"
1594 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1595 quota_show_check b u $TSTUSR
1597 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
1598 $RUNDD count=$BUNIT_SZ || quota_error u $TSTUSR "(usr) write failure, but expect success"
1599 # for now page cache of TESTFILE may still be dirty,
1600 # let's push it to the corresponding OST, this will also
1601 # cache NOQUOTA on the client from OST's reply
1602 cancel_lru_locks osc
1603 $RUNDD seek=$BUNIT_SZ && quota_error u $TSTUSR "(usr) write success, should be EDQUOT"
1607 # 1 Mb bunit per each MDS/OSS
1608 local TESTFILE="$DIR/$tdir/$tfile"
1611 run_to_block_limit $TESTFILE
1616 resetquota -u $TSTUSR
1618 set_blk_unitsz $((128 * 1024))
1619 set_blk_tunesz $((128 * 1024 / 2))
1622 run_test_with_stat 19 "test if administrative limits updates do not zero operational limits (14790) ==="
1626 LSTR=(1t 2g 3m 4k) # limits strings
1627 LVAL=($[1*1024*1024*1024] $[2*1024*1024] $[3*1024*1024] $[4*1024]) # limits values
1629 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1630 $MOUNT || error "could not set quota limits"
1632 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1633 --inode-softlimit ${LSTR[2]} \
1634 --inode-hardlimit ${LSTR[3]} \
1635 $MOUNT || error "could not set quota limits"
1637 ($LFS quota -v -u $TSTUSR $MOUNT | \
1638 grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
1639 || error "lfs quota output is unexpected"
1641 resetquota -u $TSTUSR
1643 run_test_with_stat 20 "test if setquota specifiers work properly (15754)"
1650 time=$(($(date +%s) + seconds))
1651 while [ $(date +%s) -lt $time ]; do
1652 $RUNAS dd if=/dev/zero of=$testfile bs=$BLK_SZ count=$blk_number > /dev/null 2>&1
1657 # run for fixing bug16053, setquota shouldn't fail when writing and
1658 # deleting are happening
1663 wait_delete_completed
1665 TESTFILE="$DIR/$tdir/$tfile"
1667 BLK_LIMIT=$((10 * 1024 * 1024)) # 10G
1670 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
1671 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1672 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
1673 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1675 # repeat writing on a 1M file
1676 test_21_sub ${TESTFILE}_1 1024 30 &
1678 # repeat writing on a 128M file
1679 test_21_sub ${TESTFILE}_2 $((1024 * 128)) 30 &
1682 time=$(($(date +%s) + 30))
1684 while [ $(date +%s) -lt $time ]; do
1685 log " Set quota for $i times"
1686 $LFS setquota -u $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1687 $LFS setquota -g $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1694 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1696 if [ $count -gt 60 ]; then
1697 quota_error a $TSTUSR "dd should be finished!"
1701 echo "(dd_pid=$DDPID1, time=$count)successful"
1705 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1707 if [ $count -gt 60 ]; then
1708 quota_error a $TSTUSR "dd should be finished!"
1712 echo "(dd_pid=$DDPID2, time=$count)successful"
1714 set_blk_unitsz $((128 * 1024))
1715 set_blk_tunesz $((128 * 1024 / 2))
1716 resetquota -u $TSTUSR
1717 resetquota -g $TSTUSR
1721 run_test_with_stat 21 "run for fixing bug16053 ==========="
1726 SAVEREFORMAT=$REFORMAT
1727 $LFS quotaoff -ug $DIR || error "could not turn quotas off"
1729 quota_save_version "ug"
1735 REFORMAT=$SAVEREFORMAT
1737 echo "checking parameters"
1739 do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure"
1740 do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure"
1742 run_test 0 "reboot lustre"
1744 run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
1746 # It is triggered when test_23 failed, diagnostic for bug 18293
1750 DUMPPAGE=`find /proc/fs/${FSNAME}/llite/ -name dump_page_cache`
1752 cat $DUMPPAGE > $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1753 fsize=`stat -c%s $TMP/sanity-quota_test_23_${qtime}_${NUM}.log`
1754 if [ $fsize -eq 0 ]; then
1755 rm -f $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1757 error "some IO error was found during directIO"
1763 chmod 0777 $DIR/$tdir
1764 TESTFILE="$DIR/$tdir/$tfile-0"
1766 local bs_unit=$((1024*1024))
1769 wait_delete_completed
1772 log " User quota (limit: $LIMIT kbytes)"
1773 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1775 quota_show_check b u $TSTUSR
1777 $LFS setstripe $TESTFILE -c 1
1778 chown $TSTUSR.$TSTUSR $TESTFILE
1780 log " Step1: trigger quota with 0_DIRECT"
1781 log " Write half of file"
1782 $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || \
1783 (quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT" && test_23_dumppage 1)
1784 log " Write out of block quota ..."
1785 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && \
1786 quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT" && test_23_dumppage 2
1789 log " Step2: rewrite should succeed"
1790 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || \
1791 (quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT" && test_23_dumppage 3)
1795 wait_delete_completed
1796 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1797 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1798 echo $OST0_QUOTA_USED
1799 [ $OST0_QUOTA_USED -ne 0 ] && \
1800 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released")
1802 resetquota -u $TSTUSR
1806 log "run for $((OSTCOUNT * 4))MB test file"
1807 test_23_sub $((OSTCOUNT * 4 * 1024))
1810 check_whether_skip && return 0
1811 log "run for $((OSTCOUNT * 40))MB test file"
1812 test_23_sub $((OSTCOUNT * 40 * 1024))
1814 run_test_with_stat 23 "run for fixing bug16125 ==========="
1817 local TESTFILE="$DIR/$tdir/$tfile"
1820 run_to_block_limit $TESTFILE
1821 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1825 resetquota -u $TSTUSR
1827 set_blk_unitsz $((128 * 1024))
1828 set_blk_tunesz $((128 * 1024 / 2))
1831 run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
1834 if [ $1 = "-u" ]; then
1835 if [ $2 = "$TSTUSR" ]; then
1841 if [ $2 = "$TSTUSR" ]; then
1851 chmod 0777 $DIR/$tdir
1852 TESTFILE="$DIR/$tdir/$tfile-0"
1854 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) + 4096 ))
1856 wait_delete_completed
1858 # set quota for $TSTUSR
1859 log "setquota for $TSTUSR"
1860 $LFS setquota $1 $TSTUSR -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1862 if [ "$1" == "-u" ]; then
1863 quota_show_check a u $TSTUSR
1865 quota_show_check a g $TSTUSR
1868 # set quota for $TSTUSR2
1869 log "setquota for $TSTUSR2"
1870 $LFS setquota $1 $TSTUSR2 -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1872 if [ "$1" == "-u" ]; then
1873 quota_show_check a u $TSTUSR2
1875 quota_show_check a g $TSTUSR2
1878 # set stripe index to 0
1879 log "setstripe for $DIR/$tdir to 0"
1880 $LFS setstripe $DIR/$tdir -c 1 -i 0
1881 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
1882 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1883 MDS_QUOTA_USED_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1884 OST0_QUOTA_USED_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1885 MDS_QUOTA_USED2_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1886 OST0_QUOTA_USED2_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1889 log "$TSTUSR write 4M to $TESTFILE"
1890 $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || quota_error a $TSTUSR "dd failed"
1892 show_quota $1 $TSTUSR
1893 show_quota $1 $TSTUSR2
1894 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1895 [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \
1896 quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1897 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1898 OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD))
1899 [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \
1900 quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1902 # chown/chgrp from $TSTUSR to $TSTUSR2
1903 if [ $1 = "-u" ]; then
1904 log "chown from $TSTUSR to $TSTUSR2"
1905 chown $TSTUSR2 $TESTFILE || quota_error u $TSTUSR2 "chown failed"
1907 log "chgrp from $TSTUSR to $TSTUSR2"
1908 chgrp $TSTUSR2 $TESTFILE || quota_error g $TSTUSR2 "chgrp failed"
1911 show_quota $1 $TSTUSR
1912 show_quota $1 $TSTUSR2
1913 MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1914 [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \
1915 quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
1916 OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1917 OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD))
1918 [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \
1919 quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
1920 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1921 [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \
1922 quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1923 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1924 [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \
1925 quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1928 wait_delete_completed
1929 resetquota $1 $TSTUSR
1930 resetquota $1 $TSTUSR2
1934 log "run for chown case"
1937 log "run for chgrp case"
1940 run_test_with_stat 25 "test whether quota usage is transfered when chown/chgrp (18081) ==========="
1944 chmod 0777 $DIR/$tdir
1945 TESTFILE="$DIR/$tdir/$tfile-0"
1946 TESTFILE2="$DIR/$tdir/$tfile-1"
1950 wait_delete_completed
1952 # every quota slave gets 20MB
1953 b_limit=$((OSTCOUNT * 20 * 1024))
1954 log "limit: ${b_limit}KB"
1955 $LFS setquota -u $TSTUSR -b 0 -B $b_limit -i 0 -I 0 $DIR
1957 quota_show_check b u $TSTUSR
1959 $LFS setstripe $TESTFILE -c 1 -i 0
1960 $LFS setstripe $TESTFILE2 -c 1 -i 0
1961 chown $TSTUSR.$TSTUSR $TESTFILE
1962 chown $TSTUSR.$TSTUSR $TESTFILE2
1964 #define OBD_FAIL_QUOTA_DELAY_REL 0xA03
1965 lustre_fail ost 0xA03
1967 log " Write the first file..."
1968 $RUNAS $DIRECTIO write $TESTFILE 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
1969 log " Delete the first file..."
1973 wait_delete_completed
1975 log " Write the second file..."
1976 $RUNAS $DIRECTIO write $TESTFILE2 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
1977 log " Delete the second file..."
1981 set_blk_unitsz $((128 * 1024))
1982 set_blk_tunesz $((128 * 1024 / 2))
1983 resetquota -u $TSTUSR
1985 run_test_with_stat 26 "test for false quota error(bz18491) ======================================"
1991 lctl set_param debug="-quota"
1995 run_test_with_stat 99 "Quota off ==============================="
1998 log "cleanup: ======================================================"
2000 check_and_cleanup_lustre
2001 echo '=========================== finished ==============================='
2002 [ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
2003 echo "$0: completed"