Whamcloud - gitweb
b=18623
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 0444562..4990882 100644 (file)
@@ -41,6 +41,8 @@ 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
@@ -176,7 +178,7 @@ resetquota() {
        $LFS setquota "$1" "$2" -b 0 -B 0 -i 0 -I 0 $MOUNT || error "resetquota failed"
 }
 
-quota_error() {
+quota_scan() {
         LOCAL_UG=$1
         LOCAL_ID=$2
 
@@ -189,11 +191,20 @@ quota_error() {
                 log "Files for group ($LOCAL_ID):"
                 ($LFS find -group $LOCAL_ID $DIR | xargs stat 2>/dev/null)
         fi
+}
 
+quota_error() {
+        quota_scan $1 $2
         shift 2
         error "$*"
 }
 
+quota_log() {
+        quota_scan $1 $2
+        shift 2
+        log "$*"
+}
+
 quota_show_check() {
         LOCAL_BF=$1
         LOCAL_UG=$2
@@ -204,12 +215,12 @@ quota_show_check() {
 
         if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "b" ]; then
                USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $2 }'`"
-                [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+                [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for block ($LOCAL_UG:$LOCAL_ID:$USAGE)."
         fi
 
         if [ "$LOCAL_BF" == "a" -o "$LOCAL_BF" == "f" ]; then
                USAGE="`$LFS quota -$LOCAL_UG $LOCAL_ID $DIR | awk '/^.*'$PATTERN'.*[[:digit:]+][[:space:]+]/ { print $5 }'`"
-                [ $USAGE -ne 0 ] && quota_error $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
+                [ $USAGE -ne 0 ] && quota_log $LOCAL_UG $LOCAL_ID "System is not clean for file ($LOCAL_UG:$LOCAL_ID:$USAGE)."
         fi
 }
 
@@ -791,6 +802,7 @@ test_8() {
        [ "$SLOW" = "no" ] && duration=" -t 120"
        $RUNAS bash rundbench -D $DIR/$tdir 3 $duration || quota_error a $TSTUSR "dbench failed!"
 
+        rm -rf $DIR/$tdir
        sync; sleep 3; sync;
 
        return 0
@@ -1184,13 +1196,6 @@ test_14a() {     # was test_14 b=12223 -- setting quota on root
 }
 run_test_with_stat 14a "test setting quota on root ==="
 
-# save quota version (both administrative and operational quotas)
-quota_save_version() {
-        do_facet mgs "lctl conf_param ${FSNAME}-MDT*.mdd.quota_type=$1"
-        do_facet mgs "lctl conf_param ${FSNAME}-OST*.ost.quota_type=$1"
-        sleep 5
-}
-
 test_15(){
         LIMIT=$((24 * 1024 * 1024 * 1024 * 1024)) # 24 TB
         PATTERN="`echo $DIR | sed 's/\//\\\\\//g'`"
@@ -1729,6 +1734,21 @@ test_22() {
 }
 run_test_with_stat 22 "test if quota_type saved as permanent parameter ===="
 
+# It is triggered when test_23 failed, diagnostic for bug 18293
+test_23_dumppage()
+{
+        NUM=$1
+        DUMPPAGE=`find /proc/fs/${FSNAME}/llite/ -name dump_page_cache`
+        qtime=`date +%s`
+        cat $DUMPPAGE > $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
+        fsize=`stat -c%s $TMP/sanity-quota_test_23_${qtime}_${NUM}.log`
+        if [ $fsize -eq 0 ]; then
+                rm -f $TMP/sanity-quota_test_23_${qtime}_${NUM}.log
+        else
+                error "some IO error was found during directIO"
+        fi
+}
+
 test_23_sub() {
        mkdir -p $DIR/$tdir
        chmod 0777 $DIR/$tdir
@@ -1750,13 +1770,16 @@ test_23_sub() {
 
        log "    Step1: trigger quota with 0_DIRECT"
        log "      Write half of file"
-       $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE 0 $(($LIMIT/1024/2)) $bs_unit || \
+                (quota_error u $TSTUSR "(1) write failure, but expect success: $LIMIT" && test_23_dumppage 1)
        log "      Write out of block quota ..."
-       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) $(($LIMIT/1024/2)) $bs_unit && \
+                quota_error u $TSTUSR "(2) write success, but expect EDQUOT: $LIMIT" && test_23_dumppage 2
        log "    Step1: done"
 
        log "    Step2: rewrite should succeed"
-       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT"
+       $RUNAS $DIRECTIO write $TESTFILE $(($LIMIT/1024/2)) 1 $bs_unit || \
+                (quota_error u $TSTUSR "(3) write failure, but expect success: $LIMIT" && test_23_dumppage 3)
        log "    Step2: done"
 
        rm -f $TESTFILE
@@ -1907,6 +1930,51 @@ test_25() {
 }
 run_test_with_stat 25 "test whether quota usage is transfered when chown/chgrp (18081) ==========="
 
+test_26() {
+       mkdir -p $DIR/$tdir
+       chmod 0777 $DIR/$tdir
+       TESTFILE="$DIR/$tdir/$tfile-0"
+       TESTFILE2="$DIR/$tdir/$tfile-1"
+       set_blk_tunesz 512
+       set_blk_unitsz 1024
+
+       wait_delete_completed
+
+       # every quota slave gets 20MB
+       b_limit=$((OSTCOUNT * 20 * 1024))
+       log "limit: ${b_limit}KB"
+       $LFS setquota -u $TSTUSR -b 0 -B $b_limit -i 0 -I 0 $DIR
+       sleep 3
+       quota_show_check b u $TSTUSR
+
+       $LFS setstripe $TESTFILE  -c 1 -i 0
+       $LFS setstripe $TESTFILE2 -c 1 -i 0
+       chown $TSTUSR.$TSTUSR $TESTFILE
+       chown $TSTUSR.$TSTUSR $TESTFILE2
+
+       #define OBD_FAIL_QUOTA_DELAY_REL         0xA03
+       lustre_fail ost 0xA03
+
+       log "    Write the first file..."
+       $RUNAS $DIRECTIO write $TESTFILE 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
+       log "    Delete the first file..."
+       rm -f $TESTFILE
+
+
+       wait_delete_completed
+
+       log "    Write the second file..."
+       $RUNAS $DIRECTIO write $TESTFILE2 0 10 $((BLK_SZ * 1024)) || quota_error u $TSTUSR "write failure, but expect success"
+       log "    Delete the second file..."
+       rm -f $TESTFILE2
+
+       lustre_fail ost 0
+       set_blk_unitsz $((128 * 1024))
+       set_blk_tunesz $((128 * 1024 / 2))
+       resetquota -u $TSTUSR
+}
+run_test_with_stat 26 "test for false quota error(bz18491) ======================================"
+
 # turn off quota
 test_99()
 {