Whamcloud - gitweb
LU-213 using direct io for quota test to avoid cache problem
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index 7c424df..f749443 100644 (file)
@@ -99,7 +99,7 @@ build_test_filter
 set_blk_tunesz() {
        local btune=$(($1 * BLK_SZ))
        # set btune size on all obdfilters
-       do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_btune_sz=$btune"
+       do_nodes $(comma_list $(osts_nodes)) "lctl set_param lquota.${FSNAME}-OST*.quota_btune_sz=$btune"
        # set btune size on mds
        do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_btune_sz=$btune"
 }
@@ -108,7 +108,7 @@ set_blk_tunesz() {
 set_blk_unitsz() {
        local bunit=$(($1 * BLK_SZ))
        # set bunit size on all obdfilters
-       do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_bunit_sz=$bunit"
+       do_nodes $(comma_list $(osts_nodes)) "lctl set_param lquota.${FSNAME}-OST*.quota_bunit_sz=$bunit"
        # set bunit size on mds
        do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_bunit_sz=$bunit"
 }
@@ -116,8 +116,6 @@ set_blk_unitsz() {
 # set_file_tunesz(itune_sz)
 set_file_tunesz() {
        local itune=$1
-       # set itune size on all obdfilters
-       do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_itune_sz=$itune"
        # set itune size on mds
        do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_itune_sz=$itune"
 }
@@ -125,8 +123,6 @@ set_file_tunesz() {
 # set_file_unitsz(iunit_sz)
 set_file_unitsz() {
        local iunit=$1
-       # set iunit size on all obdfilters
-       do_facet ost1 "lctl set_param lquota.${FSNAME}-OST*.quota_iunit_sz=$iunit"
        # set iunit size on mds
        do_facet $SINGLEMDS "lctl set_param lquota.mdd_obd-${FSNAME}-MDT*.quota_iunit_sz=$iunit"
 }
@@ -299,12 +295,13 @@ quota_show_check() {
 
 # set quota
 quota_init() {
+       do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
+
+       log "do the quotacheck ..."
        $LFS quotacheck -ug $DIR
 
        resetquota -u $TSTUSR
        resetquota -g $TSTUSR
-
-        do_nodes $(comma_list $(nodes_list)) "lctl set_param debug=+quota"
 }
 quota_init
 
@@ -959,7 +956,7 @@ GB=$((KB * 1024 * 1024))
 # inode->i_blkbits = min(PTLRPC_MAX_BRW_BITS+1, LL_MAX_BLKSIZE_BITS);
 blksize=$((1 << 21)) # 2Mb
 size_file=$((GB * 9 / 2))
-# this check is just for test9 and test10
+# this check is just for test_9
 OST0_MIN=4900000 #4.67G
 check_whether_skip () {
     OST0_SIZE=`$LFS df $DIR | awk '/\[OST:0\]/ {print $4}'`
@@ -997,7 +994,7 @@ test_9() {
         quota_show_check a g $TSTUSR
 
         echo "  Set stripe"
-       $LFS setstripe $TESTFILE -c 1
+       $LFS setstripe $TESTFILE -c 1 -i 0
         touch $TESTFILE
         chown $TSTUSR.$TSTUSR $TESTFILE
 
@@ -1197,10 +1194,10 @@ test_14a() {    # was test_14 b=12223 -- setting quota on root
        $LFS setquota -u root -b 10 -B 10 -i 10 -I 10 $DIR
        createmany -m ${TESTFILE} 20 || \
            quota_error u root "unexpected: user(root) create files failly!"
-       dd if=/dev/zero of=$TESTFILE bs=4k count=4096 || \
+        multiop ${TESTFILE} oO_CREAT:O_WRONLY:O_DIRECT:w$((4096 * 4096))c || \
            quota_error u root "unexpected: user(root) write files failly!"
        chmod 666 $TESTFILE
-       $RUNAS dd if=/dev/zero of=${TESTFILE} seek=4096 bs=4k count=4096 && \
+        $RUNAS multiop ${TESTFILE} oO_WRONLY:O_APPEND:O_DIRECT:w$((4096 * 4096))c && \
            quota_error u root "unexpected: user(quota_usr) write a file successfully!"
 
        # trigger the llog
@@ -1437,7 +1434,7 @@ run_test_with_stat 18a "run for fixing bug14840 ==========="
 test_18bc_sub() {
         type=$1
 
-        LIMIT=$((110 * 1024 )) # 110M
+        LIMIT=$(((100 + $OSTCOUNT * 3) * 1024))
         TESTFILE="$DIR/$tdir/$tfile"
         mkdir -p $DIR/$tdir
 
@@ -1466,14 +1463,16 @@ test_18bc_sub() {
         DDPID=$!
         do_facet $SINGLEMDS "$LCTL conf_param ${FSNAME}-MDT*.mdd.quota_type=ug"
 
+       replay_barrier $SINGLEMDS
+
        log "failing mds for $((2 * timeout)) seconds"
         fail $SINGLEMDS $((2 * timeout))
 
         # check if quotaon successful
         $LFS quota -u $TSTUSR $MOUNT 2>&1 | grep -q "quotas are not enabled"
         if [ $? -eq 0 ]; then
-            error "quotaon failed!"
             rm -rf $TESTFILE
+            error "quotaon failed!"
             return
         fi
 
@@ -1494,17 +1493,18 @@ test_18bc_sub() {
         sync
         cancel_lru_locks mdc
         cancel_lru_locks osc
-
-        testfile_size=$(stat -c %s $TESTFILE)
-        [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] && \
-           quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
         $SHOW_QUOTA_USER
-        rm -f $TESTFILE
-        sync
 
        resetquota -u $TSTUSR
        set_blk_unitsz $((128 * 1024))
        set_blk_tunesz $((128 * 1024 / 2))
+       testfile_size=$(stat -c %s $TESTFILE)
+       if [ $testfile_size -ne $((BLK_SZ * 1024 * 100)) ] ; then
+            rm -f $TESTFILE
+            quota_error u $TSTUSR "expect $((BLK_SZ * 1024 * 100)), got ${testfile_size}. Verifying file failed!"
+       fi
+       rm -f $TESTFILE
+
 }
 
 # test when mds does failover, the ost still could work well
@@ -1715,7 +1715,7 @@ test_23_sub() {
        sleep 3
         quota_show_check b u $TSTUSR
 
-       $LFS setstripe $TESTFILE -c 1
+       $LFS setstripe $TESTFILE -c 1 -i 0
        chown $TSTUSR.$TSTUSR $TESTFILE
 
        log "    Step1: trigger quota with 0_DIRECT"
@@ -1744,13 +1744,17 @@ test_23_sub() {
 }
 
 test_23() {
-       log "run for $((OSTCOUNT * 4))MB test file"
-       test_23_sub $((OSTCOUNT * 4 * 1024))
+        local slave_cnt=$((OSTCOUNT + 1)) # 1 mds, n osts
+
+        OST0_MIN=$((6 * $slave_cnt * 1024)) # extra space for meta blocks.
+       check_whether_skip && return 0
+       log "run for $((4 * $slave_cnt))MB test file"
+       test_23_sub $((4 * $slave_cnt * 1024))
 
-       OST0_MIN=120000
+       OST0_MIN=$((60 * $slave_cnt * 1024)) # extra space for meta blocks.
        check_whether_skip && return 0
-       log "run for $((OSTCOUNT * 40))MB test file"
-       test_23_sub $((OSTCOUNT * 40 * 1024))
+       log "run for $((40 * $slave_cnt))MB test file"
+       test_23_sub $((40 * $slave_cnt * 1024))
 }
 run_test_with_stat 23 "run for fixing bug16125 ==========="
 
@@ -2170,6 +2174,10 @@ test_32()
         cleanup_and_setup_lustre
         LOAD_MODULES_REMOTE=$LMR_orig
 
+        client_up
+        wait_mds_ost_sync
+        quota_init
+
         for user in $SANITY_QUOTA_USERS; do
            check_runas_id_ret $user quota_usr "runas -u $user -g quota_usr" >/dev/null 2>/dev/null || \
                missing_users="$missing_users $user"
@@ -2200,10 +2208,8 @@ quota_fini()
 }
 quota_fini
 
-log "cleanup: ======================================================"
 cd $ORIG_PWD
+complete $(basename $0) $SECONDS
 check_and_cleanup_lustre
-echo '=========================== finished ==============================='
 export QUOTA_AUTO=$QUOTA_AUTO_OLD
-[ -f "$QUOTALOG" ] && cat $QUOTALOG && grep -q FAIL $QUOTALOG && exit 1 || true
-echo "$0: completed"
+exit_status