⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sanity-quota.sh

📁 lustre 1.6.5 source code
💻 SH
📖 第 1 页 / 共 3 页
字号:
	echo  "   step2: testing ......"	count=0	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID1}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt 64 ]; then		lustre_fail ost 0		error "dd should be finished!"	    fi	    sleep 1	done	echo "(dd_pid=$DDPID1, time=$count)successful"	#Recover fail_loc and dd will finish soon	lustre_fail ost 0	echo  "   step3: testing ......"	count=0	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt 100 ]; then		error "dd should be finished!"	    fi	    sleep 1	done	echo "(dd_pid=$DDPID, time=$count)successful"	rm -f $TESTFILE $TESTFILE2        sync; sleep 3; sync;	$LFS setquota -u $TSTUSR 0 0 0 0 $DIR		# clear user limit}run_test 12 "test a deadlock between quota and journal ==="# test multiple clients write block quota b=11693test_13() {        wait_delete_completed	# one OST * 10 + (mds + other OSTs)	LIMIT=$((BUNIT_SZ * 10 + (BUNIT_SZ * OSTCOUNT)))	TESTFILE="$DIR/$tdir/$tfile"	echo "   User quota (limit: $LIMIT kbytes)"	$LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR	$SHOW_QUOTA_USER	$LFS setstripe $TESTFILE -i 0 -c 1	chown $TSTUSR.$TSTUSR $TESTFILE	$LFS setstripe $TESTFILE.2 -i 0 -c 1        chown $TSTUSR.$TSTUSR $TESTFILE.2	echo "   step1: write out of block quota ..."	# one bunit will give mds	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &	DDPID=$!	$RUNAS dd if=/dev/zero of=$TESTFILE.2 bs=$BLK_SZ count=$[($LIMIT - $BUNIT_SZ) / 2] &	DDPID1=$!	echo  "   step2: testing ......"	count=0	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt 64 ]; then		error "dd should be finished!"	    fi	    sleep 1	done	echo "(dd_pid=$DDPID, time=$count)successful"	count=0	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID1}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt 64 ]; then		error "dd should be finished!"	    fi	    sleep 1	done	echo "(dd_pid=$DDPID1, time=$count)successful"	sync; sleep 5; sync;	echo  "   step3: checking ......"	fz=`stat -c %s $TESTFILE`	fz2=`stat -c %s $TESTFILE.2`	$SHOW_QUOTA_USER	[ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \		error "files too small $fz + $fz2 < $((BUNIT_SZ * BLK_SZ * 10))"	rm -f $TESTFILE $TESTFILE.2	sync; sleep 3; sync;	$LFS setquota -u $TSTUSR 0 0 0 0 $DIR		# clear user limit}run_test 13 "test multiple clients write block quota ==="check_if_quota_zero(){        line=`$LFS quota -$1 $2 $DIR | wc -l`	for i in `seq 3 $line`; do	    if [ $i -eq 3 ]; then		field="3 4 6 7"	    else		field="3 5"	    fi	    for j in $field; do		tmp=`$LFS quota -$1 $2 $DIR | sed -n ${i}p |                     awk  '{print $'"$j"'}'`		[ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -$1 $2 $DIR && \		    error "quota on $2 isn't clean"	    done	done	echo "pass check_if_quota_zero"}pre_test_14 () {        # reboot the lustre        sync; sleep 5; sync        cd $T_PWD; sh llmountcleanup.sh || error "llmountcleanup failed"        sh llmount.sh        run_test 0 "reboot lustre"}pre_test_14test_14(){ # b=12223 -- setting quota on root	TESTFILE="$DIR/$tdir/$tfile"	# out of root's file and block quota        $LFS setquota -u root 10 10 10 10 $DIR	createmany -m ${TESTFILE} 20 || \	    error "unexpected: user(root) create files failly!"	dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \	    error "unexpected: user(root) write files failly!"	chmod 666 $TESTFILE	$RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \	    error "unexpected: user(quota_usr) write a file successfully!"	# trigger the llog	chmod 777 $DIR	for i in `seq 1 10`; do $RUNAS touch ${TESTFILE}a_$i; done	for i in `seq 1 10`; do $RUNAS rm -f ${TESTFILE}a_$i; done	# do the check	dmesg | tail | grep "\-122" |grep llog_obd_origin_add && error "err -122 not found in dmesg"	$LFS setquota -u root 0 0 0 0 $DIR	#check_if_quota_zero u root	# clean	unlinkmany ${TESTFILE} 15	rm -f $TESTFILE	sync; sleep 3; sync;}run_test 14 "test setting quota on root ==="quota_set_version() {        do_facet mds "for i in /proc/fs/lustre/mds/${FSNAME}-MDT*/quota_type; do                echo $1 >> \\\$i;        done"}test_14a(){        # 1. check that required users exist        # 2. ensure that switch to new mode will start conversion        # 3. start quota in old mode and put some entries        # 4. restart quota in new mode forcing conversion and check the entries        wait_delete_completed        MISSING_USERS=""        for i in `seq 1 30`; do                check_runas_id_ret quota15_$i "runas -u quota15_$i"                if [ "$?" != "0" ]; then                       MISSING_USERS="$MISSING_USERS quota15_$i"                fi        done        if [ -n "$MISSING_USERS" ]; then                skip "following users are missing: $MISSING_USERS"                return 0        fi        $LFS quotaoff -ug $DIR        quota_set_version 1        $LFS quotacheck -ug $DIR        for i in `seq 1 30`; do                $LFS setquota -u quota15_$i $i $i $i $i $DIR || error "lfs setquota failed"        done        $LFS quotaoff -ug $DIR        quota_set_version 2        $LFS quotainv -ug $DIR        $LFS quotacheck -ug $DIR        for i in `seq 1 30`; do                # the format is "mntpnt   curspace[*]   bsoftlimit   bhardlimit   [time]   curinodes[*]    isoftlimit  ihardlimit"                ($LFS quota -u quota15_$i $DIR | grep -E '^ *'$DIR' *[0-9]+\** *'$i' *'$i' *[0-9]+\** *'$i' *'$i) \                 || error "lfs quota output is unexpected"                $LFS setquota -u quota15_$i 0 0 0 0 $DIR || error "ifs setquota clear failed"        done}run_test 14a "setting 30 quota entries in quota v1 file before conversion ==="test_15(){        LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB        PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"	wait_delete_completed        # test for user        $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR || error "failed setting user quota limit $LIMIT"        TOTAL_LIMIT="`$LFS quota -u $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"        [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"        echo "  (user)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"        $LFS setquota -u $TSTUSR 0 0 0 0 $DIR || error "failed removing user quota limit"        # test for group        $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR || error "failed setting group quota limit $LIMIT"        TOTAL_LIMIT="`$LFS quota -g $TSTUSR $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $4 }'`"        [ $TOTAL_LIMIT -eq $LIMIT ] || error "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, failed!"        echo "  (group)total limits = $TOTAL_LIMIT; limit = $LIMIT, successful!"        $LFS setquota -g $TSTUSR 0 0 0 0 $DIR || error "failed removing group quota limit"        $LFS quotaoff -ug $DIR        quota_set_version 1        $LFS quotacheck -ug $DIR || error "quotacheck failed"        echo "Testing that >4GB quota limits fail on volume with quota v1"        ! $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR}run_test 15 "set block quota more than 4T ==="# $1=u/g $2=with qunit adjust or nottest_16_tub() {	LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 4))	TESTFILE="$DIR/$tdir/$tfile"	wait_delete_completed	echo "  User quota (limit: $LIMIT kbytes)"	if [ $1 == "u" ]; then	    $LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $DIR	    $SHOW_QUOTA_USER	else	    $LFS setquota -g $TSTUSR 0 $LIMIT 0 0 $DIR	    $SHOW_QUOTA_GROUP	fi	$LFS setstripe $TESTFILE -c 1	chown $TSTUSR.$TSTUSR $TESTFILE	echo "    Write ..."	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((BUNIT_SZ * 4)) || \	    error "(usr) write failure, but expect success"	echo "    Done"	echo "    Write out of block quota ..."	# this time maybe cache write,  ignore it's failure	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || true	# flush cache, ensure noquota flag is setted on client        cancel_lru_locks osc	if [ $2 -eq 1 ]; then	    $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) || \		error "(write failure, but expect success"	else	    $RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$BUNIT_SZ seek=$((BUNIT_SZ * 4)) && \		error "(write success, but expect EDQUOT"	fi	rm -f $TESTFILE	sync; sleep 3; sync;	$LFS setquota -$1 $TSTUSR 0 0 0 0 $DIR}# test without adjusting qunittest_16 () {	set_blk_tunesz $((BUNIT_SZ * 2))	set_blk_unitsz $((BUNIT_SZ * 4))	for i in u g; do	    for j in 0 1; do                # define OBD_FAIL_QUOTA_WITHOUT_CHANGE_QS    0xA01		echo " grp/usr: $i, adjust qunit: $j"		echo "-------------------------------"		[ $j -eq 1 ] && lustre_fail mds_ost 0		[ $j -eq 0 ] && lustre_fail mds_ost 0xA01		test_16_tub $i $j	    done	done	set_blk_unitsz $((128 * 1024))	set_blk_tunesz $((128 * 1024 / 2))}run_test 16 "test without adjusting qunit"# run for fixing bug14526, failed returned quota reqs shouldn't ruin lustre.test_17() {	set_blk_tunesz 512	set_blk_unitsz 1024	wait_delete_completed        #define OBD_FAIL_QUOTA_RET_QDATA | OBD_FAIL_ONCE	lustre_fail ost 0x80000A02	TESTFILE="$DIR/$tdir/$tfile-a"	TESTFILE2="$DIR/$tdir/$tfile-b"	BLK_LIMIT=$((100 * 1024)) # 100M	log "  Set enough high limit(block:$BLK_LIMIT) for user: $TSTUSR"	$LFS setquota -u $TSTUSR 0 $BLK_LIMIT 0 0 $DIR	log "  Set enough high limit(block:$BLK_LIMIT) for group: $TSTUSR"	$LFS setquota -g $TSTUSR 0 $BLK_LIMIT 0 0 $DIR	touch $TESTFILE	chown $TSTUSR.$TSTUSR $TESTFILE	touch $TESTFILE2	chown $TSTUSR.$TSTUSR $TESTFILE2        $SHOW_QUOTA_USER        $SHOW_QUOTA_GROUP	log "    Write the test file1 ..."	$RUNAS dd if=/dev/zero of=$TESTFILE  bs=$BLK_SZ count=$(( 10 * 1024 )) \	    || echo "write 10M file failure"        $SHOW_QUOTA_USER        $SHOW_QUOTA_GROUP	log "    write the test file2 ..."	$RUNAS dd if=/dev/zero of=$TESTFILE2  bs=$BLK_SZ count=$(( 10 * 1024 )) \	    || error "write 10M file failure"        $SHOW_QUOTA_USER        $SHOW_QUOTA_GROUP	rm -f $TESTFILE $TESTFILE2	RC=$?	sync; sleep 3; sync;	# make qd_count 64 bit	lustre_fail ost 0	set_blk_unitsz $((128 * 1024))	set_blk_tunesz $((128 * 1024 / 2))	return $RC}run_test 17 "run for fixing bug14526 ==========="# test when mds takes a long time to handle a quota req so that# the ost has dropped it, the ost still could work well b=14840test_18() {	LIMIT=$((100 * 1024 * 1024)) # 100G	TESTFILE="$DIR/$tdir/$tfile"	wait_delete_completed	set_blk_tunesz 512	set_blk_unitsz 1024	log "   User quota (limit: $LIMIT kbytes)"	$LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT	$SHOW_QUOTA_USER	$LFS setstripe $TESTFILE -i 0 -c 1	chown $TSTUSR.$TSTUSR $TESTFILE	#define OBD_FAIL_MDS_BLOCK_QUOTA_REQ      0x13c	lustre_fail mds 0x13c	log "   step1: write 100M block ..."	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &	DDPID=$!        sleep 5        lustre_fail mds 0	echo  "   step2: testing ......"	count=0	timeout=$(sysctl -n lustre.timeout)	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt $((2 * $timeout)) ]; then		error "count=$count dd should be finished!"	    fi	    sleep 1	done        log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"        if [ $count -lt $(($timeout - 10)) ]; then            error " should take longer!"        else            echo " successful"        fi	rm -f $TESTFILE	sync; sleep 3; sync;	$LFS setquota -u $TSTUSR 0 0 0 0 $MOUNT		# clear user limit	set_blk_unitsz $((128 * 1024))	set_blk_tunesz $((128 * 1024 / 2))}run_test 18 "run for fixing bug14840 ==========="# test when mds drops a quota req, the ost still could work well b=14840test_18a() {        LIMIT=$((100 * 1024 * 1024)) # 100G	TESTFILE="$DIR/$tdir/$tfile-a"	wait_delete_completed	set_blk_tunesz 512	set_blk_unitsz 1024	log "   User quota (limit: $LIMIT kbytes)"	$LFS setquota -u $TSTUSR 0 $LIMIT 0 0 $MOUNT	$SHOW_QUOTA_USER	$LFS setstripe $TESTFILE -i 0 -c 1	chown $TSTUSR.$TSTUSR $TESTFILE	#define OBD_FAIL_MDS_DROP_QUOTA_REQ | OBD_FAIL_ONCE   0x8000013d	lustre_fail mds 0x8000013d	log "   step1: write 100M block ..."	$RUNAS dd if=/dev/zero of=$TESTFILE bs=$BLK_SZ count=$((1024 * 100)) &	DDPID=$!	echo  "   step2: testing ......"	count=0	timeout=$(sysctl -n lustre.timeout)	while [ true ]; do	    if [ -z `ps -ef | awk '$2 == '${DDPID}' { print $8 }'` ]; then break; fi	    count=$[count+1]	    if [ $count -gt $((3 * $timeout)) ]; then		lustre_fail mds 0		error "count=$count dd should be finished!"	    fi	    sleep 1	done        log "(dd_pid=$DDPID, time=$count, timeout=$timeout)"        if [ $count -lt $(($timeout - 10)) ]; then	    lustre_fail mds 0            error " should take longer!"        else            echo " successful"        fi        lustre_fail mds 0	rm -f $TESTFILE	sync; sleep 3; sync;	$LFS setquota -u $TSTUSR 0 0 0 0 $MOUNT		# clear user limit	set_blk_unitsz $((128 * 1024))	set_blk_tunesz $((128 * 1024 / 2))}run_test 18a "run for fixing bug14840 ==========="# turn off quotatest_99(){	$LFS quotaoff $DIR	sysctl -w lnet.debug="-quota"	return 0}run_test 99 "Quota off ==============================="log "cleanup: ======================================================"cd $ORIG_PWDcheck_and_cleanup_lustreecho '=========================== finished ==============================='[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || trueecho "$0: completed"

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -