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)
201 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
203 $LFS quota -v -$LOCAL_UG $LOCAL_ID $DIR
205 if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then
206 USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`"
207 [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
210 if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then
211 USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`"
212 [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
218 $LFS quotaoff -ug $DIR
219 $LFS quotacheck -ug $DIR
221 resetquota -u $TSTUSR
222 resetquota -g $TSTUSR
224 lctl set_param debug="+quota"
225 do_facet $SINGLEMDS "lctl set_param debug=+quota"
226 for num in `seq $OSTCOUNT`; do
227 do_facet ost$num "lctl set_param debug=+quota"
230 run_test_with_stat 0 "Set quota ============================="
232 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
236 chmod 0777 $DIR/$tdir
237 TESTFILE="$DIR/$tdir/$tfile-0"
239 wait_delete_completed
242 log " User quota (limit: $LIMIT kbytes)"
243 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
245 quota_show_check b u $TSTUSR
247 $LFS setstripe $TESTFILE -c 1
248 chown $TSTUSR.$TSTUSR $TESTFILE
251 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error u $TSTUSR "(usr) write failure, but expect success"
253 log " Write out of block quota ..."
254 # this time maybe cache write, ignore it's failure
255 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
256 # flush cache, ensure noquota flag is setted on client
258 $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"
262 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
263 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
264 echo $OST0_QUOTA_USED
265 [ $OST0_QUOTA_USED -ne 0 ] && \
266 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
268 resetquota -u $TSTUSR
271 log "--------------------------------------"
272 log " Group quota (limit: $LIMIT kbytes)"
273 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
275 quota_show_check b g $TSTUSR
276 TESTFILE="$DIR/$tdir/$tfile-1"
278 $LFS setstripe $TESTFILE -c 1
279 chown $TSTUSR.$TSTUSR $TESTFILE
282 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || quota_error g $TSTUSR "(grp) write failure, but expect success"
284 log " Write out of block quota ..."
285 # this time maybe cache write, ignore it's failure
286 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
288 $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"
293 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
294 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
295 echo $OST0_QUOTA_USED
296 [ $OST0_QUOTA_USED -ne 0 ] && \
297 ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
299 resetquota -g $TSTUSR
302 # block hard limit (normal use and out of quota)
304 for i in `seq 1 $cycle`; do
305 # define blk_qunit is between 1M and 4M
306 blk_qunit=$(( $RANDOM % 3072 + 1024 ))
307 blk_qtune=$(( $RANDOM % $blk_qunit ))
308 # other osts and mds will occupy at 1M blk quota
309 b_limit=$(( ($RANDOM - 16384) / 8 + $OSTCOUNT * $blk_qunit * 4 ))
310 set_blk_tunesz $blk_qtune
311 set_blk_unitsz $blk_qunit
312 echo "cycle: $i(total $cycle) bunit:$blk_qunit, btune:$blk_qtune, blimit:$b_limit"
314 echo "=================================================="
315 set_blk_unitsz $((128 * 1024))
316 set_blk_tunesz $((128 * 1024 / 2))
319 run_test_with_stat 1 "Block hard limit (normal use and out of quota) ==="
321 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
325 chmod 0777 $DIR/$tdir
326 TESTFILE="$DIR/$tdir/$tfile-0"
328 wait_delete_completed
331 log " User quota (limit: $LIMIT files)"
332 $LFS setquota -u $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
334 quota_show_check f u $TSTUSR
336 log " Create $LIMIT files ..."
337 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
338 quota_error u $TSTUSR "(usr) create failure, but expect success"
340 log " Create out of file quota ..."
341 $RUNAS touch ${TESTFILE}_xxx && \
342 quota_error u $TSTUSR "(usr) touch success, but expect EDQUOT"
344 unlinkmany ${TESTFILE} $LIMIT
345 rm -f ${TESTFILE}_xxx
348 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
349 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
351 [ $MDS_QUOTA_USED -ne 0 ] && \
352 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "(usr) quota deleted isn't released")
354 resetquota -u $TSTUSR
357 log "--------------------------------------"
358 log " Group quota (limit: $LIMIT FILE)"
359 $LFS setquota -g $TSTUSR -b 0 -B 0 -i 0 -I $LIMIT $DIR
361 quota_show_check f g $TSTUSR
362 TESTFILE=$DIR/$tdir/$tfile-1
364 log " Create $LIMIT files ..."
365 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
366 quota_error g $TSTUSR "(grp) create failure, but expect success"
368 log " Create out of file quota ..."
369 $RUNAS touch ${TESTFILE}_xxx && \
370 quota_error g $TSTUSR "(grp) touch success, but expect EDQUOT"
372 unlinkmany ${TESTFILE} $LIMIT
373 rm -f ${TESTFILE}_xxx
376 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
377 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
379 [ $MDS_QUOTA_USED -ne 0 ] && \
380 ($SHOW_QUOTA_GROUP; quota_error g $TSTUSR "(grp) quota deleted isn't released")
382 resetquota -g $TSTUSR
385 # file hard limit (normal use and out of quota)
387 for i in `seq 1 $cycle`; do
388 if [ $i -eq 1 ]; then
393 # define ino_qunit is between 10 and 100
394 ino_qunit=$(( $RANDOM % 90 + 10 ))
395 ino_qtune=$(( $RANDOM % $ino_qunit ))
396 # RANDOM's maxium is 32767
397 i_limit=$(( $RANDOM % 990 + 10 ))
400 set_file_tunesz $ino_qtune
401 set_file_unitsz $ino_qunit
402 echo "cycle: $i(total $cycle) iunit:$ino_qunit, itune:$ino_qtune, ilimit:$i_limit"
404 echo "=================================================="
409 run_test_with_stat 2 "File hard limit (normal use and out of quota) ==="
413 TIMER=$(($2 * 3 / 2))
416 wait_delete_completed
418 echo " Write to exceed soft limit"
419 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
420 $RUNDD count=$((BUNIT_SZ+1)) || \
421 quota_error a $TSTUSR "write failure, but expect success"
422 OFFSET=$((OFFSET + BUNIT_SZ + 1))
429 echo " Write before timer goes off"
430 $RUNDD count=$BUNIT_SZ seek=$OFFSET || \
431 quota_error a $TSTUSR "write failure, but expect success"
432 OFFSET=$((OFFSET + BUNIT_SZ))
436 echo " Sleep $TIMER seconds ..."
443 echo " Write after timer goes off"
444 # maybe cache write, ignore.
445 $RUNDD count=$BUNIT_SZ seek=$OFFSET || true
446 OFFSET=$((OFFSET + BUNIT_SZ))
448 $RUNDD count=$BUNIT_SZ seek=$OFFSET && \
449 quota_error a $TSTUSR "write success, but expect EDQUOT"
455 echo " Unlink file to stop timer"
465 $RUNDD count=$BUNIT_SZ || quota_error a $TSTUSR "write failure, but expect success"
473 # block soft limit (start timer, timer goes off, stop timer)
476 chmod 0777 $DIR/$tdir
478 # 1 bunit on mds and 1 bunit on every ost
479 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) ))
482 echo " User quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
483 TESTFILE=$DIR/$tdir/$tfile-0
485 $LFS setstripe $TESTFILE -c 1
486 chown $TSTUSR.$TSTUSR $TESTFILE
488 $LFS setquota -t -u --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
489 $LFS setquota -u $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
491 test_block_soft $TESTFILE $GRACE
492 resetquota -u $TSTUSR
494 echo " Group quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
495 TESTFILE=$DIR/$tdir/$tfile-1
497 $LFS setstripe $TESTFILE -c 1
498 chown $TSTUSR.$TSTUSR $TESTFILE
500 $LFS setquota -t -g --block-grace $GRACE --inode-grace $MAX_IQ_TIME $DIR
501 $LFS setquota -g $TSTUSR -b $LIMIT -B 0 -i 0 -I 0 $DIR
503 test_block_soft $TESTFILE $GRACE
504 resetquota -g $TSTUSR
506 run_test_with_stat 3 "Block soft limit (start timer, timer goes off, stop timer) ==="
511 TIMER=$(($3 * 3 / 2))
513 wait_delete_completed
515 echo " Create files to exceed soft limit"
516 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) || \
517 quota_error a $TSTUSR "create failure, but expect success"
521 echo " Create file before timer goes off"
522 $RUNAS touch ${TESTFILE}_before || \
523 quota_error a $TSTUSR "failed create before timer expired, but expect success"
527 echo " Sleep $TIMER seconds ..."
534 echo " Create file after timer goes off"
535 # the least of inode qunit is 2, so there are at most 3(qunit:2+qtune:1)
536 # inode quota left here
537 $RUNAS touch ${TESTFILE}_after ${TESTFILE}_after1 ${TESTFILE}_after2 || true
539 $RUNAS touch ${TESTFILE}_after3 && \
540 quota_error a $TSTUSR "create after timer expired, but expect EDQUOT"
547 echo " Unlink files to stop timer"
548 find `dirname $TESTFILE` -name "`basename ${TESTFILE}`*" | xargs rm -f
552 $RUNAS touch ${TESTFILE}_xxx || \
553 quota_error a $TSTUSR "touch after timer stop failure, but expect success"
558 rm -f ${TESTFILE}_xxx
562 # file soft limit (start timer, timer goes off, stop timer)
563 test_4a() { # was test_4
565 chmod 0777 $DIR/$tdir
566 LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds
567 TESTFILE=$DIR/$tdir/$tfile-0
571 echo " User quota (soft limit: $LIMIT files grace: $GRACE seconds)"
572 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
573 $LFS setquota -u $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
574 quota_show_check f u $TSTUSR
576 test_file_soft $TESTFILE $LIMIT $GRACE
577 resetquota -u $TSTUSR
579 echo " Group quota (soft limit: $LIMIT files grace: $GRACE seconds)"
580 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $GRACE $DIR
581 $LFS setquota -g $TSTUSR -b 0 -B 0 -i $LIMIT -I 0 $DIR
582 quota_show_check f g $TSTUSR
583 TESTFILE=$DIR/$tdir/$tfile-1
585 test_file_soft $TESTFILE $LIMIT $GRACE
586 resetquota -g $TSTUSR
589 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
590 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
592 run_test_with_stat 4a "File soft limit (start timer, timer goes off, stop timer) ==="
594 test_4b() { # was test_4a
600 GR_STR6="1111111111111111"
602 wait_delete_completed
604 # test of valid grace strings handling
605 echo " Valid grace strings test"
606 $LFS setquota -t -u --block-grace $GR_STR1 --inode-grace $GR_STR2 $DIR
607 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
608 $LFS setquota -t -g --block-grace $GR_STR3 --inode-grace $GR_STR4 $DIR
609 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
611 # test of invalid grace strings handling
612 echo " Invalid grace strings test"
613 ! $LFS setquota -t -u --block-grace $GR_STR4 --inode-grace $GR_STR5 $DIR
614 ! $LFS setquota -t -g --block-grace $GR_STR4 --inode-grace $GR_STR6 $DIR
617 $LFS setquota -t -u --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
618 $LFS setquota -t -g --block-grace $MAX_DQ_TIME --inode-grace $MAX_IQ_TIME $DIR
620 run_test_with_stat 4b "Grace time strings handling ==="
622 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
625 BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server
626 ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds
628 wait_delete_completed
630 echo " Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR"
631 $LFS setquota -u $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
632 $LFS setquota -g $TSTUSR -b 0 -B $BLIMIT -i 0 -I $ILIMIT $DIR
633 quota_show_check a u $TSTUSR
634 quota_show_check a g $TSTUSR
636 echo " Create more than $ILIMIT files and more than $BLIMIT kbytes ..."
637 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \
638 error "touch failure, expect success"
639 dd if=/dev/zero of=$DIR/$tdir/$tfile-0_1 bs=$BLK_SZ count=$((BLIMIT+1)) || error "write failure, expect success"
641 echo " Chown files to $TSTUSR.$TSTUSR ..."
642 for i in `seq 0 $ILIMIT`; do
643 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \
644 quota_error a $TSTUSR "chown failure, but expect success"
648 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
651 resetquota -u $TSTUSR
652 resetquota -g $TSTUSR
654 run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota ==="
656 # block quota acquire & release
658 if [ $OSTCOUNT -lt 2 ]; then
659 skip "$OSTCOUNT < 2, too few osts"
663 wait_delete_completed
666 chmod 0777 $DIR/$tdir
668 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server
669 FILEA="$DIR/$tdir/$tfile-0_a"
670 FILEB="$DIR/$tdir/$tfile-0_b"
672 echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
673 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
674 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
675 quota_show_check b u $TSTUSR
676 quota_show_check b g $TSTUSR
678 echo " Create filea on OST0 and fileb on OST1"
679 $LFS setstripe $FILEA -i 0 -c 1
680 $LFS setstripe $FILEB -i 1 -c 1
681 chown $TSTUSR.$TSTUSR $FILEA
682 chown $TSTUSR.$TSTUSR $FILEB
684 echo " Exceed quota limit ..."
685 RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
686 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
687 quota_error a $TSTUSR "write fileb failure, but expect success"
692 $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
693 quota_error a $TSTUSR "write fileb success, but expect EDQUOT"
695 echo " Write to OST0 return EDQUOT"
696 # this write maybe cache write, ignore it's failure
697 RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
698 $RUNDD count=$(($BUNIT_SZ * 2)) || true
702 $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
703 quota_error a $TSTUSR "write filea success, but expect EDQUOT"
705 echo " Remove fileb to let OST1 release quota"
707 sync; sleep 10; sync; # need to allow journal commit for small fs
709 echo " Write to OST0"
710 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
711 quota_error a $TSTUSR "write filea failure, expect success"
718 resetquota -u $TSTUSR
719 resetquota -g $TSTUSR
722 run_test_with_stat 6 "Block quota acquire & release ========="
724 # quota recovery (block quota only by now)
728 chmod 0777 $DIR/$tdir
730 wait_delete_completed
732 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) ))
733 TESTFILE="$DIR/$tdir/$tfile-0"
735 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
737 $LFS setstripe $TESTFILE -c 1
738 chown $TSTUSR.$TSTUSR $TESTFILE
740 echo " Write to OST0..."
741 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \
742 quota_error u $TSTUSR "write failure, but expect success"
744 #define OBD_FAIL_OBD_DQACQ 0x604
745 lustre_fail mds 0x604
746 echo " Remove files on OST0"
750 echo " Trigger recovery..."
751 OSC0_UUID="`$LCTL dl | awk '$3 ~ /osc/ { print $1 }'`"
752 for i in $OSC0_UUID; do
753 $LCTL --device $i activate || error "activate osc failed!"
756 # sleep a while to wait for recovery done
760 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
761 TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
762 [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!"
763 echo " total limits = $TOTAL_LIMIT"
765 OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
766 [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
767 OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`"
768 [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!"
769 echo " limits on $OST0_UUID = $OST0_LIMIT"
772 resetquota -u $TSTUSR
774 run_test_with_stat 7 "Quota recovery (only block limit) ======"
776 # run dbench with quota enabled
779 BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
782 wait_delete_completed
784 echo " Set enough high limit for user: $TSTUSR"
785 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
786 echo " Set enough high limit for group: $TSTUSR"
787 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
789 chmod 0777 $DIR/$tdir
791 [ "$SLOW" = "no" ] && duration=" -t 120"
792 $RUNAS bash rundbench -D $DIR/$tdir 3 $duration || quota_error a $TSTUSR "dbench failed!"
798 run_test_with_stat 8 "Run dbench with quota enabled ==========="
800 # run for fixing bug10707, it needs a big room. test for 64bit
802 GB=$((KB * 1024 * 1024))
803 # Use this as dd bs to decrease time
804 # inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS);
805 blksize=$((1 << 21)) # 2Mb
806 size_file=$((GB * 9 / 2))
807 # this check is just for test9 and test10
808 OST0_MIN=4900000 #4.67G
809 check_whether_skip () {
810 OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'`
811 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
812 if [ $OST0_SIZE -lt $OST0_MIN ]; then
813 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
821 check_whether_skip && return 0
823 wait_delete_completed
829 chmod 0777 $DIR/$tdir
830 TESTFILE="$DIR/$tdir/$tfile-0"
832 BLK_LIMIT=$((100 * KB * KB)) # 100G
834 echo " Set block limit $BLK_LIMIT kbytes to $TSTUSR.$TSTUSR"
836 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
837 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
838 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
839 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
841 quota_show_check a u $TSTUSR
842 quota_show_check a g $TSTUSR
845 $LFS setstripe $TESTFILE -c 1
847 chown $TSTUSR.$TSTUSR $TESTFILE
849 log " Write the big file of 4.5G ..."
850 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
851 quota_error a $TSTUSR "(usr) write 4.5G file failure, but expect success"
856 log " delete the big file of 4.5G..."
857 $RUNAS rm -f $TESTFILE
865 set_blk_unitsz $((128 * 1024))
866 set_blk_tunesz $((128 * 1024 / 2))
870 run_test_with_stat 9 "run for fixing bug10707(64bit) ==========="
872 # run for fixing bug10707, it need a big room. test for 32bit
873 # 2.0 version does not support 32 bit qd_count, so such test is obsolete.
876 chmod 0777 $DIR/$tdir
877 check_whether_skip && return 0
879 wait_delete_completed
884 # make qd_count 32 bit
885 lustre_fail mds_ost 0xA00
887 TESTFILE="$DIR/$tdir/$tfile-0"
889 BLK_LIMIT=$((100 * KB * KB)) # 100G
892 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
893 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
894 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
895 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $DIR
897 quota_show_check a u $TSTUSR
898 quota_show_check a g $TSTUSR
901 $LFS setstripe $TESTFILE -c 1
903 chown $TSTUSR.$TSTUSR $TESTFILE
905 log " Write the big file of 4.5 G ..."
906 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
907 quota_error a $TSTUSR "(usr) write 4.5 G file failure, but expect success"
912 log " delete the big file of 4.5 G..."
913 $RUNAS rm -f $TESTFILE
921 # make qd_count 64 bit
922 lustre_fail mds_ost 0
924 set_blk_unitsz $((128 * 1024))
925 set_blk_tunesz $((128 * 1024 / 2))
929 #run_test_with_stat 10 "run for fixing bug10707(32bit) ==========="
932 wait_delete_completed
935 block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1`
937 orig_dbr=`sysctl -n vm.dirty_background_ratio`
938 orig_dec=`sysctl -n vm.dirty_expire_centisecs`
939 orig_dr=`sysctl -n vm.dirty_ratio`
940 orig_dwc=`sysctl -n vm.dirty_writeback_centisecs`
941 sysctl -w vm.dirty_background_ratio=1
942 sysctl -w vm.dirty_expire_centisecs=30
943 sysctl -w vm.dirty_ratio=1
944 sysctl -w vm.dirty_writeback_centisecs=50
951 [ "$SLOW" = no ] && REPS=1
954 while [ $i -le $REPS ]; do
955 echo "test: cycle($i of $REPS) start at $(date)"
956 mkdir -p $TESTDIR && chmod 777 $TESTDIR
957 echo -n " create a file for uid "
958 for j in `seq 1 30`; do
960 # 30MB per dd for a total of 900MB (if space even permits)
961 runas -u $j dd if=/dev/zero of=$TESTDIR/$tfile bs=$blksize count=15 > /dev/null 2>&1 &
964 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
966 while [ $PROCS -gt 0 ]; do
968 SECS=$((SECS + sleep))
969 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
970 USED=$(du -s $TESTDIR | awk '{print $1}')
971 PCT=$(($USED * 100 / $block_limit))
972 echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} "
973 if [ $USED -le $LAST_USED ]; then
974 kill -9 $(ps -ef | grep "dd if /dev/zero of $TESTDIR" | grep -v grep | awk '{ print $2 }')
981 echo " removing the test files..."
982 rm -f $TESTDIR/$tfile
983 echo "cycle $i done at $(date)"
986 echo "Test took $SECS sec"
989 sysctl -w vm.dirty_background_ratio=$orig_dbr
990 sysctl -w vm.dirty_expire_centisecs=$orig_dec
991 sysctl -w vm.dirty_ratio=$orig_dr
992 sysctl -w vm.dirty_writeback_centisecs=$orig_dwc
993 if [ $RV -ne 0 ]; then
994 error "Nothing was written for $SECS sec ... aborting"
998 run_test_with_stat 11 "run for fixing bug10912 ==========="
1001 # test a deadlock between quota and journal b=11693
1004 chmod 0777 $DIR/$tdir
1006 [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
1007 { skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
1009 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
1010 TESTFILE="$DIR/$tdir/$tfile-0"
1011 TESTFILE2="$DIR2/$tdir/$tfile-1"
1013 wait_delete_completed
1015 echo " User quota (limit: $LIMIT kbytes)"
1016 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1018 $LFS setstripe $TESTFILE -i 0 -c 1
1019 chown $TSTUSR.$TSTUSR $TESTFILE
1020 $LFS setstripe $TESTFILE2 -i 0 -c 1
1021 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
1023 #define OBD_FAIL_OST_HOLD_WRITE_RPC 0x21f
1024 #define OBD_FAIL_SOME 0x10000000 /* fail N times */
1025 lustre_fail ost $((0x0000021f | 0x10000000)) 1
1027 echo " step1: write out of block quota ..."
1028 $RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 &
1030 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT*2)) &
1033 echo " step2: testing ......"
1036 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1038 if [ $count -gt 64 ]; then
1040 quota_error u $TSTUSR2 "dd should be finished!"
1044 echo "(dd_pid=$DDPID1, time=$count)successful"
1046 #Recover fail_loc and dd will finish soon
1049 echo " step3: testing ......"
1052 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1054 if [ $count -gt 150 ]; then
1055 quota_error u $TSTUSR "dd should be finished!"
1059 echo "(dd_pid=$DDPID, time=$count)successful"
1061 rm -f $TESTFILE $TESTFILE2
1062 sync; sleep 3; sync;
1064 resetquota -u $TSTUSR
1066 run_test_with_stat 12 "test a deadlock between quota and journal ==="
1068 # test multiple clients write block quota b=11693
1071 wait_delete_completed
1073 # one OST * 10 + (mds + other OSTs)
1074 LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT)))
1075 TESTFILE="$DIR/$tdir/$tfile"
1077 echo " User quota (limit: $LIMIT kbytes)"
1078 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1079 quota_show_check b u $TSTUSR
1081 $LFS setstripe $TESTFILE -i 0 -c 1
1082 chown $TSTUSR.$TSTUSR $TESTFILE
1083 $LFS setstripe $TESTFILE.2 -i 0 -c 1
1084 chown $TSTUSR.$TSTUSR $TESTFILE.2
1086 echo " step1: write out of block quota ..."
1087 # one bunit will give mds
1088 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1090 $RUNAS dd if=/dev/zero of=$TESTFILE.2 bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1093 echo " step2: testing ......"
1096 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1098 if [ $count -gt 64 ]; then
1099 quota_error u $TSTUSR "dd should be finished!"
1103 echo "(dd_pid=$DDPID, time=$count)successful"
1107 if ! ps -p ${DDPID1} > /dev/null 2>&1 ; then break; fi
1109 if [ $count -gt 64 ]; then
1110 quota_error u $TSTUSR "dd should be finished!"
1114 echo "(dd_pid=$DDPID1, time=$count)successful"
1116 sync; sleep 5; sync;
1118 echo " step3: checking ......"
1119 fz=`stat -c %s $TESTFILE`
1120 fz2=`stat -c %s $TESTFILE.2`
1122 [ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
1123 quota_error u $TSTUSR "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
1125 rm -f $TESTFILE $TESTFILE.2
1126 sync; sleep 3; sync;
1128 resetquota -u $TSTUSR
1130 run_test_with_stat 13 "test multiple clients write block quota ==="
1132 check_if_quota_zero(){
1133 line=`$LFS quota -v -$1 $2 $DIR | wc -l`
1134 for i in `seq 3 $line`; do
1135 if [ $i -eq 3 ]; then
1141 tmp=`$LFS quota -v -$1 $2 $DIR | sed -n ${i}p |
1142 awk '{print $'"$j"'}'`
1143 [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -v -$1 $2 $DIR && \
1144 error "quota on $2 isn't clean"
1147 echo "pass check_if_quota_zero"
1150 test_14a() { # was test_14 b=12223 -- setting quota on root
1151 TESTFILE="$DIR/$tdir/$tfile"
1155 cleanup_and_setup_lustre
1160 # out of root's file and block quota
1161 $LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR
1162 createmany -m ${TESTFILE} 20 || \
1163 quota_error u root "unexpected: user(root) create files failly!"
1164 dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
1165 quota_error u root "unexpected: user(root) write files failly!"
1167 $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
1168 quota_error u root "unexpected: user(quota_usr) write a file successfully!"
1172 for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done
1173 for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done
1176 dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
1178 #check_if_quota_zero u root
1181 unlinkmany ${TESTFILE} 15
1183 sync; sleep 3; sync;
1185 run_test_with_stat 14a "test setting quota on root ==="
1187 # save quota version (both administrative and operational quotas)
1188 quota_save_version() {
1189 do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1"
1190 do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$1"
1195 LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1196 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
1198 wait_delete_completed
1201 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1202 TOTAL_LIMIT="`$LFS quota -v -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1203 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1204 echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1205 resetquota -u $TSTUSR
1208 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1209 TOTAL_LIMIT="`$LFS quota -v -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1210 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1211 echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1212 resetquota -g $TSTUSR
1213 $LFS quotaoff -ug $DIR
1214 do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_type=ug" | grep "error writing" && \
1215 error "fail to set version for $SINGLEMDS"
1216 for j in `seq $OSTCOUNT`; do
1217 do_facet ost$j "lctl set_param lquota.${FSNAME}-OST*.quota_type=ug" | grep "error writing" && \
1218 error "fail to set version for ost$j"
1221 echo "invalidating quota files"
1222 $LFS quotainv -ug $DIR
1223 $LFS quotainv -ugf $DIR
1224 $LFS quotacheck -ug $DIR
1226 run_test_with_stat 15 "set block quota more than 4T ==="
1228 # $1=u/g $2=with qunit adjust or not
1230 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4))
1231 TESTFILE="$DIR/$tdir/$tfile"
1234 wait_delete_completed
1236 echo " User quota (limit: $LIMIT kbytes)"
1237 if [ $1 == "u" ]; then
1238 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1239 quota_show_check b u $TSTUSR
1241 $LFS setquota -g $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1242 quota_show_check b g $TSTUSR
1245 $LFS setstripe $TESTFILE -c 1
1246 chown $TSTUSR.$TSTUSR $TESTFILE
1249 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
1250 quota_error a $TSTUSR "(usr) write failure, but expect success"
1252 echo " Write out of block quota ..."
1253 # this time maybe cache write, ignore it's failure
1254 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true
1255 # flush cache, ensure noquota flag is setted on client
1256 cancel_lru_locks osc
1257 if [ $2 -eq 1 ]; then
1258 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
1259 quota_error a $TSTUSR "(write failure, but expect success"
1261 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
1262 quota_error a $TSTUSR "(write success, but expect EDQUOT"
1266 sync; sleep 3; sync;
1267 resetquota -$1 $TSTUSR
1270 # test without adjusting qunit
1271 # 2.0 version does not support WITHOUT_CHANGE_QS, so such test is obsolete
1273 set_blk_tunesz $((BUNIT_SZ * 2))
1274 set_blk_unitsz $((BUNIT_SZ * 4))
1277 # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS 0xA01
1278 echo " grp/usr: $i, adjust qunit: $j"
1279 echo "-------------------------------"
1280 [ $j -eq 1 ] && lustre_fail mds_ost 0
1281 [ $j -eq 0 ] && lustre_fail mds_ost 0xA01
1285 set_blk_unitsz $((128 * 1024))
1286 set_blk_tunesz $((128 * 1024 / 2))
1288 #run_test_with_stat 16 "test without adjusting qunit"
1290 # run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre.
1295 wait_delete_completed
1297 #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
1298 lustre_fail ost 0x80000A02
1300 TESTFILE="$DIR/$tdir/$tfile-a"
1301 TESTFILE2="$DIR/$tdir/$tfile-b"
1304 BLK_LIMIT=$((100 * 1024)) # 100M
1306 log " Set enough high limit(block:$BLK_LIMIT) for user: $TSTUSR"
1307 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1308 log " Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
1309 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR
1311 quota_show_check b u $TSTUSR
1312 quota_show_check b g $TSTUSR
1315 chown $TSTUSR.$TSTUSR $TESTFILE
1317 chown $TSTUSR.$TSTUSR $TESTFILE2
1319 log " Write the test file1 ..."
1320 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(( 10 * 1024 )) \
1321 || quota_error a $TSTUSR "write 10M file failure"
1326 log " write the test file2 ..."
1327 $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=$(( 10 * 1024 )) \
1328 || quota_error a $TSTUSR "write 10M file failure"
1333 rm -f $TESTFILE $TESTFILE2
1335 sync; sleep 3; sync;
1337 # make qd_count 64 bit
1340 set_blk_unitsz $((128 * 1024))
1341 set_blk_tunesz $((128 * 1024 / 2))
1343 resetquota -u $TSTUSR
1344 resetquota -g $TSTUSR
1348 run_test_with_stat 17 "run for fixing bug14526 ==========="
1350 # test when mds takes a long time to handle a quota req so that
1351 # the ost has dropped it, the ost still could work well b=14840
1353 LIMIT=$((100 * 1024 * 1024)) # 100G
1354 TESTFILE="$DIR/$tdir/$tfile"
1357 wait_delete_completed
1362 log " User quota (limit: $LIMIT kbytes)"
1363 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1364 quota_show_check b u $TSTUSR
1366 $LFS setstripe $TESTFILE -i 0 -c 1
1367 chown $TSTUSR.$TSTUSR $TESTFILE
1369 #define OBD_FAIL_MDS_BLOCK_QUOTA_REQ 0x13c
1370 lustre_fail mds 0x13c
1372 log " step1: write 100M block ..."
1373 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1379 echo " step2: testing ......"
1381 if at_is_valid && at_is_enabled; then
1382 timeout=$(at_max_get mds)
1384 timeout=$(lctl get_param -n timeout)
1387 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1389 if [ $count -gt $((4 * $timeout)) ]; then
1390 quota_error u $TSTUSR "count=$count dd should be finished!"
1394 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1396 testfile_size=$(stat -c %s $TESTFILE)
1397 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1398 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1400 sync; sleep 3; sync;
1402 resetquota -u $TSTUSR
1404 set_blk_unitsz $((128 * 1024))
1405 set_blk_tunesz $((128 * 1024 / 2))
1407 run_test_with_stat 18 "run for fixing bug14840 ==========="
1409 # test when mds drops a quota req, the ost still could work well b=14840
1411 LIMIT=$((100 * 1024 * 1024)) # 100G
1412 TESTFILE="$DIR/$tdir/$tfile-a"
1415 wait_delete_completed
1420 log " User quota (limit: $LIMIT kbytes)"
1421 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1422 quota_show_check b u $TSTUSR
1424 $LFS setstripe $TESTFILE -i 0 -c 1
1425 chown $TSTUSR.$TSTUSR $TESTFILE
1427 #define OBD_FAIL_MDS_DROP_QUOTA_REQ | OBD_FAIL_ONCE 0x8000013d
1428 lustre_fail mds 0x8000013d
1430 log " step1: write 100M block ..."
1431 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1434 echo " step2: testing ......"
1436 if at_is_valid && at_is_enabled; then
1437 timeout=$(at_max_get mds)
1439 timeout=$(lctl get_param -n timeout)
1442 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1444 if [ $count -gt $((6 * $timeout)) ]; then
1446 quota_error u $TSTUSR "count=$count dd should be finished!"
1450 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1455 sync; sleep 3; sync;
1457 resetquota -u $TSTUSR
1459 set_blk_unitsz $((128 * 1024))
1460 set_blk_tunesz $((128 * 1024 / 2))
1462 run_test_with_stat 18a "run for fixing bug14840 ==========="
1464 # test when mds do failover, the ost still could work well without trigger
1469 LIMIT=$((110 * 1024 )) # 110M
1470 TESTFILE="$DIR/$tdir/$tfile"
1473 wait_delete_completed
1478 log " User quota (limit: $LIMIT kbytes)"
1479 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1480 quota_show_check b u $TSTUSR
1482 $LFS setstripe $TESTFILE -i 0 -c 1
1483 chown $TSTUSR.$TSTUSR $TESTFILE
1485 timeout=$(sysctl -n lustre.timeout)
1487 if [ $type = "directio" ]; then
1488 log " write 100M block(directio) ..."
1489 $RUNAS $DIRECTIO write $TESTFILE 0 100 $((BLK_SZ * 1024)) &
1491 log " write 100M block(normal) ..."
1492 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$((BLK_SZ * 1024)) count=100 &
1496 do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
1498 log "failing mds for $((2 * timeout)) seconds"
1499 fail $SINGLEMDS $((2 * timeout))
1501 # check if quotaon successful
1502 $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
1503 if [ $? -eq 0 ]; then
1504 error "quotaon failed!"
1510 if at_is_valid && at_is_enabled; then
1511 timeout=$(at_max_get mds)
1513 timeout=$(lctl get_param -n timeout)
1516 if ! ps -p ${DDPID} > /dev/null 2>&1; then break; fi
1517 if [ $((++count % (2 * timeout) )) -eq 0 ]; then
1518 log "it took $count second"
1522 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1525 testfile_size=$(stat -c %s $TESTFILE)
1526 [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
1527 quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
1529 resetquota -u $TSTUSR
1534 # test when mds does failover, the ost still could work well
1535 # this test shouldn't trigger watchdog b=14840
1537 test_18bc_sub normal
1538 test_18bc_sub directio
1539 # check if watchdog is triggered
1540 do_facet ost1 dmesg > $TMP/lustre-log-${TESTNAME}.log
1541 watchdog=`awk '/test 18b/ {start = 1;}
1542 /Watchdog triggered/ {
1546 }' $TMP/lustre-log-${TESTNAME}.log`
1547 [ `echo "$watchdog" | wc -l` -ge 3 ] && error "$watchdog"
1548 rm -f $TMP/lustre-log-${TESTNAME}.log
1550 run_test_with_stat 18b "run for fixing bug14840(mds failover, no watchdog) ==========="
1552 # test when mds does failover, the ost still could work well
1553 # this test will prevent OST_DISCONNET from happening b=14840
1555 # define OBD_FAIL_OST_DISCONNECT_NET 0x202(disable ost_disconnect for osts)
1556 lustre_fail ost 0x202
1557 test_18bc_sub normal
1558 test_18bc_sub directio
1561 run_test_with_stat 18c "run for fixing bug14840(mds failover, OST_DISCONNECT is disabled) ==========="
1563 run_to_block_limit() {
1564 local LIMIT=$((($OSTCOUNT + 1) * $BUNIT_SZ))
1566 wait_delete_completed
1568 # set 1 Mb quota unit size
1572 # bind file to a single OST
1573 $LFS setstripe -c 1 $TESTFILE
1574 chown $TSTUSR.$TSTUSR $TESTFILE
1576 echo " User quota (limit: $LIMIT kbytes)"
1577 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1578 quota_show_check b u $TSTUSR
1579 echo " Updating quota limits"
1580 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $MOUNT
1581 quota_show_check b u $TSTUSR
1583 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
1584 $RUNDD count=$BUNIT_SZ || quota_error u $TSTUSR "(usr) write failure, but expect success"
1585 # for now page cache of TESTFILE may still be dirty,
1586 # let's push it to the corresponding OST, this will also
1587 # cache NOQUOTA on the client from OST's reply
1588 cancel_lru_locks osc
1589 $RUNDD seek=$BUNIT_SZ && quota_error u $TSTUSR "(usr) write success, should be EDQUOT"
1593 # 1 Mb bunit per each MDS/OSS
1594 local TESTFILE="$DIR/$tdir/$tfile"
1597 run_to_block_limit $TESTFILE
1602 resetquota -u $TSTUSR
1604 set_blk_unitsz $((128 * 1024))
1605 set_blk_tunesz $((128 * 1024 / 2))
1608 run_test_with_stat 19 "test if administrative limits updates do not zero operational limits (14790) ==="
1612 LSTR=(1t 2g 3m 4k) # limits strings
1613 LVAL=($[1*1024*1024*1024] $[2*1024*1024] $[3*1024*1024] $[4*1024]) # limits values
1615 $LFS setquota -u $TSTUSR --block-softlimit ${LSTR[0]} \
1616 $MOUNT || error "could not set quota limits"
1618 $LFS setquota -u $TSTUSR --block-hardlimit ${LSTR[1]} \
1619 --inode-softlimit ${LSTR[2]} \
1620 --inode-hardlimit ${LSTR[3]} \
1621 $MOUNT || error "could not set quota limits"
1623 ($LFS quota -v -u $TSTUSR $MOUNT | \
1624 grep -E '^ *'$MOUNT' *[0-9]+\** *'${LVAL[0]}' *'${LVAL[1]}' *[0-9]+\** *'${LVAL[2]}' *'${LVAL[3]}) \
1625 || error "lfs quota output is unexpected"
1627 resetquota -u $TSTUSR
1629 run_test_with_stat 20 "test if setquota specifiers work properly (15754)"
1636 time=$(($(date +%s) + seconds))
1637 while [ $(date +%s) -lt $time ]; do
1638 $RUNAS dd if=/dev/zero of=$testfile bs=$BLK_SZ count=$blk_number > /dev/null 2>&1
1643 # run for fixing bug16053, setquota shouldn't fail when writing and
1644 # deleting are happening
1649 wait_delete_completed
1651 TESTFILE="$DIR/$tdir/$tfile"
1653 BLK_LIMIT=$((10 * 1024 * 1024)) # 10G
1656 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
1657 $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1658 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
1659 $LFS setquota -g $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I $FILE_LIMIT $MOUNT
1661 # repeat writing on a 1M file
1662 test_21_sub ${TESTFILE}_1 1024 30 &
1664 # repeat writing on a 128M file
1665 test_21_sub ${TESTFILE}_2 $((1024 * 128)) 30 &
1668 time=$(($(date +%s) + 30))
1670 while [ $(date +%s) -lt $time ]; do
1671 log " Set quota for $i times"
1672 $LFS setquota -u $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1673 $LFS setquota -g $TSTUSR -b 0 -B $((BLK_LIMIT + 1024 * i)) -i 0 -I $((FILE_LIMIT + i)) $MOUNT
1680 if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
1682 if [ $count -gt 60 ]; then
1683 quota_error a $TSTUSR "dd should be finished!"
1687 echo "(dd_pid=$DDPID1, time=$count)successful"
1691 if ! ps -p ${DDPID2} > /dev/null 2>&1; then break; fi
1693 if [ $count -gt 60 ]; then
1694 quota_error a $TSTUSR "dd should be finished!"
1698 echo "(dd_pid=$DDPID2, time=$count)successful"
1700 set_blk_unitsz $((128 * 1024))
1701 set_blk_tunesz $((128 * 1024 / 2))
1702 resetquota -u $TSTUSR
1703 resetquota -g $TSTUSR
1707 run_test_with_stat 21 "run for fixing bug16053 ==========="
1712 SAVEREFORMAT=$REFORMAT
1713 $LFS quotaoff -ug $DIR || error "could not turn quotas off"
1715 quota_save_version "ug"
1721 REFORMAT=$SAVEREFORMAT
1723 echo "checking parameters"
1725 do_facet $SINGLEMDS "lctl get_param mdd.${FSNAME}-MDT*.quota_type" | grep "ug" || error "admin failure"
1726 do_facet ost1 "lctl get_param obdfilter.*.quota_type" | grep "ug" || error "op failure"
1728 run_test 0 "reboot lustre"
1730 run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
1732 # It is triggered when test_23 failed, diagnostic for bug 18293
1736 DUMPPAGE=`find /proc/fs/${FSNAME}/llite/ -name dump_page_cache`
1738 cat $DUMPPAGE > $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1739 fsize=`stat -c%s $TMP/sanity-quota_test_23_${qtime}_${NUM}.log`
1740 if [ $fsize -eq 0 ]; then
1741 rm -f $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
1743 error "some IO error was found during directIO"
1749 chmod 0777 $DIR/$tdir
1750 TESTFILE="$DIR/$tdir/$tfile-0"
1752 local bs_unit=$((1024*1024))
1755 wait_delete_completed
1758 log " User quota (limit: $LIMIT kbytes)"
1759 $LFS setquota -u $TSTUSR -b 0 -B $LIMIT -i 0 -I 0 $DIR
1761 quota_show_check b u $TSTUSR
1763 $LFS setstripe $TESTFILE -c 1
1764 chown $TSTUSR.$TSTUSR $TESTFILE
1766 log " Step1: trigger quota with 0_DIRECT"
1767 log " Write half of file"
1768 $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || \
1769 (quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT" && test_23_dumppage 1)
1770 log " Write out of block quota ..."
1771 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && \
1772 quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT" && test_23_dumppage 2
1775 log " Step2: rewrite should succeed"
1776 $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || \
1777 (quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT" && test_23_dumppage 3)
1781 wait_delete_completed
1782 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1783 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1784 echo $OST0_QUOTA_USED
1785 [ $OST0_QUOTA_USED -ne 0 ] && \
1786 ($SHOW_QUOTA_USER; quota_error u $TSTUSR "quota deleted isn't released")
1788 resetquota -u $TSTUSR
1792 log "run for $((OSTCOUNT * 4))MB test file"
1793 test_23_sub $((OSTCOUNT * 4 * 1024))
1796 check_whether_skip && return 0
1797 log "run for $((OSTCOUNT * 40))MB test file"
1798 test_23_sub $((OSTCOUNT * 40 * 1024))
1800 run_test_with_stat 23 "run for fixing bug16125 ==========="
1803 local TESTFILE="$DIR/$tdir/$tfile"
1806 run_to_block_limit $TESTFILE
1807 $SHOW_QUOTA_USER | grep '*' || error "no matching *"
1811 resetquota -u $TSTUSR
1813 set_blk_unitsz $((128 * 1024))
1814 set_blk_tunesz $((128 * 1024 / 2))
1817 run_test_with_stat 24 "test if lfs draws an asterix when limit is reached (16646) ==========="
1820 if [ $1 = "-u" ]; then
1821 if [ $2 = "$TSTUSR" ]; then
1827 if [ $2 = "$TSTUSR" ]; then
1837 chmod 0777 $DIR/$tdir
1838 TESTFILE="$DIR/$tdir/$tfile-0"
1840 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) + 4096 ))
1842 wait_delete_completed
1844 # set quota for $TSTUSR
1845 log "setquota for $TSTUSR"
1846 $LFS setquota $1 $TSTUSR -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1848 if [ "$1" == "-u" ]; then
1849 quota_show_check a u $TSTUSR
1851 quota_show_check a g $TSTUSR
1854 # set quota for $TSTUSR2
1855 log "setquota for $TSTUSR2"
1856 $LFS setquota $1 $TSTUSR2 -b $LIMIT -B $LIMIT -i 10 -I 10 $DIR
1858 if [ "$1" == "-u" ]; then
1859 quota_show_check a u $TSTUSR2
1861 quota_show_check a g $TSTUSR2
1864 # set stripe index to 0
1865 log "setstripe for $DIR/$tdir to 0"
1866 $LFS setstripe $DIR/$tdir -c 1 -i 0
1867 MDS_UUID=`do_facet $SINGLEMDS $LCTL dl | grep -m1 " mdt " | awk '{print $((NF-1))}'`
1868 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
1869 MDS_QUOTA_USED_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1870 OST0_QUOTA_USED_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1871 MDS_QUOTA_USED2_OLD=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1872 OST0_QUOTA_USED2_OLD=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1875 log "$TSTUSR write 4M to $TESTFILE"
1876 $RUNAS dd if=/dev/zero of=$TESTFILE bs=4K count=1K || quota_error a $TSTUSR "dd failed"
1878 show_quota $1 $TSTUSR
1879 show_quota $1 $TSTUSR2
1880 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1881 [ $MDS_QUOTA_USED_NEW -ne $((MDS_QUOTA_USED_OLD + 1)) ] && \
1882 quota_error a $TSTUSR "$TSTUSR inode quota usage error: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1883 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1884 OST0_QUOTA_USED_DELTA=$((OST0_QUOTA_USED_NEW - OST0_QUOTA_USED_OLD))
1885 [ $OST0_QUOTA_USED_DELTA -lt 4096 ] && \
1886 quota_error a $TSTUSR "$TSTUSR block quota usage error: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1888 # chown/chgrp from $TSTUSR to $TSTUSR2
1889 if [ $1 = "-u" ]; then
1890 log "chown from $TSTUSR to $TSTUSR2"
1891 chown $TSTUSR2 $TESTFILE || quota_error u $TSTUSR2 "chown failed"
1893 log "chgrp from $TSTUSR to $TSTUSR2"
1894 chgrp $TSTUSR2 $TESTFILE || quota_error g $TSTUSR2 "chgrp failed"
1897 show_quota $1 $TSTUSR
1898 show_quota $1 $TSTUSR2
1899 MDS_QUOTA_USED2_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1900 [ $MDS_QUOTA_USED2_NEW -ne $((MDS_QUOTA_USED2_OLD + 1)) ] && \
1901 quota_error a $TSTUSR2 "$TSTUSR2 inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED2_OLD|$MDS_QUOTA_USED2_NEW]"
1902 OST0_QUOTA_USED2_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR2 $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1903 OST0_QUOTA_USED2_DELTA=$((OST0_QUOTA_USED2_NEW - OST0_QUOTA_USED2_OLD))
1904 [ $OST0_QUOTA_USED2_DELTA -ne $OST0_QUOTA_USED_DELTA ] && \
1905 quota_error a $TSTUSR2 "$TSTUSR2 block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED2_OLD|$OST0_QUOTA_USED2_NEW]"
1906 MDS_QUOTA_USED_NEW=`$LFS quota -o $MDS_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
1907 [ $MDS_QUOTA_USED_NEW -ne $MDS_QUOTA_USED_OLD ] && \
1908 quota_error a $TSTUSR "$TSTUSR inode quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$MDS_QUOTA_USED_OLD|$MDS_QUOTA_USED_NEW]"
1909 OST0_QUOTA_USED_NEW=`$LFS quota -o $OST0_UUID $1 $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
1910 [ $OST0_QUOTA_USED_NEW -ne $OST0_QUOTA_USED_OLD ] && \
1911 quota_error a $TSTUSR "$TSTUSR block quota usage transfer from $TSTUSR to $TSTUSR2 failed: [$OST0_QUOTA_USED_OLD|$OST0_QUOTA_USED_NEW]"
1914 wait_delete_completed
1915 resetquota $1 $TSTUSR
1916 resetquota $1 $TSTUSR2
1920 log "run for chown case"
1923 log "run for chgrp case"
1926 run_test_with_stat 25 "test whether quota usage is transfered when chown/chgrp (18081) ==========="
1932 lctl set_param debug="-quota"
1936 run_test_with_stat 99 "Quota off ==============================="
1939 log "cleanup: ======================================================"
1941 check_and_cleanup_lustre
1942 echo '=========================== finished ==============================='
1943 [ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
1944 echo "$0: completed"