Whamcloud - gitweb
branch: HEAD
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 0c35e41..d752e97 100644 (file)
@@ -43,8 +43,6 @@ IUNIT_SZ=${IUNIT_SZ:-10}      # min inode quota unit
 MAX_DQ_TIME=604800
 MAX_IQ_TIME=604800
 
-unset ENABLE_QUOTA
-
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
@@ -53,6 +51,9 @@ init_test_env $@
 DIRECTIO=${DIRECTIO:-$LUSTRE/tests/directio}
 
 [ $MDSCOUNT -gt 1 ] && skip "CMD case" && exit 0
+
+unset ENABLE_QUOTA
+
 remote_mds_nodsh && skip "remote MDS with nodsh" && exit 0
 remote_ost_nodsh && skip "remote OST with nodsh" && exit 0
 
@@ -77,8 +78,10 @@ LOVNAME=`lctl get_param -n llite.*.lov.common_name | tail -n 1`
 OSTCOUNT=`lctl get_param -n lov.$LOVNAME.numobd`
 
 SHOW_QUOTA_USER="$LFS quota -v -u $TSTUSR $DIR"
+SHOW_QUOTA_USERID="$LFS quota -v -u $TSTID $DIR"
 SHOW_QUOTA_USER2="$LFS quota -v -u $TSTUSR2 $DIR"
 SHOW_QUOTA_GROUP="$LFS quota -v -g $TSTUSR $DIR"
+SHOW_QUOTA_GROUPID="$LFS quota -v -g $TSTID $DIR"
 SHOW_QUOTA_GROUP2="$LFS quota -v -g $TSTUSR2 $DIR"
 SHOW_QUOTA_INFO_USER="$LFS quota -t -u $DIR"
 SHOW_QUOTA_INFO_GROUP="$LFS quota -t -g $DIR"
@@ -717,7 +720,7 @@ run_test_with_stat 5 "Chown & chgrp successfully even out of block/file quota ==
 # block quota acquire & release
 test_6() {
        if [ $OSTCOUNT -lt 2 ]; then
-               skip "$OSTCOUNT < 2, too few osts"
+               skip_env "$OSTCOUNT < 2, too few osts"
                return 0;
        fi
 
@@ -1035,7 +1038,7 @@ test_12() {
        chmod 0777 $DIR/$tdir
 
        [ "$(grep $DIR2 /proc/mounts)" ] || mount_client $DIR2 || \
-               { skip "Need lustre mounted on $MOUNT2 " && retutn 0; }
+               { skip_env "Need lustre mounted on $MOUNT2 " && retutn 0; }
 
        LIMIT=$(( $BUNIT_SZ * $(($OSTCOUNT + 1)) * 10)) # 10 bunits each sever
        TESTFILE="$DIR/$tdir/$tfile-0"
@@ -1062,17 +1065,24 @@ test_12() {
        DDPID=$!
 
        echo  "   step2: testing ......"
-       count=0
-       while [ true ]; do
-           if ! ps -p ${DDPID1} > /dev/null 2>&1; then break; fi
-           count=$[count+1]
-           if [ $count -gt 64 ]; then
+        local last_size=$(stat -c %s $TESTFILE2) 
+        local stall_secs=0
+        local start_secs=$SECONDS
+        while [ -d /proc/${DDPID1} ]; do
+            local size=$(stat -c %s $TESTFILE2) 
+            if [ $size -eq $last_size ]; then
+                stall_secs=$[stall_secs+1]
+            else
+                stall_secs=0
+            fi
+           if [ $stall_secs -gt 30 ]; then
                lustre_fail ost 0
-               quota_error u $TSTUSR2 "dd should be finished!"
+               quota_error u $TSTUSR2 "giving up: dd stalled (i.e. made no progress) for 30 seconds!"
            fi
+            last_size=$size
            sleep 1
        done
-       echo "(dd_pid=$DDPID1, time=$count)successful"
+       echo "(dd_pid=$DDPID1, time=$((SECONDS-start_secs)))successful"
 
        #Recover fail_loc and dd will finish soon
        lustre_fail ost 0
@@ -1980,12 +1990,25 @@ test_26() {
 }
 run_test_with_stat 26 "test for false quota error(bz18491) ======================================"
 
-test_27() {
+test_27a() {
         $LFS quota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed"
         $LFS setquota $TSTUSR $DIR && error "lfs succeeded with no type, but should have failed"
         return 0
 }
-run_test_with_stat 27 "lfs quota/setquota should handle wrong arguments (19612) ================="
+run_test_with_stat 27a "lfs quota/setquota should handle wrong arguments (19612) ================="
+
+test_27b() {
+        $LFS setquota -u $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR || \
+                error "lfs setquota failed with uid argument"
+        $LFS setquota -g $TSTID -b 1000 -B 1000 -i 1000 -I 1000 $DIR || \
+                error "lfs stequota failed with gid argument"
+        $SHOW_QUOTA_USERID || error "lfs quota failed with uid argument"
+        $SHOW_QUOTA_GROUPID || error "lfs quota failed with gid argument"
+        resetquota -u $TSTUSR
+        resetquota -g $TSTUSR
+        return 0
+}
+run_test 27b "lfs quota/setquota should handle user/group ID (20200) ================="
 
 test_28() {
         BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
@@ -2059,6 +2082,47 @@ test_30()
 }
 run_test_with_stat 30 "hard limit updates should not reset grace times ================"
 
+test_29()
+{
+        local BLK_LIMIT=$((100 * 1024 * 1024)) # 100G
+        local timeout
+        local pid
+        local origin_resends
+
+        if at_is_enabled; then
+                timeout=$(at_max_get client)
+                at_max_set 10 client
+        else
+                timeout=$(lctl get_param -n timeout)
+                lctl set_param timeout=10
+        fi
+
+        origin_resends=$(lctl get_param -n mdc.${FSNAME}-*.quota_resend_count | head -1)
+        lctl set_param -n mdc.${FSNAME}-*.quota_resend_count 0
+
+        #define OBD_FAIL_MDS_QUOTACTL_NET 0x12e
+        lustre_fail mds 0x12e
+
+        $LFS setquota -u $TSTUSR -b 0 -B $BLK_LIMIT -i 0 -I 0 $DIR & pid=$!
+
+        echo "sleeping for $((10 * 2)) seconds"
+        sleep $((10 * 2))
+        ps -p $pid && error "lfs hadn't finished by timeout"
+        wait $pid && error "succeeded, but should have failed"
+
+        lustre_fail mds 0
+
+        if at_is_enabled; then
+                at_max_set $timeout client
+        else
+                lctl set_param timeout=$timeout
+        fi
+
+        lctl set_param -n mdc.${FSNAME}-*.quota_resend_count $origin_resends
+        resetquota -u $TSTUSR
+}
+run_test_with_stat 29 "unhandled quotactls must not hang lustre client (19778) ========"
+
 # turn off quota
 quota_fini()
 {