Whamcloud - gitweb
Branch head
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 0bde19a..92a0080 100644 (file)
@@ -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()
 {