📄 sanity-quota.sh
字号:
test_4() { chmod 0777 $DIR/$tdir LIMIT=$(($IUNIT_SZ * 10)) # 10 iunits on mds TESTFILE=$DIR/$tdir/$tfile-0 GRACE=5 echo " User quota (soft limit: $LIMIT files grace: $GRACE seconds)" $LFS setquota -t -u $MAX_DQ_TIME $GRACE $DIR $LFS setquota -u $TSTUSR 0 0 $LIMIT 0 $DIR $SHOW_QUOTA_USER test_file_soft $TESTFILE $LIMIT $GRACE $LFS setquota -u $TSTUSR 0 0 0 0 $DIR echo " Group quota (soft limit: $LIMIT files grace: $GRACE seconds)" $LFS setquota -t -g $MAX_DQ_TIME $GRACE $DIR $LFS setquota -g $TSTUSR 0 0 $LIMIT 0 $DIR $SHOW_QUOTA_GROUP TESTFILE=$DIR/$tdir/$tfile-1 test_file_soft $TESTFILE $LIMIT $GRACE $LFS setquota -g $TSTUSR 0 0 0 0 $DIR # cleanup $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR}run_test 4 "File soft limit (start timer, timer goes off, stop timer) ==="test_4a() { GR_STR1="1w3d" GR_STR2="1000s" GR_STR3="5s" GR_STR4="1w2d3h4m5s" GR_STR5="5c" GR_STR6="1111111111111111" wait_delete_completed # test of valid grace strings handling echo " Valid grace strings test" $LFS setquota -t -u $GR_STR1 $GR_STR2 $DIR $LFS quota -u -t $DIR | grep "Block grace time: $GR_STR1" $LFS setquota -t -g $GR_STR3 $GR_STR4 $DIR $LFS quota -g -t $DIR | grep "Inode grace time: $GR_STR4" # test of invalid grace strings handling echo " Invalid grace strings test" ! $LFS setquota -t -u $GR_STR4 $GR_STR5 $DIR ! $LFS setquota -t -g $GR_STR4 $GR_STR6 $DIR # cleanup $LFS setquota -t -u $MAX_DQ_TIME $MAX_IQ_TIME $DIR $LFS setquota -t -g $MAX_DQ_TIME $MAX_IQ_TIME $DIR}run_test 4a "Grace time strings handling ==="# chown & chgrp (chown & chgrp successfully even out of block/file quota)test_5() { BLIMIT=$(( $BUNIT_SZ * $((OSTCOUNT + 1)) * 10)) # 10 bunits on each server ILIMIT=$(( $IUNIT_SZ * 10 )) # 10 iunits on mds wait_delete_completed echo " Set quota limit (0 $BLIMIT 0 $ILIMIT) for $TSTUSR.$TSTUSR" $LFS setquota -u $TSTUSR 0 $BLIMIT 0 $ILIMIT $DIR $LFS setquota -g $TSTUSR 0 $BLIMIT 0 $ILIMIT $DIR $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP echo " Create more than $ILIMIT files and more than $BLIMIT kbytes ..." createmany -m $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) || \ error "touch failure, expect success" dd if=/dev/zero of=$DIR/$tdir/$tfile-0_1 bs=$BLK_SZ count=$((BLIMIT+1)) || error "write failure, expect success" echo " Chown files to $TSTUSR.$TSTUSR ..." for i in `seq 0 $ILIMIT`; do chown $TSTUSR.$TSTUSR $DIR/$tdir/$tfile-0_$i || \ error "chown failure, but expect success" done # cleanup unlinkmany $DIR/$tdir/$tfile-0_ $((ILIMIT + 1)) sync; sleep 3; sync; $LFS setquota -u $TSTUSR 0 0 0 0 $DIR $LFS setquota -g $TSTUSR 0 0 0 0 $DIR}run_test 5 "Chown & chgrp successfully even out of block/file quota ==="# block quota acquire & releasetest_6() { if [ $OSTCOUNT -lt 2 ]; then skip "$OSTCOUNT < 2, too few osts" return 0; fi wait_delete_completed chmod 0777 $DIR/$tdir LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server FILEA="$DIR/$tdir/$tfile-0_a" FILEB="$DIR/$tdir/$tfile-0_b" echo " Set block limit $LIMIT kbytes to $TSTUSR.$TSTUSR" $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP echo " Create filea on OST0 and fileb on OST1" $LFS setstripe $FILEA -i 0 -c 1 $LFS setstripe $FILEB -i 1 -c 1 chown $TSTUSR.$TSTUSR $FILEA chown $TSTUSR.$TSTUSR $FILEB echo " Exceed quota limit ..." RUNDD="$RUNAS dd if=/dev/zero of=$FILEB bs=$BLK_SZ" $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \ error "write fileb failure, but expect success" cancel_lru_locks osc $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP $RUNDD seek=$LIMIT count=$((BUNIT_SZ * OSTCOUNT)) && \ error "write fileb success, but expect EDQUOT" cancel_lru_locks osc echo " Write to OST0 return EDQUOT" # this write maybe cache write, ignore it's failure RUNDD="$RUNAS dd if=/dev/zero of=$FILEA bs=$BLK_SZ" $RUNDD count=$(($BUNIT_SZ * 2)) || true cancel_lru_locks osc $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP $RUNDD count=$((BUNIT_SZ * 2)) seek=$((BUNIT_SZ *2)) && \ error "write filea success, but expect EDQUOT" echo " Remove fileb to let OST1 release quota" rm -f $FILEB sync; sleep 10; sync; # need to allow journal commit for small fs echo " Write to OST0" $RUNDD count=$((LIMIT - BUNIT_SZ * OSTCOUNT)) || \ error "write filea failure, expect success" echo " Done" # cleanup rm -f $FILEA sync; sleep 3; sync; $LFS setquota -u $TSTUSR 0 0 0 0 $DIR $LFS setquota -g $TSTUSR 0 0 0 0 $DIR return 0}run_test 6 "Block quota acquire & release ========="# quota recovery (block quota only by now)test_7(){ chmod 0777 $DIR/$tdir remote_mds && skip "remote mds" && return 0 wait_delete_completed LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) )) TESTFILE="$DIR/$tdir/$tfile-0" $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR $LFS setstripe $TESTFILE -c 1 chown $TSTUSR.$TSTUSR $TESTFILE echo " Write to OST0..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ || \ error "write failure, but expect success" #define OBD_FAIL_OBD_DQACQ 0x604 lustre_fail mds 0x604 echo " Remove files on OST0" rm -f $TESTFILE lustre_fail mds 0 echo " Trigger recovery..." OSC0_UUID="`$LCTL dl | awk '$3 ~ /osc/ { print $1 }'`" for i in $OSC0_UUID; do $LCTL --device $i activate || error "activate osc failed!" done # sleep a while to wait for recovery done sleep 20 # check limits PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`" TOTAL_LIMIT="`$LFS quota -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`" [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!" echo " total limits = $TOTAL_LIMIT" OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'` [ -z "$OST0_UUID" ] && OST0_UUID=`do_facet ost1 "$LCTL dl | grep -m1 obdfilter" | awk '{print $((NF-1))}'` OST0_LIMIT="`$LFS quota -o $OST0_UUID -u $TSTUSR $DIR | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`" [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!" echo " limits on $OST0_UUID = $OST0_LIMIT" # cleanup $LFS setquota -u $TSTUSR 0 0 0 0 $DIR}run_test 7 "Quota recovery (only block limit) ======"# run dbench with quota enabledtest_8() { BLK_LIMIT=$((100 * 1024 * 1024)) # 100G FILE_LIMIT=1000000 DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench} [ ! -d $DBENCH_LIB ] && skip "dbench not installed" && return 0 wait_delete_completed echo " Set enough high limit for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR echo " Set enough high limit for group: $TSTUSR" $LFS setquota -g $USER 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR TGT=$DIR/$tdir/client.txt SRC=${SRC:-$DBENCH_LIB/client.txt} [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT SRC=$DBENCH_LIB/client_plain.txt [ ! -e $TGT -a -e $SRC ] && echo "copying $SRC to $TGT" && cp $SRC $TGT chmod 0777 $DIR/$tdir SAVE_PWD=$PWD cd $DIR/$tdir local duration="" [ "$SLOW" = "no" ] && duration=" -t 120" $RUNAS dbench -c client.txt 3 $duration RC=$? [ $RC -ne 0 ] && killall -9 dbench rm -f client.txt sync; sleep 3; sync; cd $SAVE_PWD return $RC}run_test 8 "Run dbench with quota enabled ==========="# run for fixing bug10707, it needs a big room. test for 64bitKB=1024GB=$((KB * 1024 * 1024))# Use this as dd bs to decrease time# inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS);blksize=$((1 << 21)) # 2Mbsize_file=$((GB * 9 / 2))# this check is just for test9 and test10OST0_MIN=4900000 #4.67Gcheck_whether_skip () { OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'` log "OST0_SIZE: $OST0_SIZE required: $OST0_MIN" if [ $OST0_SIZE -lt $OST0_MIN ]; then echo "WARN: OST0 has less than $OST0_MIN free, skip this test." return 0 else return 1 fi}test_9() { check_whether_skip && return 0 wait_delete_completed set_blk_tunesz 512 set_blk_unitsz 1024 chmod 0777 $DIR/$tdir TESTFILE="$DIR/$tdir/$tfile-0" BLK_LIMIT=$((100 * KB * KB)) # 100G FILE_LIMIT=1000000 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR" $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR echo " Set stripe" $LFS setstripe $TESTFILE -c 1 touch $TESTFILE chown $TSTUSR.$TSTUSR $TESTFILE $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP log " Write the big file of 4.5G ..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \ error "(usr) write 4.5G file failure, but expect success" $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP log " delete the big file of 4.5G..." $RUNAS rm -f $TESTFILE sync; sleep 3; sync; $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP RC=$? set_blk_unitsz $((128 * 1024)) set_blk_tunesz $((128 * 1024 / 2)) return $RC}run_test 9 "run for fixing bug10707(64bit) ==========="# run for fixing bug10707, it need a big room. test for 32bittest_10() { chmod 0777 $DIR/$tdir check_whether_skip && return 0 wait_delete_completed set_blk_tunesz 512 set_blk_unitsz 1024 # make qd_count 32 bit lustre_fail mds_ost 0xA00 TESTFILE="$DIR/$tdir/$tfile-0" BLK_LIMIT=$((100 * KB * KB)) # 100G FILE_LIMIT=1000000 log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for user: $TSTUSR" $LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR log " Set enough high limit(block:$BLK_LIMIT; file: $FILE_LIMIT) for group: $TSTUSR" $LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 $FILE_LIMIT $DIR echo " Set stripe" $LFS setstripe $TESTFILE -c 1 touch $TESTFILE chown $TSTUSR.$TSTUSR $TESTFILE $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP log " Write the big file of 4.5 G ..." $RUNAS dd if=/dev/zero of=$TESTFILE bs=$blksize count=$((size_file / blksize)) || \ error "(usr) write 4.5 G file failure, but expect success" $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP log " delete the big file of 4.5 G..." $RUNAS rm -f $TESTFILE sync; sleep 3; sync; $SHOW_QUOTA_USER $SHOW_QUOTA_GROUP RC=$? # make qd_count 64 bit lustre_fail mds_ost 0 set_blk_unitsz $((128 * 1024)) set_blk_tunesz $((128 * 1024 / 2)) return $RC}run_test 10 "run for fixing bug10707(32bit) ==========="test_11() { wait_delete_completed #prepare the test block_limit=`(echo 0; df -t lustre -P | awk '{print $(NF - 4)}') | tail -n 1` echo $block_limit orig_dbr=`cat /proc/sys/vm/dirty_background_ratio` orig_dec=`cat /proc/sys/vm/dirty_expire_centisecs` orig_dr=`cat /proc/sys/vm/dirty_ratio` orig_dwc=`cat /proc/sys/vm/dirty_writeback_centisecs` echo 1 > /proc/sys/vm/dirty_background_ratio echo 30 > /proc/sys/vm/dirty_expire_centisecs echo 1 > /proc/sys/vm/dirty_ratio echo 50 > /proc/sys/vm/dirty_writeback_centisecs TESTDIR="$DIR/$tdir" local RV=0 #do the test local SECS=0 local REPS=3 [ "$SLOW" = no ] && REPS=1 local sleep=20 local i=1 while [ $i -le $REPS ]; do echo "test: cycle($i of $REPS) start at $(date)" mkdir -p $DIR/$tdir && chmod 777 $DIR/$tdir echo -n " create a file for uid " for j in `seq 1 30`; do echo -n "$j " # 30MB per dd for a total of 900MB (if space even permits) runas -u $j dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$blksize count=15 > /dev/null 2>&1 & done echo "" PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) LAST_USED=0 while [ $PROCS -gt 0 ]; do sleep 20 SECS=$((SECS + sleep)) PROCS=$(ps -ef | grep -v grep | grep "dd if /dev/zero of $TESTDIR" | wc -l) USED=$(du -s $DIR/$tdir | awk '{print $1}') PCT=$(($USED * 100 / $block_limit)) echo "${i}/${REPS} ${PCT}% p${PROCS} t${SECS} " if [ $USED -le $LAST_USED ]; then kill -9 $(ps -ef | grep "dd if /dev/zero of $DIR/$tdir" | grep -v grep | awk '{ print $2 }') i=$REPS RV=2 break fi LAST_USED=$USED done echo " removing the test files..." rm -f $DIR/$tdir/$tfile echo "cycle $i done at $(date)" i=$[$i+1] done echo "Test took $SECS sec" #clean echo $orig_dbr > /proc/sys/vm/dirty_background_ratio echo $orig_dec > /proc/sys/vm/dirty_expire_centisecs echo $orig_dr > /proc/sys/vm/dirty_ratio echo $orig_dwc > /proc/sys/vm/dirty_writeback_centisecs if [ $RV -ne 0 ]; then error "Nothing was written for $SECS sec ... aborting" fi return $RV}run_test 11 "run for fixing bug10912 ==========="# test a deadlock between quota and journal b=11693test_12() { chmod 0777 $DIR/$tdir [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \ { skip "Need lustre mounted on $MOUNT2 " && retutn 0; } if [ $OSTCOUNT -lt 2 ]; then skip "$OSTCOUNT < 2, too few osts" return 0; fi LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever TESTFILE="$DIR/$tdir/$tfile-0" TESTFILE2="$DIR2/$tdir/$tfile-1" wait_delete_completed echo " User quota (limit: $LIMIT kbytes)" $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR $LFS setstripe $TESTFILE -i 0 -c 1 chown $TSTUSR.$TSTUSR $TESTFILE $LFS setstripe $TESTFILE2 -i 1 -c 1 chown $TSTUSR2.$TSTUSR2 $TESTFILE2 #define OBD_FAIL_OST_HOLD_WRITE_RPC 0x21f lustre_fail ost 0x0000021f echo " step1: write out of block quota ..." $RUNAS2 dd if=/dev/zero of=$TESTFILE2 bs=$BLK_SZ count=102400 & DDPID1=$! $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$(($LIMIT*2)) & DDPID=$!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -