Whamcloud - gitweb
LU-1182 tests: run accounting tests when OFD is used
[fs/lustre-release.git] / lustre / tests / sanity-quota.sh
index a169b59..ef00fdf 100644 (file)
@@ -6,16 +6,14 @@
 # Run test by setting NOSETUP=true when ltest has setup env for us
 set -e
 
-#kernel 2.4.x doesn't support quota
-K_VER=`uname --kernel-release | cut -b 1-3`
-if [ $K_VER = "2.4" ]; then
-    echo "Kernel 2.4 doesn't support quota"
-    exit 0
-fi
-
 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
@@ -24,11 +22,6 @@ ONLY=${ONLY:-"$*"}
 ALWAYS_EXCEPT="10 12 $SANITY_QUOTA_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-case `uname -r` in
-2.6*) FSTYPE=${FSTYPE:-ldiskfs};;
-*) error "unsupported kernel" ;;
-esac
-
 [ "$ALWAYS_EXCEPT$EXCEPT" ] && \
        echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT`"
 
@@ -50,6 +43,7 @@ SANITY_QUOTA_USERS="quota15_1 quota15_2 quota15_3 quota15_4 quota15_5 quota15_6
                     quota15_19 quota15_20 quota15_21 quota15_22 quota15_23 quota15_24 \
                     quota15_25 quota15_26 quota15_27 quota15_28 quota15_29 quota15_30"
 
+export MULTIOP=${MULTIOP:-multiop}
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
@@ -95,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))
@@ -1194,10 +1204,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!"
-        multiop ${TESTFILE} oO_CREAT:O_WRONLY:O_DIRECT:w$((4096 * 4096))c || \
+        $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 multiop ${TESTFILE} oO_WRONLY:O_APPEND:O_DIRECT:w$((4096 * 4096))c && \
+        $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
@@ -2226,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`
@@ -2250,6 +2262,7 @@ test_33() {
         cleanup_quota_test
 
         echo "Verify disk usage after delete"
+        wait_delete_completed
         USED=`getquota -u $TSTID global curspace`
         [ $USED -eq 0 ] || error "Used space for user $TSTID isn't 0. $USED"
         USED=`getquota -u $TSTID global curinodes`
@@ -2266,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
@@ -2275,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 ] && \
@@ -2293,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 ] || \
@@ -2313,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`
@@ -2360,7 +2381,6 @@ test_35() {
 }
 run_test 35 "usage is still accessible across reboot ============================"
 
-
 # turn off quota
 quota_fini()
 {