X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Ftests%2Fsanity-quota.sh;h=92a008007ff1cb0ae8dc4e969754ad78806d4dfd;hb=6e499f65f2e3ee14487c3bf8f7237ec4d988b5d1;hp=dd1dc883fbcf8703e663158c0f1d6f964a71b23e;hpb=44711ce0e1c6de1bb016d4d39e1054efb0223568;p=fs%2Flustre-release.git diff --git a/lustre/tests/sanity-quota.sh b/lustre/tests/sanity-quota.sh index dd1dc88..92a0080 100644 --- a/lustre/tests/sanity-quota.sh +++ b/lustre/tests/sanity-quota.sh @@ -194,7 +194,7 @@ STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount` STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize` ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail` MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))} -MDS=$(\ls $LPROC/mds 2> /dev/null | grep -v num_refs | tail -n 1) +MDS=$(\ls $LPROC/mdt 2> /dev/null | grep -v num_refs | tail -n 1) TSTDIR=$DIR/quota_test_dir TSTDIR2=$DIR2/quota_test_dir SHOW_QUOTA_USER="$LFS quota -u $TSTUSR $MOUNT" @@ -280,27 +280,27 @@ post_test() { setup() { # create local test group - GRP="`cat /etc/group | grep "$TSTUSR" | awk -F: '{print $1}'`" + GRP="`cat /etc/group | grep "^${TSTUSR}:" | awk -F: '{print $1}'`" if [ -z "$GRP" ]; then groupadd -g $TSTID "$TSTUSR" fi - TSTID="`cat /etc/group | grep "$TSTUSR" | awk -F: '{print $3}'`" + TSTID="`cat /etc/group | grep "^${TSTUSR}:" | awk -F: '{print $3}'`" - GRP2="`cat /etc/group | grep "$TSTUSR2" | awk -F: '{print $1}'`" + GRP2="`cat /etc/group | grep "^${TSTUSR2}:" | awk -F: '{print $1}'`" if [ -z "$GRP2" ]; then groupadd -g $TSTID2 "$TSTUSR2" fi - TSTID2="`cat /etc/group | grep "$TSTUSR2" | awk -F: '{print $3}'`" + TSTID2="`cat /etc/group | grep "^${TSTUSR2}:" | awk -F: '{print $3}'`" # create test user - USR="`cat /etc/passwd | grep "$TSTUSR" | awk -F: '{print $1}'`" + USR="`cat /etc/passwd | grep "^${TSTUSR}:" | awk -F: '{print $1}'`" if [ -z "$USR" ]; then useradd -u $TSTID -g $TSTID -d /tmp "$TSTUSR" fi RUNAS="runas -u $TSTID" - USR2="`cat /etc/passwd | grep "$TSTUSR2" | awk -F: '{print $1}'`" + USR2="`cat /etc/passwd | grep "^${TSTUSR2}:" | awk -F: '{print $1}'`" if [ -z "$USR2" ]; then useradd -u $TSTID2 -g $TSTID2 -d /tmp "$TSTUSR2" fi @@ -617,7 +617,7 @@ test_6() { return 0; fi - LIMIT=$((BUNIT_SZ * (OSTCOUNT + 1) * 5)) # 5 bunits per server + LIMIT=$(($BUNIT_SZ * $(($OSTCOUNT + 1)) * 5)) # 5 bunits per server FILEA="$TSTDIR/quota_tst60_a" FILEB="$TSTDIR/quota_tst60_b" @@ -712,8 +712,8 @@ test_7() [ $TOTAL_LIMIT -eq $LIMIT ] || error "total limits not recovery!" echo " total limits = $TOTAL_LIMIT" - OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'| head -n1` - [ -z "$OST0_UUID" ] && OST0_UUID=`$LCTL dl | awk '$3 ~ /obdfilter/ { print $5 }'|head -n1` + 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 $MOUNT | awk '/^.*[[:digit:]+][[:space:]+]/ { print $3 }'`" [ $OST0_LIMIT -eq $BUNIT_SZ ] || error "high limits not released!" echo " limits on $OST0_UUID = $OST0_LIMIT" @@ -1043,8 +1043,6 @@ test_13() { $SHOW_QUOTA_USER [ $((fz + fz2)) -lt $((BUNIT_SZ * BLK_SZ * 10)) ] && \ error "files too small $fz + $fz < $((BUNIT_SZ * BLK_SZ * 10))" - [ $((fz + fz2)) -gt $((BUNIT_SZ * BLK_SZ * 11)) ] && \ - error "files too large $fz + $fz > $((BUNIT_SZ * BLK_SZ * 11))" rm -f $TESTFILE $TESTFILE.2 @@ -1052,6 +1050,56 @@ test_13() { } run_test 13 "test multiple clients write block quota ===" +check_if_quota_zero(){ + line=`$LFS quota -$1 $2 $MOUNT | wc -l` + for i in `seq 3 $line`; do + for j in 3 4 6 7; do + tmp=`$LFS quota -$1 $2 $MOUNT | sed -n ${i}p | + awk '{print $'"$j"'}'` + [ -n "$tmp" ] && [ $tmp -ne 0 ] && $LFS quota -$1 $2 $MOUNT && \ + error "quota on $1 isn't clean" + done + done + echo "pass check_if_quota_zero" +} + +# test setting quota on root, b=12223 +test_13(){ + TESTFILE="$TSTDIR/quota_tst13" + + # reboot the lustre + cd $T_PWD; sh llmountcleanup.sh || error "llmountcleanup failed" + sh llmount.sh + pre_test + setup + run_test 0 "reboot lustre" + + # out of root's file and block quota + $LFS setquota -u root 10 10 10 10 $MOUNT + 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 $MOUNT + 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 "test_13 failed." + $LFS setquota -u root 0 0 0 0 $MOUNT + #check_if_quota_zero u root + + # clean + unlinkmany ${TESTFILE} 15 + rm -f $TESTFILE +} +run_test 13 "test setting quota on root ===" + # turn off quota test_99() {