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"
1200 do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$1"
1205 LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1206 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
1208 wait_delete_completed
1211 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1212 TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1213 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1214 echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1215 resetquota -u $TSTUSR
1218 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1219 TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1220 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1221 echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1222 resetquota -g $TSTUSR
1223 $LFS quotaoff -ug $DIR
1224 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
1225 error "fail to set version for $SINGLEMDS"
1226 for j in `seq $OSTCOUNT`; do
1227 do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=ug" | grep "error writing" && \
1228 error "fail to set version for ost$j"
1231 echo "invalidating quota files"
1232 $LFS quotainv -ug $DIR
1233 $LFS quotainv -ugf $DIR
1234 $LFS quotacheck -ug $DIR
1236 run_test_with_stat 15 "set block quota more than 4T ==="
1238 # $1=u/g $2=with qunit adjust or not
1240 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4))
1241 TESTFILE="$DIR/$tdir/$tfile"
1244 wait_delete_completed
1246 echo " User quota (limit: $LIMIT kbytes)"
1247 if [ $1 == "u" ]; then
1248 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1249 quota_show_check b u $TSTUSR
1251 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1252 quota_show_check b g $TSTUSR
1255 $LFS setstripe $TESTFILE -c 1
1256 chown $TSTUSR.$TSTUSR $TESTFILE
1259 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
1260 quota_error a $TSTUSR "(usr) write failure, but expect success"
1262 echo " Write out of block quota ..."
1263 # this time maybe cache write, ignore it's failure
1264 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true
1265 # flush cache, ensure noquota flag is setted on client
1266 cancel_lru_locks osc
1267 if [ $2 -eq 1 ]; then
1268 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
1269 quota_error a $TSTUSR "(write failure, but expect success"
1271 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
1272 quota_error a $TSTUSR "(write success, but expect EDQUOT"
1276 sync; sleep 3; sync;
1277 resetquota -$1 $TSTUSR
1280 # test without adjusting qunit
1281 # 2.0 version does not support WITHOUT_CHANGE_QS, so such test is obsolete
1283 set_blk_tunesz $((BUNIT_SZ * 2))
1284 set_blk_unitsz $((BUNIT_SZ * 4))
1287 # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS 0xA01
1288 echo " grp/usr: $i, adjust qunit: $j"
1289 echo "-------------------------------"
1290 [ $j -eq 1 ] && lustre_fail mds_ost 0
1291 [ $j -eq 0 ] && lustre_fail mds_ost 0xA01
1295 set_blk_unitsz $((128 * 1024))
1296 set_blk_tunesz $((128 * 1024 / 2))
1298 #run_test_with_stat 16 "test without adjusting qunit"
1300 # run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre.
1305 wait_delete_completed
1307 #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
1308 lustre_fail ost 0x80000A02
1310 TESTFILE="$DIR/$tdir/$tfile-a"
1311 TESTFILE2="$DIR/$tdir/$tfile-b"
1314 BLK_LIMIT=$((100 * 1024)) # 100M
1316 log " Set enough high limit(block:$BLK_LIMIT) for user: $TSTUSR"
1317 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1318 log " Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
1319 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1321 quota_show_check b u $TSTUSR
1322 quota_show_check b g $TSTUSR
1325 chown $TSTUSR.$TSTUSR $TESTFILE
1327 chown $TSTUSR.$TSTUSR $TESTFILE2
1329 log " Write the test file1 ..."
1330 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(( 10 * 1024 )) \
1331 || quota_error a $TSTUSR "write 10M file failure"
1336 log " write the test file2 ..."
1337 $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=$(( 10 * 1024 )) \
1338 || quota_error a $TSTUSR "write 10M file failure"
1343 rm -f $TESTFILE $TESTFILE2
1345 sync; sleep 3; sync;
1347 # make qd_count 64 bit
1350 set_blk_unitsz $((128 * 1024))
1351 set_blk_tunesz $((128 * 1024 / 2))
1353 resetquota -u $TSTUSR
1354 resetquota -g $TSTUSR
1358 run_test_with_stat 17 "run for fixing bug14526 ==========="
1360 # test when mds takes a long time to handle a quota req so that
1361 # the ost has dropped it, the ost still could work well b=14840
1363 LIMIT=$((100 * 1024 * 1024)) # 100G
1364 TESTFILE="$DIR/$tdir/$tfile"
1367 wait_delete_completed
1372 log " User quota (limit: $LIMIT kbytes)"
1373 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1374 quota_show_check b u $TSTUSR
1376 $LFS setstripe $TESTFILE -i 0 -c 1
1377 chown $TSTUSR.$TSTUSR $TESTFILE
1379 #define OBD_FAIL_MDS_BLOCK_QUOTA_REQ 0x13c
1380 lustre_fail mds 0x13c
1382 log " step1: write 100M block ..."
1383 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1389 echo " step2: testing ......"
1391 if at_is_valid && at_is_enabled; then
1392 timeout=$(at_max_get mds)
1394 timeout=$(lctl get_param -n timeout)
1397 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1399 if [ $count -gt $((4 * $timeout)) ]; then
1400 quota_error u $TSTUSR "count=$count dd should be finished!"
1404 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1406 testfile_size=$(stat -c %s $TESTFILE)
1407 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1408 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1410 sync; sleep 3; sync;
1412 resetquota -u $TSTUSR
1414 set_blk_unitsz $((128 * 1024))
1415 set_blk_tunesz $((128 * 1024 / 2))
1417 run_test_with_stat 18 "run for fixing bug14840 ==========="
1419 # test when mds drops a quota req, the ost still could work well b=14840
1421 LIMIT=$((100 * 1024 * 1024)) # 100G
1422 TESTFILE="$DIR/$tdir/$tfile-a"
1425 wait_delete_completed
1430 log " User quota (limit: $LIMIT kbytes)"
1431 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1432 quota_show_check b u $TSTUSR
1434 $LFS setstripe $TESTFILE -i 0 -c 1
1435 chown $TSTUSR.$TSTUSR $TESTFILE
1437 #define OBD_FAIL_MDS_DROP_QUOTA_REQ | OBD_FAIL_ONCE 0x8000013d
1438 lustre_fail mds 0x8000013d
1440 log " step1: write 100M block ..."
1441 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1444 echo " step2: testing ......"
1446 if at_is_valid && at_is_enabled; then
1447 timeout=$(at_max_get mds)
1449 timeout=$(lctl get_param -n timeout)
1452 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1454 if [ $count -gt $((6 * $timeout)) ]; then
1456 quota_error u $TSTUSR "count=$count dd should be finished!"
1460 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1465 sync; sleep 3; sync;
1467 resetquota -u $TSTUSR
1469 set_blk_unitsz $((128 * 1024))
1470 set_blk_tunesz $((128 * 1024 / 2))
1472 run_test_with_stat 18a "run for fixing bug14840 ==========="
1474 # test when mds do failover, the ost still could work well without trigger
1479 LIMIT=$((110 * 1024 )) # 110M
1480 TESTFILE="$DIR/$tdir/$tfile"
1483 wait_delete_completed
1488 log " User quota (limit: $LIMIT kbytes)"
1489 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1490 quota_show_check b u $TSTUSR
1492 $LFS setstripe $TESTFILE -i 0 -c 1
1493 chown $TSTUSR.$TSTUSR $TESTFILE
1495 timeout=$(sysctl -n lustre.timeout)
1497 if [ $type = "directio" ]; then
1498 log " write 100M block(directio) ..."
1499 $RUNAS $DIRECTIO write $TESTFILE 0 100 $((BLK_SZ * 1024)) &
1501 log " write 100M block(normal) ..."
1502 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$((BLK_SZ * 1024)) count=100 &
1506 do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
1508 log "failing mds for $((2 * timeout)) seconds"
1509 fail $SINGLEMDS $((2 * timeout))
1511 # check if quotaon successful
1512 $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
1513 if [ $? -eq 0 ]; then
1514 error "quotaon failed!"
1520 if at_is_valid && at_is_enabled; then
1521 timeout=$(at_max_get mds)
1523 timeout=$(lctl get_param -n timeout)
1526 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1527 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1528 log "it took $count second"
1532 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1535 testfile_size=$(stat -c %s $TESTFILE)
1536 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1537 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1539 resetquota -u $TSTUSR
1544 # test when mds does failover, the ost still could work well
1545 # this test shouldn't trigger watchdog b=14840
1547 test_18bc_sub normal
1548 test_18bc_sub directio
1549 # check if watchdog is triggered
1550 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1551 watchdog=`awk '/test 18b/ {start = 1;}
1552 /Watchdog triggered/ {
1556 }' $TMP/lustre-log-${TESTNAME}.log`
1557 [ `echo "$watchdog" | wc -l` -ge 3 ] && error "$watchdog"
1558 rm -f $TMP/lustre-log-${TESTNAME}.log
1560 run_test_with_stat 18b "run for fixing bug14840(mds failover, no watchdog) ==========="
1562 # test when mds does failover, the ost still could work well
1563 # this test will prevent OST_DISCONNET from happening b=14840
1565 # define OBD_FAIL_OST_DISCONNECT_NET 0x202(disable ost_disconnect for osts)
1566 lustre_fail ost 0x202
1567 test_18bc_sub normal
1568 test_18bc_sub directio
1571 run_test_with_stat 18c "run for fixing bug14840(mds failover, OST_DISCONNECT is disabled) ==========="
1573 run_to_block_limit() {
1574 local LIMIT=$((($OSTCOUNT + 1) * $BUNIT_SZ))
1576 wait_delete_completed
1578 # set 1 Mb quota unit size
1582 # bind file to a single OST
1583 $LFS setstripe -c 1 $TESTFILE
1584 chown $TSTUSR.$TSTUSR $TESTFILE
1586 echo " User quota (limit: $LIMIT kbytes)"
1587 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1588 quota_show_check b u $TSTUSR
1589 echo " Updating quota limits"
1590 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1591 quota_show_check b u $TSTUSR
1593 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
1594 $RUNDD count=$BUNIT_SZ || quota_error u $TSTUSR "(usr) write failure, but expect success"
1595 # for now page cache of TESTFILE may still be dirty,
1596 # let's push it to the corresponding OST, this will also
1597 # cache NOQUOTA on the client from OST's reply
1598 cancel_lru_locks osc
1599 $RUNDD seek=$BUNIT_SZ && quota_error u $TSTUSR "(usr) write success, should be EDQUOT"
1603 # 1 Mb bunit per each MDS/OSS
1604 local TESTFILE="$DIR/$tdir/$tfile"
1607 run_to_block_limit $TESTFILE
1612 resetquota -u $TSTUSR
1614 set_blk_unitsz $((128 * 1024))
1615 set_blk_tunesz $((128 * 1024 / 2))
1618 run_test_with_stat 19 "test if administrative limits updates do not zero operational limits (14790) ==="
1622 LSTR=(1t 2g 3m 4k) # limits strings
1623 LVAL=($[1*1024*1024*1024] $[2*1024*1024] $[3*1024*1024] $[4*1024]) # limits values
1625 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1626 $MOUNT || error "could not set quota limits"
1628 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1629 --inode-softlimit ${LSTR[2]} \
1630 --inode-hardlimit ${LSTR[3]} \
1631 $MOUNT || error "could not set quota limits"
1633 ($LFS quota -v -u $TSTUSR $MOUNT | \
1634 grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
1635 || error "lfs quota output is unexpected"
1637 resetquota -u $TSTUSR
1639 run_test_with_stat 20 "test if setquota specifiers work properly (15754)"
1646 time=$(($(date +%s) + seconds))
1647 while [ $(date +%s) -lt $time ]; do
1648 $RUNAS dd if=/dev/zero of=$testfile bs=$BLK_SZ count=$blk_number > /dev/null 2>&1
1653 # run for fixing bug16053, setquota shouldn't fail when writing and
1654 # deleting are happening
1659 wait_delete_completed
1661 TESTFILE="$DIR/$tdir/$tfile"
1663 BLK_LIMIT=$((10 * 1024 * 1024)) # 10G
1666 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
1667 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1668 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
1669 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1671 # repeat writing on a 1M file
1672 test_21_sub ${TESTFILE}_1 1024 30 &
1674 # repeat writing on a 128M file
1675 test_21_sub ${TESTFILE}_2 $((1024 * 128)) 30 &
1678 time=$(($(date +%s) + 30))
1680 while [ $(date +%s) -lt $time ]; do
1681 log " Set quota for $i times"
1682 $LFS setquota -u $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1683 $LFS setquota -g $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1690 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1692 if [ $count -gt 60 ]; then
1693 quota_error a $TSTUSR "dd should be finished!"
1697 echo "(dd_pid=$DDPID1, time=$count)successful"
1701 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1703 if [ $count -gt 60 ]; then
1704 quota_error a $TSTUSR "dd should be finished!"
1708 echo "(dd_pid=$DDPID2, time=$count)successful"
1710 set_blk_unitsz $((128 * 1024))
1711 set_blk_tunesz $((128 * 1024 / 2))
1712 resetquota -u $TSTUSR
1713 resetquota -g $TSTUSR
1717 run_test_with_stat 21 "run for fixing bug16053 ==========="
1722 SAVEREFORMAT=$REFORMAT
1723 $LFS quotaoff -ug $DIR || error "could not turn quotas off"
1725 quota_save_version "ug"
1731 REFORMAT=$SAVEREFORMAT
1733 echo "checking parameters"
1735 do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure"
1736 do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure"
1738 run_test 0 "reboot lustre"
1740 run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
1742 # It is triggered when test_23 failed, diagnostic for bug 18293
1746 DUMPPAGE=`find /proc/fs/${FSNAME}/llite/ -name dump_page_cache`
1748 cat $DUMPPAGE > $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1749 fsize=`stat -c%s $TMP/sanity-quota_test_23_${qtime}_${NUM}.log`
1750 if [ $fsize -eq 0 ]; then
1751 rm -f $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1753 error "some IO error was found during directIO"
1759 chmod 0777 $DIR/$tdir
1760 TESTFILE="$DIR/$tdir/$tfile-0"
1762 local bs_unit=$((1024*1024))
1765 wait_delete_completed
1768 log " User quota (limit: $LIMIT kbytes)"
1769 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1771 quota_show_check b u $TSTUSR
1773 $LFS setstripe $TESTFILE -c 1
1774 chown $TSTUSR.$TSTUSR $TESTFILE
1776 log " Step1: trigger quota with 0_DIRECT"
1777 log " Write half of file"
1778 $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || \
1779 (quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT" && test_23_dumppage 1)
1780 log " Write out of block quota ..."
1781 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && \
1782 quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT" && test_23_dumppage 2
1785 log " Step2: rewrite should succeed"
1786 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || \
1787 (quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT" && test_23_dumppage 3)
1791 wait_delete_completed
1792 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1793 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1794 echo $OST0_QUOTA_USED
1795 [ $OST0_QUOTA_USED -ne 0 ] && \
1796 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released")
1798 resetquota -u $TSTUSR
1802 log "run for $((OSTCOUNT * 4))MB test file"
1803 test_23_sub $((OSTCOUNT * 4 * 1024))
1806 check_whether_skip && return 0
1807 log "run for $((OSTCOUNT * 40))MB test file"
1808 test_23_sub $((OSTCOUNT * 40 * 1024))
1810 run_test_with_stat 23 "run for fixing bug16125 ==========="
1813 local TESTFILE="$DIR/$tdir/$tfile"
1816 run_to_block_limit $TESTFILE
1817 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1821 resetquota -u $TSTUSR
1823 set_blk_unitsz $((128 * 1024))
1824 set_blk_tunesz $((128 * 1024 / 2))
1827 run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
1830 if [ $1 = "-u" ]; then
1831 if [ $2 = "$TSTUSR" ]; then
1837 if [ $2 = "$TSTUSR" ]; then
1847 chmod 0777 $DIR/$tdir
1848 TESTFILE="$DIR/$tdir/$tfile-0"
1850 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) + 4096 ))
1852 wait_delete_completed
1854 # set quota for $TSTUSR
1855 log "setquota for $TSTUSR"
1856 $LFS setquota $1 $TSTUSR -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1858 if [ "$1" == "-u" ]; then
1859 quota_show_check a u $TSTUSR
1861 quota_show_check a g $TSTUSR
1864 # set quota for $TSTUSR2
1865 log "setquota for $TSTUSR2"
1866 $LFS setquota $1 $TSTUSR2 -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1868 if [ "$1" == "-u" ]; then
1869 quota_show_check a u $TSTUSR2
1871 quota_show_check a g $TSTUSR2
1874 # set stripe index to 0
1875 log "setstripe for $DIR/$tdir to 0"
1876 $LFS setstripe $DIR/$tdir -c 1 -i 0
1877 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
1878 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1879 MDS_QUOTA_USED_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1880 OST0_QUOTA_USED_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1881 MDS_QUOTA_USED2_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1882 OST0_QUOTA_USED2_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1885 log "$TSTUSR write 4M to $TESTFILE"
1886 $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || quota_error a $TSTUSR "dd failed"
1888 show_quota $1 $TSTUSR
1889 show_quota $1 $TSTUSR2
1890 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1891 [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \
1892 quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1893 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1894 OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD))
1895 [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \
1896 quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1898 # chown/chgrp from $TSTUSR to $TSTUSR2
1899 if [ $1 = "-u" ]; then
1900 log "chown from $TSTUSR to $TSTUSR2"
1901 chown $TSTUSR2 $TESTFILE || quota_error u $TSTUSR2 "chown failed"
1903 log "chgrp from $TSTUSR to $TSTUSR2"
1904 chgrp $TSTUSR2 $TESTFILE || quota_error g $TSTUSR2 "chgrp failed"
1907 show_quota $1 $TSTUSR
1908 show_quota $1 $TSTUSR2
1909 MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1910 [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \
1911 quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
1912 OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1913 OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD))
1914 [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \
1915 quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
1916 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1917 [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \
1918 quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1919 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1920 [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \
1921 quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1924 wait_delete_completed
1925 resetquota $1 $TSTUSR
1926 resetquota $1 $TSTUSR2
1930 log "run for chown case"
1933 log "run for chgrp case"
1936 run_test_with_stat 25 "test whether quota usage is transfered when chown/chgrp (18081) ==========="
1940 chmod 0777 $DIR/$tdir
1941 TESTFILE="$DIR/$tdir/$tfile-0"
1942 TESTFILE2="$DIR/$tdir/$tfile-1"
1946 wait_delete_completed
1948 # every quota slave gets 20MB
1949 b_limit=$((OSTCOUNT * 20 * 1024))
1950 log "limit: ${b_limit}KB"
1951 $LFS setquota -u $TSTUSR -b 0 -B $b_limit -i 0 -I 0 $DIR
1953 quota_show_check b u $TSTUSR
1955 $LFS setstripe $TESTFILE -c 1 -i 0
1956 $LFS setstripe $TESTFILE2 -c 1 -i 0
1957 chown $TSTUSR.$TSTUSR $TESTFILE
1958 chown $TSTUSR.$TSTUSR $TESTFILE2
1960 #define OBD_FAIL_QUOTA_DELAY_REL 0xA03
1961 lustre_fail ost 0xA03
1963 log " Write the first file..."
1964 $RUNAS $DIRECTIO write $TESTFILE 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
1965 log " Delete the first file..."
1969 wait_delete_completed
1971 log " Write the second file..."
1972 $RUNAS $DIRECTIO write $TESTFILE2 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
1973 log " Delete the second file..."
1977 set_blk_unitsz $((128 * 1024))
1978 set_blk_tunesz $((128 * 1024 / 2))
1979 resetquota -u $TSTUSR
1981 run_test_with_stat 26 "test for false quota error(bz18491) ======================================"
1987 lctl set_param debug="-quota"
1991 run_test_with_stat 99 "Quota off ==============================="
1994 log "cleanup: ======================================================"
1996 check_and_cleanup_lustre
1997 echo '=========================== finished ==============================='
1998 [ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
1999 echo "$0: completed"