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="$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}
50 [ "$SLOW" = "no" ] && EXCEPT_SLOW="9 10 11"
52 QUOTALOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
54 [ "$QUOTALOG" ] && rm -f $QUOTALOG || true
59 cleanup_and_setup_lustre
61 LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
62 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
64 SHOW_QUOTA_USER="$LFS quota -u $TSTUSR $DIR"
65 SHOW_QUOTA_GROUP="$LFS quota -g $TSTUSR $DIR"
66 SHOW_QUOTA_INFO="$LFS quota -t $DIR"
68 # control the time of tests
70 [ "$SLOW" = "no" ] && cycle=10
77 # set_blk_tunables(btune_sz)
79 local btune=$(($1 * BLK_SZ))
80 # set btune size on all obdfilters
81 do_facet ost1 "lctl set_param obdfilter.*.quota_btune_sz=$btune"
82 # set btune size on mds
83 do_facet mds "lctl set_param mds.${FSNAME}-MDT*.quota_btune_sz=$btune"
86 # set_blk_unitsz(bunit_sz)
88 local bunit=$(($1 * BLK_SZ))
89 # set bunit size on all obdfilters
90 do_facet ost1 "lctl set_param obdfilter.*.quota_bunit_sz=$bunit"
91 # set bunit size on mds
92 do_facet mds "lctl set_param mds.${FSNAME}-MDT*.quota_bunit_sz=$bunit"
95 # set_file_tunesz(itune_sz)
98 # set itune size on all obdfilters
99 do_facet ost1 "lctl set_param obdfilter.*.quota_itune_sz=$itune"
100 # set itune size on mds
101 do_facet mds "lctl set_param mds.${FSNAME}-MDT*.quota_itune_sz=$itune"
104 # set_file_unitsz(iunit_sz)
107 # set iunit size on all obdfilters
108 do_facet ost1 "lctl set_param obdfilter.*.quota_iunit_sz=$iunit"
109 # set iunit size on mds
110 do_facet mds "lctl set_param mds.${FSNAME}-MDT*.quota_iunit_sz=$iunit"
119 do_facet mds "lctl set_param fail_loc=$fail_loc" ;;
121 for num in `seq $OSTCOUNT`; do
122 do_facet ost$num "lctl set_param fail_loc=$fail_loc"
125 do_facet mds "lctl set_param fail_loc=$fail_loc" ;
126 for num in `seq $OSTCOUNT`; do
127 do_facet ost$num "lctl set_param fail_loc=$fail_loc"
129 * ) echo "usage: lustre_fail fail_node fail_loc" ;
134 RUNAS="runas -u $TSTID"
135 RUNAS2="runas -u $TSTID2"
136 FAIL_ON_ERROR=true check_runas_id $TSTID $RUNAS
137 FAIL_ON_ERROR=true check_runas_id $TSTID2 $RUNAS2
143 $LFS quotaoff -ug $DIR
144 $LFS quotacheck -ug $DIR
146 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
147 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR
148 lctl set_param debug="+quota"
149 do_facet mds "lctl set_param debug=+quota"
150 for num in `seq $OSTCOUNT`; do
151 do_facet ost$num "lctl set_param debug=+quota"
154 run_test 0 "Set quota ============================="
156 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
159 chmod 0777 $DIR/$tdir
160 TESTFILE="$DIR/$tdir/$tfile-0"
162 wait_delete_completed
165 log " User quota (limit: $LIMIT kbytes)"
166 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
170 $LFS setstripe $TESTFILE -c 1
171 chown $TSTUSR.$TSTUSR $TESTFILE
174 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(usr) write failure, but expect success"
176 log " Write out of block quota ..."
177 # this time maybe cache write, ignore it's failure
178 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
179 # flush cache, ensure noquota flag is setted on client
181 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(usr) write success, but expect EDQUOT"
185 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
186 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
187 echo $OST0_QUOTA_USED
188 [ $OST0_QUOTA_USED -ne 0 ] && \
189 ($SHOW_QUOTA_USER; error "quota deleted isn't released")
191 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR # clear user limit
194 log "--------------------------------------"
195 log " Group quota (limit: $LIMIT kbytes)"
196 $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR
199 TESTFILE="$DIR/$tdir/$tfile-1"
201 $LFS setstripe $TESTFILE -c 1
202 chown $TSTUSR.$TSTUSR $TESTFILE
205 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) || error "(grp) write failure, but expect success"
207 log " Write out of block quota ..."
208 # this time maybe cache write, ignore it's failure
209 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT/2)) seek=$(($LIMIT/2)) || true
211 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$LIMIT && error "(grp) write success, but expect EDQUOT"
216 OST0_UUID=`do_facet ost1 $LCTL dl | grep -m1 obdfilter | awk '{print $((NF-1))}'`
217 OST0_QUOTA_USED=`$LFS quota -o $OST0_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $1 }'`
218 echo $OST0_QUOTA_USED
219 [ $OST0_QUOTA_USED -ne 0 ] && \
220 ($SHOW_QUOTA_USER; error "quota deleted isn't released")
222 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR # clear group limit
225 # block hard limit (normal use and out of quota)
227 for i in `seq 1 $cycle`; do
228 # define blk_qunit is between 1M and 4M
229 blk_qunit=$(( $RANDOM % 3072 + 1024 ))
230 blk_qtune=$(( $RANDOM % $blk_qunit ))
231 # other osts and mds will occupy at 1M blk quota
232 b_limit=$(( ($RANDOM - 16384) / 8 + $OSTCOUNT * $blk_qunit * 4 ))
233 set_blk_tunesz $blk_qtune
234 set_blk_unitsz $blk_qunit
235 echo "cycle: $i(total $cycle) bunit:$blk_qunit, btune:$blk_qtune, blimit:$b_limit"
237 echo "=================================================="
238 set_blk_unitsz $((128 * 1024))
239 set_blk_tunesz $((128 * 1024 / 2))
242 run_test 1 "Block hard limit (normal use and out of quota) ==="
244 # test for specific quota limitation, qunit, qtune $1=block_quota_limit
247 chmod 0777 $DIR/$tdir
248 TESTFILE="$DIR/$tdir/$tfile-0"
250 wait_delete_completed
253 log " User quota (limit: $LIMIT files)"
254 $LFS setquota -u $TSTUSR 0 0 0 $LIMIT $DIR
258 log " Create $LIMIT files ..."
259 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
260 error "(usr) create failure, but expect success"
262 log " Create out of file quota ..."
263 $RUNAS touch ${TESTFILE}_xxx && \
264 error "(usr) touch success, but expect EDQUOT"
266 unlinkmany ${TESTFILE} $LIMIT
267 rm -f ${TESTFILE}_xxx
270 MDS_UUID=`do_facet mds $LCTL dl | grep -m1 mds | awk '{print $((NF-1))}'`
271 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
273 [ $MDS_QUOTA_USED -ne 0 ] && \
274 ($SHOW_QUOTA_USER; error "quota deleted isn't released")
276 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR # clear user limit
279 log "--------------------------------------"
280 log " Group quota (limit: $LIMIT FILE)"
281 $LFS setquota -g $TSTUSR 0 0 0 $LIMIT $DIR
284 TESTFILE=$DIR/$tdir/$tfile-1
286 log " Create $LIMIT files ..."
287 $RUNAS createmany -m ${TESTFILE} $LIMIT || \
288 error "(usr) create failure, but expect success"
290 log " Create out of file quota ..."
291 $RUNAS touch ${TESTFILE}_xxx && \
292 error "(usr) touch success, but expect EDQUOT"
294 unlinkmany ${TESTFILE} $LIMIT
295 rm -f ${TESTFILE}_xxx
298 MDS_UUID=`do_facet mds $LCTL dl | grep -m1 mds | awk '{print $((NF-1))}'`
299 MDS_QUOTA_USED=`$LFS quota -o $MDS_UUID -g $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $4 }'`
301 [ $MDS_QUOTA_USED -ne 0 ] && \
302 ($SHOW_QUOTA_USER; error "quota deleted isn't released")
304 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR # clear user limit
307 # file hard limit (normal use and out of quota)
309 for i in `seq 1 $cycle`; do
310 # define ino_qunit is between 10 and 100
311 ino_qunit=$(( $RANDOM % 90 + 10 ))
312 ino_qtune=$(( $RANDOM % $ino_qunit ))
313 # RANDOM's maxium is 32767
314 i_limit=$(( $RANDOM % 990 + 10 ))
315 set_file_tunesz $ino_qtune
316 set_file_unitsz $ino_qunit
317 echo "cycle: $i(total $cycle) iunit:$ino_qunit, itune:$ino_qtune, ilimit:$i_limit"
319 echo "=================================================="
324 run_test 2 "File hard limit (normal use and out of quota) ==="
328 TIMER=$(($2 * 3 / 2))
331 wait_delete_completed
333 echo " Write to exceed soft limit"
334 RUNDD="$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ"
335 $RUNDD count=$((BUNIT_SZ+1)) || \
336 error "write failure, but expect success"
337 OFFSET=$((OFFSET + BUNIT_SZ + 1))
344 echo " Write before timer goes off"
345 $RUNDD count=$BUNIT_SZ seek=$OFFSET || \
346 error "write failure, but expect success"
347 OFFSET=$((OFFSET + BUNIT_SZ))
351 echo " Sleep $TIMER seconds ..."
358 echo " Write after timer goes off"
359 # maybe cache write, ignore.
360 $RUNDD count=$BUNIT_SZ seek=$OFFSET || true
361 OFFSET=$((OFFSET + BUNIT_SZ))
363 $RUNDD count=$BUNIT_SZ seek=$OFFSET && \
364 error "write success, but expect EDQUOT"
370 echo " Unlink file to stop timer"
380 $RUNDD count=$BUNIT_SZ || error "write failure, but expect success"
388 # block soft limit (start timer, timer goes off, stop timer)
390 chmod 0777 $DIR/$tdir
392 # 1 bunit on mds and 1 bunit on every ost
393 LIMIT=$(( $BUNIT_SZ * ($OSTCOUNT + 1) ))
396 echo " User quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
397 TESTFILE=$DIR/$tdir/$tfile-0
399 $LFS setstripe $TESTFILE -c 1
400 chown $TSTUSR.$TSTUSR $TESTFILE
402 $LFS setquota -t -u $GRACE $MAX_IQ_TIME $DIR
403 $LFS setquota -u $TSTUSR $LIMIT 0 0 0 $DIR
405 test_block_soft $TESTFILE $GRACE
406 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
408 echo " Group quota (soft limit: $LIMIT kbytes grace: $GRACE seconds)"
409 TESTFILE=$DIR/$tdir/$tfile-1
411 $LFS setstripe $TESTFILE -c 1
412 chown $TSTUSR.$TSTUSR $TESTFILE
414 $LFS setquota -t -g $GRACE $MAX_IQ_TIME $DIR
415 $LFS setquota -g $TSTUSR $LIMIT 0 0 0 $DIR
417 test_block_soft $TESTFILE $GRACE
418 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR
420 run_test 3 "Block soft limit (start timer, timer goes off, stop timer) ==="
425 TIMER=$(($3 * 3 / 2))
427 wait_delete_completed
429 echo " Create files to exceed soft limit"
430 $RUNAS createmany -m ${TESTFILE}_ $((LIMIT + 1)) || \
431 error "create failure, but expect success"
435 echo " Create file before timer goes off"
436 $RUNAS touch ${TESTFILE}_before || \
437 error "failed create before timer expired, but expect success"
441 echo " Sleep $TIMER seconds ..."
448 echo " Create file after timer goes off"
449 $RUNAS touch ${TESTFILE}_after ${TESTFILE}_after1 && \
450 error "create after timer expired, but expect EDQUOT"
457 echo " Unlink files to stop timer"
458 find `dirname $TESTFILE` -name "`basename ${TESTFILE}`*" | xargs rm -f
462 $RUNAS touch ${TESTFILE}_xxx || \
463 error "touch after timer stop failure, but expect success"
468 rm -f ${TESTFILE}_xxx
472 # file soft limit (start timer, timer goes off, stop timer)
474 chmod 0777 $DIR/$tdir
475 LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds
476 TESTFILE=$DIR/$tdir/$tfile-0
480 echo " User quota (soft limit: $LIMIT files grace: $GRACE seconds)"
481 $LFS setquota -t -u $MAX_DQ_TIME $GRACE $DIR
482 $LFS setquota -u $TSTUSR 0 0 $LIMIT 0 $DIR
485 test_file_soft $TESTFILE $LIMIT $GRACE
486 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
488 echo " Group quota (soft limit: $LIMIT files grace: $GRACE seconds)"
489 $LFS setquota -t -g $MAX_DQ_TIME $GRACE $DIR
490 $LFS setquota -g $TSTUSR 0 0 $LIMIT 0 $DIR
492 TESTFILE=$DIR/$tdir/$tfile-1
494 test_file_soft $TESTFILE $LIMIT $GRACE
495 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR
498 $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR
499 $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR
501 run_test 4 "File soft limit (start timer, timer goes off, stop timer) ==="
509 GR_STR6="1111111111111111"
511 wait_delete_completed
513 # test of valid grace strings handling
514 echo " Valid grace strings test"
515 $LFS setquota -t -u $GR_STR1 $GR_STR2 $DIR
516 $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1"
517 $LFS setquota -t -g $GR_STR3 $GR_STR4 $DIR
518 $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4"
520 # test of invalid grace strings handling
521 echo " Invalid grace strings test"
522 ! $LFS setquota -t -u $GR_STR4 $GR_STR5 $DIR
523 ! $LFS setquota -t -g $GR_STR4 $GR_STR6 $DIR
526 $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR
527 $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR
529 run_test 4a "Grace time strings handling ==="
531 # chown & chgrp (chown & chgrp successfully even out of block/file quota)
533 BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server
534 ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds
536 wait_delete_completed
538 echo " Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR"
539 $LFS setquota -u $TSTUSR 0 $BLIMIT 0 $ILIMIT $DIR
540 $LFS setquota -g $TSTUSR 0 $BLIMIT 0 $ILIMIT $DIR
544 echo " Create more than $ILIMIT files and more than $BLIMIT kbytes ..."
545 createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \
546 error "touch failure, expect success"
547 dd if=/dev/zero of=$DIR/$tdir/$tfile-0_1 bs=$BLK_SZ count=$((BLIMIT+1)) || error "write failure, expect success"
549 echo " Chown files to $TSTUSR.$TSTUSR ..."
550 for i in `seq 0 $ILIMIT`; do
551 chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \
552 error "chown failure, but expect success"
556 unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1))
559 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
560 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR
562 run_test 5 "Chown & chgrp successfully even out of block/file quota ==="
564 # block quota acquire & release
566 if [ $OSTCOUNT -lt 2 ]; then
567 skip "$OSTCOUNT < 2, too few osts"
571 wait_delete_completed
573 chmod 0777 $DIR/$tdir
575 LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server
576 FILEA="$DIR/$tdir/$tfile-0_a"
577 FILEB="$DIR/$tdir/$tfile-0_b"
579 echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR"
580 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
581 $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR
585 echo " Create filea on OST0 and fileb on OST1"
586 $LFS setstripe $FILEA -i 0 -c 1
587 $LFS setstripe $FILEB -i 1 -c 1
588 chown $TSTUSR.$TSTUSR $FILEA
589 chown $TSTUSR.$TSTUSR $FILEB
591 echo " Exceed quota limit ..."
592 RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ"
593 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
594 error "write fileb failure, but expect success"
599 $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \
600 error "write fileb success, but expect EDQUOT"
602 echo " Write to OST0 return EDQUOT"
603 # this write maybe cache write, ignore it's failure
604 RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ"
605 $RUNDD count=$(($BUNIT_SZ * 2)) || true
609 $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \
610 error "write filea success, but expect EDQUOT"
612 echo " Remove fileb to let OST1 release quota"
614 sync; sleep 10; sync; # need to allow journal commit for small fs
616 echo " Write to OST0"
617 $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \
618 error "write filea failure, expect success"
625 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
626 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR
629 run_test 6 "Block quota acquire & release ========="
631 # quota recovery (block quota only by now)
634 chmod 0777 $DIR/$tdir
635 remote_mds && skip "remote mds" && return 0
637 wait_delete_completed
639 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) ))
640 TESTFILE="$DIR/$tdir/$tfile-0"
642 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
644 $LFS setstripe $TESTFILE -c 1
645 chown $TSTUSR.$TSTUSR $TESTFILE
647 echo " Write to OST0..."
648 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \
649 error "write failure, but expect success"
651 #define OBD_FAIL_OBD_DQACQ 0x604
652 lustre_fail mds 0x604
653 echo " Remove files on OST0"
657 echo " Trigger recovery..."
658 OSC0_UUID="`$LCTL dl | awk '$3 ~ /osc/ { print $1 }'`"
659 for i in $OSC0_UUID; do
660 $LCTL --device $i activate || error "activate osc failed!"
663 # sleep a while to wait for recovery done
667 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
668 TOTAL_LIMIT="`$LFS quota -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
669 [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!"
670 echo " total limits = $TOTAL_LIMIT"
672 OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
673 [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'`
674 OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`"
675 [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!"
676 echo " limits on $OST0_UUID = $OST0_LIMIT"
679 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR
681 run_test 7 "Quota recovery (only block limit) ======"
683 # run dbench with quota enabled
685 BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
687 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
689 [ ! -d $DBENCH_LIB ] && skip "dbench not installed" && return 0
691 wait_delete_completed
693 echo " Set enough high limit for user: $TSTUSR"
694 $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
695 echo " Set enough high limit for group: $TSTUSR"
696 $LFS setquota -g $USER 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
698 TGT=$DIR/$tdir/client.txt
699 SRC=${SRC:-$DBENCH_LIB/client.txt}
700 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
701 SRC=$DBENCH_LIB/client_plain.txt
702 [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT
704 chmod 0777 $DIR/$tdir
708 [ "$SLOW" = "no" ] && duration=" -t 120"
709 $RUNAS dbench -c client.txt 3 $duration
711 [ $RC -ne 0 ] && killall -9 dbench
719 run_test 8 "Run dbench with quota enabled ==========="
721 # run for fixing bug10707, it needs a big room. test for 64bit
723 GB=$((KB * 1024 * 1024))
724 # Use this as dd bs to decrease time
725 # inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS);
726 blksize=$((1 << 21)) # 2Mb
727 size_file=$((GB * 9 / 2))
728 # this check is just for test9 and test10
729 OST0_MIN=4900000 #4.67G
730 check_whether_skip () {
731 OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'`
732 log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN"
733 if [ $OST0_SIZE -lt $OST0_MIN ]; then
734 echo "WARN: OST0 has less than $OST0_MIN free, skip this test."
742 check_whether_skip && return 0
744 wait_delete_completed
749 chmod 0777 $DIR/$tdir
750 TESTFILE="$DIR/$tdir/$tfile-0"
752 BLK_LIMIT=$((100 * KB * KB)) # 100G
754 echo " Set block limit $BLK_LIMIT kbytes to $TSTUSR.$TSTUSR"
756 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
757 $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
758 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
759 $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
762 $LFS setstripe $TESTFILE -c 1
764 chown $TSTUSR.$TSTUSR $TESTFILE
769 log " Write the big file of 4.5G ..."
770 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
771 error "(usr) write 4.5G file failure, but expect success"
776 log " delete the big file of 4.5G..."
777 $RUNAS rm -f $TESTFILE
785 set_blk_unitsz $((128 * 1024))
786 set_blk_tunesz $((128 * 1024 / 2))
790 run_test 9 "run for fixing bug10707(64bit) ==========="
792 # run for fixing bug10707, it need a big room. test for 32bit
794 chmod 0777 $DIR/$tdir
795 check_whether_skip && return 0
797 wait_delete_completed
802 # make qd_count 32 bit
803 lustre_fail mds_ost 0xA00
805 TESTFILE="$DIR/$tdir/$tfile-0"
807 BLK_LIMIT=$((100 * KB * KB)) # 100G
810 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR"
811 $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
812 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR"
813 $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR
816 $LFS setstripe $TESTFILE -c 1
818 chown $TSTUSR.$TSTUSR $TESTFILE
823 log " Write the big file of 4.5 G ..."
824 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \
825 error "(usr) write 4.5 G file failure, but expect success"
830 log " delete the big file of 4.5 G..."
831 $RUNAS rm -f $TESTFILE
839 # make qd_count 64 bit
840 lustre_fail mds_ost 0
842 set_blk_unitsz $((128 * 1024))
843 set_blk_tunesz $((128 * 1024 / 2))
847 run_test 10 "run for fixing bug10707(32bit) ==========="
850 wait_delete_completed
853 block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1`
855 orig_dbr=`sysctl -n vm.dirty_background_ratio`
856 orig_dec=`sysctl -n vm.dirty_expire_centisecs`
857 orig_dr=`sysctl -n vm.dirty_ratio`
858 orig_dwc=`sysctl -n vm.dirty_writeback_centisecs`
859 sysctl -w vm.dirty_background_ratio=1
860 sysctl -w vm.dirty_expire_centisecs=30
861 sysctl -w vm.dirty_ratio=1
862 sysctl -w vm.dirty_writeback_centisecs=50
869 [ "$SLOW" = no ] && REPS=1
872 while [ $i -le $REPS ]; do
873 echo "test: cycle($i of $REPS) start at $(date)"
874 mkdir -p $DIR/$tdir && chmod 777 $DIR/$tdir
875 echo -n " create a file for uid "
876 for j in `seq 1 30`; do
878 # 30MB per dd for a total of 900MB (if space even permits)
879 runas -u $j dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$blksize count=15 > /dev/null 2>&1 &
882 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
884 while [ $PROCS -gt 0 ]; do
886 SECS=$((SECS + sleep))
887 PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l)
888 USED=$(du -s $DIR/$tdir | awk '{print $1}')
889 PCT=$(($USED * 100 / $block_limit))
890 echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} "
891 if [ $USED -le $LAST_USED ]; then
892 kill -9 $(ps -ef | grep "dd if /dev/zero of $DIR/$tdir" | grep -v grep | awk '{ print $2 }')
899 echo " removing the test files..."
900 rm -f $DIR/$tdir/$tfile
901 echo "cycle $i done at $(date)"
904 echo "Test took $SECS sec"
907 sysctl -w vm.dirty_background_ratio=$orig_dbr
908 sysctl -w vm.dirty_expire_centisecs=$orig_dec
909 sysctl -w vm.dirty_ratio=$orig_dr
910 sysctl -w vm.dirty_writeback_centisecs=$orig_dwc
911 if [ $RV -ne 0 ]; then
912 error "Nothing was written for $SECS sec ... aborting"
916 run_test 11 "run for fixing bug10912 ==========="
919 # test a deadlock between quota and journal b=11693
921 chmod 0777 $DIR/$tdir
923 [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
924 { skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
926 if [ $OSTCOUNT -lt 2 ]; then
927 skip "$OSTCOUNT < 2, too few osts"
931 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
932 TESTFILE="$DIR/$tdir/$tfile-0"
933 TESTFILE2="$DIR2/$tdir/$tfile-1"
935 wait_delete_completed
937 echo " User quota (limit: $LIMIT kbytes)"
938 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
940 $LFS setstripe $TESTFILE -i 0 -c 1
941 chown $TSTUSR.$TSTUSR $TESTFILE
942 $LFS setstripe $TESTFILE2 -i 1 -c 1
943 chown $TSTUSR2.$TSTUSR2 $TESTFILE2
945 #define OBD_FAIL_OST_HOLD_WRITE_RPC 0x21f
946 lustre_fail ost 0x0000021f
948 echo " step1: write out of block quota ..."
949 $RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 &
951 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT*2)) &
954 echo " step2: testing ......"
957 if [ -z `ps -ef | awk '$2 == '${DDPID1}' { print $8 }'` ]; then break; fi
959 if [ $count -gt 64 ]; then
961 error "dd should be finished!"
965 echo "(dd_pid=$DDPID1, time=$count)successful"
967 #Recover fail_loc and dd will finish soon
970 echo " step3: testing ......"
973 if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi
975 if [ $count -gt 150 ]; then
976 error "dd should be finished!"
980 echo "(dd_pid=$DDPID, time=$count)successful"
982 rm -f $TESTFILE $TESTFILE2
985 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR # clear user limit
987 run_test 12 "test a deadlock between quota and journal ==="
989 # test multiple clients write block quota b=11693
991 wait_delete_completed
993 # one OST * 10 + (mds + other OSTs)
994 LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT)))
995 TESTFILE="$DIR/$tdir/$tfile"
997 echo " User quota (limit: $LIMIT kbytes)"
998 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
1001 $LFS setstripe $TESTFILE -i 0 -c 1
1002 chown $TSTUSR.$TSTUSR $TESTFILE
1003 $LFS setstripe $TESTFILE.2 -i 0 -c 1
1004 chown $TSTUSR.$TSTUSR $TESTFILE.2
1006 echo " step1: write out of block quota ..."
1007 # one bunit will give mds
1008 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1010 $RUNAS dd if=/dev/zero of=$TESTFILE.2 bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &
1013 echo " step2: testing ......"
1016 if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi
1018 if [ $count -gt 64 ]; then
1019 error "dd should be finished!"
1023 echo "(dd_pid=$DDPID, time=$count)successful"
1027 if [ -z `ps -ef | awk '$2 == '${DDPID1}' { print $8 }'` ]; then break; fi
1029 if [ $count -gt 64 ]; then
1030 error "dd should be finished!"
1034 echo "(dd_pid=$DDPID1, time=$count)successful"
1036 sync; sleep 5; sync;
1038 echo " step3: checking ......"
1039 fz=`stat -c %s $TESTFILE`
1040 fz2=`stat -c %s $TESTFILE.2`
1042 [ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \
1043 error "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"
1045 rm -f $TESTFILE $TESTFILE.2
1046 sync; sleep 3; sync;
1048 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR # clear user limit
1050 run_test 13 "test multiple clients write block quota ==="
1052 check_if_quota_zero(){
1053 line=`$LFS quota -$1 $2 $DIR | wc -l`
1054 for i in `seq 3 $line`; do
1055 if [ $i -eq 3 ]; then
1061 tmp=`$LFS quota -$1 $2 $DIR | sed -n ${i}p |
1062 awk '{print $'"$j"'}'`
1063 [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -$1 $2 $DIR && \
1064 error "quota on $2 isn't clean"
1067 echo "pass check_if_quota_zero"
1073 cd $T_PWD; sh llmountcleanup.sh || error "llmountcleanup failed"
1075 run_test 0 "reboot lustre"
1079 test_14(){ # b=12223 -- setting quota on root
1080 TESTFILE="$DIR/$tdir/$tfile"
1082 # out of root's file and block quota
1083 $LFS setquota -u root 10 10 10 10 $DIR
1084 createmany -m ${TESTFILE} 20 || \
1085 error "unexpected: user(root) create files failly!"
1086 dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
1087 error "unexpected: user(root) write files failly!"
1089 $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
1090 error "unexpected: user(quota_usr) write a file successfully!"
1094 for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done
1095 for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done
1098 dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"
1099 $LFS setquota -u root 0 0 0 0 $DIR
1100 #check_if_quota_zero u root
1103 unlinkmany ${TESTFILE} 15
1105 sync; sleep 3; sync;
1107 run_test 14 "test setting quota on root ==="
1109 quota_set_version() {
1111 do_facet mds "lctl set_param mds.${FSNAME}-MDT*.quota_type=$qver"
1115 # 1. check that required users exist
1116 # 2. ensure that switch to new mode will start conversion
1117 # 3. start quota in old mode and put some entries
1118 # 4. restart quota in new mode forcing conversion and check the entries
1120 wait_delete_completed
1123 for i in `seq 1 30`; do
1124 check_runas_id_ret quota15_$i "runas -u quota15_$i"
1125 if [ "$?" != "0" ]; then
1126 MISSING_USERS="$MISSING_USERS quota15_$i"
1130 if [ -n "$MISSING_USERS" ]; then
1131 skip "following users are missing: $MISSING_USERS"
1135 $LFS quotaoff -ug $DIR
1137 $LFS quotacheck -ug $DIR
1139 for i in `seq 1 30`; do
1140 $LFS setquota -u quota15_$i $i $i $i $i $DIR || error "lfs setquota failed"
1143 $LFS quotaoff -ug $DIR
1145 $LFS quotainv -ug $DIR
1146 $LFS quotacheck -ug $DIR
1148 for i in `seq 1 30`; do
1149 # the format is "mntpnt curspace[*] bsoftlimit bhardlimit [time] curinodes[*] isoftlimit ihardlimit"
1150 ($LFS quota -u quota15_$i $DIR | grep -E '^ *'$DIR' *[0-9]+\** *'$i' *'$i' *[0-9]+\** *'$i' *'$i) \
1151 || error "lfs quota output is unexpected"
1152 $LFS setquota -u quota15_$i 0 0 0 0 $DIR || error "ifs setquota clear failed"
1155 run_test 14a "setting 30 quota entries in quota v1 file before conversion ==="
1158 LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
1159 PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
1161 wait_delete_completed
1164 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR || error "failed setting user quota limit $LIMIT"
1165 TOTAL_LIMIT="`$LFS quota -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1166 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1167 echo " (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1168 $LFS setquota -u $TSTUSR 0 0 0 0 $DIR || error "failed removing user quota limit"
1171 $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR || error "failed setting group quota limit $LIMIT"
1172 TOTAL_LIMIT="`$LFS quota -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"
1173 [ $TOTAL_LIMIT -eq $LIMIT ] || error " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"
1174 echo " (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"
1175 $LFS setquota -g $TSTUSR 0 0 0 0 $DIR || error "failed removing group quota limit"
1176 $LFS quotaoff -ug $DIR
1178 $LFS quotacheck -ug $DIR || error "quotacheck failed"
1180 echo "Testing that >4GB quota limits fail on volume with quota v1"
1181 ! $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
1183 run_test 15 "set block quota more than 4T ==="
1185 # $1=u/g $2=with qunit adjust or not
1187 LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4))
1188 TESTFILE="$DIR/$tdir/$tfile"
1190 wait_delete_completed
1192 echo " User quota (limit: $LIMIT kbytes)"
1193 if [ $1 == "u" ]; then
1194 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR
1197 $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR
1201 $LFS setstripe $TESTFILE -c 1
1202 chown $TSTUSR.$TSTUSR $TESTFILE
1205 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \
1206 error "(usr) write failure, but expect success"
1208 echo " Write out of block quota ..."
1209 # this time maybe cache write, ignore it's failure
1210 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true
1211 # flush cache, ensure noquota flag is setted on client
1212 cancel_lru_locks osc
1213 if [ $2 -eq 1 ]; then
1214 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \
1215 error "(write failure, but expect success"
1217 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \
1218 error "(write success, but expect EDQUOT"
1222 sync; sleep 3; sync;
1223 $LFS setquota -$1 $TSTUSR 0 0 0 0 $DIR
1226 # test without adjusting qunit
1228 set_blk_tunesz $((BUNIT_SZ * 2))
1229 set_blk_unitsz $((BUNIT_SZ * 4))
1232 # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS 0xA01
1233 echo " grp/usr: $i, adjust qunit: $j"
1234 echo "-------------------------------"
1235 [ $j -eq 1 ] && lustre_fail mds_ost 0
1236 [ $j -eq 0 ] && lustre_fail mds_ost 0xA01
1240 set_blk_unitsz $((128 * 1024))
1241 set_blk_tunesz $((128 * 1024 / 2))
1243 run_test 16 "test without adjusting qunit"
1245 # run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre.
1250 wait_delete_completed
1252 #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE
1253 lustre_fail ost 0x80000A02
1255 TESTFILE="$DIR/$tdir/$tfile-a"
1256 TESTFILE2="$DIR/$tdir/$tfile-b"
1258 BLK_LIMIT=$((100 * 1024)) # 100M
1260 log " Set enough high limit(block:$BLK_LIMIT) for user: $TSTUSR"
1261 $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 0 $DIR
1262 log " Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"
1263 $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 0 $DIR
1266 chown $TSTUSR.$TSTUSR $TESTFILE
1268 chown $TSTUSR.$TSTUSR $TESTFILE2
1273 log " Write the test file1 ..."
1274 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(( 10 * 1024 )) \
1275 || echo "write 10M file failure"
1280 log " write the test file2 ..."
1281 $RUNAS dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=$(( 10 * 1024 )) \
1282 || error "write 10M file failure"
1287 rm -f $TESTFILE $TESTFILE2
1289 sync; sleep 3; sync;
1291 # make qd_count 64 bit
1294 set_blk_unitsz $((128 * 1024))
1295 set_blk_tunesz $((128 * 1024 / 2))
1299 run_test 17 "run for fixing bug14526 ==========="
1301 # test when mds takes a long time to handle a quota req so that
1302 # the ost has dropped it, the ost still could work well b=14840
1304 LIMIT=$((100 * 1024 * 1024)) # 100G
1305 TESTFILE="$DIR/$tdir/$tfile"
1307 wait_delete_completed
1312 log " User quota (limit: $LIMIT kbytes)"
1313 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT
1316 $LFS setstripe $TESTFILE -i 0 -c 1
1317 chown $TSTUSR.$TSTUSR $TESTFILE
1319 #define OBD_FAIL_MDS_BLOCK_QUOTA_REQ 0x13c
1320 lustre_fail mds 0x13c
1322 log " step1: write 100M block ..."
1323 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1329 echo " step2: testing ......"
1331 timeout=$(lctl get_param -n timeout)
1333 if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi
1335 if [ $count -gt $((2 * $timeout)) ]; then
1336 error "count=$count dd should be finished!"
1340 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1341 if [ $count -lt $(($timeout - 10)) ]; then
1342 error " should take longer!"
1348 sync; sleep 3; sync;
1350 $LFS setquota -u $TSTUSR 0 0 0 0 $MOUNT # clear user limit
1352 set_blk_unitsz $((128 * 1024))
1353 set_blk_tunesz $((128 * 1024 / 2))
1355 run_test 18 "run for fixing bug14840 ==========="
1357 # test when mds drops a quota req, the ost still could work well b=14840
1359 LIMIT=$((100 * 1024 * 1024)) # 100G
1360 TESTFILE="$DIR/$tdir/$tfile-a"
1362 wait_delete_completed
1367 log " User quota (limit: $LIMIT kbytes)"
1368 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT
1371 $LFS setstripe $TESTFILE -i 0 -c 1
1372 chown $TSTUSR.$TSTUSR $TESTFILE
1374 #define OBD_FAIL_MDS_DROP_QUOTA_REQ | OBD_FAIL_ONCE 0x8000013d
1375 lustre_fail mds 0x8000013d
1377 log " step1: write 100M block ..."
1378 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &
1381 echo " step2: testing ......"
1383 timeout=$(lctl get_param -n timeout)
1385 if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi
1387 if [ $count -gt $((3 * $timeout)) ]; then
1389 error "count=$count dd should be finished!"
1393 log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"
1394 if [ $count -lt $(($timeout - 10)) ]; then
1396 error " should take longer!"
1404 sync; sleep 3; sync;
1406 $LFS setquota -u $TSTUSR 0 0 0 0 $MOUNT # clear user limit
1408 set_blk_unitsz $((128 * 1024))
1409 set_blk_tunesz $((128 * 1024 / 2))
1411 run_test 18a "run for fixing bug14840 ==========="
1414 # 1 Mb bunit per each MDS/OSS
1415 LIMIT=$((($OSTCOUNT + 1) * 1024))
1416 TESTFILE="$DIR/$tdir/$tfile"
1418 wait_delete_completed
1420 # set 1 Mb quota unit size
1424 # bind file to a single OST
1425 $LFS setstripe -c 1 $TESTFILE
1426 chown $TSTUSR.$TSTUSR $TESTFILE
1428 echo " User quota (limit: $LIMIT kbytes)"
1429 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT
1431 echo " Updating quota limits"
1432 $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT
1435 $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=1028 || true
1436 # for now page cache of TESTFILE may still be dirty,
1437 # let's push it to the corresponding OST, this will also
1438 # cache NOQUOTA on the client from OST's reply
1439 cancel_lru_locks osc
1440 $RUNAS dd if=/dev/zero of=$TESTFILE seek=1028 bs=$BLK_SZ count=1 && \
1441 error "(usr) write success, should be EDQUOT"
1446 $LFS setquota -u $TSTUSR 0 0 0 0 $MOUNT
1448 set_blk_unitsz $((128 * 1024))
1449 set_blk_tunesz $((128 * 1024 / 2))
1452 run_test 19 "test if administrative limits updates do not zero operational limits (14790) ==="
1458 lctl set_param debug="-quota"
1462 run_test 99 "Quota off ==============================="
1465 log "cleanup: ======================================================"
1467 check_and_cleanup_lustre
1468 echo '=========================== finished ==============================='
1469 [ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
1470 echo "$0: completed"