Whamcloud - gitweb
LU-4971 ldlm: drop redundant ibits lock interoperability check
[fs/lustre-release.git] / lustre / tests / sanity.sh
index 0229fb0..0f7c7d4 100644 (file)
@@ -38,6 +38,7 @@ export PATH=$PATH:/sbin
 
 TMP=${TMP:-/tmp}
 
+CC=${CC:-cc}
 CHECKSTAT=${CHECKSTAT:-"checkstat -v"}
 CREATETEST=${CREATETEST:-createtest}
 LFS=${LFS:-lfs}
@@ -69,6 +70,7 @@ CLEANUP=${CLEANUP:-:}
 SETUP=${SETUP:-:}
 TRACE=${TRACE:-""}
 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
+LUSTRE_TESTS_API_DIR=${LUSTRE_TESTS_API_DIR:-${LUSTRE}/tests/clientapi}
 . $LUSTRE/tests/test-framework.sh
 init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
@@ -212,19 +214,19 @@ run_test 3 "mkdir; touch; rmdir; check dir ====================="
 # LU-4471 - failed rmdir on remote directories still removes directory on MDT0
 test_4() {
        local MDTIDX=1
-       local remote_dir=remote_dir
 
-       [ $MDSCOUNT -ge 2 ] && skip "skip now for LU-4690" && return #LU-4690
-       test_mkdir $DIR/$remote_dir ||
+       test_mkdir $DIR/$tdir ||
                error "Create remote directory failed"
 
-       touch $DIR/$remote_dir/$tfile ||
+       touch $DIR/$tdir/$tfile ||
                error "Create file under remote directory failed"
 
-       rmdir $DIR/$remote_dir &&
-               error "Expect error removing in-use dir $DIR/$remote_dir"
+       rmdir $DIR/$tdir &&
+               error "Expect error removing in-use dir $DIR/$tdir"
 
-       test -d $DIR/$remote_dir || error "Remote directory disappeared"
+       test -d $DIR/$tdir || error "Remote directory disappeared"
+
+       rm -rf $DIR/$tdir || error "remove remote dir error"
 }
 run_test 4 "mkdir; touch dir/file; rmdir; checkdir (expect error)"
 
@@ -446,14 +448,14 @@ test_17e() {
 run_test 17e "symlinks: create recursive symlink (should return error) ===="
 
 test_17f() {
-       test_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
+       test_mkdir -p $DIR/$tdir
+       ln -s 1234567890/2234567890/3234567890/4234567890 $DIR/$tdir/111
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890 $DIR/$tdir/222
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890 $DIR/$tdir/333
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890 $DIR/$tdir/444
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890 $DIR/$tdir/555
+       ln -s 1234567890/2234567890/3234567890/4234567890/5234567890/6234567890/7234567890/8234567890/9234567890/a234567890/b234567890/c234567890/d234567890/f234567890/aaaaaaaaaa/bbbbbbbbbb/cccccccccc/dddddddddd/eeeeeeeeee/ffffffffff/ $DIR/$tdir/666
+       ls -l  $DIR/$tdir
 }
 run_test 17f "symlinks: long and very long symlink name ========================"
 
@@ -515,7 +517,7 @@ run_test 17h "create objects: lov_free_memmd() doesn't lbug"
 test_17i() { #bug 20018
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       test_mkdir -p $DIR/$tdir
+       test_mkdir -c1 $DIR/$tdir
        local foo=$DIR/$tdir/$tfile
        local mdt_idx
        if [[ $MDSCOUNT -gt 1 ]]; then
@@ -664,9 +666,9 @@ test_17n() {
 
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
 
-       mkdir -p $DIR/$tdir
+       mkdir $DIR/$tdir
        for ((i=0; i<10; i++)); do
-               $LFS mkdir -i 1 $DIR/$tdir/remote_dir_${i} ||
+               $LFS mkdir -i1 -c2 $DIR/$tdir/remote_dir_${i} ||
                        error "create remote dir error $i"
                createmany -o $DIR/$tdir/remote_dir_${i}/f 10 ||
                        error "create files under remote dir failed $i"
@@ -732,7 +734,7 @@ test_17o() {
 run_test 17o "stat file with incompat LMA feature"
 
 test_18() {
-       touch $DIR/f || error "Failed to touch $DIR/f: $?"
+       touch $DIR/$tfile || error "Failed to touch $DIR/$tfile: $?"
        ls $DIR || error "Failed to ls $DIR: $?"
 }
 run_test 18 "touch .../f ; ls ... =============================="
@@ -1035,7 +1037,6 @@ test_24t() {
 run_test 24t "mkdir .../R16a/b/c; rename .../R16a/b/c .../R16a ="
 
 test_24u() { # bug12192
-       rm -rf $DIR/$tfile
        $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error
        $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
 }
@@ -1100,7 +1101,7 @@ test_24w() { # bug21506
         dd if=/dev/zero bs=$SZ1 count=1 >> $DIR/$tfile || return 2
         dd if=$DIR/$tfile of=$DIR/${tfile}_left bs=1M skip=4097 || return 3
         SZ2=`ls -l $DIR/${tfile}_left | awk '{print $5}'`
-        [ "$SZ1" = "$SZ2" ] || \
+       [[ "$SZ1" -eq "$SZ2" ]] ||
                 error "Error reading at the end of the file $tfile"
 }
 run_test 24w "Reading a file larger than 4Gb"
@@ -1196,16 +1197,71 @@ test_24A() { # LU-3182
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
        createmany -m $DIR/$tdir/$tfile $NFILES
-       local t=`ls $DIR/$tdir | wc -l`
-       local u=`ls $DIR/$tdir | sort -u | wc -l`
-       if [ $t -ne $NFILES -o $u -ne $NFILES ] ; then
-               error "Expected $NFILES files, got $t ($u unique)"
+       local t=$(ls $DIR/$tdir | wc -l)
+       local u=$(ls $DIR/$tdir | sort -u | wc -l)
+       local v=$(ls -ai $DIR/$tdir | sort -u | wc -l)
+       if [ $t -ne $NFILES -o $u -ne $NFILES -o $v -ne $((NFILES + 2)) ] ; then
+               error "Expected $NFILES files, got $t ($u unique $v .&..)"
        fi
 
        rm -rf $DIR/$tdir || error "Can not delete directories"
 }
 run_test 24A "readdir() returns correct number of entries."
 
+test_24B() { # LU-4805
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       local count
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
+               error "create striped dir failed"
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 2 ] || error "Expected 2, got $count"
+
+       touch $DIR/$tdir/striped_dir/a
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 3 ] || error "Expected 3, got $count"
+
+       touch $DIR/$tdir/striped_dir/.f
+
+       count=$(ls -ai $DIR/$tdir/striped_dir | wc -l)
+       [ $count -eq 4 ] || error "Expected 4, got $count"
+
+       rm -rf $DIR/$tdir || error "Can not delete directories"
+}
+run_test 24B "readdir for striped dir return correct number of entries"
+
+test_24C() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       mkdir $DIR/$tdir/d0
+       mkdir $DIR/$tdir/d1
+
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/d0/striped_dir ||
+               error "create striped dir failed"
+
+       cd $DIR/$tdir/d0/striped_dir
+
+       local d0_ino=$(ls -i -l -a $DIR/$tdir | grep "d0" | awk '{print $1}')
+       local d1_ino=$(ls -i -l -a $DIR/$tdir | grep "d1" | awk '{print $1}')
+       local parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
+
+       [ "$d0_ino" = "$parent_ino" ] ||
+               error ".. wrong, expect $d0_ino, get $parent_ino"
+
+       mv $DIR/$tdir/d0/striped_dir $DIR/$tdir/d1/ ||
+               error "mv striped dir failed"
+
+       parent_ino=$(ls -i -l -a | grep "\.\." | awk '{print $1}')
+
+       [ "$d1_ino" = "$parent_ino" ] ||
+               error ".. wrong after mv, expect $d1_ino, get $parent_ino"
+}
+run_test 24C "check .. in striped dir"
+
 test_25a() {
        echo '== symlink sanity ============================================='
 
@@ -2225,6 +2281,25 @@ test_31o() { # LU-2901
 }
 run_test 31o "duplicate hard links with same filename"
 
+test_31p() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+       $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
+
+       opendirunlink $DIR/$tdir/striped_dir/test1 ||
+               error "open unlink test1 failed"
+       opendirunlink $DIR/$tdir/striped_dir/test2 ||
+               error "open unlink test2 failed"
+
+       $CHECKSTAT -a $DIR/$tdir/striped_dir/test1 ||
+               error "test1 still exists"
+       $CHECKSTAT -a $DIR/$tdir/striped_dir/test2 ||
+               error "test2 still exists"
+}
+run_test 31p "remove of open striped directory"
+
 cleanup_test32_mount() {
        trap 0
        $UMOUNT -d $DIR/$tdir/ext2-mountpoint
@@ -2397,7 +2472,6 @@ test_32n() {
 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
 
 test_32o() {
-       rm -fr $DIR/d32o $DIR/$tfile
        touch $DIR/$tfile
        test_mkdir -p $DIR/d32o/tmp
        TMP_DIR=$DIR/d32o/tmp
@@ -2487,9 +2561,9 @@ test_33b() {
         rm -fr $DIR/d33
         test_mkdir -p $DIR/d33
         chown $RUNAS_ID $DIR/d33
-        $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33 && error "create" || true
+        $RUNAS $OPENFILE -f 1286739555 $DIR/d33/f33
 }
-run_test 33b "test open file with malformed flags (No panic and return error)"
+run_test 33b "test open file with malformed flags (No panic)"
 
 test_33c() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
@@ -2583,6 +2657,52 @@ test_33d() {
 }
 run_test 33d "openfile with 444 modes and malformed flags under remote dir"
 
+test_33e() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+
+       $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+       $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+       mkdir $DIR/$tdir/local_dir
+
+       local s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+       local s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+       local l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+       [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+               error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode"
+
+       rmdir $DIR/$tdir/* || error "rmdir failed"
+
+       umask 777
+       $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+       $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+       mkdir $DIR/$tdir/local_dir
+
+       s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+       s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+       l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+       [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+               error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 777"
+
+       rmdir $DIR/$tdir/* || error "rmdir(umask 777) failed"
+
+       umask 000
+       $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
+       $LFS setdirstripe -i1 -c2 $DIR/$tdir/striped_dir1
+       mkdir $DIR/$tdir/local_dir
+
+       s0_mode=$(stat -c%f $DIR/$tdir/striped_dir)
+       s1_mode=$(stat -c%f $DIR/$tdir/striped_dir1)
+       l_mode=$(stat -c%f $DIR/$tdir/local_dir)
+
+       [ "$l_mode" = "$s0_mode" -a "$l_mode" = "$s1_mode" ] ||
+               error "mkdir $l_mode striped0 $s0_mode striped1 $s1_mode 0"
+}
+run_test 33e "mkdir and striped directory should have same mode"
+
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
        rm -f $DIR/f34
@@ -2804,6 +2924,25 @@ test_36h() {
 }
 run_test 36h "utime on file racing with OST BRW write =========="
 
+test_36i() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
+
+       local mtime=$(stat -c%Y $DIR/$tdir/striped_dir)
+       local new_mtime=$((mtime + 200))
+
+       #change Modify time of striped dir
+       touch -m -d @$new_mtime $DIR/$tdir/striped_dir ||
+                       error "change mtime failed"
+
+       local got=$(stat -c%Y $DIR/$tdir/striped_dir)
+
+       [ "$new_mtime" = "$got" ] || error "expect $new_mtime got $got"
+}
+run_test 36i "change mtime on striped directory"
+
 # test_37 - duplicate with tests 32q 32r
 
 test_38() {
@@ -3803,7 +3942,7 @@ run_test 50 "special situations: /proc symlinks  ==============="
 
 test_51a() {   # was test_51
        # bug 1516 - create an empty entry right after ".." then split dir
-       test_mkdir -p $DIR/$tdir
+       test_mkdir -c1 $DIR/$tdir
        touch $DIR/$tdir/foo
        $MCREATE $DIR/$tdir/bar
        rm $DIR/$tdir/foo
@@ -3827,7 +3966,7 @@ test_51b() {
        # cleanup the directory
        rm -fr $BASE
 
-       test_mkdir -p $BASE
+       test_mkdir -p -c1 $BASE
 
        local mdtidx=$(printf "%04x" $($LFS getstripe -M $BASE))
        local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
@@ -3930,6 +4069,23 @@ test_51d() {
 }
 run_test 51d "check object distribution ===================="
 
+test_51e() {
+       if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
+               skip "Only applicable to ldiskfs-based MDTs"
+               return
+       fi
+
+       test_mkdir -c1 $DIR/$tdir       || error "create $tdir failed"
+       test_mkdir -c1 $DIR/$tdir/d0    || error "create d0 failed"
+
+       touch $DIR/$tdir/d0/foo
+       createmany -l $DIR/$tdir/d0/foo $DIR/$tdir/d0/f- 65001 &&
+               error "file exceed 65000 nlink limit!"
+       unlinkmany $DIR/$tdir/d0/f- 65001
+       return 0
+}
+run_test 51e "check file nlink limit"
+
 test_52a() {
        [ -f $DIR/$tdir/foo ] && chattr -a $DIR/$tdir/foo
        test_mkdir -p $DIR/$tdir
@@ -4072,31 +4228,34 @@ cleanup_54c() {
        loopdev="$DIR/loop54c"
 
        trap 0
-       $UMOUNT -d $tdir || rc=$?
+       $UMOUNT -d $DIR/$tdir || rc=$?
        losetup -d $loopdev || true
-       rm $loopdev
+       losetup -d $LOOPDEV || true
+       rm -rf $loopdev $DIR/$tfile $DIR/$tdir
        return $rc
 }
 
 test_54c() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       tfile="$DIR/f54c"
-       tdir="$DIR/d54c"
        loopdev="$DIR/loop54c"
 
        find_loop_dev
        [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
-       mknod $loopdev b 7 $LOOPNUM
-       echo "make a loop file system with $tfile on $loopdev ($LOOPNUM)..."
-       dd if=/dev/zero of=$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
-       losetup $loopdev $tfile || error "can't set up $loopdev for $tfile"
        trap cleanup_54c EXIT
+       mknod $loopdev b 7 $LOOPNUM
+       echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
+       dd if=/dev/zero of=$DIR/$tfile bs=$(get_page_size client) seek=1024 count=1 > /dev/null
+       losetup $loopdev $DIR/$tfile ||
+               error "can't set up $loopdev for $DIR/$tfile"
        mkfs.ext2 $loopdev || error "mke2fs on $loopdev"
-       test_mkdir -p $tdir
-       mount -t ext2 $loopdev $tdir || error "error mounting $loopdev on $tdir"
-       dd if=/dev/zero of=$tdir/tmp bs=`page_size` count=30 || error "dd write"
-       df $tdir
-       dd if=$tdir/tmp of=/dev/zero bs=`page_size` count=30 || error "dd read"
+       test_mkdir -p $DIR/$tdir
+       mount -t ext2 $loopdev $DIR/$tdir ||
+               error "error mounting $loopdev on $DIR/$tdir"
+       dd if=/dev/zero of=$DIR/$tdir/tmp bs=$(get_page_size client) count=30 ||
+               error "dd write"
+       df $DIR/$tdir
+       dd if=$DIR/$tdir/tmp of=/dev/zero bs=$(get_page_size client) count=30 ||
+               error "dd read"
        cleanup_54c
 }
 run_test 54c "block device works in lustre ====================="
@@ -4450,31 +4609,41 @@ test_56s() { # LU-611
        EXPECTED=$(((NUMDIRS + 1) * NUMFILES))
        CMD="$LFIND -stripe-count $OSTCOUNT -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=$(((NUMDIRS + 1) * NUMFILES + EXTRA))
        CMD="$LFIND -stripe-count +0 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=$ONESTRIPE
        CMD="$LFIND -stripe-count 1 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        CMD="$LFIND -stripe-count -2 -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 
        EXPECTED=0
        CMD="$LFIND -stripe-count $((OSTCOUNT + 1)) -type f $TDIR"
        NUMS=$($CMD | wc -l)
-       [ $NUMS -eq $EXPECTED ] ||
+       [ $NUMS -eq $EXPECTED ] || {
+               $GETSTRIPE -R $TDIR
                error "\"$CMD\" wrong: found $NUMS, expected $EXPECTED"
+       }
 }
 run_test 56s "check lfs find -stripe-count works"
 
@@ -4741,6 +4910,30 @@ test_56y() {
 }
 run_test 56y "lfs find -L raid0|released"
 
+test_56z() { # LU-4824
+       # This checks to make sure 'lfs find' continues after errors
+       # There are two classes of errors that should be caught:
+       # - If multiple paths are provided, all should be searched even if one
+       #   errors out
+       # - If errors are encountered during the search, it should not terminate
+       #   early
+       local i
+       test_mkdir $DIR/$tdir
+       for i in d{0..9}; do
+               test_mkdir $DIR/$tdir/$i
+       done
+       touch $DIR/$tdir/d{0..9}/$tfile
+       $LFS find $DIR/non_existent_dir $DIR/$tdir &&
+               error "$LFS find did not return an error"
+       # Make a directory unsearchable. This should NOT be the last entry in
+       # directory order.  Arbitrarily pick the 6th entry
+       chmod 700 $(lfs find $DIR/$tdir -type d | sed '6!d')
+       local count=$($RUNAS $LFS find $DIR/non_existent $DIR/$tdir | wc -l)
+       # The user should be able to see 10 directories and 9 files
+       [ $count == 19 ] || error "$LFS find did not continue after error"
+}
+run_test 56z "lfs find should continue after an error"
+
 test_57a() {
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        # note test will not do anything if MDS is not local
@@ -5310,8 +5503,6 @@ test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
                skip_env "User $RUNAS_ID does not exist - skipping"
                return 0
        }
-       # We had better clear the $DIR to get enough space for dd
-       rm -rf $DIR/*
        touch $DIR/$tfile
        chmod 777 $DIR/$tfile
        chmod ug+s $DIR/$tfile
@@ -6234,7 +6425,7 @@ cleanup_test102() {
 }
 
 test_102a() {
-       local testfile=$DIR/xattr_testfile
+       local testfile=$DIR/$tfile
 
        touch $testfile
 
@@ -6699,6 +6890,8 @@ test_103 () {
                run_acl_subtest 2561_zfs || error "LU-2561 zfs test failed"
        fi
 
+       run_acl_subtest 4924 || error "LU-4924 test failed"
+
        cd $SAVE_PWD
        umask $SAVE_UMASK
 
@@ -7644,12 +7837,16 @@ test_120e() {
         cancel_lru_locks osc
         dd if=$DIR/$tdir/f1 of=/dev/null
         stat $DIR/$tdir $DIR/$tdir/f1 > /dev/null
+       # XXX client can not do early lock cancel of OST lock
+       # during unlink (LU-4206), so cancel osc lock now.
+       cancel_lru_locks osc
        can1=$(do_facet $SINGLEMDS \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
        unlink $DIR/$tdir/f1
+       sleep 5
        can2=$(do_facet $SINGLEMDS \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
@@ -7671,19 +7868,23 @@ test_120f() {
         lru_resize_disable osc
        test_mkdir -p -c1 $DIR/$tdir/d1
        test_mkdir -p -c1 $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
+       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
+       # XXX client can not do early lock cancel of OST lock
+       # during rename (LU-4206), so cancel osc lock now.
+       cancel_lru_locks osc
        can1=$(do_facet $SINGLEMDS \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
        blk1=$($LCTL get_param -n ldlm.services.ldlm_cbd.stats |
               awk '/ldlm_bl_callback/ {print $2}')
-       mv $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+       mrename $DIR/$tdir/d1/f1 $DIR/$tdir/d2/f2
+       sleep 5
        can2=$(do_facet $SINGLEMDS \
               "$LCTL get_param -n ldlm.services.ldlm_canceld.stats" |
               awk '/ldlm_cancel/ {print $2}')
@@ -8967,7 +9168,8 @@ test_133g() {
                -type f \
                -not -name force_lbug \
                -not -name changelog_mask \
-               -exec badarea_io '{}' \; > /dev/null
+               -exec badarea_io '{}' \; &> /dev/null ||
+               error "find $proc_dirs failed"
 
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.5.54) ] &&
                skip "Too old lustre on MDS"
@@ -8980,7 +9182,8 @@ test_133g() {
                        -type f \
                        -not -name force_lbug \
                        -not -name changelog_mask \
-                       -exec badarea_io '{}' \\\; &> /dev/null
+                       -exec badarea_io '{}' \\\; &> /dev/null ||
+               error "$facet find $proc_dirs failed"
 
        done
 
@@ -9078,14 +9281,14 @@ function roc_hit_init() {
                dd if=/dev/urandom of=$file bs=4k count=4 2>&1 > /dev/null
                idx=$(printf %04x $i)
                BEFORE=$(get_osd_param $list *OST*$idx stats |
-                       awk '$1 == "cache_access" {sum += $2}
+                       awk '$1 == "cache_access" {sum += $7}
                                END { printf("%0.0f", sum) }')
 
                cancel_lru_locks osc
                cat $file >/dev/null
 
                AFTER=$(get_osd_param $list *OST*$idx stats |
-                       awk '$1 == "cache_access" {sum += $2}
+                       awk '$1 == "cache_access" {sum += $7}
                                END { printf("%0.0f", sum) }')
 
                echo BEFORE:$BEFORE AFTER:$AFTER
@@ -9102,7 +9305,7 @@ function roc_hit_init() {
 function roc_hit() {
        local list=$(comma_list $(osts_nodes))
        echo $(get_osd_param $list '' stats |
-               awk '$1 == "cache_hit" {sum += $2}
+               awk '$1 == "cache_hit" {sum += $7}
                        END { printf("%0.0f", sum) }')
 }
 
@@ -9895,6 +10098,12 @@ run_test 160b "Verify that very long rename doesn't crash in changelog"
 
 test_160c() {
        local rc=0
+       local server_version=$(lustre_version_code $SINGLEMDS)
+
+       [[ $server_version -gt $(version_code 2.5.57) ]] ||
+               [[ $server_version -gt $(version_code 2.5.1) &&
+                  $server_version -lt $(version_code 2.5.50) ]] ||
+               { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
        [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
 
        # Registration step
@@ -10131,25 +10340,30 @@ test_162() {
        test_mkdir -p -c1 $DIR/$tdir/d2/p/q/r
        # regular file
        FID=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
-       check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0
+       check_path "$tdir/d2/$tfile" $FSNAME $FID --link 0 ||
+               error "check path $tdir/d2/$tfile failed"
 
        # softlink
        ln -s $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/slink
        FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
-       check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0
+       check_path "$tdir/d2/p/q/r/slink" $FSNAME $FID --link 0 ||
+               error "check path $tdir/d2/p/q/r/slink failed"
 
        # softlink to wrong file
        ln -s /this/is/garbage $DIR/$tdir/d2/p/q/r/slink.wrong
        FID=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink.wrong | tr -d '[]')
-       check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0
+       check_path "$tdir/d2/p/q/r/slink.wrong" $FSNAME $FID --link 0 ||
+               error "check path $tdir/d2/p/q/r/slink.wrong failed"
 
        # hardlink
        ln $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/p/q/r/hlink
        mv $DIR/$tdir/d2/$tfile $DIR/$tdir/d2/a/b/c/new_file
        FID=$($LFS path2fid $DIR/$tdir/d2/a/b/c/new_file | tr -d '[]')
        # fid2path dir/fsname should both work
-       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1
-       check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0
+       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 1 ||
+               error "check path $tdir/d2/a/b/c/new_file failed"
+       check_path "$DIR/$tdir/d2/p/q/r/hlink" $DIR $FID --link 0 ||
+               error "check path $DIR/$tdir/d2/p/q/r/hlink failed"
 
        # hardlink count: check that there are 2 links
        # Doesnt work with CMD yet: 17935
@@ -10158,12 +10372,45 @@ test_162() {
 
        # hardlink indexing: remove the first link
        rm $DIR/$tdir/d2/p/q/r/hlink
-       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0
+       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $FID --link 0 ||
+               error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
 
        return 0
 }
 run_test 162 "path lookup sanity"
 
+test_162b() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+                               error "create striped dir failed"
+
+       local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
+                                       tail -n 1 | awk '{print $2}')
+       stat $MOUNT/.lustre/fid/$FID && error "sub_stripe can be accessed"
+
+       touch $DIR/$tdir/striped_dir/f{0..4} || error "touch f0..4 failed"
+       mkdir $DIR/$tdir/striped_dir/d{0..4} || error "mkdir d0..4 failed"
+
+       # regular file
+       for ((i=0;i<5;i++)); do
+               FID=$($LFS path2fid $DIR/$tdir/striped_dir/f$i | tr -d '[]') ||
+                       error "get fid for f$i failed"
+               check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0 ||
+                       error "check path $tdir/striped_dir/f$i failed"
+
+               FID=$($LFS path2fid $DIR/$tdir/striped_dir/d$i | tr -d '[]') ||
+                       error "get fid for d$i failed"
+               check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0 ||
+                       error "check path $tdir/striped_dir/d$i failed"
+       done
+
+       return 0
+}
+run_test 162b "striped directory path lookup sanity"
+
 test_169() {
        # do directio so as not to populate the page cache
        log "creating a 10 Mb file"
@@ -10254,7 +10501,7 @@ test_171() { # bug20592
 }
 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
 
-# it would be good to share it with obdfilter-survey/libecho code
+# it would be good to share it with obdfilter-survey/iokit-libecho code
 setup_obdecho_osc () {
         local rc=0
         local ost_nid=$1
@@ -12426,7 +12673,8 @@ run_test 236 "Layout swap on open unlinked file"
 # The new system calls are supported in glibc >= 2.14.
 
 test_237() {
-       echo "Test file_handle syscalls" > $DIR/$tfile
+       echo "Test file_handle syscalls" > $DIR/$tfile ||
+               error "write failed"
        check_fhandle_syscalls $DIR/$tfile ||
                error "check_fhandle_syscalls failed"
 }
@@ -12434,6 +12682,13 @@ run_test 237 "Verify name_to_handle_at/open_by_handle_at syscalls"
 
 # LU-4659 linkea consistency
 test_238() {
+       local server_version=$(lustre_version_code $SINGLEMDS)
+
+       [[ $server_version -gt $(version_code 2.5.57) ]] ||
+               [[ $server_version -gt $(version_code 2.5.1) &&
+                  $server_version -lt $(version_code 2.5.50) ]] ||
+               { skip "Need MDS version at least 2.5.58 or 2.5.2+"; return; }
+
        touch $DIR/$tfile
        ln $DIR/$tfile $DIR/$tfile.lnk
        touch $DIR/$tfile.new
@@ -12449,15 +12704,60 @@ test_238() {
 }
 run_test 238 "Verify linkea consistency"
 
+test_239() {
+       local list=$(comma_list $(mdts_nodes))
+
+       mkdir -p $DIR/$tdir
+       createmany -o $DIR/$tdir/f- 5000
+       unlinkmany $DIR/$tdir/f- 5000
+       do_nodes $list "lctl set_param -n osp*.*.sync_changes 1"
+       changes=$(do_nodes $list "lctl get_param -n osc.*MDT*.sync_changes \
+                       osc.*MDT*.sync_in_flight" | calc_sum)
+       [ "$changes" -eq 0 ] || error "$changes not synced"
+}
+run_test 239 "osp_sync test"
+
+test_240() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+
+       mkdir -p $DIR/$tdir
+
+       $LFS mkdir -i 0 $DIR/$tdir/d0 ||
+               error "failed to mkdir $DIR/$tdir/d0 on MDT0"
+       $LFS mkdir -i 1 $DIR/$tdir/d0/d1 ||
+               error "failed to mkdir $DIR/$tdir/d0/d1 on MDT1"
+
+       umount_client $MOUNT || error "umount failed"
+       #define OBD_FAIL_TGT_DELAY_CONDITIONAL   0x713
+       do_facet mds2 lctl set_param fail_loc=0x713 fail_val=1
+       mount_client $MOUNT || error "failed to mount client"
+
+       echo "stat $DIR/$tdir/d0/d1, should not fail/ASSERT"
+       stat $DIR/$tdir/d0/d1 || error "fail to stat $DIR/$tdir/d0/d1"
+}
+run_test 240 "race between ldlm enqueue and the connection RPC (no ASSERT)"
+
+cleanup_test_300() {
+       trap 0
+       umask $SAVE_UMASK
+}
 test_striped_dir() {
        local mdt_index=$1
        local stripe_count
        local stripe_index
 
        mkdir -p $DIR/$tdir
-       $LFS setdirstripe -i $mdt_index -c 2 -t all_char $DIR/$tdir/striped_dir ||
+
+       SAVE_UMASK=$(umask)
+       trap cleanup_test_300 RETURN EXIT
+
+       $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
+                                               $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
+       local mode=$(stat -c%a $DIR/$tdir/striped_dir)
+       [ "$mode" = "755" ] || error "expect 755 got $mode"
+
        stripe_count=$($LFS getdirstripe -c $DIR/$tdir/striped_dir)
        if [ "$stripe_count" != "2" ]; then
                error "stripe_count is $stripe_count, expect 2"
@@ -12492,6 +12792,9 @@ test_striped_dir() {
 
        rmdir $DIR/$tdir/striped_dir ||
                error "rmdir striped dir error"
+
+       cleanup_test_300
+
        true
 }
 
@@ -12679,6 +12982,151 @@ test_300f() {
 }
 run_test 300f "check rename cross striped directory"
 
+test_300g() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       local stripe_count
+       local dir
+
+       mkdir $DIR/$tdir
+       $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
+                                       $DIR/$tdir/striped_dir ||
+               error "set striped dir error"
+
+       $LFS setdirstripe -D -c $MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+               error "set default stripe on striped dir error"
+
+       stripe_count=$($LFS getdirstripe -D -c $DIR/$tdir/striped_dir)
+       [ $stripe_count -eq $MDSCOUNT ] ||
+               error "default stripe wrong expect $MDSCOUNT get $stripe_count"
+
+       mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
+
+       for dir in $(find $DIR/$tdir/striped_dir/*); do
+               stripe_count=$($LFS getdirstripe -c $dir)
+               [ $stripe_count -eq $MDSCOUNT ] ||
+                       error "expect $MDSCOUNT get $stripe_count for $dir"
+       done
+
+       rmdir $DIR/$tdir/striped_dir/* || error "rmdir1 failed"
+       #change default stripe count to 2
+       $LFS setdirstripe -D -c 2 -t all_char $DIR/$tdir/striped_dir ||
+               error "set default stripe on striped dir error"
+
+       mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
+
+       rmdir $DIR/$tdir/striped_dir/* || error "rmdir2 failed"
+
+       #change default stripe count to 1
+       $LFS setdirstripe -D -c 1 -t all_char $DIR/$tdir/striped_dir ||
+               error "set default stripe on striped dir error"
+
+       mkdir -p $DIR/$tdir/striped_dir/{test1,test2,test3,test4}
+       for dir in $(find $DIR/$tdir/striped_dir/*); do
+               stripe_count=$($LFS getdirstripe -c $dir)
+               [ $stripe_count -eq 1 ] ||
+                       error "expect 1 get $stripe_count for $dir"
+       done
+       rmdir $DIR/$tdir/striped_dir/* || error "rmdir3 failed"
+}
+run_test 300g "check default striped directory for striped directory"
+
+test_300h() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       local stripe_count
+       local file
+
+       mkdir $DIR/$tdir
+
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+               error "set striped dir error"
+
+       createmany -o $DIR/$tdir/striped_dir/f- 10 ||
+               error "create files under striped dir failed"
+
+       # unfortunately, we need to umount to clear dir layout cache for now
+       # once we fully implement dir layout, we can drop this
+       umount_client $MOUNT || error "umount failed"
+       mount_client $MOUNT || error "mount failed"
+
+       #set the stripe to be unknown hash type
+       #define OBD_FAIL_UNKNOWN_LMV_STRIPE     0x1901
+       $LCTL set_param fail_loc=0x1901
+       for ((i = 0; i < 10; i++)); do
+               $CHECKSTAT -t file $DIR/$tdir/striped_dir/f-$i ||
+                       error "stat f-$i failed"
+               rm $DIR/$tdir/striped_dir/f-$i || error "unlink f-$i failed"
+       done
+
+       touch $DIR/$tdir/striped_dir/f0 &&
+               error "create under striped dir with unknown hash should fail"
+
+       $LCTL set_param fail_loc=0
+
+       umount_client $MOUNT || error "umount failed"
+       mount_client $MOUNT || error "mount failed"
+
+       return 0
+}
+run_test 300h "client handle unknown hash type striped directory"
+
+test_400a() { # LU-1606, was conf-sanity test_74
+       local extra_flags=''
+       local out=$TMP/$tfile
+       local prefix=/usr/include/lustre
+       local prog
+
+       if ! which $CC > /dev/null 2>&1; then
+               skip_env "$CC is not installed"
+               return 0
+       fi
+
+       if ! [[ -d $prefix ]]; then
+               # Assume we're running in tree and fixup the include path.
+               extra_flags+=" -I$LUSTRE/../libcfs/include"
+               extra_flags+=" -I$LUSTRE/include"
+               extra_flags+=" -L$LUSTRE/utils"
+       fi
+
+       for prog in $LUSTRE_TESTS_API_DIR/*.c; do
+               $CC -Wall -Werror $extra_flags -llustreapi -o $out $prog ||
+                       error "client api broken"
+       done
+}
+run_test 400a "Lustre client api program can compile and link"
+
+test_400b() { # LU-1606, LU-5011
+       local header
+       local out=$TMP/$tfile
+       local prefix=/usr/include/lustre
+
+       # We use a hard coded prefix so that this test will not fail
+       # when run in tree. There are headers in lustre/include/lustre/
+       # that are not packaged (like lustre_idl.h) and have more
+       # complicated include dependencies (like config.h and lnet/types.h).
+       # Since this test about correct packaging we just skip them when
+       # they don't exist (see below) rather than try to fixup cppflags.
+
+       if ! which $CC > /dev/null 2>&1; then
+               skip_env "$CC is not installed"
+               return 0
+       fi
+
+       for header in $prefix/*.h; do
+               if ! [[ -f "$header" ]]; then
+                       continue
+               fi
+
+               if [[ "$(basename $header)" == liblustreapi.h ]]; then
+                       continue # liblustreapi.h is deprecated.
+               fi
+
+               $CC -Wall -Werror -include $header -c -x c /dev/null -o $out ||
+                       error "cannot compile '$header'"
+       done
+}
+run_test 400b "packaged headers can be compiled"
+
 #
 # tests that do cleanup/setup should be run at the end
 #