Whamcloud - gitweb
LU-1182 tests: run accounting tests when OFD is used
authorJohann Lombardi <johann@whamcloud.com>
Tue, 26 Jun 2012 14:46:31 +0000 (16:46 +0200)
committerOleg Drokin <green@whamcloud.com>
Mon, 2 Jul 2012 16:31:36 +0000 (12:31 -0400)
Skip all quota enforcement tests in sanity-quota.sh and only run
the accounting tests when OFD is used.

This patch also enables the ext4 quota feature when OFD is in use.
Although it is not done in a very efficient way, it still allows
us to run tests.

Signed-off-by: Johann Lombardi <johann@whamcloud.com>
Change-Id: Ie35bba9fb064acd8e878e4c31f1b43e90e164e15
Reviewed-on: http://review.whamcloud.com/3191
Tested-by: Hudson
Reviewed-by: Li Wei <liwei@whamcloud.com>
Tested-by: Maloo <whamcloud.maloo@gmail.com>
Reviewed-by: Niu Yawei <niu@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/tests/sanity-quota.sh
lustre/tests/test-framework.sh

index da93c05..ef00fdf 100644 (file)
@@ -9,6 +9,11 @@ set -e
 SRCDIR=`dirname $0`
 export PATH=$PWD/$SRCDIR:$SRCDIR:$PWD/$SRCDIR/../utils:$PATH:/sbin
 
+if [ "$USE_OFD" = "yes" -a -z "$ONLY" ]; then
+       # only accounting tests are supported with OFD for the time being
+       ONLY="33 34 35"
+fi
+
 ONLY=${ONLY:-"$*"}
 # test_11 has been used to protect a kernel bug(bz10912), now it isn't
 # useful any more. Then add it to ALWAYS_EXCEPT. b=19835
@@ -84,6 +89,22 @@ cycle=30
 
 build_test_filter
 
+if [ "$USE_OFD" = "yes" ]; then
+       for num in `seq $OSTCOUNT`; do
+               if [ $(facet_fstype ost$num) = ldiskfs ]; then
+                       # not the most efficient way to enable the quota feature
+                       # on ost, but it still allows us to test ofd accounting
+                       # for now
+                       device=$(ostdevname $num)
+                       stop ost$num
+                       do_facet ost$num "$TUNE2FS -O quota $device"
+                       [ ${PIPESTATUS[0]} -ne 0] && \
+                             error "failed to enable quota feature for ost$num"
+                       start ost$num $device $OST_MOUNT_OPTS
+               fi
+       done
+fi
+
 # set_blk_tunables(btune_sz)
 set_blk_tunesz() {
        local btune=$(($1 * BLK_SZ))
@@ -2215,11 +2236,13 @@ test_33() {
         [ $USED -ne 0 ] && \
                 error "Used space ($USED) for group $TSTID isn't 0."
 
-        echo "Write files..."
-        for i in `seq 0 $INODES`; do
-                $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=$BLK_SZ \
-                   count=$BLK_CNT oflag=sync 2>/dev/null || error "write failed"
-        done
+       for i in `seq 0 $INODES`; do
+               $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile-$i conv=fsync \
+                       bs=$((BLK_SZ * BLK_CNT)) count=1 2>/dev/null ||
+                       error "write failed"
+               echo "Iteration $i/$INODES completed"
+       done
+       sync; sync_all_data;
 
         echo "Verify disk usage after write"
         USED=`getquota -u $TSTID global curspace`
@@ -2256,7 +2279,7 @@ test_34() {
         BLK_CNT=1024
         mkdir -p $DIR/$tdir
         chmod 0777 $DIR/$tdir
-        
+
         trap cleanup_quota_test EXIT
 
         # make sure the system is clean
@@ -2265,13 +2288,17 @@ test_34() {
         USED=`getquota -g $TSTID global curspace`
         [ $USED -ne 0 ] && error "Used space ($USED) for group $TSTID isn't 0."
 
-        echo "Write file..."
-        dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$BLK_SZ count=$BLK_CNT \
-                oflag=sync 2>/dev/null || error "write failed"
+       echo "Write file..."
+       dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$((BLK_SZ * BLK_CNT)) count=1 \
+               conv=fsync 2>/dev/null || error "write failed"
+       sync; sync_all_data;
 
         echo "chown the file to user $TSTID"
         chown $TSTID $DIR/$tdir/$tfile || error "chown failed"
 
+       echo "Wait for setattr on objects finished..."
+       wait_delete_completed
+
         echo "Verify disk usage for user $TSTID"
         USED=`getquota -u $TSTID global curspace`
         [ $USED -lt $BLK_CNT ] && \
@@ -2283,6 +2310,9 @@ test_34() {
         echo "chgrp the file to group $TSTID"
         chgrp $TSTID $DIR/$tdir/$tfile || error "chgrp failed"
 
+       echo "Wait for setattr on objects finished..."
+       wait_delete_completed
+
         echo "Verify disk usage for group $TSTID"
         USED=`getquota -g $TSTID global curspace`
         [ $USED -ge $BLK_CNT ] || \
@@ -2303,9 +2333,10 @@ test_35() {
 
         trap cleanup_quota_test EXIT
 
-        echo "Write file..."
-        $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$BLK_SZ \
-                count=$BLK_CNT oflag=sync 2>/dev/null || error "write failed"
+       echo "Write file..."
+       $RUNAS dd if=/dev/zero of=$DIR/$tdir/$tfile bs=$((BLK_SZ * BLK_CNT)) \
+               count=1 conv=fsync 2>/dev/null || error "write failed"
+       sync; sync_all_data;
 
         echo "Save disk usage before restart"
         ORIG_USR_SPACE=`getquota -u $TSTID global curspace`
@@ -2350,7 +2381,6 @@ test_35() {
 }
 run_test 35 "usage is still accessible across reboot ============================"
 
-
 # turn off quota
 quota_fini()
 {
index 1562de6..146746c 100644 (file)
@@ -902,6 +902,11 @@ restore_quota_type () {
 setup_quota(){
     local mntpt=$1
 
+       if [ "$USE_OFD" = "yes" ]; then
+               $LFS quotacheck $mntpt || error "quotacheck failed"
+               return
+       fi
+
     # We need save the original quota_type params, and restore them after testing
 
     # Suppose that quota type the same on mds and ost
@@ -2755,7 +2760,7 @@ init_param_vars () {
     osc_ensure_active $SINGLEMDS $TIMEOUT
     osc_ensure_active client $TIMEOUT
 
-       if [ $QUOTA_AUTO -ne 0 ] && [ "$USE_OFD" != yes ]; then
+       if [ $QUOTA_AUTO -ne 0 ]; then
         if [ "$ENABLE_QUOTA" ]; then
             echo "enable quota as required"
             setup_quota $MOUNT || return 2