Whamcloud - gitweb
b=13557
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 4a7bc92..16ef6f5 100644 (file)
@@ -7,21 +7,25 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 5188/5749 10764
-ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27o 27q  42a  42b  42c  42d  45   68        75"}
+# bug number for skipped test: 4900 4900 2108 9789 3637 9789 3561 5188/5749 13310 10764
+ALWAYS_EXCEPT="                 27o 27q  42a  42b  42c  42d  45   68        74b   75 $SANITY_EXCEPT"
+# bug number for skipped test: 2108 9789 3637 9789 3561 5188/5749 1443
+#ALWAYS_EXCEPT=${ALWAYS_EXCEPT:-"27m 42a 42b 42c 42d 45 68 76"}
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 24o 27m 36f 36g 51b 51c 63 64b 71 73 77 101 107 108"
+[ "$SLOW" = "no" ] && EXCEPT="$EXCEPT 24o 27m 36f 36g 51b 51c 63 64b 71 73 101 115"
 
-# Tests that fail on uml, maybe elsewhere, FIXME
+# Tests that fail on uml
 CPU=`awk '/model/ {print $4}' /proc/cpuinfo`
 #                                    buffer i/o errs             sock spc runas
 [ "$CPU" = "UML" ] && EXCEPT="$EXCEPT 27m 27n 27o 27p 27q 27r 31d 54a  64b 99a 99b 99c 99d 99e 99f 101"
 
+# test76 is not valid with FIDs because inode numbers are not reused
+ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
+
 case `uname -r` in
-2.4*) FSTYPE=${FSTYPE:-ext3};    ALWAYS_EXCEPT="$ALWAYS_EXCEPT 76"
-       [ "$CPU" = "UML" ] && ALWAYS_EXCEPT="$ALWAYS_EXCEPT 105a";;
-2.6*) FSTYPE=${FSTYPE:-ldiskfs}; ALWAYS_EXCEPT="$ALWAYS_EXCEPT " ;;
+2.4*) FSTYPE=${FSTYPE:-ext3} ;;
+2.6*) FSTYPE=${FSTYPE:-ldiskfs} ;;
 *) error "unsupported kernel" ;;
 esac
 
@@ -55,6 +59,9 @@ MEMHOG=${MEMHOG:-memhog}
 DIRECTIO=${DIRECTIO:-directio}
 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
 UMOUNT=${UMOUNT:-"umount -d"}
+STRIPES_PER_OBJ=-1
+CHECK_GRANT=${CHECK_GRANT:-"yes"}
+GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 
 if [ $UID -ne 0 ]; then
        echo "Warning: running as non-root uid $UID"
@@ -71,44 +78,36 @@ else
        fi
 fi
 
-SANITYLOG=${SANITYLOG:-/tmp/sanity.log}
-
 export NAME=${NAME:-local}
 
 SAVE_PWD=$PWD
 
+CLEANUP=${CLEANUP:-:}
+SETUP=${SETUP:-:}
+TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-`dirname $0`/..}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+. ${CONFIG:=$LUSTRE/tests/cfg/local.sh}
+
+if $GSS_KRB5; then
+    $RUNAS krb5_login.sh || exit 1
+    $RUNAS -u $(($RUNAS_ID + 1)) krb5_login.sh || exit 1
+fi
+
+SANITYLOG=${TESTSUITELOG:-$TMP/$(basename $0 .sh).log}
+FAIL_ON_ERROR=false
 
 cleanup() {
        echo -n "cln.."
        cleanupall ${FORCE} $* || { echo "FAILed to clean up"; exit 20; }
 }
-CLEANUP=${CLEANUP:-:}
-
 setup() {
        echo -n "mnt.."
         load_modules
        setupall || exit 10
        echo "done"
 }
-SETUP=${SETUP:-:}
-
-log() {
-       echo "$*"
-       $LCTL mark "$*" 2> /dev/null || true
-}
-
-trace() {
-       log "STARTING: $*"
-       strace -o $TMP/$1.strace -ttt $*
-       RC=$?
-       log "FINISHED: $*: rc $RC"
-       return 1
-}
-TRACE=${TRACE:-""}
 
 check_kernel_version() {
        VERSION_FILE=$LPROC/version
@@ -121,114 +120,14 @@ check_kernel_version() {
        return 1
 }
 
-_basetest() {
-    echo $*
-}
-
-basetest() {
-    IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_one() {
-       if ! grep -q $DIR /proc/mounts; then
-               $SETUP
-       fi
-       testnum=$1
-       message=$2
-       BEFORE=`date +%s`
-       log "== test $testnum: $message= `date +%H:%M:%S` ($BEFORE)"
-       export TESTNAME=test_$testnum
-       export tfile=f${testnum}
-       export tdir=d${base}
-       test_${testnum} || error "exit with rc=$?"
-       unset TESTNAME
-       pass "($((`date +%s` - $BEFORE))s)"
-       cd $SAVE_PWD
-       $CLEANUP
-}
-
-build_test_filter() {
-       [ "$ALWAYS_EXCEPT$EXCEPT$SANITY_EXCEPT" ] && \
-           echo "Skipping tests: `echo $ALWAYS_EXCEPT $EXCEPT $SANITY_EXCEPT`"
-
-        for O in $ONLY; do
-            eval ONLY_${O}=true
-        done
-        for E in $EXCEPT $ALWAYS_EXCEPT $SANITY_EXCEPT; do
-            eval EXCEPT_${E}=true
-        done
-}
-
-_basetest() {
-       echo $*
-}
-
-basetest() {
-       IFS=abcdefghijklmnopqrstuvwxyz _basetest $1
-}
-
-run_test() {
-         export base=`basetest $1`
-         if [ "$ONLY" ]; then
-                 testname=ONLY_$1
-                 if [ ${!testname}x != x ]; then
-                       run_one $1 "$2"
-                       return $?
-                 fi
-                 testname=ONLY_$base
-                 if [ ${!testname}x != x ]; then
-                         run_one $1 "$2"
-                         return $?
-                 fi
-                 echo -n "."
-                 return 0
-       fi
-        testname=EXCEPT_$1
-        if [ ${!testname}x != x ]; then
-                 echo "skipping excluded test $1"
-                 return 0
-        fi
-        testname=EXCEPT_$base
-        if [ ${!testname}x != x ]; then
-                 echo "skipping excluded test $1 (base $base)"
-                 return 0
-        fi
-        run_one $1 "$2"
-       return $?
-}
+if [ "$ONLY" == "cleanup" ]; then
+       sh llmountcleanup.sh
+       exit 0
+fi
 
 [ "$SANITYLOG" ] && rm -f $SANITYLOG || true
 
-error() { 
-       sysctl -w lustre.fail_loc=0
-       log "$0: FAIL: $TESTNAME $@"
-       $LCTL dk $TMP/lustre-log-$TESTNAME.log
-       if [ "$SANITYLOG" ]; then
-               echo "$0: FAIL: $TESTNAME $@" >> $SANITYLOG
-       else
-               exit 1
-       fi
-       sysctl -w lustre.fail_loc=0
-}
-
-pass() { 
-       echo PASS $@
-}
-
-mounted_lustre_filesystems() {
-       awk '($3 ~ "lustre" && $1 ~ ":") { print $2 }' /proc/mounts
-}
-
-MOUNTED="`mounted_lustre_filesystems`"
-if [ -z "$MOUNTED" ]; then
-        formatall
-       setupall
-       MOUNTED="`mounted_lustre_filesystems`"
-       [ -z "$MOUNTED" ] && error "NAME=$NAME not mounted"
-       I_MOUNTED=yes
-fi
-
-[ `echo $MOUNT | wc -w` -gt 1 ] && error "NAME=$NAME mounted more than once"
+check_and_setup_lustre
 
 DIR=${DIR:-$MOUNT}
 [ -z "`echo $DIR | grep $MOUNT`" ] && echo "$DIR not in $MOUNT" && exit 99
@@ -239,7 +138,6 @@ STRIPECOUNT=`cat $LPROC/lov/$LOVNAME/stripecount`
 STRIPESIZE=`cat $LPROC/lov/$LOVNAME/stripesize`
 ORIGFREE=`cat $LPROC/lov/$LOVNAME/kbytesavail`
 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
-MDS=$(\ls $LPROC/mds 2> /dev/null | grep -v num_refs | tail -n 1)
 
 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
 [ -f $DIR/d52b/foo ] && chattr -i $DIR/d52b/foo
@@ -247,6 +145,11 @@ rm -rf $DIR/[Rdfs][1-9]*
 
 build_test_filter
 
+if [ "${ONLY}" = "MOUNT" ] ; then 
+       echo "Lustre is up, please go on"
+       exit
+fi
+
 echo "preparing for tests involving mounts"
 EXT2_DEV=${EXT2_DEV:-$TMP/SANITY.LOOP}
 touch $EXT2_DEV
@@ -272,6 +175,7 @@ run_test 0b "chmod 0755 $DIR ============================="
 test_1a() {
        mkdir $DIR/d1
        mkdir $DIR/d1/d2
+       mkdir $DIR/d1/d2 && error "we expect EEXIST, but not returned"
        $CHECKSTAT -t dir $DIR/d1/d2 || error
 }
 run_test 1a "mkdir .../d1; mkdir .../d1/d2 ====================="
@@ -348,7 +252,7 @@ test_6a() {
 run_test 6a "touch .../f6a; chmod .../f6a ======================"
 
 test_6b() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        if [ ! -f $DIR/f6a ]; then
                touch $DIR/f6a
                chmod 0666 $DIR/f6a
@@ -359,7 +263,7 @@ test_6b() {
 run_test 6b "$RUNAS chmod .../f6a (should return error) =="
 
 test_6c() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        touch $DIR/f6c
        chown $RUNAS_ID $DIR/f6c || error
        $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/f6c || error
@@ -367,7 +271,7 @@ test_6c() {
 run_test 6c "touch .../f6c; chown .../f6c ======================"
 
 test_6d() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        if [ ! -f $DIR/f6c ]; then
                touch $DIR/f6c
                chown $RUNAS_ID $DIR/f6c
@@ -378,7 +282,7 @@ test_6d() {
 run_test 6d "$RUNAS chown .../f6c (should return error) =="
 
 test_6e() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        touch $DIR/f6e
        chgrp $RUNAS_ID $DIR/f6e || error
        $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/f6e || error
@@ -386,7 +290,7 @@ test_6e() {
 run_test 6e "touch .../f6e; chgrp .../f6e ======================"
 
 test_6f() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        if [ ! -f $DIR/f6e ]; then
                touch $DIR/f6e
                chgrp $RUNAS_ID $DIR/f6e
@@ -397,7 +301,7 @@ test_6f() {
 run_test 6f "$RUNAS chgrp .../f6e (should return error) =="
 
 test_6g() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
         mkdir $DIR/d6g || error
         chmod 777 $DIR/d6g || error
         $RUNAS mkdir $DIR/d6g/d || error
@@ -408,7 +312,7 @@ test_6g() {
 run_test 6g "Is new dir in sgid dir inheriting group?"
 
 test_6h() { # bug 7331
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        touch $DIR/f6h || error "touch failed"
        chown $RUNAS_ID:$RUNAS_ID $DIR/f6h || error "initial chown failed"
        $RUNAS -G$RUNAS_ID chown $RUNAS_ID:0 $DIR/f6h && error "chown worked"
@@ -546,6 +450,18 @@ test_17d() {
 }
 run_test 17d "symlinks: create dangling ========================"
 
+test_17f() {
+       mkdir -p $DIR/d17f
+       ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/d17f/111
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/d17f/222
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/d17f/333
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/d17f/444
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/d17f/555
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/d17f/666
+       ls -l  $DIR/d17f
+}
+run_test 17f "symlinks: long and very long symlink name ========================"
+
 test_18() {
        touch $DIR/f
        ls $DIR || error
@@ -566,7 +482,7 @@ test_19b() {
 run_test 19b "ls -l .../f19 (should return error) =============="
 
 test_19c() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        $RUNAS touch $DIR/f19 && error || true
 }
 run_test 19c "$RUNAS touch .../f19 (should return error) =="
@@ -602,15 +518,15 @@ test_21() {
 run_test 21 "write to dangling link ============================"
 
 test_22() {
-       mkdir $DIR/d22
-       chown $RUNAS_ID $DIR/d22
-       # Tar gets pissy if it can't access $PWD *sigh*
-       (cd $TMP || error "cd $TMP failed";
+       WDIR=$DIR/$tdir
+       mkdir $WDIR
+       chown $RUNAS_ID $WDIR
+       (cd $WDIR || error "cd $WDIR failed";
        $RUNAS tar cf - /etc/hosts /etc/sysconfig/network | \
-       $RUNAS tar xfC - $DIR/d22)
-       ls -lR $DIR/d22/etc || error "ls -lR $DIR/d22/etc failed"
-       $CHECKSTAT -t dir $DIR/d22/etc || error "checkstat -t dir failed"
-       $CHECKSTAT -u \#$RUNAS_ID $DIR/d22/etc || error "checkstat -u failed"
+       $RUNAS tar xf -)
+       ls -lR $WDIR/etc || error "ls -lR $WDIR/etc failed"
+       $CHECKSTAT -t dir $WDIR/etc || error "checkstat -t dir failed"
+       $CHECKSTAT -u \#$RUNAS_ID $WDIR/etc || error "checkstat -u failed"
 }
 run_test 22 "unpack tar archive as non-root user ==============="
 
@@ -684,7 +600,7 @@ test_24g() {
        $CHECKSTAT -a $DIR/R7a/d || error
        $CHECKSTAT -t dir $DIR/R7b/e || error
 }
-run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R5b/e ======"
+run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
 
 test_24h() {
        mkdir $DIR/R8{a,b}
@@ -720,8 +636,8 @@ test_24k() {
        mkdir $DIR/R11a $DIR/R11a/d
        touch $DIR/R11a/f
        mv $DIR/R11a/f $DIR/R11a/d
-       $CHECKSTAT -a $DIR/R11a/f || error
-       $CHECKSTAT -t file $DIR/R11a/d/f || error
+        $CHECKSTAT -a $DIR/R11a/f || error
+        $CHECKSTAT -t file $DIR/R11a/d/f || error
 }
 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
 
@@ -811,6 +727,12 @@ test_24t() {
 }
 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
 
+test_24u() { # bug12192
+        multiop $DIR/$tfile C2w$((2048 * 1024))c || error
+        $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
+}
+run_test 24u "create stripe file"
+
 test_25a() {
        echo '== symlink sanity ============================================='
 
@@ -886,13 +808,13 @@ test_27a() {
        $SETSTRIPE $DIR/d27/f0 65536 0 1 || error "lstripe failed"
        $CHECKSTAT -t file $DIR/d27/f0 || error "checkstat failed"
        pass
-       log "== test_27b: write to one stripe file ========================="
+       log "== test_27a: write to one stripe file ========================="
        cp /etc/hosts $DIR/d27/f0 || error
 }
 run_test 27a "one stripe file =================================="
 
 test_27c() {
-       [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        mkdir -p $DIR/d27
        $SETSTRIPE $DIR/d27/f01 65536 0 2 || error "lstripe failed"
        [ `$GETSTRIPE $DIR/d27/f01 | grep -A 10 obdidx | wc -l` -eq 4 ] ||
@@ -969,9 +891,9 @@ test_27l() {
 run_test 27l "check setstripe permissions (should return error)"
 
 test_27m() {
-       [ "$OSTCOUNT" -lt "2" ] && echo "skipping out-of-space test on OST0" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
        if [ $ORIGFREE -gt $MAXFREE ]; then
-               echo "skipping out-of-space test on OST0"
+               skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
                return
        fi
        mkdir -p $DIR/d27
@@ -992,6 +914,7 @@ test_27m() {
        [ `$GETSTRIPE $DIR/d27/f27m_$i | grep -A 10 obdidx | awk '{print $1}'| grep -w "0"` ] && \
                error "OST0 was full but new created file still use it"
        rm -r $DIR/d27
+       sleep 15
 }
 run_test 27m "create file while OST0 was full =================="
 
@@ -1008,16 +931,17 @@ exhaust_precreations() {
        OST=$(grep ${OSTIDX}": " $LPROC/lov/${LOVNAME}/target_obd | \
            awk '{print $2}' | sed -e 's/_UUID$//')
        # on the mdt's osc
-       last_id=$(cat $LPROC/osc/${OST}-osc/prealloc_last_id)
-       next_id=$(cat $LPROC/osc/${OST}-osc/prealloc_next_id)
+        OSC=$(ls $LPROC/osc | grep "${OST}-osc-MDT0000")
+        last_id=$(cat $LPROC/osc/${OSC}/prealloc_last_id)
+       next_id=$(cat $LPROC/osc/${OSC}/prealloc_next_id)
 
-       mkdir -p $DIR/d27/${OST}
+        mkdir -p $DIR/d27/${OST}
        $SETSTRIPE $DIR/d27/${OST} 0 $OSTIDX 1
 #define OBD_FAIL_OST_ENOSPC              0x215
        sysctl -w lustre.fail_loc=0x215
        echo "Creating to objid $last_id on ost $OST..."
        createmany -o $DIR/d27/${OST}/f $next_id $((last_id - next_id + 2))
-       grep '[0-9]' $LPROC/osc/${OST}-osc/prealloc*
+       grep '[0-9]' $LPROC/osc/${OSC}/prealloc*
        reset_enospc $2
 }
 
@@ -1030,8 +954,8 @@ exhaust_all_precreations() {
 }
 
 test_27n() {
-       [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && \
-               echo "skip $TESTNAME for remote MDS or OST count" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        reset_enospc
        rm -f $DIR/d27/f27n
@@ -1044,7 +968,8 @@ test_27n() {
 run_test 27n "create file with some full OSTs =================="
 
 test_27o() {
-       [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        reset_enospc
        rm -f $DIR/d27/f27o
@@ -1054,11 +979,13 @@ test_27o() {
        touch $DIR/d27/f27o && error "able to create $DIR/d27/f27o"
 
        reset_enospc
+       rm -rf $DIR/d27/*
 }
 run_test 27o "create file with all full OSTs (should error) ===="
 
 test_27p() {
-       [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        reset_enospc
        rm -f $DIR/d27/f27p
@@ -1076,7 +1003,8 @@ test_27p() {
 run_test 27p "append to a truncated file with some full OSTs ==="
 
 test_27q() {
-       [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        reset_enospc
        rm -f $DIR/d27/f27q
@@ -1095,7 +1023,8 @@ test_27q() {
 run_test 27q "append to truncated file with all OSTs full (should error) ==="
 
 test_27r() {
-       [ "$OSTCOUNT" -lt "2" -o -z "$MDS" ] && echo "skipping $TESTNAME" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        reset_enospc
        rm -f $DIR/d27/f27r
@@ -1108,9 +1037,9 @@ test_27r() {
 run_test 27r "stripe file with some full OSTs (shouldn't LBUG) ="
 
 test_27s() { # bug 10725
-       mkdir -p $DIR/$tdir
-       $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
-               error "stripe width >= 2^32 succeeded" || true
+       mkdir -p $DIR/$tdir
+       $LSTRIPE $DIR/$tdir $((2048 * 1024 * 1024)) -1 2 && \
+               error "stripe width >= 2^32 succeeded" || true
 }
 run_test 27s "lsm_xfersize overflow (should error) (bug 10725)"
 
@@ -1124,13 +1053,59 @@ test_27t() { # bug 10864
 }
 run_test 27t "check that utils parse path correctly"
 
-test_27x() { # bug 10997
+test_27u() { # bug 4900
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
+
+        #define OBD_FAIL_MDS_OSC_PRECREATE      0x13d
+
+        sysctl -w lustre.fail_loc=0x13d
+        mkdir -p $DIR/d27u
+        createmany -o $DIR/d27u/t- 1000
+        sysctl -w lustre.fail_loc=0
+
+        $LFS getstripe $DIR/d27u > $TMP/files
+        OBJS=`cat $TMP/files | awk -vobjs=0 '($1 == 0) { objs += 1 } END { print objs;}'`
+        unlinkmany $DIR/d27u/t- 1000
+        [ $OBJS -gt 0 ] && \
+                error "Found $OBJS objects were created on OST-0" || pass
+}
+run_test 27u "skip object creation on OSC w/o objects =========="
+
+test_27v() { # bug 4900
+       [ "$OSTCOUNT" -lt "2" ] && skip "too few OSTs" && return
+       remote_mds && skip "remote MDS" && return
+
+        exhaust_all_precreations
+
+        mkdir -p $DIR/$tdir
+        lfs setstripe $DIR/$tdir 0 -1 1         # 1 stripe / file
+
+        touch $DIR/$tdir/$tfile
+        #define OBD_FAIL_TGT_DELAY_PRECREATE     0x705
+        sysctl -w lustre.fail_loc=0x705
+        START=`date +%s`
+        for F in `seq 1 32`; do
+                touch $DIR/$tdir/$tfile.$F
+        done
+        sysctl -w lustre.fail_loc=0
+
+        FINISH=`date +%s`
+        TIMEOUT=`sysctl -n lustre.timeout`
+        [ $((FINISH - START)) -ge $((TIMEOUT / 2)) ] && \
+               error "$FINISH - $START >= $TIMEOUT / 2"
+
+        reset_enospc
+}
+run_test 27v "skip object creation on slow OST ================="
+
+test_27w() { # bug 10997
         mkdir -p $DIR/d27w || error "mkdir failed"
         $LSTRIPE $DIR/d27w/f0 -s 65536 || error "lstripe failed"
         size=`$LSTRIPEINFO $DIR/d27w/f0 | awk {'print $1'}`
         [ $size -ne 65536 ] && error "stripe size $size != 65536" || true
 
-        [ "$OSTCOUNT" -lt "2" ] && echo "skipping multiple stripe count/offset test" && return
+        [ "$OSTCOUNT" -lt "2" ] && skip "skipping multiple stripe count/offset test" && return
         for i in `seq 1 $OSTCOUNT`; do
                 offset=$(($i-1))
                 $LSTRIPE $DIR/d27w/f$i -c $i -i $offset || error "lstripe -c $i -i $offset failed"
@@ -1140,7 +1115,7 @@ test_27x() { # bug 10997
                 [ $index -ne $offset ] && error "stripe offset $index != $offset" || true
         done
 }
-run_test 27x "check lfs setstripe -c -s -i options ============="
+run_test 27w "check lfs setstripe -c -s -i options ============="
 
 test_28() {
        mkdir $DIR/d28
@@ -1154,7 +1129,7 @@ test_29() {
        touch $DIR/d29/foo
        log 'first d29'
        ls -l $DIR/d29
-       MDCDIR=${MDCDIR:-`find $LPROC/ldlm/namespaces | grep mdc | head -1`}
+       MDCDIR=${MDCDIR:-$LPROC/ldlm/namespaces/*-mdc-*}
        LOCKCOUNTORIG=`cat $MDCDIR/lock_count`
        LOCKUNUSEDCOUNTORIG=`cat $MDCDIR/lock_unused_count`
        [ -z $"LOCKCOUNTORIG" ] && echo "No mdc lock count" && return 1
@@ -1180,7 +1155,7 @@ test_29() {
 run_test 29 "IT_GETATTR regression  ============================"
 
 test_30() {
-       cp `which ls` $DIR
+       cp `which ls` $DIR || cp /bin/ls $DIR
        $DIR/ls /
        rm $DIR/ls
 }
@@ -1258,6 +1233,87 @@ test_31f() { # bug 4554
 }
 run_test 31f "remove of open directory with open-unlink file ==="
 
+test_31g() {
+        echo "-- cross directory link --"
+        mkdir $DIR/d31g{a,b}
+        touch $DIR/d31ga/f
+        ln $DIR/d31ga/f $DIR/d31gb/g
+        $CHECKSTAT -t file $DIR/d31ga/f || error "source"
+        [ `stat -c%h $DIR/d31ga/f` == '2' ] || error "source nlink"
+        $CHECKSTAT -t file $DIR/d31gb/g || error "target"
+        [ `stat -c%h $DIR/d31gb/g` == '2' ] || error "target nlink"
+}
+run_test 31g "cross directory link==============="
+
+test_31h() {
+        echo "-- cross directory link --"
+        mkdir $DIR/d31h
+        mkdir $DIR/d31h/dir
+        touch $DIR/d31h/f
+        ln $DIR/d31h/f $DIR/d31h/dir/g
+        $CHECKSTAT -t file $DIR/d31h/f || error "source"
+        [ `stat -c%h $DIR/d31h/f` == '2' ] || error "source nlink"
+        $CHECKSTAT -t file $DIR/d31h/dir/g || error "target"
+        [ `stat -c%h $DIR/d31h/dir/g` == '2' ] || error "target nlink"
+}
+run_test 31h "cross directory link under child==============="
+
+test_31i() {
+        echo "-- cross directory link --"
+        mkdir $DIR/d31i
+        mkdir $DIR/d31i/dir
+        touch $DIR/d31i/dir/f
+        ln $DIR/d31i/dir/f $DIR/d31i/g
+        $CHECKSTAT -t file $DIR/d31i/dir/f || error "source"
+        [ `stat -c%h $DIR/d31i/dir/f` == '2' ] || error "source nlink"
+        $CHECKSTAT -t file $DIR/d31i/g || error "target"
+        [ `stat -c%h $DIR/d31i/g` == '2' ] || error "target nlink"
+}
+run_test 31i "cross directory link under parent==============="
+
+
+test_31j() {
+        mkdir $DIR/d31j
+        mkdir $DIR/d31j/dir1
+        ln $DIR/d31j/dir1 $DIR/d31j/dir2 && error "ln for dir"
+        link $DIR/d31j/dir1 $DIR/d31j/dir3 && error "link for dir"
+        mlink $DIR/d31j/dir1 $DIR/d31j/dir4 && error "mlink for dir"
+        mlink $DIR/d31j/dir1 $DIR/d31j/dir1 && error "mlink to the same dir"
+       return 0
+}
+run_test 31j "link for directory==============="
+
+
+test_31k() {
+        mkdir $DIR/d31k
+        touch $DIR/d31k/s
+        touch $DIR/d31k/exist
+        mlink $DIR/d31k/s $DIR/d31k/t || error "mlink"
+        mlink $DIR/d31k/s $DIR/d31k/exist && error "mlink to exist file"
+        mlink $DIR/d31k/s $DIR/d31k/s && error "mlink to the same file"
+        mlink $DIR/d31k/s $DIR/d31k && error "mlink to parent dir"
+        mlink $DIR/d31k $DIR/d31k/s && error "mlink parent dir to target"
+        mlink $DIR/d31k/not-exist $DIR/d31k/foo && error "mlink non-existing to new"
+        mlink $DIR/d31k/not-exist $DIR/d31k/s && error "mlink non-existing to exist"
+       return 0
+}
+run_test 31k "link to file: the same, non-existing, dir==============="
+
+test_31m() {
+        mkdir $DIR/d31m
+        touch $DIR/d31m/s
+        mkdir $DIR/d31m2
+        touch $DIR/d31m2/exist
+        mlink $DIR/d31m/s $DIR/d31m2/t || error "mlink"
+        mlink $DIR/d31m/s $DIR/d31m2/exist && error "mlink to exist file"
+        mlink $DIR/d31m/s $DIR/d31m2 && error "mlink to parent dir"
+        mlink $DIR/d31m2 $DIR/d31m/s && error "mlink parent dir to target"
+        mlink $DIR/d31m/not-exist $DIR/d31m2/foo && error "mlink non-existing to new"
+        mlink $DIR/d31m/not-exist $DIR/d31m2/s && error "mlink non-existing to exist"
+       return 0
+}
+run_test 31m "link to file: the same, non-existing, dir==============="
+
 test_32a() {
        echo "== more mountpoints and symlinks ================="
        [ -e $DIR/d32a ] && rm -fr $DIR/d32a
@@ -1582,7 +1638,7 @@ test_36d() {
 run_test 36d "non-root OST utime check (open, utime) ==========="
 
 test_36e() {
-       [ $RUNAS_ID -eq $UID ] && echo "skipping $TESTNAME" && return
+       [ $RUNAS_ID -eq $UID ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
        mkdir -p $DIR/$tdir
        touch $DIR/$tdir/$tfile
        $RUNAS utime $DIR/$tdir/$tfile && \
@@ -1614,9 +1670,9 @@ test_36f() {
 }
 run_test 36f "utime on file racing with OST BRW write =========="
 
-export FMD_MAX_AGE=`cat $LPROC/obdfilter/*/client_cache_seconds 2> /dev/null | head -n 1`
+export FMD_MAX_AGE=`do_facet ost1 cat $LPROC/obdfilter/*/client_cache_seconds | head -n 1`
 test_36g() {
-       [ -z "$FMD_MAX_AGE" ] && echo "skip $TESTNAME for remote OST" && return
+       [ -z "$FMD_MAX_AGE" ] && skip "skip test for remote OST" && return
        FMD_BEFORE="`awk '/ll_fmd_cache/ { print $2 }' /proc/slabinfo`"
        touch $DIR/d36/$tfile
        sleep $((FMD_MAX_AGE + 12))
@@ -1682,17 +1738,25 @@ count_ost_writes() {
 
 # decent default
 WRITEBACK_SAVE=500
+DIRTY_RATIO_SAVE=40
+MAX_DIRTY_RATIO=50
+BG_DIRTY_RATIO_SAVE=10
+MAX_BG_DIRTY_RATIO=25
 
 start_writeback() {
        trap 0
-       # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs
+       # in 2.6, restore /proc/sys/vm/dirty_writeback_centisecs,
+       # dirty_ratio, dirty_background_ratio
        if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
                echo $WRITEBACK_SAVE > /proc/sys/vm/dirty_writeback_centisecs
+               echo $BG_DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_background_ratio
+               echo $DIRTY_RATIO_SAVE > /proc/sys/vm/dirty_ratio
        else
                # if file not here, we are a 2.4 kernel
                kill -CONT `pidof kupdated`
        fi
 }
+
 stop_writeback() {
        # setup the trap first, so someone cannot exit the test at the
        # exact wrong time and mess up a machine
@@ -1701,6 +1765,13 @@ stop_writeback() {
        if [ -f /proc/sys/vm/dirty_writeback_centisecs ]; then
                WRITEBACK_SAVE=`cat /proc/sys/vm/dirty_writeback_centisecs`
                echo 0 > /proc/sys/vm/dirty_writeback_centisecs
+               echo 0 > /proc/sys/vm/dirty_writeback_centisecs
+               # save and increase /proc/sys/vm/dirty_ratio
+               DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_ratio`
+               echo $MAX_DIRTY_RATIO > /proc/sys/vm/dirty_ratio
+               # save and increase /proc/sys/vm/dirty_background_ratio
+               BG_DIRTY_RATIO_SAVE=`cat /proc/sys/vm/dirty_background_ratio`
+               echo $MAX_BG_DIRTY_RATIO > /proc/sys/vm/dirty_background_ratio
        else
                # if file not here, we are a 2.4 kernel
                kill -STOP `pidof kupdated`
@@ -1725,8 +1796,8 @@ test_42a() {
        stop_writeback
        sync; sleep 1; sync # just to be safe
        BEFOREWRITES=`count_ost_writes`
-       grep "[0-9]" $LPROC/osc/*[oO][sS][cC]*/cur_grant_bytes
-       dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
+        grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur_grant_bytes
+        dd if=/dev/zero of=$DIR/f42a bs=1024 count=100
        AFTERWRITES=`count_ost_writes`
        [ $BEFOREWRITES -eq $AFTERWRITES ] || \
                error "$BEFOREWRITES < $AFTERWRITES"
@@ -1809,15 +1880,15 @@ run_test 42d "test complete truncate of file with cached dirty data"
 test_43() {
        mkdir $DIR/$tdir
        cp -p /bin/ls $DIR/$tdir/$tfile
-       exec 100>> $DIR/$tdir/$tfile
+       exec 9>> $DIR/$tdir/$tfile
        $DIR/$tdir/$tfile && error || true
-       exec 100<&-
+       exec 9<&-
 }
 run_test 43 "execution of file opened for write should return -ETXTBSY"
 
 test_43a() {
         mkdir -p $DIR/d43
-       cp -p `which multiop` $DIR/d43/multiop
+       cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
         $DIR/d43/multiop $TMP/test43.junk O_c &
         MULTIPID=$!
         sleep 1
@@ -1830,7 +1901,7 @@ run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
 
 test_43b() {
         mkdir -p $DIR/d43
-       cp -p `which multiop` $DIR/d43/multiop
+       cp -p `which multiop` $DIR/d43/multiop || cp -p multiop $DIR/d43/multiop
         $DIR/d43/multiop $TMP/test43.junk O_c &
         MULTIPID=$!
         sleep 1
@@ -1851,40 +1922,43 @@ test_43c() {
 run_test 43c "md5sum of copy into lustre========================"
 
 test_44() {
-       [  "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
+       [  "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
-       dd if=$DIR/f1 bs=4k count=1
+       dd if=$DIR/f1 bs=4k count=1 > /dev/null
 }
 run_test 44 "zero length read from a sparse stripe ============="
 
 test_44a() {
     local nstripe=`$LCTL lov_getconfig $DIR | grep default_stripe_count: | \
                          awk '{print $2}'`
+    [ -z "$nstripe" ] && skip "can't get stripe info" && return
+    [ "$nstripe" -gt "$OSTCOUNT" ] && skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" && return
     local stride=`$LCTL lov_getconfig $DIR | grep default_stripe_size: | \
                       awk '{print $2}'`
-    if [ $nstripe -eq 0 ] ; then
+    if [ $nstripe -eq 0 -o $nstripe -gt 1024 ] ; then
         nstripe=`$LCTL lov_getconfig $DIR | grep obd_count: | awk '{print $2}'`
     fi
-    [ -z "$nstripe" ] && error "can't get stripe info"
 
     OFFSETS="0 $((stride/2)) $((stride-1))"
     for offset in $OFFSETS ; do
       for i in `seq 0 $((nstripe-1))`; do
-        rm -f $DIR/d44a
         local GLOBALOFFSETS=""
         local size=$((((i + 2 * $nstripe )*$stride + $offset)))  # Bytes
-        ll_sparseness_write $DIR/d44a $size  || error "ll_sparseness_write"
+       local myfn=$DIR/d44a-$size
+       echo "--------writing $myfn at $size"
+        ll_sparseness_write $myfn $size  || error "ll_sparseness_write"
         GLOBALOFFSETS="$GLOBALOFFSETS $size"
-        ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
+        ll_sparseness_verify $myfn $GLOBALOFFSETS \
                             || error "ll_sparseness_verify $GLOBALOFFSETS"
 
         for j in `seq 0 $((nstripe-1))`; do
             size=$((((j + $nstripe )*$stride + $offset)))  # Bytes
-            ll_sparseness_write $DIR/d44a $size || error "ll_sparseness_write"
+            ll_sparseness_write $myfn $size || error "ll_sparseness_write"
             GLOBALOFFSETS="$GLOBALOFFSETS $size"
         done
-        ll_sparseness_verify $DIR/d44a $GLOBALOFFSETS \
+        ll_sparseness_verify $myfn $GLOBALOFFSETS \
                             || error "ll_sparseness_verify $GLOBALOFFSETS"
+       rm -f $myfn
       done
     done
 }
@@ -1965,8 +2039,8 @@ test_48a() { # bug 2399
                touch .foo || error "'touch .foo' failed after recreating cwd"
                mkdir .bar || error "'mkdir .foo' failed after recreating cwd"
        fi
-       ls . || error "'ls .' failed after recreating cwd"
-       ls .. || error "'ls ..' failed after removing cwd"
+       ls . > /dev/null || error "'ls .' failed after recreating cwd"
+       ls .. > /dev/null || error "'ls ..' failed after removing cwd"
        cd . || error "'cd .' failed after recreating cwd"
        mkdir . && error "'mkdir .' worked after recreating cwd"
        rmdir . && error "'rmdir .' worked after recreating cwd"
@@ -1986,9 +2060,9 @@ test_48b() { # bug 2399
                touch .foo && error "'touch .foo' worked after removing cwd"
                mkdir .foo && error "'mkdir .foo' worked after removing cwd"
        fi
-       ls . && error "'ls .' worked after removing cwd"
-       ls .. || error "'ls ..' failed after removing cwd"
-       cd . && error "'cd .' worked after removing cwd"
+       ls . > /dev/null && error "'ls .' worked after removing cwd"
+       ls .. > /dev/null || error "'ls ..' failed after removing cwd"
+       is_patchless || ( cd . && error "'cd .' worked after removing cwd" )
        mkdir . && error "'mkdir .' worked after removing cwd"
        rmdir . && error "'rmdir .' worked after removing cwd"
        ln -s . foo && error "'ln -s .' worked after removing cwd"
@@ -2011,7 +2085,7 @@ test_48c() { # bug 2350
        fi
        $TRACE ls . && error "'ls .' worked after removing cwd"
        $TRACE ls .. || error "'ls ..' failed after removing cwd"
-       $TRACE cd . && error "'cd .' worked after removing cwd"
+       is_patchless || ( $TRACE cd . && error "'cd .' worked after removing cwd" )
        $TRACE mkdir . && error "'mkdir .' worked after removing cwd"
        $TRACE rmdir . && error "'rmdir .' worked after removing cwd"
        $TRACE ln -s . foo && error "'ln -s .' worked after removing cwd"
@@ -2035,11 +2109,11 @@ test_48d() { # bug 2350
        fi
        $TRACE ls . && error "'ls .' worked after removing parent"
        $TRACE ls .. && error "'ls ..' worked after removing parent"
-       $TRACE cd . && error "'cd .' worked after recreate parent"
+       is_patchless || ( $TRACE cd . && error "'cd .' worked after recreate parent" )
        $TRACE mkdir . && error "'mkdir .' worked after removing parent"
        $TRACE rmdir . && error "'rmdir .' worked after removing parent"
        $TRACE ln -s . foo && error "'ln -s .' worked after removing parent"
-       $TRACE cd .. && error "'cd ..' worked after removing parent" || true
+       is_patchless || ( $TRACE cd .. && error "'cd ..' worked after removing parent" || true )
 }
 run_test 48d "Access removed parent subdir (should return errors)"
 
@@ -2086,11 +2160,14 @@ test_51() {
 }
 run_test 51 "special situations: split htree with empty entry =="
 
-export NUMTEST=70000
+#export NUMTEST=70000
+# FIXME: I select a relatively small number to do basic test.
+# large number may give panic(). debugging on this is going on.
+export NUMTEST=70
 test_51b() {
        NUMFREE=`df -i -P $DIR | tail -n 1 | awk '{ print $4 }'`
        [ $NUMFREE -lt 21000 ] && \
-               echo "skipping $TESTNAME, not enough free inodes ($NUMFREE)" && \
+               skip "not enough free inodes ($NUMFREE)" && \
                return
 
        check_kernel_version 40 || NUMTEST=31000
@@ -2102,7 +2179,7 @@ test_51b() {
 run_test 51b "mkdir .../t-0 --- .../t-$NUMTEST ===================="
 
 test_51c() {
-       [ ! -d $DIR/d51b ] && echo "skipping $TESTNAME: $DIR/51b missing" && \
+       [ ! -d $DIR/d51b ] && skip "$DIR/51b missing" && \
                return
 
        unlinkmany -d $DIR/d51b/t- $NUMTEST
@@ -2110,7 +2187,7 @@ test_51c() {
 run_test 51c "rmdir .../t-0 --- .../t-$NUMTEST ===================="
 
 test_51d() {
-        [  "$OSTCOUNT" -lt "3" ] && echo "skipping test with few OSTs" && return
+        [  "$OSTCOUNT" -lt "3" ] && skip "skipping test with few OSTs" && return
         mkdir -p $DIR/d51d
         createmany -o $DIR/d51d/t- 1000
         $LFS getstripe $DIR/d51d > $TMP/files
@@ -2176,9 +2253,10 @@ test_52b() {
 run_test 52b "immutable flag test (should return errors) ======="
 
 test_53() {
-       [ -z "$MDS" ] && echo "skipping $TESTNAME with remote MDS" && return
-       
-        for i in `ls -d $LPROC/osc/*-osc 2> /dev/null` ; do
+       remote_mds && skip "remote MDS" && return
+
+       # only test MDT0000 
+        for i in `ls -d $LPROC/osc/*-osc-MDT0000 2> /dev/null` ; do
                 ostname=`basename $i | cut -d - -f 1-2`
                 ost_last=`cat $LPROC/obdfilter/$ostname/last_id`
                 mds_last=`cat $i/prealloc_last_id`
@@ -2191,8 +2269,8 @@ test_53() {
 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
 
 test_54a() {
-        [ ! -f "$SOCKETSERVER" ] && echo "no socketserver, skipping" && return
-        [ ! -f "$SOCKETCLIENT" ] && echo "no socketclient, skipping" && return
+        [ ! -f "$SOCKETSERVER" ] && skip "no socketserver, skipping" && return
+        [ ! -f "$SOCKETCLIENT" ] && skip "no socketclient, skipping" && return
        $SOCKETSERVER $DIR/socket
        $SOCKETCLIENT $DIR/socket || error
        $MUNLINK $DIR/socket
@@ -2274,7 +2352,7 @@ check_fstype() {
 test_55() {
         rm -rf $DIR/d55
         mkdir $DIR/d55
-        check_fstype && echo "can't find fs $FSTYPE, skipping $TESTNAME" && return
+        check_fstype && skip "can't find fs $FSTYPE" && return
         mount -t $FSTYPE -o loop,iopen $EXT2_DEV $DIR/d55 || error "mounting"
         touch $DIR/d55/foo
         $IOPENTEST1 $DIR/d55/foo $DIR/d55 || error "running $IOPENTEST1"
@@ -2324,7 +2402,7 @@ test_56() {
                 error "lfs getstripe --obd wrong_uuid should return error message"
 
         [  "$OSTCOUNT" -lt 2 ] && \
-                echo "skipping other lfs getstripe --obd test" && return
+                skip "skipping other lfs getstripe --obd test" && return
         FILENUM=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[  ]*1[    ]/p' | wc -l`
         OBDUUID=`$GETSTRIPE --recursive $DIR/d56 | sed -n '/^[  ]*1:/p' | awk '{print $2}'`
         FOUND=`$GETSTRIPE -r --obd $OBDUUID $DIR/d56 | wc -l`
@@ -2388,8 +2466,19 @@ test_56h() {
 }
 run_test 56h "check lfs find ! -name ============================="
 
+test_56i() {
+       tdir=${tdir}i
+       mkdir -p $DIR/$tdir
+       UUID=`$GETSTRIPE $DIR/$tdir | awk '/0: / { print $2 }'`
+       OUT="`$LFIND -ost $UUID $DIR/$tdir`"
+       [ "$OUT" ] && error "$LFIND returned directory '$OUT'" || true
+}
+run_test 56i "check 'lfs find -ost UUID' skips directories ======="
+
 test_57a() {
-       [ -z "$MDS" ] && echo "skipping $TESTNAME for remote MDS" && return
+       # note test will not do anything if MDS is not local
+       remote_mds && skip "remote MDS" && return
+
        for DEV in `cat $LPROC/mds/*/mntdev`; do
                dumpe2fs -h $DEV > $TMP/t57a.dump || error "can't access $DEV"
                DEVISIZE=`awk '/Inode size:/ { print $3 }' $TMP/t57a.dump`
@@ -2425,22 +2514,22 @@ test_57b() {
        $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
 
        sleep 1 # make sure we get new statfs data
-       MDSFREE2="`cat $LPROC/mds/*/kbytesfree 2> /dev/null`"
-       MDCFREE2="`cat $LPROC/mdc/*/kbytesfree | head -n 1`"
-       if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
-               if [ "$MDSFREE" != "$MDSFREE2" ]; then
-                       error "MDC before $MDCFREE != after $MDCFREE2"
-               else
-                       echo "MDC before $MDCFREE != after $MDCFREE2"
-                       echo "unable to confirm if MDS has large inodes"
-               fi
-       fi
+#      MDSFREE2="`cat $LPROC/mds/*/kbytesfree`"
+#      MDCFREE2="`cat $LPROC/mdc/*/kbytesfree`"
+#      if [ "$MDCFREE2" -lt "$((MDCFREE - 8))" ]; then
+#              if [ "$MDSFREE" != "$MDSFREE2" ]; then
+#                      error "MDC before $MDCFREE != after $MDCFREE2"
+#              else
+#                      echo "MDC before $MDCFREE != after $MDCFREE2"
+#                      echo "unable to confirm if MDS has large inodes"
+#              fi
+#      fi
        rm -rf $DIR/d57b
 }
 run_test 57b "default LOV EAs are stored inside large inodes ==="
 
 test_58() {
-    [ -z "$(which wiretest 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find wiretest)" && return
+    [ -z "$(which wiretest 2>/dev/null)" ] && skip "could not find wiretest" && return
     wiretest
 }
 run_test 58 "verify cross-platform wire constants =============="
@@ -2457,12 +2546,12 @@ test_59() {
 run_test 59 "verify cancellation of llog records async ========="
 
 TEST60_HEAD="test_60 run $RANDOM"
-test_60() {
-        [ ! -f run-llog.sh ] && echo "missing subtest, skipping" && return
+test_60a() {
+        [ ! -f run-llog.sh ] && skip "missing subtest run-llog.sh" && return
        log "$TEST60_HEAD - from kernel mode"
-       sh run-llog.sh
+#      sh run-llog.sh
 }
-run_test 60 "llog sanity tests run from kernel module =========="
+run_test 60a "llog sanity tests run from kernel module =========="
 
 test_60b() { # bug 6411
        dmesg > $DIR/$tfile
@@ -2470,6 +2559,16 @@ test_60b() { # bug 6411
        [ $LLOG_COUNT -gt 50 ] && error "CDEBUG_LIMIT not limiting messages"|| true
 }
 run_test 60b "limit repeated messages from CERROR/CWARN ========"
+test_60c() {
+       echo "create 5000 files" 
+       createmany -o $DIR/f60c- 5000
+#define OBD_FAIL_MDS_LLOG_CREATE_FAILED  0x13c
+        sysctl -w lustre.fail_loc=0x8000013c
+       unlinkmany $DIR/f60c- 5000
+        sysctl -w lustre.fail_loc=0
+}
+run_test 60c "unlink file when mds full"
 
 test_61() {
        f="$DIR/f61"
@@ -2514,7 +2613,7 @@ run_test 63 "Verify oig_wait interruption does not crash ======="
 # bug 2248 - async write errors didn't return to application on sync
 # bug 3677 - async write errors left page locked
 test_63b() {
-       DBG_SAVE="`sysctl -n lnet.debug`"
+       debugsave
        sysctl -w lnet.debug=-1
 
        # ensure we have a grant to do async writes
@@ -2524,26 +2623,22 @@ test_63b() {
        #define OBD_FAIL_OSC_BRW_PREP_REQ        0x406
        sysctl -w lustre.fail_loc=0x80000406
        multiop $DIR/$tfile Owy && \
-               $LCTL dk /tmp/test63b.debug && \
-               sysctl -w lnet.debug="$DBG_SAVE" && \
                error "sync didn't return ENOMEM"
        sync; sleep 2; sync     # do a real sync this time to flush page
        grep locked $LPROC/llite/*/dump_page_cache && \
-               $LCTL dk /tmp/test63b.debug && \
-               sysctl -w lnet.debug="$DBG_SAVE" && \
                error "locked page left in cache after async error" || true
-       sysctl -w lnet.debug="$DBG_SAVE"
+       debugrestore
 }
 run_test 63b "async write errors should be returned to fsync ==="
 
 test_64a () {
        df $DIR
-       grep "[0-9]" $LPROC/osc/*[oO][sS][cC]*/cur*
+       grep "[0-9]" $LPROC/osc/*[oO][sS][cC][_-]*/cur*
 }
 run_test 64a "verify filter grant calculations (in kernel) ====="
 
 test_64b () {
-        [ ! -f oos.sh ] && echo "missing subtest, skipping" && return
+        [ ! -f oos.sh ] && skip "missing subtest oos.sh" && return
        sh oos.sh $MOUNT
 }
 run_test 64b "check out-of-space detection on client ==========="
@@ -2575,15 +2670,21 @@ test_65c() {
 }
 run_test 65c "directory setstripe $(($STRIPESIZE * 4)) 1 $(($OSTCOUNT - 1))"
 
-[ $STRIPECOUNT -eq 0 ] && sc=1 || sc=$(($STRIPECOUNT - 1))
-
 test_65d() {
        mkdir -p $DIR/d65
+       if [ $STRIPECOUNT -le 0 ]; then
+               sc=1
+       elif [ $STRIPECOUNT -gt 160 ]; then
+#LOV_MAX_STRIPE_COUNT is 160
+               [ $OSTCOUNT -gt 160 ] && sc=160 || sc=$(($OSTCOUNT - 1))
+       else
+               sc=$(($STRIPECOUNT - 1))
+       fi
        $SETSTRIPE $DIR/d65 $STRIPESIZE -1 $sc || error "setstripe"
        touch $DIR/d65/f4 $DIR/d65/f5
        $LVERIFY $DIR/d65 $DIR/d65/f4 $DIR/d65/f5 || error "lverify failed"
 }
-run_test 65d "directory setstripe $STRIPESIZE -1 $sc =============="
+run_test 65d "directory setstripe $STRIPESIZE -1 stripe_count =============="
 
 test_65e() {
        mkdir -p $DIR/d65
@@ -2630,10 +2731,46 @@ test_65j() { # bug6367
                cleanup -f || error "failed to unmount"
                setup
        fi
-       $SETSTRIPE -d $MOUNT
+       $SETSTRIPE -d $MOUNT || error "setstripe failed"
 }
 run_test 65j "set default striping on root directory (bug 6367)="
 
+test_65k() { # bug11679
+        [ "$OSTCOUNT" -lt 2 ] && skip "too few OSTs" && return
+
+        echo "Check OST status: "
+        MDS_OSCS=`do_facet mds lctl dl | awk '/[oO][sS][cC].*md[ts]/ { print $4 }'`
+        for OSC in $MDS_OSCS; do
+                echo $OSC "is activate"
+                do_facet mds lctl --device %$OSC activate
+        done
+        do_facet client mkdir -p $DIR/$tdir
+        for INACTIVE_OSC in $MDS_OSCS; do
+                echo $INACTIVE_OSC "is Deactivate:"
+                do_facet mds lctl --device  %$INACTIVE_OSC deactivate
+                for STRIPE_OSC in $MDS_OSCS; do
+                        STRIPE_OST=`osc_to_ost $STRIPE_OSC`
+                        STRIPE_INDEX=`do_facet mds cat $LPROC/lov/*md*/target_obd |
+                                      grep $STRIPE_OST | awk -F: '{print $1}'`
+                        echo "$SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1"
+                        do_facet client $SETSTRIPE $DIR/$tdir/${STRIPE_INDEX} 0 ${STRIPE_INDEX} 1
+                        RC=$?
+                        [ $RC -ne 0 ] && error "setstripe should have succeeded"
+                done
+                do_facet client rm -f $DIR/$tdir/*
+                echo $INACTIVE_OSC "is Activate."
+                do_facet mds lctl --device  %$INACTIVE_OSC activate
+        done
+}
+run_test 65k "validate manual striping works properly with deactivated OSCs"
+
+test_65l() { # bug 12836
+       mkdir -p $DIR/$tdir/test_dir
+       $LFS setstripe $DIR/$tdir/test_dir 65536 -1 -1
+       $LFS find -mtime -1 $DIR/$tdir
+}
+run_test 65l "lfs find on -1 stripe dir ========================"
+
 # bug 2543 - update blocks count on client
 test_66() {
        COUNT=${COUNT:-8}
@@ -2644,52 +2781,11 @@ test_66() {
 }
 run_test 66 "update inode blocks count on client ==============="
 
-test_67() { # bug 3285 - supplementary group fails on MDS, passes on client
-       [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
-       check_kernel_version 35 || return 0
-       mkdir $DIR/$tdir
-       chmod 771 $DIR/$tdir
-       chgrp $RUNAS_ID $DIR/$tdir
-       $RUNAS -u $RUNAS_ID -g $(($RUNAS_ID + 1)) -G1,2,$RUNAS_ID ls $DIR/$tdir
-       RC=$?
-       if [ "$MDS" ]; then
-               # can't tell which is correct otherwise
-               GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
-               [ "$GROUP_UPCALL" = "NONE" -a $RC -eq 0 ] && \
-                       error "no-upcall passed" || true
-               [ "$GROUP_UPCALL" != "NONE" -a $RC -ne 0 ] && \
-                       error "upcall failed" || true
-       fi
+test_67() {
+        [ ! -f sanity-sec.sh ] && skip "missing subtest sanity-sec.sh" && return
+       sh sanity-sec.sh
 }
-run_test 67 "supplementary group failure (should return error) ="
-
-cleanup_67b() {
-       trap 0
-       echo NONE > $LPROC/mds/$MDS/group_upcall
-       set +vx
-}
-
-test_67b() { # bug 3285 - supplementary group fails on MDS, passes on client
-       T67_UID=${T67_UID:-1}   # needs to be in /etc/groups on MDS, gid == uid
-       [ "$UID" = "$T67_UID" ] && echo "skipping $TESTNAME" && return
-       check_kernel_version 35 || return 0
-       [ -z "$MDS" ] && echo "skipping $TESTNAME - no MDS" && return
-       GROUP_UPCALL=`cat $LPROC/mds/$MDS/group_upcall`
-       [ "$GROUP_UPCALL" != "NONE" ] && echo "skip $TESTNAME - upcall" &&return
-       set -vx
-       trap cleanup_67b EXIT
-       mkdir -p $DIR/$tdir
-       chmod 771 $DIR/$tdir
-       chgrp $T67_UID $DIR/$tdir
-       echo `which l_getgroups` > $LPROC/mds/$MDS/group_upcall
-       l_getgroups -d $T67_UID
-       $RUNAS -u $T67_UID -g $((T67_UID + 1)) -G8,9 id
-       $RUNAS -u $T67_UID -g 999 -G8,9,$T67_UID touch $DIR/$tdir/$tfile || \
-               error "'touch $DIR/$tdir/$tfile' failed"
-       [ -f $DIR/$tdir/$tfile ] || error "$DIR/$tdir/$tfile create error"
-       cleanup_67b
-}
-run_test 67b "supplementary group test ========================="
+run_test 67 "security test ====================================="
 
 cleanup_68() {
        trap 0
@@ -2712,9 +2808,9 @@ swap_used() {
 # excercise swapping to lustre by adding a high priority swapfile entry
 # and then consuming memory until it is used.
 test_68() {
-       [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
-       [ "`lsmod|grep obdfilter`" ] && echo "skipping $TESTNAME (local OST)" && \
-               return
+       [ "$UID" != 0 ] && skip "must run as root" && return
+       grep -q obdfilter $LPROC/devices && \
+               skip "local OST" && return
 
        find_loop_dev
        dd if=/dev/zero of=$DIR/f68 bs=64k count=1024
@@ -2740,14 +2836,15 @@ run_test 68 "support swapping to Lustre ========================"
 # bug5265, obdfilter oa2dentry return -ENOENT
 # #define OBD_FAIL_OST_ENOENT 0x217
 test_69() {
-       [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
-               echo "skipping $TESTNAME for remote OST" && return
+       [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+               skip "skipping test for remote OST" && return
+       $GSS && skip "gss with bulk security will triger oops. re-enable this after b10091 get fixed" && return
 
        f="$DIR/$tfile"
        touch $f
 
        if ! $DIRECTIO write ${f}.2 0 1; then
-               echo "skipping $TESTNAME - O_DIRECT not implemented"
+               skip "O_DIRECT not implemented"
                return 0
        fi
 
@@ -2770,7 +2867,7 @@ test_69() {
 run_test 69 "verify oa2dentry return -ENOENT doesn't LBUG ======"
 
 test_71() {
-        which dbench > /dev/null 2>&1 || echo "dbench not installed, skip this test" && return 0
+        which dbench > /dev/null 2>&1 || skip "dbench not installed, skip this test" && return 0
        DBENCH_LIB=${DBENCH_LIB:-/usr/lib/dbench}
        PATH=${DBENCH_LIB}:${PATH}
        cp `which dbench` $DIR
@@ -2799,7 +2896,9 @@ run_test 71 "Running dbench on lustre (don't segment fault) ===="
 
 test_72() { # bug 5695 - Test that on 2.6 remove_suid works properly
        check_kernel_version 43 || return 0
-       [ "$RUNAS_ID" = "$UID" ] && echo "skipping $TESTNAME" && return
+       [ "$RUNAS_ID" = "$UID" ] && skip "RUNAS_ID = UID = $UID -- skipping" && return
+       # We had better clear the $DIR to get enough space for dd
+       rm -rf $DIR/*
        touch $DIR/f72
        chmod 777 $DIR/f72
        chmod ug+s $DIR/f72
@@ -2843,18 +2942,32 @@ test_73() {
 }
 run_test 73 "multiple MDC requests (should not deadlock)"
 
-test_74() { # bug 6149, 6184
+test_74a() { # bug 6149, 6184
+       #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
+       #
+       # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
+       # will spin in a tight reconnection loop
+       touch $DIR/f74a
+       sysctl -w lustre.fail_loc=0x8000030e
+       # get any lock that won't be difficult - lookup works.
+       ls $DIR/f74a
+       sysctl -w lustre.fail_loc=0
+       true
+}
+run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
+
+test_74b() { # bug 13310
        #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
        #
        # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
        # will spin in a tight reconnection loop
        sysctl -w lustre.fail_loc=0x8000030e
-       # get any lock
-       touch $DIR/f74
+       # get a "difficult" lock
+       touch $DIR/f74b
        sysctl -w lustre.fail_loc=0
        true
 }
-run_test 74 "ldlm_enqueue freed-export error path (shouldn't LBUG)"
+run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
 
 JOIN=${JOIN:-"lfs join"}
 F75=$DIR/f75
@@ -2873,6 +2986,9 @@ test75_prep() {
 }
  
 test_75a() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         cp -p ${F128k} ${FHEAD}
@@ -2890,6 +3006,9 @@ test_75a() {
 run_test 75a "TEST join file ===================================="
  
 test_75b() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         cp -p ${F128k} ${FTAIL}
@@ -2903,6 +3022,9 @@ test_75b() {
 run_test 75b "TEST join file 2 =================================="
  
 test_75c() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         cp -p ${F128k} ${FTAIL}
@@ -2916,6 +3038,9 @@ test_75c() {
 run_test 75c "TEST join file 3 =================================="
  
 test_75d() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         cp -p ${F128k} ${FHEAD}
@@ -2930,6 +3055,9 @@ test_75d() {
 run_test 75d "TEST join file 4 =================================="
  
 test_75e() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         rm -rf ${FHEAD} || "delete join file error"
@@ -2937,6 +3065,9 @@ test_75e() {
 run_test 75e "TEST join file 5 (remove joined file) ============="
  
 test_75f() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         test75_prep
  
         cp -p ${F128k} ${F75}_join_10_compare
@@ -2954,6 +3085,9 @@ test_75f() {
 run_test 75f "TEST join file 6 (join 10 files) =================="
  
 test_75g() {
+#      skipped temporarily: we do not have join file currently
+#      please remove this when ready - huanghua
+       return
         [ ! -f ${F75}_join_10 ] && echo "${F75}_join_10 missing" && return
         $LFS getstripe ${F75}_join_10
  
@@ -2968,7 +3102,9 @@ num_inodes() {
 }
 
 test_76() { # bug 1443
-       BEFORE_INODES=`num_inodes`
+       DETH=$(grep deathrow /proc/kallsyms /proc/ksyms 2> /dev/null | wc -l)
+       [ $DETH -eq 0 ] && skip "No _iget." && return 0
+        BEFORE_INODES=`num_inodes`
        echo "before inodes: $BEFORE_INODES"
        for i in `seq 1000`; do
                touch $DIR/$tfile
@@ -2982,112 +3118,174 @@ test_76() { # bug 1443
 }
 run_test 76 "destroy duplicate inodes in client inode cache ===="
 
+export ORIG_CSUM=""
+set_checksums()
+{
+       [ "$ORIG_CSUM" ]||ORIG_CSUM=`cat $LPROC/llite/*/checksum_pages|head -n1`
+       for f in $LPROC/llite/*/checksum_pages; do
+               echo $1 >> $f
+       done
+
+       return 0
+}
+
 F77_TMP=$TMP/f77-temp
+F77SZ=8
+setup_f77() {
+       dd if=/dev/urandom of=$F77_TMP bs=1M count=$F77SZ || \
+               error "error writing to $F77_TMP"
+}
+
 test_77a() { # bug 10889
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
-       if [ ! -f $F77_TMP ]; then
-               dd if=/dev/urandom of=$F77_TMP bs=1M count=8 || \
-                       error "error writing to $F77_TMP"
-       fi
-       dd if=$F77_TMP of=$DIR/$tfile bs=1M count=8 || error "dd error"
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       [ ! -f $F77_TMP ] && setup_f77
+       set_checksums 1
+       dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
+       set_checksums 0
 }
 run_test 77a "normal checksum read/write operation ============="
 
 test_77b() { # bug 10889
-       [ ! -f $F77_TMP ] && echo "requires 77a" && return  
+       [ ! -f $F77_TMP ] && setup_f77
        #define OBD_FAIL_OSC_CHECKSUM_SEND       0x409
        sysctl -w lustre.fail_loc=0x80000409
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
-       dd if=$F77_TMP of=$DIR/f77b bs=8M count=1 conv=sync || \
-               error "write error: rc=$?"
+       set_checksums 1
+       dd if=$F77_TMP of=$DIR/f77b bs=1M count=$F77SZ conv=sync || \
+               error "dd error: $?"
        sysctl -w lustre.fail_loc=0
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77b "checksum error on client write ===================="
 
 test_77c() { # bug 10889
-       [ ! -f $F77_TMP ] && echo "requires 77a" && return  
+       [ ! -f $DIR/f77b ] && skip "requires 77b - skipping" && return  
        cancel_lru_locks osc
        #define OBD_FAIL_OSC_CHECKSUM_RECEIVE    0x408
        sysctl -w lustre.fail_loc=0x80000408
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
+       set_checksums 1
        cmp $F77_TMP $DIR/f77b || error "file compare failed"
        sysctl -w lustre.fail_loc=0
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77c "checksum error on client read ==================="
 
 test_77d() { # bug 10889
        #define OBD_FAIL_OSC_CHECKSUM_SEND       0x409
        sysctl -w lustre.fail_loc=0x80000409
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
-       directio write $DIR/f77  0 1 || error "direct write: rc=$?"
+       set_checksums 1
+       directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
+               error "direct write: rc=$?"
        sysctl -w lustre.fail_loc=0
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77d "checksum error on OST direct write ==============="
 
 test_77e() { # bug 10889
+       [ ! -f $DIR/f77 ] && skip "requires 77d - skipping" && return  
        #define OBD_FAIL_OSC_CHECKSUM_RECEIVE    0x408
        sysctl -w lustre.fail_loc=0x80000408
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
+       set_checksums 1
        cancel_lru_locks osc
-       directio read $DIR/f77 0 1 || error "direct read: rc=$?"
+       directio read $DIR/f77 0 $F77SZ $((1024 * 1024)) || \
+               error "direct read: rc=$?"
        sysctl -w lustre.fail_loc=0
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77e "checksum error on OST direct read ================"
 
 test_77f() { # bug 10889
        #define OBD_FAIL_OSC_CHECKSUM_SEND       0x409
        sysctl -w lustre.fail_loc=0x409
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
-       directio write $DIR/f77 0 1 && error "direct write succeeded"
+       set_checksums 1
+       directio write $DIR/f77 0 $F77SZ $((1024 * 1024)) && \
+               error "direct write succeeded"
        sysctl -w lustre.fail_loc=0
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77f "repeat checksum error on write (expect error) ===="
 
 test_77g() { # bug 10889
-       [ ! -f $F77_TMP ] && echo "requires 77a" && return  
-       [ -z "`lsmod|grep obdfilter`" ] &&
-               echo "skipping $TESTNAME (remote OST)" && return
+       [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+               skip "remote OST" && return
+       [ ! -f $F77_TMP ] && setup_f77
        #define OBD_FAIL_OST_CHECKSUM_RECEIVE       0x21a
        sysctl -w lustre.fail_loc=0x8000021a
-       for f in  $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
-       dd if=$F77_TMP of=$DIR/f77 bs=8M count=1 || error "write error: rc=$?"
+       set_checksums 1
+       dd if=$F77_TMP of=$DIR/f77 bs=1M count=$F77SZ || \
+               error "write error: rc=$?"
        sysctl -w lustre.fail_loc=0
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77g "checksum error on OST write ======================"
 
 test_77h() { # bug 10889
-       [ ! -f $DIR/f77 ] && echo "requires 77a,g" && return  
-       [ -z "`lsmod|grep obdfilter`" ] &&
-               echo "skipping $TESTNAME (remote OST)" && return
+       [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] && \
+               skip "remote OST" && return
+       [ ! -f $DIR/f77 ] && skip "requires 77g - skipping" && return  
        cancel_lru_locks osc
        #define OBD_FAIL_OST_CHECKSUM_SEND          0x21b
        sysctl -w lustre.fail_loc=0x8000021b
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 1 >> $f ; done
+       set_checksums 1
        cmp $F77_TMP $DIR/f77 || error "file compare failed"
        sysctl -w lustre.fail_loc=0
-       for f in $LPROC/llite/${FSNAME}-*/checksum_pages ; do echo 0 >> $f ; done
+       set_checksums 0
 }
 run_test 77h "checksum error on OST read ======================="
 
+[ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
 rm -f $F77_TMP
 unset F77_TMP
 
 test_78() { # bug 10901
+       NSEQ=5
        F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
        [ $F78SIZE -gt 512 ] && F78SIZE=512
        [ $F78SIZE -gt $((MAXFREE / 1024)) ] && F78SIZE=$((MAXFREE / 1024))
-       $SETSTRIPE $DIR/$tfile 0 -1 -1
-       $DIRECTIO rdwr $DIR/$tfile 0 $F78SIZE 1048576
+       SMALLESTOST=`lfs df $DIR |grep OST | awk '{print $4}' |sort -n |head -1`
+       [ $F78SIZE -gt $((SMALLESTOST * $OSTCOUNT / 1024)) ] && \
+               F78SIZE=$((SMALLESTOST * $OSTCOUNT / 1024))
+       $SETSTRIPE $DIR/$tfile 0 -1 -1 || error "setstripe failed"
+       for i in `seq 1 $NSEQ`
+       do
+               echo directIO rdwr round $i of $NSEQ
+               $DIRECTIO rdwr $DIR/$tfile 0 $F78SIZE 1048576 || error "rdwr failed"
+       done
+
+       rm -f $DIR/$tfile
 }
 run_test 78 "handle large O_DIRECT writes correctly ============"
 
+test_79() { # bug 12743
+       [ $(grep -c obdfilter $LPROC/devices) -eq 0 ] &&
+               skip "skipping test for remote OST" && return
+        BKTOTAL=`awk 'BEGIN{total=0}; {total+=$1}; END{print total}' \
+                 $LPROC/obdfilter/*/kbytestotal`
+        BKFREE=`awk 'BEGIN{free=0}; {free+=$1}; END{print free}' \
+                $LPROC/obdfilter/*/kbytesfree`
+        BKAVAIL=`awk 'BEGIN{avail=0}; {avail+=$1}; END{print avail}' \
+                 $LPROC/obdfilter/*/kbytesavail`
+        STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
+        DFTOTAL=`echo $STRING | cut -d, -f1`
+        DFUSED=`echo $STRING  | cut -d, -f2`
+        DFAVAIL=`echo $STRING | cut -d, -f3`
+        DFFREE=$(($DFTOTAL - $DFUSED))
+
+        ALLOWANCE=$((64 * $OSTCOUNT))
+
+        if [ $DFTOTAL -lt $(($BKTOTAL - $ALLOWANCE)) ] ||  
+           [ $DFTOTAL -gt $(($BKTOTAL + $ALLOWANCE)) ] ; then
+                error "df total($DFTOTAL) mismatch OST total($BKTOTAL)"
+        fi
+        if [ $DFFREE -lt $(($BKFREE - $ALLOWANCE)) ] || 
+           [ $DFFREE -gt $(($BKFREE + $ALLOWANCE)) ] ; then
+                error "df free($DFFREE) mismatch OST free($BKFREE)"
+        fi
+        if [ $DFAVAIL -lt $(($BKAVAIL - $ALLOWANCE)) ] || 
+           [ $DFAVAIL -gt $(($BKAVAIL + $ALLOWANCE)) ] ; then
+                error "df avail($DFAVAIL) mismatch OST avail($BKAVAIL)"
+        fi
+}
+run_test 79 "df report consistency check ======================="
+
 # on the LLNL clusters, runas will still pick up root's $TMP settings,
 # which will not be writable for the runas user, and then you get a CVS
 # error message with a corrupt path string (CVS bug) and panic.
@@ -3181,7 +3379,7 @@ function get_named_value()
     done
 }
 
-export CACHE_MAX=`cat /proc/fs/lustre/llite/*/max_cached_mb | head -n 1`
+export CACHE_MAX=`cat $LPROC/llite/*/max_cached_mb | head -n 1`
 cleanup_101() {
        for s in $LPROC/llite/*/max_cached_mb; do
                echo $CACHE_MAX > $s
@@ -3196,7 +3394,7 @@ test_101() {
        [ "$CPU" = "UML" ] && nreads=1000
        local cache_limit=32
 
-       for s in $LPROC/osc/*/rpc_stats; do
+       for s in $LPROC/osc/*-osc*/rpc_stats; do
                echo 0 > $s
        done
        trap cleanup_101 EXIT
@@ -3218,7 +3416,7 @@ test_101() {
        cleanup_101
 
        if [ $(($discard * 10)) -gt $nreads ] ;then
-               for s in $LPROC/osc/*/rpc_stats; do
+               for s in $LPROC/osc/*-osc*/rpc_stats; do
                        echo $s; cat $s
                done
                for s in $LPROC/llite/*/read_ahead_stats; do
@@ -3261,7 +3459,7 @@ setup_test102() {
 }
 
 cleanup_test102() {
-       [ "SETUP_TEST102" = "YES" ] || return
+       [ "$SETUP_TEST102" = "yes" ] || return
        trap 0
        rm -f $TMP/f102.tar
        rm -rf $DIR/$tdir
@@ -3274,9 +3472,10 @@ test_102a() {
        rm -f $testfile
         touch $testfile
 
-       [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
-       [ -z "`grep xattr $LPROC/mdc/*[mM][dD][cC]*/connect_flags`" ] && echo "skipping $TESTNAME (must have user_xattr)" && return
-       [ -z "$(which setfattr 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfattr)" && return
+       [ "$UID" != 0 ] && skip "must run as root" && return
+       [ -z "`grep xattr $LPROC/mdc/*-mdc-*/connect_flags`" ] && skip "must have user_xattr" && return
+
+       [ -z "$(which setfattr 2>/dev/null)" ] && skip "could not find setfattr" && return
 
        echo "set/get xattr..."
         setfattr -n trusted.name1 -v value1 $testfile || error
@@ -3319,11 +3518,11 @@ run_test 102a "user xattr test =================================="
 test_102b() {
        # b10930: get/set/list trusted.lov xattr
        echo "get/set/list trusted.lov xattr ..."
-       [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        local testfile=$DIR/$tfile
        $SETSTRIPE $testfile 65536 1 2
        getfattr -d -m "^trusted" $testfile 2> /dev/null | \
-       grep "trusted.lov" || error
+       grep "trusted.lov" || error "can't get trusted.lov from $testfile"
 
        local testfile2=${testfile}2
        local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
@@ -3335,21 +3534,21 @@ test_102b() {
        $GETSTRIPE -v $testfile2 > $tmp_file
        local stripe_size=`grep "size"  $tmp_file| awk '{print $2}'`
        local stripe_count=`grep "count"  $tmp_file| awk '{print $2}'`
-       [ $stripe_size -eq 65536 ] || error "different stripe size"
-       [ $stripe_count -eq 2 ] || error "different stripe count"
+       [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
+       [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
 }
 run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
 
 test_102c() {
        # b10930: get/set/list trusted.lov xattr
        echo "get/set/list trusted.lov xattr ..."
-       [ "$OSTCOUNT" -lt "2" ] && echo "skipping 2-stripe test" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
        mkdir -p $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
        local testfile=$DIR/$tdir/$tfile
        $RUNAS $SETSTRIPE $testfile 65536 1 2
        $RUNAS getfattr -d -m "^trusted" $testfile 2> /dev/null | \
-       grep "trusted.lov" || error
+       grep "trusted.lov" || error "can't get trusted.lov from $testfile"
 
        local testfile2=${testfile}2
        local value=`getfattr -n trusted.lov $testfile 2> /dev/null | \
@@ -3361,8 +3560,8 @@ test_102c() {
        $RUNAS $GETSTRIPE -v $testfile2 > $tmp_file
        local stripe_size=`grep "size"  $tmp_file| awk '{print $2}'`
        local stripe_count=`grep "count"  $tmp_file| awk '{print $2}'`
-       [ $stripe_size -eq 65536 ] || error "different stripe size"
-       [ $stripe_count -eq 2 ] || error "different stripe count"
+       [ $stripe_size -eq 65536 ] || error "stripe size $stripe_size != 65536"
+       [ $stripe_count -eq 2 ] || error "stripe count $stripe_count != 2"
 }
 run_test 102c "non-root getfattr/setfattr for trusted.lov EAs ==========="
 
@@ -3442,9 +3641,9 @@ test_102d() {
        star --xhelp 2>&1 | grep -q nolustre  
        if [ $? -ne 0 ]
        then
-               echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
+               skip "being skipped because a lustre-aware star is not installed." && return
        fi
-       [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
+       [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
        setup_test102
        mkdir -p $DIR/d102d
        star -x  f=$TMP/f102.tar -C $DIR/d102d
@@ -3459,9 +3658,9 @@ test_102e() {
        star --xhelp 2>&1 | grep -q nolustre  
        if [ $? -ne 0 ]
        then
-               echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
+               skip "being skipped because a lustre-aware star is not installed." && return
        fi
-       [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
+       [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
        setup_test102
        mkdir -p $DIR/d102e
        star -x  -preserve-osts f=$TMP/f102.tar -C $DIR/d102e
@@ -3475,9 +3674,9 @@ test_102f() {
        star --xhelp 2>&1 | grep -q nolustre  
        if [ $? -ne 0 ]
        then
-               echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
+               skip "being skipped because a lustre-aware star is not installed." && return
        fi
-       [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
+       [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
        setup_test102
        mkdir -p $DIR/d102f
        cd $DIR
@@ -3492,9 +3691,9 @@ test_102g() {
        star --xhelp 2>&1 | grep -q nolustre  
        if [ $? -ne 0 ]
        then
-               echo "$TESTNUM being skipped because a lustre-aware star is not installed." && return
+               skip "being skipped because a lustre-aware star is not installed." && return
        fi
-       [ "$OSTCOUNT" -lt "4" ] && echo "skipping 4-stripe test" && return
+       [ "$OSTCOUNT" -lt "4" ] && skip "skipping 4-stripe test" && return
        setup_test102
        mkdir -p $DIR/d102g
        cd $DIR
@@ -3512,9 +3711,10 @@ run_acl_subtest()
 }
 
 test_103 () {
-    [ "$UID" != 0 ] && echo "skipping $TESTNAME (must run as root)" && return
-    [ -z "$(grep acl $LPROC/mdc/*[mM][dD][cC]*/connect_flags)" ] && echo "skipping $TESTNAME (must have acl enabled)" && return
-    [ -z "$(which setfacl 2>/dev/null)" ] && echo "skipping $TESTNAME (could not find setfacl)" && return
+    [ "$UID" != 0 ] && skip "must run as root" && return
+    [ -z "$(grep acl $LPROC/mdc/*-mdc-*/connect_flags)" ] && skip "must have acl enabled" && return
+    [ -z "$(which setfacl 2>/dev/null)" ] && skip "could not find setfacl" && return
+    $GSS && skip "could not run under gss" && return
 
     SAVE_UMASK=`umask`
     umask 0022
@@ -3553,7 +3753,7 @@ test_104() {
        lfs df $DIR/$tfile || error "lfs df $DIR/$tfile failed"
        lfs df -ih $DIR/$tfile || error "lfs df -ih $DIR/$tfile failed"
        
-       OSC=`awk '/-osc-|OSC.*MNT/ {print $4}' $LPROC/devices | head -n 1`
+       OSC=`awk '/-osc-/ {print $4}' $LPROC/devices | head -n 1`
        lctl --device %$OSC deactivate
        lfs df || error "lfs df with deactivated OSC failed"
        lctl --device %$OSC recover
@@ -3595,10 +3795,10 @@ test_105c() {
 }
 run_test 105c "lockf when mounted without -o flock test ========"
 
-test_106() { #10921
-        mkdir $DIR/d106
-       $DIR/d106 && error
-       chmod 777 $DIR/d106 || error
+test_106() { #bug 10921
+       mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
+       $DIR/$tdir && error "exec $DIR/$tdir succeeded"
+       chmod 777 $DIR/$tdir || error "chmod $DIR/$tdir failed"
 }
 run_test 106 "attempt exec of dir followed by chown of that dir"
 
@@ -3628,10 +3828,21 @@ test_107() {
 }
 run_test 107 "Coredump on SIG"
 
+test_110() {
+       mkdir -p $DIR/d110
+       mkdir $DIR/d110/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa || error "mkdir with 255 char fail"
+       mkdir $DIR/d110/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb && error "mkdir with 256 char should fail, but not"
+       touch $DIR/d110/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx || error "create with 255 char fail"
+       touch $DIR/d110/yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy && error ""create with 256 char should fail, but not
+
+       ls -l $DIR/d110
+}
+run_test 110 "filename length checking"
+
 test_115() {
        OSTIO_pre=$(ps -e|grep ll_ost_io|awk '{print $4}'|sort -n|tail -1|\
            cut -c11-20)
-        [ -z "$OSTIO_pre" ] && echo "skipping $TESTNAME: no OSS threads" && \
+        [ -z "$OSTIO_pre" ] && skip "no OSS threads" && \
            return
         echo "Starting with $OSTIO_pre threads"
 
@@ -3657,8 +3868,8 @@ test_115() {
 run_test 115 "verify dynamic thread creation===================="
 
 free_min_max () {
-       AVAIL=($(cat $LPROC/osc/*[oO][sS][cC]-*/kbytesavail))
-       echo OST kbytes available: ${AVAIL[@]}
+        AVAIL=($(cat $LPROC/osc/*[oO][sS][cC]-[^M]*/kbytesavail))
+        echo OST kbytes available: ${AVAIL[@]}
        MAXI=0; MAXV=${AVAIL[0]}
        MINI=0; MINV=${AVAIL[0]}
        for ((i = 0; i < ${#AVAIL[@]}; i++)); do
@@ -3675,14 +3886,15 @@ free_min_max () {
 }
 
 test_116() {
-       [ "$OSTCOUNT" -lt "2" ] && echo "not enough OSTs" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs" && return
+       remote_mds && skip "remote MDS" && return
 
        echo -n "Free space priority "
-       cat $LPROC/lov/*/qos_prio_free
-               DELAY=$(cat $LPROC/lov/*/qos_maxage | head -1 | awk '{print $1}')
+       cat $LPROC/lov/*-clilov-*/qos_prio_free
+               DELAY=$(cat $LPROC/lov/*-clilov-*/qos_maxage | head -1 | awk '{print $1}')
        declare -a AVAIL
        free_min_max
-       [ $MINV -gt 960000 ] && echo "too much free space in OST$MINI, skip" &&\
+       [ $MINV -gt 960000 ] && skip "too much free space in OST$MINI, skip" &&\
                return
 
        # generate uneven OSTs
@@ -3691,12 +3903,12 @@ test_116() {
        FILL=$(($MINV / 4))
        echo "Filling 25% remaining space in OST${MINI} with ${FILL}Kb"
        $SETSTRIPE $DIR/$tdir/OST${MINI} 0 $MINI 1
-       i=1
+       i=0
        while [ $FILL -gt 0 ]; do
+           i=$(($i + 1))
            dd if=/dev/zero of=$DIR/$tdir/OST${MINI}/$tfile-$i bs=2M count=1 2>/dev/null
            FILL=$(($FILL - 2048))
            echo -n .
-           i=$(($i + 1))
        done
        FILL=$(($MINV / 4))
        sync
@@ -3719,12 +3931,13 @@ test_116() {
 
        # now fill using QOS
        echo writing a bunch of files to QOS-assigned OSTs
-       i=1
+       $SETSTRIPE $DIR/$tdir 0 -1 1
+       i=0
        while [ $FILL -gt 0 ]; do
+           i=$(($i + 1))
            dd if=/dev/zero of=$DIR/$tdir/$tfile-$i bs=1024 count=200 2>/dev/null
            FILL=$(($FILL - 200))
            echo -n .
-           i=$(($i + 1))
        done
        echo "wrote $i 200k files"
        sync
@@ -3747,6 +3960,7 @@ test_116() {
         MINC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
        echo "$MINC files created on smaller OST $MINI1"
        UUID=$(awk '/'$MAXI1': / {print $2; exit}' $LPROC/lov/${FSNAME}-clilov-*/target_obd)
+       echo $UUID
         MAXC=$($LFS getstripe --obd $UUID $DIR/$tdir | wc -l)
        echo "$MAXC files created on larger OST $MAXI1"
        [ $MINC -gt 0 ] && echo "Wrote $(($MAXC * 100 / $MINC - 100))% more files to larger OST $MAXI1"
@@ -3765,19 +3979,360 @@ test_117() # bug 10891
 }
 run_test 117 "verify fsfilt_extend =========="
 
+test_118() #bug 11710
+{
+       sync; sleep 1; sync
+       multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c;
+       dirty=$(grep -c dirty $LPROC/llite/*/dump_page_cache)
+       
+       return $dirty
+}
+run_test 118 "verify O_SYNC work"
+
+test_119a() # bug 11737
+{
+        BSIZE=$((512 * 1024))
+        directio write $DIR/$tfile 0 1 $BSIZE
+        # We ask to read two blocks, which is more than a file size.
+        # directio will indicate an error when requested and actual
+        # sizes aren't equeal (a normal situation in this case) and
+        # print actual read amount.
+        NOB=`directio read $DIR/$tfile 0 2 $BSIZE | awk '/error/ {print $6}'`
+        if [ "$NOB" != "$BSIZE" ]; then
+                error "read $NOB bytes instead of $BSIZE"
+        fi
+        rm -f $DIR/$tfile
+}
+run_test 119a "Short directIO read must return actual read amount"
+
+test_119b() # bug 11737
+{
+        [ "$OSTCOUNT" -lt "2" ] && skip "skipping 2-stripe test" && return
+
+        lfs setstripe $DIR/$tfile 0 -1 2
+        dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1 || error "dd failed"
+        sync
+        multiop $DIR/$tfile oO_RDONLY:O_DIRECT:r$((2048 * 1024)) || \
+                error "direct read failed"
+}
+run_test 119b "Sparse directIO read must return actual read amount"
+
+LDLM_POOL_CTL_RECALC=1
+LDLM_POOL_CTL_SHRINK=2
+
+disable_pool_recalc() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL & ~LDLM_POOL_CTL_RECALC))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+enable_pool_recalc() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL | LDLM_POOL_CTL_RECALC))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+disable_pool_shrink() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL & ~LDLM_POOL_CTL_SHRINK))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+enable_pool_shrink() {
+        for NSD in $LPROC/ldlm/namespaces/*$1*; do
+                if test -f $NSD/pool/control; then
+                        CONTROL=`cat $NSD/pool/control`
+                        CONTROL=$((CONTROL | LDLM_POOL_CTL_SHRINK))
+                        echo "$CONTROL" > $NSD/pool/control
+                fi
+        done
+}
+
+disable_pool() {
+        disable_pool_shrink $1
+        disable_pool_recalc $1
+}
+
+enable_pool() {
+        enable_pool_shrink $1
+        enable_pool_recalc $1
+}
+
+lru_resize_enable()
+{
+        enable_pool osc
+        enable_pool "filter-$FSNAME"
+        enable_pool mdc
+        enable_pool "mds-$FSNAME"
+}
+
+lru_resize_disable()
+{
+        disable_pool osc
+        disable_pool "filter-$FSNAME"
+        disable_pool mdc
+        disable_pool "mds-$FSNAME"
+}
+
+test_120a() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        mkdir $DIR/$tdir
+        cancel_lru_locks mdc
+        stat $DIR/$tdir > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        mkdir $DIR/$tdir/d1
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120a "Early Lock Cancel: mkdir test"
+
+test_120b() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        mkdir $DIR/$tdir
+        cancel_lru_locks mdc
+        stat $DIR/$tdir > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        touch $DIR/$tdir/f1
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120b "Early Lock Cancel: create test"
+
+test_120c() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
+        touch $DIR/$tdir/d1/f1
+        cancel_lru_locks mdc
+        stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        ln $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120c "Early Lock Cancel: link test"
+
+test_120d() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        touch $DIR/$tdir
+        cancel_lru_locks mdc
+        stat $DIR/$tdir > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        chmod a+x $DIR/$tdir
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120d "Early Lock Cancel: setattr test"
+
+test_120e() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        mkdir $DIR/$tdir
+        dd if=/dev/zero of=$DIR/$tdir/f1 count=1
+        cancel_lru_locks mdc
+        cancel_lru_locks osc
+        dd if=$DIR/$tdir/f1 of=/dev/null
+        stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        unlink $DIR/$tdir/f1
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120e "Early Lock Cancel: unlink test"
+
+test_120f() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        mkdir -p $DIR/$tdir/d1 $DIR/$tdir/d2
+        dd if=/dev/zero of=$DIR/$tdir/d1/f1 count=1
+        dd if=/dev/zero of=$DIR/$tdir/d2/f2 count=1
+        cancel_lru_locks mdc
+        cancel_lru_locks osc
+        dd if=$DIR/$tdir/d1/f1 of=/dev/null
+        dd if=$DIR/$tdir/d2/f2 of=/dev/null
+        stat $DIR/$tdir/d1 $DIR/$tdir/d2 $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2 > /dev/null
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        [ $can1 -eq $can2 ] || error $((can2-can1)) "cancel RPC occured."
+        [ $blk1 -eq $blk2 ] || error $((blk2-blk1)) "blocking RPC occured."
+        lru_resize_enable
+}
+run_test 120f "Early Lock Cancel: rename test"
+
+test_120g() {
+        [ -z "`grep early_lock_cancel $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no early lock cancel on server" && return 0
+        lru_resize_disable
+        count=10000
+        echo create $count files
+        mkdir  $DIR/$tdir
+        cancel_lru_locks mdc
+        cancel_lru_locks osc
+        t0=`date +%s`
+
+        can0=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk0=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        createmany -o $DIR/$tdir/f $count
+        sync
+        can1=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk1=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        t1=`date +%s`
+        echo total: $((can1-can0)) cancels, $((blk1-blk0)) blockings
+        echo rm $count files
+        rm -r $DIR/$tdir
+        sync
+        can2=`awk '/ldlm_cancel/ {print $2}' $LPROC/ldlm/services/ldlm_canceld/stats`
+        blk2=`awk '/ldlm_bl_callback/ {print $2}' $LPROC/ldlm/services/ldlm_cbd/stats`
+        t2=`date +%s`
+        echo total: $count removes in $((t2-t1))
+        echo total: $((can2-can1)) cancels, $((blk2-blk1)) blockings
+        sleep 2
+        # wait for commitment of removal
+        lru_resize_enable
+}
+run_test 120g "Early Lock Cancel: performance test"
+
+test_121() { #bug #10589
+       rm -rf $DIR/$tfile
+       writes=`dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk 'BEGIN { FS="+" } /out/ {print $1}'`
+#define OBD_FAIL_LDLM_CANCEL_RACE        0x310
+       sysctl -w lustre.fail_loc=0x310
+       cancel_lru_locks osc > /dev/null
+       reads=`dd if=$DIR/$tfile of=/dev/null 2>&1 | awk 'BEGIN { FS="+" } /in/ {print $1}'`
+       sysctl -w lustre.fail_loc=0
+       [ $reads -eq $writes ] || error "read" $reads "blocks, must be" $writes
+}
+run_test 121 "read cancel race ========="
+
+test_124() {
+       [ -z "`grep lru_resize $LPROC/mdc/*/connect_flags`" ] && \
+               skip "no lru resize on server" && return 0
+        cancel_lru_locks mdc
+        lru_resize_enable
+        NSDIR=`find $LPROC/ldlm/namespaces | grep mdc | head -1`
+
+        # we want to test main pool functionality, that is cancel based on SLV
+        # this is why shrinkers are disabled
+        disable_pool_shrink "mds-$FSNAME"
+        disable_pool_shrink mdc
+
+        NR=2000
+        mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
+
+        LRU_SIZE=`cat $NSDIR/lru_size`
+
+        # use touch to produce $NR new locks
+        log "create $NR files at $DIR/$tdir"
+        for ((i=0;i<$NR;i++)); do touch $DIR/$tdir/f$i; done
+
+        LRU_SIZE_B=`cat $NSDIR/lru_size`
+        if test $LRU_SIZE -ge $LRU_SIZE_B; then
+                skip "No cached locks created!"
+                cat $NSDIR/pool/state
+                return 0
+        fi
+        LRU_SIZE_B=$((LRU_SIZE_B-LRU_SIZE))
+        log "created $LRU_SIZE_B lock(s)"
+
+        # we want to sleep 30s to not make test too long
+        SLEEP=30
+        SLEEP_ADD=10
+
+        # we know that lru resize allows one client to hold $LIMIT locks for 10h
+        MAX_HRS=10
+
+        # get the pool limit
+        LIMIT=`cat $NSDIR/pool/limit`
+
+        # calculate lock volume factor taking into account sleep and data set
+        # use $LRU_SIZE_B here to take into account real number of locks created
+        # in the case of CMD, LRU_SIZE_B != $NR in most of cases
+        LVF=$(($LIMIT * $MAX_HRS * 60 * 60 / $LRU_SIZE_B / $SLEEP))
+
+        log "make client drop locks $LVF times faster so that ${SLEEP}s is enough to cancel $LRU_SIZE_B lock(s)"
+        OLD_LVF=`cat $NSDIR/pool/lock_volume_factor`
+        echo "$LVF" > $NSDIR/pool/lock_volume_factor
+        log "sleep for "$((SLEEP+SLEEP_ADD))"s"
+        sleep $((SLEEP+SLEEP_ADD))
+        echo "$OLD_LVF" > $NSDIR/pool/lock_volume_factor
+        LRU_SIZE_A=`cat $NSDIR/lru_size`
+
+        [ $LRU_SIZE_B -ge $LRU_SIZE_A ] || {
+                error "No locks dropped in "$((SLEEP+SLEEP_ADD))"s. LRU size: $LRU_SIZE_A"
+                lru_resize_enable
+                unlinkmany $DIR/$tdir/f $NR
+                return
+        }
+
+        log "Dropped "$((LRU_SIZE_B-LRU_SIZE_A))" locks in "$((SLEEP+SLEEP_ADD))"s"
+        lru_resize_enable
+        log "unlink $NR files at $DIR/$tdir"
+        unlinkmany $DIR/$tdir/f $NR
+}
+run_test 124 "lru resize ======================================="
+
+test_125() { # 13358
+       mkdir -p $DIR/d125 || error "mkdir failed"
+       $SETSTRIPE $DIR/d125 65536 -1 -1 || error "setstripe failed"
+       setfacl -R -m u:bin:rwx $DIR/d125 || error "setfacl $DIR/d125 failed"
+       ls -ld $DIR/d125 || error "cannot access $DIR/d125"
+}
+run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
+
 TMPDIR=$OLDTMPDIR
 TMP=$OLDTMP
 HOME=$OLDHOME
 
 log "cleanup: ======================================================"
-if [ "`mount | grep $MOUNT`" ]; then
-    rm -rf $DIR/[Rdfs][1-9]*
-fi
-if [ "$I_MOUNTED" = "yes" ]; then
-    cleanupall -f || error "cleanup failed"
+check_and_cleanup_lustre
+if [ "$I_MOUNTED" != "yes" ]; then
+       sysctl -w lnet.debug="$OLDDEBUG" 2> /dev/null || true
 fi
 
-
 echo '=========================== finished ==============================='
-[ -f "$SANITYLOG" ] && cat $SANITYLOG && exit 1 || true
+[ -f "$SANITYLOG" ] && cat $SANITYLOG && grep -q FAIL $SANITYLOG && exit 1 || true
 echo "$0: completed"