Whamcloud - gitweb
LU-11215 tests: replace "large_xattr" with "ea_inode"
[fs/lustre-release.git] / lustre / tests / sanity.sh
index dce54bb..868be7a 100755 (executable)
@@ -8,12 +8,14 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: LU-9693 LU-6493 LU-9693
-ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c"
+# bug number for skipped test: LU-9693 LU-6493 LU-9693 LU-11058
+ALWAYS_EXCEPT="$SANITY_EXCEPT  42a     42b     42c     77k"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-# skipped tests: LU-8411 LU-9096 LU-9054
+# skipped tests: LU-8411 LU-9096 LU-9054 ..
 ALWAYS_EXCEPT="  407     253     312     $ALWAYS_EXCEPT"
+# skipped tests: LU-4684
+ALWAYS_EXCEPT="  17n 160d 230 316      $ALWAYS_EXCEPT"
 
 # Check Grants after these tests
 GRANT_CHECK_LIST="$GRANT_CHECK_LIST 42a 42b 42c 42d 42e 63a 63b 64a 64b 64c"
@@ -40,7 +42,7 @@ SOCKETCLIENT=${SOCKETCLIENT:-socketclient}
 MEMHOG=${MEMHOG:-memhog}
 DIRECTIO=${DIRECTIO:-directio}
 ACCEPTOR_PORT=${ACCEPTOR_PORT:-988}
-STRIPES_PER_OBJ=-1
+DEF_STRIPE_COUNT=-1
 CHECK_GRANT=${CHECK_GRANT:-"yes"}
 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
 export PARALLEL=${PARALLEL:-"no"}
@@ -59,6 +61,11 @@ init_test_env $@
 . ${CONFIG:=$LUSTRE/tests/cfg/${NAME}.sh}
 init_logging
 
+if [[ $MDSCOUNT -gt 1 ]]; then
+       # bug number:    LU-11161
+       ALWAYS_EXCEPT+=" 160g"
+fi
+
 #                                  5          12          (min)"
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="27m 64b 68 71 115 300o"
 
@@ -69,11 +76,10 @@ if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
        [ "$SLOW" = "no" ] && EXCEPT_SLOW="$EXCEPT_SLOW 51b"
 fi
 
-# Get the SLES version so we can make decisions on if a test should be run
+# Get the SLES distro version
 #
 # Returns a version string that should only be used in comparing
 # strings returned by version_code()
-
 sles_version_code()
 {
        local version=$(grep VERSION_ID /etc/os-release | cut -d'"' -f2)
@@ -83,6 +89,8 @@ sles_version_code()
        version_code $sles_version
 }
 
+# Check if we are running on Ubuntu or SLES so we can make decisions on
+# what tests to run
 if [ -r /etc/SuSE-release ]; then
        sles_version=$(sles_version_code)
        [ $sles_version -lt $(version_code 11.4.0) ] &&
@@ -91,6 +99,21 @@ if [ -r /etc/SuSE-release ]; then
        [ $sles_version -lt $(version_code 12.0.0) ] &&
                # bug number for skipped test: LU-3703
                ALWAYS_EXCEPT="$ALWAYS_EXCEPT  234"
+elif [ -r /etc/os-release ]; then
+       if grep -qi ubuntu /etc/os-release; then
+               ubuntu_version=$(version_code $(sed -n -e 's/"//g' \
+                                               -e 's/^VERSION=//p' \
+                                               /etc/os-release |
+                                               awk '{ print $1 }'))
+
+               if [[ $ubuntu_version -gt $(version_code 16.0.0) ]]; then
+                       # bug number for skipped test:
+                       #                LU-10334 LU-10335 LU-10335 LU-10335
+                       ALWAYS_EXCEPT+=" 103a     130a     130b     130c"
+                       #                LU-10335 LU-10335 LU-10365 LU-10366
+                       ALWAYS_EXCEPT+=" 130d     130e     400a     410"
+               fi
+       fi
 fi
 
 FAIL_ON_ERROR=false
@@ -110,16 +133,13 @@ setup() {
 check_swap_layouts_support()
 {
        $LCTL get_param -n llite.*.sbi_flags | grep -q layout ||
-               { skip "Does not support layout lock."; return 0; }
-       return 1
+               skip "Does not support layout lock."
 }
 
 check_and_setup_lustre
 DIR=${DIR:-$MOUNT}
 assert_DIR
 
-MDT0=$($LCTL get_param -n mdc.*.mds_server_uuid |
-       awk '{ gsub(/_UUID/,""); print $1 }' | head -n1)
 MAXFREE=${MAXFREE:-$((200000 * $OSTCOUNT))}
 
 [ -f $DIR/d52a/foo ] && chattr -a $DIR/d52a/foo
@@ -170,6 +190,45 @@ test_0c() {
 }
 run_test 0c "check import proc"
 
+test_0d() { # LU-3397
+       [ $(lustre_version_code mgs) -lt $(version_code 2.10.57) ] &&
+               skip "proc exports not supported before 2.10.57"
+
+       local mgs_exp="mgs.MGS.exports"
+       local client_uuid=$($LCTL get_param -n mgc.*.uuid)
+       local exp_client_nid
+       local exp_client_version
+       local exp_val
+       local imp_val
+       local temp_imp=$DIR/$tfile.import
+       local temp_exp=$DIR/$tfile.export
+
+       # save mgc import file to $temp_imp
+       $LCTL get_param mgc.*.import | tee $temp_imp
+       # Check if client uuid is found in MGS export
+       for exp_client_nid in $(do_facet mgs $LCTL get_param -N $mgs_exp.*); do
+               [ $(do_facet mgs $LCTL get_param -n $exp_client_nid.uuid) == \
+                       $client_uuid ] &&
+                       break;
+       done
+       # save mgs export file to $temp_exp
+       do_facet mgs $LCTL get_param $exp_client_nid.export | tee $temp_exp
+
+       # Compare the value of field "connect_flags"
+       imp_val=$(grep "connect_flags" $temp_imp)
+       exp_val=$(grep "connect_flags" $temp_exp)
+       [ "$exp_val" == "$imp_val" ] ||
+               error "export flags '$exp_val' != import flags '$imp_val'"
+
+       # Compare the value of client version
+       exp_client_version=$(awk '/target_version:/ { print $2 }' $temp_exp)
+       exp_val=$(version_code $exp_client_version)
+       imp_val=$(lustre_version_code client)
+       [ "$exp_val" == "$imp_val" ] ||
+               error "export client version '$exp_val' != '$imp_val'"
+}
+run_test 0d "check export proc ============================="
+
 test_1() {
        test_mkdir $DIR/$tdir
        test_mkdir $DIR/$tdir/d2
@@ -237,7 +296,8 @@ test_6a() {
 run_test 6a "touch f6a; chmod f6a; $RUNAS chmod f6a (should return error) =="
 
 test_6c() {
-       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
+
        touch $DIR/$tfile
        chown $RUNAS_ID $DIR/$tfile || error "chown $RUNAS_ID $file failed"
        $CHECKSTAT -t file -u \#$RUNAS_ID $DIR/$tfile ||
@@ -249,7 +309,8 @@ test_6c() {
 run_test 6c "touch f6c; chown f6c; $RUNAS chown f6c (should return error) =="
 
 test_6e() {
-       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
+
        touch $DIR/$tfile
        chgrp $RUNAS_ID $DIR/$tfile || error "chgrp $RUNAS_ID $file failed"
        $CHECKSTAT -t file -u \#$UID -g \#$RUNAS_ID $DIR/$tfile ||
@@ -261,7 +322,8 @@ test_6e() {
 run_test 6e "touch+chgrp $tfile; $RUNAS chgrp $tfile (should return error)"
 
 test_6g() {
-       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
+
        test_mkdir $DIR/$tdir
        chmod 777 $DIR/$tdir || error "chmod 0777 $tdir failed"
        $RUNAS mkdir $DIR/$tdir/d || error "mkdir $tdir/d failed"
@@ -288,7 +350,8 @@ test_6g() {
 run_test 6g "verify new dir in sgid dir inherits group"
 
 test_6h() { # bug 7331
-       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID" && return
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID"
+
        touch $DIR/$tfile || error "touch failed"
        chown $RUNAS_ID:$RUNAS_GID $DIR/$tfile || error "initial chown failed"
        $RUNAS -G$RUNAS_GID chown $RUNAS_ID:0 $DIR/$tfile &&
@@ -500,15 +563,13 @@ test_17g() {
 run_test 17g "symlinks: really long symlink name and inode boundaries"
 
 test_17h() { #bug 17378
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local mdt_idx
+
        test_mkdir $DIR/$tdir
-       if [[ $MDSCOUNT -gt 1 ]]; then
-               mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
-       else
-               mdt_idx=0
-       fi
+       mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
        $LFS setstripe -c -1 $DIR/$tdir
        #define OBD_FAIL_MDS_LOV_PREP_CREATE 0x141
        do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000141
@@ -517,30 +578,28 @@ test_17h() { #bug 17378
 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 -c1 $DIR/$tdir
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local foo=$DIR/$tdir/$tfile
        local mdt_idx
-       if [[ $MDSCOUNT -gt 1 ]]; then
-               mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
-       else
-               mdt_idx=0
-       fi
+
+       test_mkdir -c1 $DIR/$tdir
+       mdt_idx=$($LFS getdirstripe -i $DIR/$tdir)
        ln -s $foo $foo || error "create symlink failed"
 #define OBD_FAIL_MDS_READLINK_EPROTO     0x143
        do_facet mds$((mdt_idx + 1)) lctl set_param fail_loc=0x80000143
        ls -l $foo && error "error not detected"
        return 0
 }
-run_test 17i "don't panic on short symlink"
+run_test 17i "don't panic on short symlink (should return error)"
 
 test_17k() { #bug 22301
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ -z "$(which rsync 2>/dev/null)" ]] &&
-               skip "no rsync command" && return 0
+               skip "no rsync command"
        rsync --help | grep -q xattr ||
                skip_env "$(rsync --version | head -n1) does not support xattrs"
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
        test_mkdir $DIR/$tdir
        test_mkdir $DIR/$tdir.new
        touch $DIR/$tdir/$tfile
@@ -552,7 +611,8 @@ run_test 17k "symlinks: rsync with xattrs enabled"
 
 test_17l() { # LU-279
        [[ -z "$(which getfattr 2>/dev/null)" ]] &&
-               skip "no getfattr command" && return 0
+               skip "no getfattr command"
+
        test_mkdir $DIR/$tdir
        touch $DIR/$tdir/$tfile
        ln -s $DIR/$tdir/$tfile $DIR/$tdir/$tfile.lnk
@@ -570,19 +630,17 @@ run_test 17l "Ensure lgetxattr's returned xattr size is consistent"
 
 # LU-1540
 test_17m() {
-       local short_sym="0123456789"
-       local wdir=$DIR/$tdir
-       local i
-
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+               skip_env "ldiskfs only test"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
-               skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
+               skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
 
-       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return 0
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       local short_sym="0123456789"
+       local wdir=$DIR/$tdir
+       local i
 
        test_mkdir $wdir
        long_sym=$short_sym
@@ -609,7 +667,7 @@ test_17m() {
                ln -sf ${short_sym} $wdir/short-$i || error "short_sym failed"
        done
 
-       local mds_index=$(($($LFS getstripe -M $wdir) + 1))
+       local mds_index=$(($($LFS getstripe -m $wdir) + 1))
        local devname=$(mdsdevname $mds_index)
 
        echo "stop and checking mds${mds_index}:"
@@ -623,6 +681,7 @@ test_17m() {
        df $MOUNT > /dev/null 2>&1
        [ $rc -eq 0 ] ||
                error "e2fsck detected error for short/long symlink: rc=$rc"
+       rm -f $wdir/*
 }
 run_test 17m "run e2fsck against MDT which contains short/long symlink"
 
@@ -647,19 +706,16 @@ check_fs_consistency_17n() {
 }
 
 test_17n() {
-       local i
-
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+               skip_env "ldiskfs only test"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] &&
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.2.93) ] &&
-               skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks" && return
-
-       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return 0
+               skip "MDS 2.2.0-2.2.93 do not NUL-terminate symlinks"
 
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       local i
 
        test_mkdir $DIR/$tdir
        for ((i=0; i<10; i++)); do
@@ -681,7 +737,7 @@ test_17n() {
                error "e2fsck report error after unlink files under remote dir"
 
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.50) ] &&
-               skip "lustre < 2.4.50 does not support migrate mv " && return
+               skip "lustre < 2.4.50 does not support migrate mv"
 
        for ((i = 0; i < 10; i++)); do
                mkdir -p $DIR/$tdir/remote_dir_${i}
@@ -702,9 +758,9 @@ test_17n() {
 run_test 17n "run e2fsck against master/slave MDT which contains remote dir"
 
 test_17o() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.64) ] &&
-               skip "Need MDS version at least 2.3.64" && return
+               skip "Need MDS version at least 2.3.64"
 
        local wdir=$DIR/${tdir}o
        local mdt_index
@@ -712,7 +768,7 @@ test_17o() {
 
        test_mkdir $wdir
        touch $wdir/$tfile
-       mdt_index=$($LFS getstripe -M $wdir/$tfile)
+       mdt_index=$($LFS getstripe -m $wdir/$tfile)
        mdt_index=$((mdt_index + 1))
 
        cancel_lru_locks mdc
@@ -749,7 +805,8 @@ run_test 19b "ls -l .../f19 (should return error) =============="
 
 test_19c() {
        [ $RUNAS_ID -eq $UID ] &&
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
+
        $RUNAS touch $DIR/$tfile && error "create non-root file failed" || true
 }
 run_test 19c "$RUNAS touch .../f19 (should return error) =="
@@ -819,6 +876,51 @@ test_23b() { # bug 18988
 }
 run_test 23b "O_APPEND check"
 
+# LU-9409, size with O_APPEND and tiny writes
+test_23c() {
+       local file=$DIR/$tfile
+
+       # single dd
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800
+       $CHECKSTAT -s 6400 $file || error "wrong size, expected 6400"
+       rm -f $file
+
+       # racing tiny writes
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=800 &
+       wait
+       $CHECKSTAT -s 12800 $file || error "wrong size, expected 12800"
+       rm -f $file
+
+       #racing tiny & normal writes
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4096 count=4 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=8 count=100 &
+       wait
+       $CHECKSTAT -s 17184 $file || error "wrong size, expected 17184"
+       rm -f $file
+
+       #racing tiny & normal writes 2, ugly numbers
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=4099 count=11 &
+       dd conv=notrunc oflag=append if=/dev/zero of=$file bs=17 count=173 &
+       wait
+       $CHECKSTAT -s 48030 $file || error "wrong size, expected 48030"
+       rm -f $file
+}
+run_test 23c "O_APPEND size checks for tiny writes"
+
+# LU-11069 file offset is correct after appending writes
+test_23d() {
+       local file=$DIR/$tfile
+       local offset
+
+       echo CentaurHauls > $file
+       offset=$($MULTIOP $file oO_WRONLY:O_APPEND:w13Zp)
+       if ((offset != 26)); then
+               error "wrong offset, expected 26, got '$offset'"
+       fi
+}
+run_test 23d "file offset is correct after appending writes"
+
 # rename sanity
 test_24a() {
        echo '-- same directory rename'
@@ -863,8 +965,8 @@ test_24e() {
        test_mkdir $DIR/R5b
        touch $DIR/R5a/f
        mv $DIR/R5a/f $DIR/R5b/g
-       $CHECKSTAT -a $DIR/R5a/f || error
-       $CHECKSTAT -t file $DIR/R5b/g || error
+       $CHECKSTAT -a $DIR/R5a/f || error "$DIR/R5a/f exists"
+       $CHECKSTAT -t file $DIR/R5b/g || error "$DIR/R5b/g not file type"
 }
 run_test 24e "touch .../R5a/f; rename .../R5a/f .../R5b/g ======"
 
@@ -873,8 +975,8 @@ test_24f() {
        test_mkdir $DIR/R6b
        touch $DIR/R6a/f $DIR/R6b/g
        mv $DIR/R6a/f $DIR/R6b/g
-       $CHECKSTAT -a $DIR/R6a/f || error
-       $CHECKSTAT -t file $DIR/R6b/g || error
+       $CHECKSTAT -a $DIR/R6a/f || error "$DIR/R6a/f exists"
+       $CHECKSTAT -t file $DIR/R6b/g || error "$DIR/R6b/g not file type"
 }
 run_test 24f "touch .../R6a/f R6b/g; mv .../R6a/f .../R6b/g ===="
 
@@ -883,8 +985,8 @@ test_24g() {
        test_mkdir $DIR/R7b
        test_mkdir $DIR/R7a/d
        mv $DIR/R7a/d $DIR/R7b/e
-       $CHECKSTAT -a $DIR/R7a/d || error
-       $CHECKSTAT -t dir $DIR/R7b/e || error
+       $CHECKSTAT -a $DIR/R7a/d || error "$DIR/R7a/d exists"
+       $CHECKSTAT -t dir $DIR/R7b/e || error "$DIR/R7b/e not dir type"
 }
 run_test 24g "mkdir .../R7{a,b}/d; mv .../R7a/d .../R7b/e ======"
 
@@ -894,8 +996,8 @@ test_24h() {
        test_mkdir -c1 $DIR/R8a/d
        test_mkdir -c1 $DIR/R8b/e
        mrename $DIR/R8a/d $DIR/R8b/e
-       $CHECKSTAT -a $DIR/R8a/d || error
-       $CHECKSTAT -t dir $DIR/R8b/e || error
+       $CHECKSTAT -a $DIR/R8a/d || error "$DIR/R8a/d exists"
+       $CHECKSTAT -t dir $DIR/R8b/e || error "$DIR/R8b/e not dir type"
 }
 run_test 24h "mkdir .../R8{a,b}/{d,e}; rename .../R8a/d .../R8b/e"
 
@@ -905,18 +1007,18 @@ test_24i() {
        test_mkdir $DIR/R9/a
        touch $DIR/R9/f
        mrename $DIR/R9/f $DIR/R9/a
-       $CHECKSTAT -t file $DIR/R9/f || error
-       $CHECKSTAT -t dir  $DIR/R9/a || error
-       $CHECKSTAT -a $DIR/R9/a/f || error
+       $CHECKSTAT -t file $DIR/R9/f || error "$DIR/R9/f not file type"
+       $CHECKSTAT -t dir  $DIR/R9/a || error "$DIR/R9/a not dir type"
+       $CHECKSTAT -a $DIR/R9/a/f || error "$DIR/R9/a/f exists"
 }
 run_test 24i "rename file to dir error: touch f ; mkdir a ; rename f a"
 
 test_24j() {
        test_mkdir $DIR/R10
        mrename $DIR/R10/f $DIR/R10/g
-       $CHECKSTAT -t dir $DIR/R10 || error
-       $CHECKSTAT -a $DIR/R10/f || error
-       $CHECKSTAT -a $DIR/R10/g || error
+       $CHECKSTAT -t dir $DIR/R10 || error "$DIR/R10 not dir type"
+       $CHECKSTAT -a $DIR/R10/f || error "$DIR/R10/f exists"
+       $CHECKSTAT -a $DIR/R10/g || error "$DIR/R10/g exists"
 }
 run_test 24j "source does not exist ============================"
 
@@ -925,15 +1027,15 @@ test_24k() {
        test_mkdir $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 "$DIR/R11a/f exists"
+       $CHECKSTAT -t file $DIR/R11a/d/f || error "$DIR/R11a/d/f not file type"
 }
 run_test 24k "touch .../R11a/f; mv .../R11a/f .../R11a/d ======="
 
 # bug 2429 - rename foo foo foo creates invalid file
 test_24l() {
        f="$DIR/f24l"
-       $MULTIOP $f OcNs || error
+       $MULTIOP $f OcNs || error "rename of ${f} to itself failed"
 }
 run_test 24l "Renaming a file to itself ========================"
 
@@ -951,10 +1053,10 @@ test_24n() {
     f="$DIR/f24n"
     # this stats the old file after it was renamed, so it should fail
     touch ${f}
-    $CHECKSTAT ${f}
+    $CHECKSTAT ${f} || error "${f} missing"
     mv ${f} ${f}.rename
-    $CHECKSTAT ${f}.rename
-    $CHECKSTAT -a ${f}
+    $CHECKSTAT ${f}.rename || error "${f}.rename missing"
+    $CHECKSTAT -a ${f} || error "${f} exists"
 }
 run_test 24n "Statting the old file after renaming (Posix rename 2)"
 
@@ -969,8 +1071,8 @@ test_24p() {
        test_mkdir $DIR/R12b
        DIRINO=`ls -lid $DIR/R12a | awk '{ print $1 }'`
        mrename $DIR/R12a $DIR/R12b
-       $CHECKSTAT -a $DIR/R12a || error
-       $CHECKSTAT -t dir $DIR/R12b || error
+       $CHECKSTAT -a $DIR/R12a || error "$DIR/R12a exists"
+       $CHECKSTAT -t dir $DIR/R12b || error "$DIR/R12b not dir type"
        DIRINO2=`ls -lid $DIR/R12b | awk '{ print $1 }'`
        [ "$DIRINO" = "$DIRINO2" ] || error "R12a $DIRINO != R12b $DIRINO2"
 }
@@ -982,7 +1084,8 @@ cleanup_multiop_pause() {
 }
 
 test_24q() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/R13a
        test_mkdir $DIR/R13b
        local DIRINO=$(ls -lid $DIR/R13a | awk '{ print $1 }')
@@ -1029,7 +1132,7 @@ 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
+       $MULTIOP $DIR/$tfile C2w$((2048 * 1024))c || error "multiop failed"
        $CHECKSTAT -s $((2048 * 1024)) $DIR/$tfile || error "wrong file size"
 }
 run_test 24u "create stripe file"
@@ -1059,12 +1162,14 @@ max_pages_per_rpc() {
 }
 
 test_24v() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local nrfiles=${COUNT:-100000}
+       local fname="$DIR/$tdir/$tfile"
+
        # Performance issue on ZFS see LU-4072 (c.f. LU-2887)
        [ $(facet_fstype $SINGLEMDS) = "zfs" ] && nrfiles=${COUNT:-10000}
 
-       local fname="$DIR/$tdir/$tfile"
        test_mkdir "$(dirname $fname)"
        # assume MDT0000 has the fewest inodes
        local stripes=$($LFS getdirstripe -c $(dirname $fname))
@@ -1121,12 +1226,11 @@ test_24w() { # bug21506
 run_test 24w "Reading a file larger than 4Gb"
 
 test_24x() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
-
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
-               skip "Need MDS version at least 2.7.56" && return
+               skip "Need MDS version at least 2.7.56"
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        local MDTIDX=1
        local remote_dir=$DIR/$tdir/remote_dir
 
@@ -1154,14 +1258,15 @@ test_24x() {
 run_test 24x "cross MDT rename/link"
 
 test_24y() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local remote_dir=$DIR/$tdir/remote_dir
        local mdtidx=1
 
        test_mkdir $DIR/$tdir
        $LFS mkdir -i $mdtidx $remote_dir ||
-                  error "create remote directory failed"
+               error "create remote directory failed"
 
        test_mkdir $remote_dir/src_dir
        touch $remote_dir/src_file
@@ -1200,7 +1305,8 @@ test_24A() { # LU-3182
 run_test 24A "readdir() returns correct number of entries."
 
 test_24B() { # LU-4805
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local count
 
        test_mkdir $DIR/$tdir
@@ -1225,7 +1331,7 @@ test_24B() { # LU-4805
 run_test 24B "readdir for striped dir return correct number of entries"
 
 test_24C() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        mkdir $DIR/$tdir
        mkdir $DIR/$tdir/d0
@@ -1254,8 +1360,8 @@ test_24C() {
 run_test 24C "check .. in striped dir"
 
 test_24E() {
-       [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        mkdir -p $DIR/$tdir
        mkdir $DIR/$tdir/src_dir
@@ -1290,13 +1396,14 @@ test_25a() {
 
        test_mkdir $DIR/d25
        ln -s d25 $DIR/s25
-       touch $DIR/s25/foo || error
+       touch $DIR/s25/foo ||
+               error "File creation in symlinked directory failed"
 }
 run_test 25a "create file in symlinked directory ==============="
 
 test_25b() {
        [ ! -d $DIR/d25 ] && test_25a
-       $CHECKSTAT -t file $DIR/s25/foo || error
+       $CHECKSTAT -t file $DIR/s25/foo || error "$DIR/s25/foo not file type"
 }
 run_test 25b "lookup file in symlinked directory ==============="
 
@@ -1304,14 +1411,14 @@ test_26a() {
        test_mkdir $DIR/d26
        test_mkdir $DIR/d26/d26-2
        ln -s d26/d26-2 $DIR/s26
-       touch $DIR/s26/foo || error
+       touch $DIR/s26/foo || error "File creation failed"
 }
 run_test 26a "multiple component symlink ======================="
 
 test_26b() {
        test_mkdir -p $DIR/$tdir/d26-2
        ln -s $tdir/d26-2/foo $DIR/s26-2
-       touch $DIR/s26-2 || error
+       touch $DIR/s26-2 || error "File creation failed"
 }
 run_test 26b "multiple component symlink at end of lookup ======"
 
@@ -1360,12 +1467,13 @@ test_27a() {
        $LFS getstripe $DIR/$tdir
        $LFS setstripe -c 1 $DIR/$tdir/$tfile || error "setstripe failed"
        $CHECKSTAT -t file $DIR/$tdir/$tfile || error "checkstat failed"
-       cp /etc/hosts $DIR/$tdir/$tfile || error
+       cp /etc/hosts $DIR/$tdir/$tfile || error "Can't copy to one stripe file"
 }
 run_test 27a "one stripe file"
 
 test_27b() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        test_mkdir $DIR/$tdir
        $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
        $LFS getstripe -c $DIR/$tdir/$tfile
@@ -1388,7 +1496,8 @@ run_test 27d "create file with default settings"
 test_27e() {
        # LU-5839 adds check for existed layout before setting it
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.56) ]] &&
-               skip "Need MDS version at least 2.7.56" && return
+               skip "Need MDS version at least 2.7.56"
+
        test_mkdir $DIR/$tdir
        $LFS setstripe -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
        $LFS setstripe -c 2 $DIR/$tdir/$tfile && error "setstripe worked twice"
@@ -1451,13 +1560,12 @@ test_27l() {
 run_test 27l "check setstripe permissions (should return error)"
 
 test_27m() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        ORIGFREE=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
                   head -n1)
        if [[ $ORIGFREE -gt $MAXFREE ]]; then
                skip "$ORIGFREE > $MAXFREE skipping out-of-space test on OST0"
-               return
        fi
        trap simple_cleanup_common EXIT
        test_mkdir $DIR/$tdir
@@ -1485,7 +1593,7 @@ run_test 27m "create file while OST0 was full"
 
 sleep_maxage() {
        local delay=$(do_facet $SINGLEMDS lctl get_param -n lov.*.qos_maxage |
-                     head -n 1 | awk '{ print $1 * 2 }')
+                     awk '{ print $1 * 2; exit; }')
        sleep $delay
 }
 
@@ -1509,7 +1617,7 @@ exhaust_precreations() {
        local ofacet=ost$((OSTIDX + 1))
 
        test_mkdir -p -c1 $DIR/$tdir
-       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local mdtidx=$($LFS getstripe -m $DIR/$tdir)
        local mfacet=mds$((mdtidx + 1))
        echo OSTIDX=$OSTIDX MDTIDX=$mdtidx
 
@@ -1544,26 +1652,26 @@ exhaust_all_precreations() {
 }
 
 test_27n() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_enospc
        rm -f $DIR/$tdir/$tfile
        exhaust_precreations 0 0x80000215
-       $LFS setstripe -c -1 $DIR/$tdir
-       touch $DIR/$tdir/$tfile || error
+       $LFS setstripe -c -1 $DIR/$tdir || error "setstripe failed"
+       touch $DIR/$tdir/$tfile || error "touch failed"
        $LFS getstripe $DIR/$tdir/$tfile
        reset_enospc
 }
 run_test 27n "create file with some full OSTs"
 
 test_27o() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_enospc
        rm -f $DIR/$tdir/$tfile
@@ -1577,10 +1685,10 @@ test_27o() {
 run_test 27o "create file with all full OSTs (should error)"
 
 test_27p() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_enospc
        rm -f $DIR/$tdir/$tfile
@@ -1600,10 +1708,10 @@ test_27p() {
 run_test 27p "append to a truncated file with some full OSTs"
 
 test_27q() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_enospc
        rm -f $DIR/$tdir/$tfile
@@ -1624,16 +1732,16 @@ test_27q() {
 run_test 27q "append to truncated file with all OSTs full (should error)"
 
 test_27r() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_enospc
        rm -f $DIR/$tdir/$tfile
        exhaust_precreations 0 0x80000215
 
-       $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile # && error
+       $LFS setstripe -i 0 -c 2 $DIR/$tdir/$tfile || error "setstripe failed"
 
        reset_enospc
 }
@@ -1661,8 +1769,9 @@ test_27t() { # bug 10864
 run_test 27t "check that utils parse path correctly"
 
 test_27u() { # bug 4900
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local index
        local list=$(comma_list $(mdts_nodes))
 
@@ -1685,10 +1794,10 @@ test_27u() { # bug 4900
 run_test 27u "skip object creation on OSC w/o objects"
 
 test_27v() { # bug 4900
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        exhaust_all_precreations 0x215
        reset_enospc
@@ -1726,7 +1835,7 @@ run_test 27w "check $LFS setstripe -S and getstrip -d options"
 
 test_27wa() {
        [[ $OSTCOUNT -lt 2 ]] &&
-               skip_env "skipping multiple stripe count/offset test" && return
+               skip_env "skipping multiple stripe count/offset test"
 
        test_mkdir $DIR/$tdir
        for i in $(seq 1 $OSTCOUNT); do
@@ -1743,9 +1852,10 @@ test_27wa() {
 run_test 27wa "check $LFS setstripe -c -i options"
 
 test_27x() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        OFFSET=$(($OSTCOUNT - 1))
        OSTIDX=0
        local OST=$(ostname_from_index $OSTIDX)
@@ -1765,10 +1875,10 @@ test_27x() {
 run_test 27x "create files while OST0 is degraded"
 
 test_27y() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $FSNAME-OST0000)
        local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
@@ -1776,7 +1886,7 @@ test_27y() {
        local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
                osc.$mdtosc.prealloc_next_id)
        local fcount=$((last_id - next_id))
-       [[ $fcount -eq 0 ]] && skip "not enough space on OST0" && return
+       [[ $fcount -eq 0 ]] && skip "not enough space on OST0"
        [[ $fcount -gt $OSTCOUNT ]] && fcount=$OSTCOUNT
 
        local MDS_OSCS=$(do_facet $SINGLEMDS lctl dl |
@@ -1951,10 +2061,10 @@ check_seq_oid()
 }
 
 test_27z() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       test_mkdir $DIR/$tdir
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
+       test_mkdir $DIR/$tdir
        $LFS setstripe -c 1 -i 0 -S 64k $DIR/$tdir/$tfile-1 ||
                { error "setstripe -c -1 failed"; return 1; }
        # We need to send a write to every object to get parent FID info set.
@@ -1976,20 +2086,20 @@ test_27z() {
 run_test 27z "check SEQ/OID on the MDT and OST filesystems"
 
 test_27A() { # b=19102
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        local restore_size=$($GETSTRIPE -S $MOUNT)
-        local restore_count=$($GETSTRIPE -c $MOUNT)
-        local restore_offset=$($GETSTRIPE -i $MOUNT)
-        $SETSTRIPE -c 0 -i -1 -S 0 $MOUNT
-        wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/  *//g'" "1" 20 ||
-                error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
-        local default_size=$($GETSTRIPE -S $MOUNT)
-        local default_offset=$($GETSTRIPE -i $MOUNT)
-        local dsize=$((1024 * 1024))
-        [ $default_size -eq $dsize ] ||
-                error "stripe size $default_size != $dsize"
-        [ $default_offset -eq -1 ] ||error "stripe offset $default_offset != -1"
-        $SETSTRIPE -c $restore_count -i $restore_offset -S $restore_size $MOUNT
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       save_layout_restore_at_exit $MOUNT
+       $LFS setstripe -c 0 -i -1 -S 0 $MOUNT
+       wait_update $HOSTNAME "$GETSTRIPE -c $MOUNT | sed 's/  *//g'" "1" 20 ||
+               error "stripe count $($GETSTRIPE -c $MOUNT) != 1"
+       local default_size=$($GETSTRIPE -S $MOUNT)
+       local default_offset=$($GETSTRIPE -i $MOUNT)
+       local dsize=$(do_facet $SINGLEMDS \
+               "$LCTL get_param -n lod.$(facet_svc $SINGLEMDS)*.stripesize")
+       [ $default_size -eq $dsize ] ||
+               error "stripe size $default_size != $dsize"
+       [ $default_offset -eq -1 ] ||
+               error "stripe offset $default_offset != -1"
 }
 run_test 27A "check filesystem-wide default LOV EA values"
 
@@ -2017,7 +2127,7 @@ test_27B() { # LU-2523
 run_test 27B "call setstripe on open unlinked file/rename victim"
 
 test_27C() { #LU-2871
-       [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        declare -a ost_idx
        local index
@@ -2055,9 +2165,10 @@ test_27C() { #LU-2871
 run_test 27C "check full striping across all OSTs"
 
 test_27D() {
-       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local POOL=${POOL:-testpool}
        local first_ost=0
        local last_ost=$(($OSTCOUNT - 1))
@@ -2093,9 +2204,9 @@ run_test 27D "validate llapi_layout API"
 # Verify that default_easize is increased from its initial value after
 # accessing a widely striped file.
 test_27E() {
-       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
        [ $(lustre_version_code client) -lt $(version_code 2.5.57) ] &&
-               skip "client does not have LU-3338 fix" && return
+               skip "client does not have LU-3338 fix"
 
        # 72 bytes is the minimum space required to store striping
        # information for a file striped across one OST:
@@ -2122,10 +2233,11 @@ test_27E() {
 run_test 27E "check that default extended attribute size properly increases"
 
 test_27F() { # LU-5346/LU-7975
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip "needs >= 2 OSTs"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.51) ]] &&
-               skip "Need MDS version at least 2.8.51" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+               skip "Need MDS version at least 2.8.51"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        test_mkdir $DIR/$tdir
        rm -f $DIR/$tdir/f0
@@ -2160,16 +2272,61 @@ test_27F() { # LU-5346/LU-7975
 }
 run_test 27F "Client resend delayed layout creation with non-zero size"
 
+test_27G() { #LU-10629
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       local POOL=${POOL:-testpool}
+       local ostrange="0 0 1"
+
+       test_mkdir $DIR/$tdir
+       pool_add $POOL || error "pool_add failed"
+       pool_add_targets $POOL $ostrange || error "pool_add_targets failed"
+       $LFS setstripe -p $POOL $DIR/$tdir
+
+       local pool=$($LFS getstripe -p $DIR/$tdir)
+
+       [ "$pool" = "$POOL" ] || error "Striping failed got '$pool' not '$POOL'"
+
+       $LFS setstripe -d $DIR/$tdir
+
+       pool=$($LFS getstripe -p $DIR/$tdir)
+
+       rmdir $DIR/$tdir
+
+       [ -z "$pool" ] || error "'$pool' is not empty"
+}
+run_test 27G "Clear OST pool from stripe"
+
+test_27H() {
+       [[ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.11.53) ]] &&
+               skip "Need MDS version newer than 2.11.53"
+       [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
+       test_mkdir $DIR/$tdir
+       $LFS setstripe -o 0 -o 2 $DIR/$tdir || error "setstripe failed"
+       touch $DIR/$tdir/$tfile
+       $LFS getstripe -c $DIR/$tdir/$tfile
+       [ $($LFS getstripe -c $DIR/$tdir/$tfile) -eq 2 ] ||
+               error "two-stripe file doesn't have two stripes"
+
+       dd if=/dev/zero of=$DIR/$tdir/$tfile bs=4k count=4 || error "dd failed"
+       $LFS getstripe -y $DIR/$tdir/$tfile
+       (( $($LFS getstripe -y $DIR/$tdir/$tfile |
+            egrep -c "l_ost_idx: [02]$") == "2" )) ||
+               error "expected l_ost_idx: [02]$ not matched"
+}
+run_test 27H "Set specific OSTs stripe"
+
 # createtest also checks that device nodes are created and
 # then visible correctly (#2091)
 test_28() { # bug 2091
        test_mkdir $DIR/d28
-       $CREATETEST $DIR/d28/ct || error
+       $CREATETEST $DIR/d28/ct || error "createtest failed"
 }
 run_test 28 "create/mknod/mkdir with bad file types ============"
 
 test_29() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return 0
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        sync; sleep 1; sync # flush out any dirty pages from previous tests
        cancel_lru_locks
        test_mkdir $DIR/d29
@@ -2220,7 +2377,7 @@ run_test 29 "IT_GETATTR regression  ============================"
 
 test_30a() { # was test_30
        cp $(which ls) $DIR || cp /bin/ls $DIR
-       $DIR/ls / || error
+       $DIR/ls / || error "Can't execute binary from lustre"
        rm $DIR/ls
 }
 run_test 30a "execute binary from Lustre (execve) =============="
@@ -2228,40 +2385,42 @@ run_test 30a "execute binary from Lustre (execve) =============="
 test_30b() {
        cp `which ls` $DIR || cp /bin/ls $DIR
        chmod go+rx $DIR/ls
-       $RUNAS $DIR/ls / || error
+       $RUNAS $DIR/ls / || error "Can't execute binary from lustre as non-root"
        rm $DIR/ls
 }
 run_test 30b "execute binary from Lustre as non-root ==========="
 
 test_30c() { # b=22376
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        cp `which ls` $DIR || cp /bin/ls $DIR
        chmod a-rw $DIR/ls
        cancel_lru_locks mdc
        cancel_lru_locks osc
-       $RUNAS $DIR/ls / || error
+       $RUNAS $DIR/ls / || error "Can't execute binary from lustre"
        rm -f $DIR/ls
 }
 run_test 30c "execute binary from Lustre without read perms ===="
 
 test_31a() {
-       $OPENUNLINK $DIR/f31 $DIR/f31 || error
-       $CHECKSTAT -a $DIR/f31 || error
+       $OPENUNLINK $DIR/f31 $DIR/f31 || error "openunlink failed"
+       $CHECKSTAT -a $DIR/f31 || error "$DIR/f31 exists"
 }
 run_test 31a "open-unlink file =================================="
 
 test_31b() {
-       touch $DIR/f31 || error
-       ln $DIR/f31 $DIR/f31b || error
-       $MULTIOP $DIR/f31b Ouc || error
-       $CHECKSTAT -t file $DIR/f31 || error
+       touch $DIR/f31 || error "touch $DIR/f31 failed"
+       ln $DIR/f31 $DIR/f31b || error "ln failed"
+       $MULTIOP $DIR/f31b Ouc || error "multiop failed"
+       $CHECKSTAT -t file $DIR/f31 || error "$DIR/f31 not file type"
 }
 run_test 31b "unlink file with multiple links while open ======="
 
 test_31c() {
-       touch $DIR/f31 || error
-       ln $DIR/f31 $DIR/f31c || error
-       multiop_bg_pause $DIR/f31 O_uc || return 1
+       touch $DIR/f31 || error "touch $DIR/f31 failed"
+       ln $DIR/f31 $DIR/f31c || error "ln failed"
+       multiop_bg_pause $DIR/f31 O_uc ||
+               error "multiop_bg_pause for $DIR/f31 failed"
        MULTIPID=$!
        $MULTIOP $DIR/f31c Ouc
        kill -USR1 $MULTIPID
@@ -2270,18 +2429,19 @@ test_31c() {
 run_test 31c "open-unlink file with multiple links ============="
 
 test_31d() {
-       opendirunlink $DIR/d31d $DIR/d31d || error
-       $CHECKSTAT -a $DIR/d31d || error
+       opendirunlink $DIR/d31d $DIR/d31d || error "opendirunlink failed"
+       $CHECKSTAT -a $DIR/d31d || error "$DIR/d31d exists"
 }
 run_test 31d "remove of open directory ========================="
 
 test_31e() { # bug 2904
-       openfilleddirunlink $DIR/d31e || error
+       openfilleddirunlink $DIR/d31e || error "openfilleddirunlink failed"
 }
 run_test 31e "remove of open non-empty directory ==============="
 
 test_31f() { # bug 4554
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        set -vx
        test_mkdir $DIR/d31f
        $SETSTRIPE -S 1048576 -c 1 $DIR/d31f
@@ -2433,11 +2593,11 @@ test_31o() { # LU-2901
 run_test 31o "duplicate hard links with same filename"
 
 test_31p() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        test_mkdir $DIR/$tdir
        $LFS setdirstripe -i0 -c2 $DIR/$tdir/striped_dir
-       $LFS setdirstripe -D -c2 -t all_char $DIR/$tdir/striped_dir
+       $LFS setdirstripe -D -c2 -H all_char $DIR/$tdir/striped_dir
 
        opendirunlink $DIR/$tdir/striped_dir/test1 ||
                error "open unlink test1 failed"
@@ -2462,48 +2622,60 @@ cleanup_test32_mount() {
 }
 
 test_32a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        echo "== more mountpoints and symlinks ================="
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
-       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
+       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/.. ||
+               error "$DIR/$tdir/ext2-mountpoint/.. not dir type"
        cleanup_test32_mount
 }
 run_test 32a "stat d32a/ext2-mountpoint/.. ====================="
 
 test_32b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
-       ls -al $DIR/$tdir/ext2-mountpoint/.. || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
+       ls -al $DIR/$tdir/ext2-mountpoint/.. ||
+               error "Can't list $DIR/$tdir/ext2-mountpoint/.."
        cleanup_test32_mount
 }
 run_test 32b "open d32b/ext2-mountpoint/.. ====================="
 
 test_32c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2/test_dir
-       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
+       $CHECKSTAT -t dir $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
+               error "$DIR/$tdir/ext2-mountpoint/../d2/test_dir not dir type"
        cleanup_test32_mount
 }
 run_test 32c "stat d32c/ext2-mountpoint/../d2/test_dir ========="
 
 test_32d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2/test_dir
-       ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir || error
+       ls -al $DIR/$tdir/ext2-mountpoint/../d2/test_dir ||
+               error "Can't list $DIR/$tdir/ext2-mountpoint/../d2/test_dir"
        cleanup_test32_mount
 }
 run_test 32d "open d32d/ext2-mountpoint/../d2/test_dir"
@@ -2556,51 +2728,63 @@ test_32h() {
 run_test 32h "open d32h/symlink->tmp/symlink->lustre-subdir/${tdir}2"
 
 test_32i() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        touch $DIR/$tdir/test_file
-       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file || error
+       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../test_file ||
+               error "$DIR/$tdir/ext2-mountpoint/../test_file not file type"
        cleanup_test32_mount
 }
 run_test 32i "stat d32i/ext2-mountpoint/../test_file ==========="
 
 test_32j() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        touch $DIR/$tdir/test_file
-       cat $DIR/$tdir/ext2-mountpoint/../test_file || error
+       cat $DIR/$tdir/ext2-mountpoint/../test_file ||
+               error "Can't open $DIR/$tdir/ext2-mountpoint/../test_file"
        cleanup_test32_mount
 }
 run_test 32j "open d32j/ext2-mountpoint/../test_file ==========="
 
 test_32k() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2
-       touch $DIR/$tdir/d2/test_file || error
-       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
+       touch $DIR/$tdir/d2/test_file || error "touch failed"
+       $CHECKSTAT -t file $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
+               error "$DIR/$tdir/ext2-mountpoint/../d2/test_file not file type"
        cleanup_test32_mount
 }
 run_test 32k "stat d32k/ext2-mountpoint/../d2/test_file ========"
 
 test_32l() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint || error
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        test_mkdir -p $DIR/$tdir/d2
-       touch $DIR/$tdir/d2/test_file
-       cat  $DIR/$tdir/ext2-mountpoint/../d2/test_file || error
+       touch $DIR/$tdir/d2/test_file || error "touch failed"
+       cat  $DIR/$tdir/ext2-mountpoint/../d2/test_file ||
+               error "Can't open $DIR/$tdir/ext2-mountpoint/../d2/test_file"
        cleanup_test32_mount
 }
 run_test 32l "open d32l/ext2-mountpoint/../d2/test_file ========"
@@ -2611,8 +2795,10 @@ test_32m() {
        TMP_DIR=$DIR/d32m/tmp
        ln -s $DIR $TMP_DIR/symlink11
        ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
-       $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 || error
-       $CHECKSTAT -t link $DIR/d32m/symlink01 || error
+       $CHECKSTAT -t link $DIR/d32m/tmp/symlink11 ||
+               error "symlink11 not a link"
+       $CHECKSTAT -t link $DIR/d32m/symlink01 ||
+               error "symlink01 not a link"
 }
 run_test 32m "stat d32m/symlink->tmp/symlink->lustre-root ======"
 
@@ -2622,8 +2808,8 @@ test_32n() {
        TMP_DIR=$DIR/d32n/tmp
        ln -s $DIR $TMP_DIR/symlink11
        ln -s $TMP_DIR/symlink11 $TMP_DIR/../symlink01
-       ls -l $DIR/d32n/tmp/symlink11  || error
-       ls -l $DIR/d32n/symlink01 || error
+       ls -l $DIR/d32n/tmp/symlink11  || error "listing symlink11"
+       ls -l $DIR/d32n/symlink01 || error "listing symlink01"
 }
 run_test 32n "open d32n/symlink->tmp/symlink->lustre-root ======"
 
@@ -2633,10 +2819,13 @@ test_32o() {
        TMP_DIR=$DIR/d32o/tmp
        ln -s $DIR/$tfile $TMP_DIR/symlink12
        ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
-       $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 || error
-       $CHECKSTAT -t link $DIR/d32o/symlink02 || error
-       $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 || error
-       $CHECKSTAT -t file -f $DIR/d32o/symlink02 || error
+       $CHECKSTAT -t link $DIR/d32o/tmp/symlink12 ||
+               error "symlink12 not a link"
+       $CHECKSTAT -t link $DIR/d32o/symlink02 || error "symlink02 not a link"
+       $CHECKSTAT -t file -f $DIR/d32o/tmp/symlink12 ||
+               error "$DIR/d32o/tmp/symlink12 not file type"
+       $CHECKSTAT -t file -f $DIR/d32o/symlink02 ||
+               error "$DIR/d32o/symlink02 not file type"
 }
 run_test 32o "stat d32o/symlink->tmp/symlink->lustre-root/$tfile"
 
@@ -2656,32 +2845,37 @@ test_32p() {
        log 32p_7
        ln -s $TMP_DIR/symlink12 $TMP_DIR/../symlink02
        log 32p_8
-       cat $DIR/d32p/tmp/symlink12 || error
+       cat $DIR/d32p/tmp/symlink12 ||
+               error "Can't open $DIR/d32p/tmp/symlink12"
        log 32p_9
-       cat $DIR/d32p/symlink02 || error
+       cat $DIR/d32p/symlink02 || error "Can't open $DIR/d32p/symlink02"
        log 32p_10
 }
 run_test 32p "open d32p/symlink->tmp/symlink->lustre-root/$tfile"
 
 test_32q() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       touch $DIR/$tdir/ext2-mountpoint/under_the_mount
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        ls $DIR/$tdir/ext2-mountpoint | grep "\<under_the_mount\>" && error
        cleanup_test32_mount
 }
 run_test 32q "stat follows mountpoints in Lustre (should return error)"
 
 test_32r() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        [ -e $DIR/$tdir ] && rm -fr $DIR/$tdir
        trap cleanup_test32_mount EXIT
        test_mkdir -p $DIR/$tdir/ext2-mountpoint
-       touch $DIR/$tdir/ext2-mountpoint/under_the_mount
-       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint
+       touch $DIR/$tdir/ext2-mountpoint/under_the_mount || error "touch failed"
+       mount -t ext2 -o loop $EXT2_DEV $DIR/$tdir/ext2-mountpoint ||
+               error "mount failed for $EXT2_DEV $DIR/$tdir/ext2-mountpoint"
        ls $DIR/$tdir/ext2-mountpoint | grep -q under_the_mount && error || true
        cleanup_test32_mount
 }
@@ -2718,13 +2912,14 @@ test_33b() {
 run_test 33b "test open file with malformed flags (No panic)"
 
 test_33c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
        local ostnum
        local ostname
        local write_bytes
        local all_zeros
 
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
        all_zeros=:
        rm -fr $DIR/$tdir
        test_mkdir $DIR/$tdir
@@ -2784,8 +2979,9 @@ test_33c() {
 run_test 33c "test llobdstat and write_bytes"
 
 test_33d() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local MDTIDX=1
        local remote_dir=$DIR/$tdir/remote_dir
 
@@ -2809,7 +3005,7 @@ 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
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        mkdir $DIR/$tdir
 
@@ -2860,15 +3056,15 @@ cleanup_33f() {
 }
 
 test_33f() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        mkdir $DIR/$tdir
        chmod go+rwx $DIR/$tdir
        do_facet $SINGLEMDS $LCTL set_param mdt.*.enable_remote_dir_gid=-1
        trap cleanup_33f EXIT
 
-       $RUNAS lfs mkdir -c$MDSCOUNT $DIR/$tdir/striped_dir ||
+       $RUNAS lfs mkdir -i 0 -c$MDSCOUNT $DIR/$tdir/striped_dir ||
                error "cannot create striped directory"
 
        $RUNAS touch $DIR/$tdir/striped_dir/{0..16} ||
@@ -2896,55 +3092,68 @@ run_test 33g "nonroot user create already existing root created file"
 TEST_34_SIZE=${TEST_34_SIZE:-2000000000000}
 test_34a() {
        rm -f $DIR/f34
-       $MCREATE $DIR/f34 || error
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $TRUNCATE $DIR/f34 $TEST_34_SIZE || error
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $MCREATE $DIR/f34 || error "mcreate failed"
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $TRUNCATE $DIR/f34 $TEST_34_SIZE || error "truncate failed"
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34a "truncate file that has not been opened ==========="
 
 test_34b() {
        [ ! -f $DIR/f34 ] && test_34a
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        $OPENFILE -f O_RDONLY $DIR/f34
-       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" ||
+               error "getstripe failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34b "O_RDONLY opening file doesn't create objects ====="
 
 test_34c() {
        [ ! -f $DIR/f34 ] && test_34a
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        $OPENFILE -f O_RDWR $DIR/f34
        $GETSTRIPE $DIR/f34 2>&1 | grep -q "no stripe info" && error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
 }
 run_test 34c "O_RDWR opening file-with-size works =============="
 
 test_34d() {
        [ ! -f $DIR/f34 ] && test_34a
-       dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 || error
+       dd if=/dev/zero of=$DIR/f34 conv=notrunc bs=4k count=1 ||
+               error "dd failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/f34 ||
+               error "Size of $DIR/f34 not equal to $TEST_34_SIZE bytes"
        rm $DIR/f34
 }
 run_test 34d "write to sparse file ============================="
 
 test_34e() {
        rm -f $DIR/f34e
-       $MCREATE $DIR/f34e || error
-       $TRUNCATE $DIR/f34e 1000 || error
-       $CHECKSTAT -s 1000 $DIR/f34e || error
+       $MCREATE $DIR/f34e || error "mcreate failed"
+       $TRUNCATE $DIR/f34e 1000 || error "truncate failed"
+       $CHECKSTAT -s 1000 $DIR/f34e ||
+               error "Size of $DIR/f34e not equal to 1000 bytes"
        $OPENFILE -f O_RDWR $DIR/f34e
-       $CHECKSTAT -s 1000 $DIR/f34e || error
+       $CHECKSTAT -s 1000 $DIR/f34e ||
+               error "Size of $DIR/f34e not equal to 1000 bytes"
 }
 run_test 34e "create objects, some with size and some without =="
 
 test_34f() { # bug 6242, 6243
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        SIZE34F=48000
        rm -f $DIR/f34f
-       $MCREATE $DIR/f34f || error
+       $MCREATE $DIR/f34f || error "mcreate failed"
        $TRUNCATE $DIR/f34f $SIZE34F || error "truncating $DIR/f3f to $SIZE34F"
        dd if=$DIR/f34f of=$TMP/f34f
        $CHECKSTAT -s $SIZE34F $TMP/f34f || error "$TMP/f34f not $SIZE34F bytes"
@@ -2956,29 +3165,33 @@ test_34f() { # bug 6242, 6243
 run_test 34f "read from a file with no objects until EOF ======="
 
 test_34g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE || error
-       $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error
-       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || error "truncate failed"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1 count=100 seek=$TEST_34_SIZE ||
+               error "dd failed"
+       $TRUNCATE $DIR/$tfile $((TEST_34_SIZE / 2))|| error "truncate failed"
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
+               error "Size of $DIR/$tfile not equal to $((TEST_34_SIZE / 2))"
        cancel_lru_locks osc
-       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile || \
+       $CHECKSTAT -s $((TEST_34_SIZE / 2)) $DIR/$tfile ||
                error "wrong size after lock cancel"
 
-       $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+       $TRUNCATE $DIR/$tfile $TEST_34_SIZE || error "truncate failed"
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
                error "expanding truncate failed"
        cancel_lru_locks osc
-       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile || \
+       $CHECKSTAT -s $TEST_34_SIZE $DIR/$tfile ||
                error "wrong expanded size after lock cancel"
 }
 run_test 34g "truncate long file ==============================="
 
 test_34h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local gid=10
        local sz=1000
 
-       dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=10 || error "dd failed"
        sync # Flush the cache so that multiop below does not block on cache
             # flush when getting the group lock
        $MULTIOP $DIR/$tfile OG${gid}T${sz}g${gid}c &
@@ -3012,13 +3225,13 @@ run_test 35a "exec file with mode 444 (should return and not leak)"
 
 test_36a() {
        rm -f $DIR/f36
-       utime $DIR/f36 || error
+       utime $DIR/f36 || error "utime failed for MDS"
 }
 run_test 36a "MDS utime check (mknod, utime)"
 
 test_36b() {
        echo "" > $DIR/f36
-       utime $DIR/f36 || error
+       utime $DIR/f36 || error "utime failed for OST"
 }
 run_test 36b "OST utime check (open, utime)"
 
@@ -3026,19 +3239,20 @@ test_36c() {
        rm -f $DIR/d36/f36
        test_mkdir $DIR/d36
        chown $RUNAS_ID $DIR/d36
-       $RUNAS utime $DIR/d36/f36 || error
+       $RUNAS utime $DIR/d36/f36 || error "utime failed for MDS as non-root"
 }
 run_test 36c "non-root MDS utime check (mknod, utime)"
 
 test_36d() {
        [ ! -d $DIR/d36 ] && test_36c
        echo "" > $DIR/d36/f36
-       $RUNAS utime $DIR/d36/f36 || error
+       $RUNAS utime $DIR/d36/f36 || error "utime failed for OST as non-root"
 }
 run_test 36d "non-root OST utime check (open, utime)"
 
 test_36e() {
-       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+       [ $RUNAS_ID -eq $UID ] && skip_env "RUNAS_ID = UID = $UID -- skipping"
+
        test_mkdir $DIR/$tdir
        touch $DIR/$tdir/$tfile
        $RUNAS utime $DIR/$tdir/$tfile &&
@@ -3074,15 +3288,17 @@ subr_36fh() {
 }
 
 test_36f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        #define OBD_FAIL_OST_BRW_PAUSE_BULK 0x214
        subr_36fh "0x80000214"
 }
 run_test 36f "utime on file racing with OST BRW write =========="
 
 test_36g() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local fmd_max_age
        local fmd_before
        local fmd_after
@@ -3108,14 +3324,15 @@ test_36g() {
 run_test 36g "filter mod data cache expiry ====================="
 
 test_36h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        #define OBD_FAIL_OST_BRW_PAUSE_BULK2 0x227
        subr_36fh "0x80000227"
 }
 run_test 36h "utime on file racing with OST BRW write =========="
 
 test_36i() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        test_mkdir $DIR/$tdir
        $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
@@ -3243,9 +3460,9 @@ run_test 39c "mtime change on rename ==========================="
 
 # bug 21114
 test_39d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       touch $DIR1/$tfile
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
+       touch $DIR1/$tfile
        touch -m -d @$TEST_39_MTIME $DIR1/$tfile
 
        for (( i=0; i < 2; i++ )) ; do
@@ -3261,7 +3478,8 @@ run_test 39d "create, utime, stat =============================="
 
 # bug 21114
 test_39e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        local mtime1=`stat -c %Y $DIR1/$tfile`
 
@@ -3280,7 +3498,8 @@ run_test 39e "create, stat, utime, stat ========================"
 
 # bug 21114
 test_39f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        mtime1=`stat -c %Y $DIR1/$tfile`
 
@@ -3300,7 +3519,8 @@ run_test 39f "create, stat, sleep, utime, stat ================="
 
 # bug 11063
 test_39g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        echo hello >> $DIR1/$tfile
        local mtime1=`stat -c %Y $DIR1/$tfile`
 
@@ -3320,7 +3540,8 @@ run_test 39g "write, chmod, stat ==============================="
 
 # bug 11063
 test_39h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        sleep 1
 
@@ -3346,7 +3567,8 @@ test_39h() {
 run_test 39h "write, utime within one second, stat ============="
 
 test_39i() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        sleep 1
 
@@ -3368,7 +3590,8 @@ test_39i() {
 run_test 39i "write, rename, stat =============================="
 
 test_39j() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        start_full_debug_logging
        touch $DIR1/$tfile
        sleep 1
@@ -3400,7 +3623,8 @@ test_39j() {
 run_test 39j "write, rename, close, stat ======================="
 
 test_39k() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        sleep 1
 
@@ -3429,8 +3653,9 @@ run_test 39k "write, utime, close, stat ========================"
 TEST_39_ATIME=`date -d "1 year" +%s`
 
 test_39l() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local atime_diff=$(do_facet $SINGLEMDS \
                                lctl get_param -n mdd.*MDT0000*.atime_diff)
        rm -rf $DIR/$tdir
@@ -3478,7 +3703,8 @@ test_39l() {
 run_test 39l "directory atime update ==========================="
 
 test_39m() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR1/$tfile
        sleep 2
        local far_past_mtime=$(date -d "May 29 1953" +%s)
@@ -3499,7 +3725,8 @@ test_39m() {
 run_test 39m "test atime and mtime before 1970"
 
 test_39n() { # LU-3832
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local atime_diff=$(do_facet $SINGLEMDS \
                lctl get_param -n mdd.*MDT0000*.atime_diff)
        local atime0
@@ -3551,7 +3778,8 @@ test_39o() {
 run_test 39o "directory cached attributes updated after create"
 
 test_39p() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
+
        local MDTIDX=1
        TESTDIR=$DIR/$tdir/$tdir
        [ -e $TESTDIR ] && rm -rf $TESTDIR
@@ -3660,7 +3888,8 @@ setup_test42() {
 # Tests 42* verify that our behaviour is correct WRT caching, file closure,
 # file truncation, and file removal.
 test_42a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        setup_test42
        cancel_lru_locks $OSC
        stop_writeback
@@ -3676,7 +3905,8 @@ test_42a() {
 run_test 42a "ensure that we don't flush on close"
 
 test_42b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        setup_test42
        cancel_lru_locks $OSC
        stop_writeback
@@ -3733,25 +3963,28 @@ trunc_test() {
 }
 
 test_42c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        trunc_test 42c 1024
-        [ $BEFOREWRITES -eq $AFTERWRITES ] && \
-            error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
-        rm $file
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       trunc_test 42c 1024
+       [ $BEFOREWRITES -eq $AFTERWRITES ] &&
+               error "beforewrites $BEFOREWRITES == afterwrites $AFTERWRITES on truncate"
+       rm $file
 }
 run_test 42c "test partial truncate of file with cached dirty data"
 
 test_42d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        trunc_test 42d 0
-        [ $BEFOREWRITES -eq $AFTERWRITES ] || \
-            error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
-        rm $file
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       trunc_test 42d 0
+       [ $BEFOREWRITES -eq $AFTERWRITES ] ||
+               error "beforewrites $BEFOREWRITES != afterwrites $AFTERWRITES on truncate"
+       rm $file
 }
 run_test 42d "test complete truncate of file with cached dirty data"
 
 test_42e() { # bug22074
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local TDIR=$DIR/${tdir}e
        local pagesz=$(page_size)
        local pages=16 # hardcoded 16 pages, don't change it.
@@ -3854,7 +4087,8 @@ test_43a() {
 run_test 43a "open(RDWR) of file being executed should return -ETXTBSY"
 
 test_43b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        cp -p $(which $MULTIOP) $DIR/$tdir/multiop ||
                cp -p multiop $DIR/$tdir/multiop
@@ -3878,7 +4112,8 @@ test_43c() {
 run_test 43c "md5sum of copy into lustre"
 
 test_44A() { # was test_44
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        dd if=/dev/zero of=$DIR/f1 bs=4k count=1 seek=1023
        dd if=$DIR/f1 bs=4k count=1 > /dev/null
 }
@@ -3887,10 +4122,10 @@ run_test 44A "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
+       [ -z "$nstripe" ] && skip "can't get stripe info"
        [[ $nstripe -gt $OSTCOUNT ]] &&
-           skip "Wrong default_stripe_count: $nstripe (OSTCOUNT: $OSTCOUNT)" &&
-           return
+               skip "Wrong default_stripe_count: $nstripe OSTCOUNT: $OSTCOUNT"
+
        local stride=$($LCTL lov_getconfig $DIR | grep default_stripe_size: |
                awk '{ print $2 }')
        if [[ $nstripe -eq 0 || $nstripe -eq -1 ]]; then
@@ -3942,7 +4177,8 @@ do_dirty_record() {
        echo before $before, after $after
 }
 test_45() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        f="$DIR/f45"
        # Obtain grants from OST if it supports it
        echo blah > ${f}_grant
@@ -3970,7 +4206,8 @@ run_test 45 "osc io page accounting ============================"
 # objects offset and an assert hit when an rpc was built with 1023's mapped
 # offset 511 and 511's raw 511 offset. it also found general redirtying bugs.
 test_46() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        f="$DIR/f46"
        stop_writeback
        sync
@@ -3988,8 +4225,8 @@ run_test 46 "dirtying a previously written page ================"
 test_48a() { # bug 2399
        [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.63) ] &&
-               skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly" &&
-               return
+               skip "MDS prior to 2.3.63 handle ZFS dir .. incorrectly"
+
        test_mkdir $DIR/$tdir
        cd $DIR/$tdir
        mv $DIR/$tdir $DIR/$tdir.new || error "move directory failed"
@@ -4086,8 +4323,9 @@ test_48e() { # bug 4134
 run_test 48e "Access to recreated parent subdir (should return errors)"
 
 test_49() { # LU-1030
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
        # get ost1 size - lustre-OST0000
        ost1_size=$(do_facet ost1 $LFS df | grep ${ost1_svc} |
                awk '{ print $4 }')
@@ -4146,9 +4384,9 @@ cleanup_print_lfs_df () {
 }
 
 test_51b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       local dir=$DIR/$tdir
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
+       local dir=$DIR/$tdir
        local nrdirs=$((65536 + 100))
 
        # cleanup the directory
@@ -4158,17 +4396,15 @@ test_51b() {
 
        $LFS df
        $LFS df -i
-       local mdtidx=$(printf "%04x" $($LFS getstripe -M $dir))
+       local mdtidx=$(printf "%04x" $($LFS getstripe -m $dir))
        local numfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.filesfree)
        [[ $numfree -lt $nrdirs ]] &&
-               skip "not enough free inodes ($numfree) on MDT$mdtidx" &&
-               return
+               skip "not enough free inodes ($numfree) on MDT$mdtidx"
 
        # need to check free space for the directories as well
        local blkfree=$(lctl get_param -n mdc.$FSNAME-MDT$mdtidx*.kbytesavail)
        numfree=$(( blkfree / $(fs_inode_ksize) ))
-       [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)" &&
-               return
+       [[ $numfree -lt $nrdirs ]] && skip "not enough blocks ($numfree)"
 
        trap cleanup_print_lfs_df EXIT
 
@@ -4212,8 +4448,9 @@ test_51b() {
 run_test 51b "exceed 64k subdirectory nlink limit on create, verify unlink"
 
 test_51d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
+
        test_mkdir $DIR/$tdir
        createmany -o $DIR/$tdir/t- 1000
        $LFS getstripe $DIR/$tdir > $TMP/$tfile
@@ -4250,8 +4487,7 @@ run_test 51d "check object distribution"
 
 test_51e() {
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
-               skip "ldiskfs only test"
-               return
+               skip_env "ldiskfs only test"
        fi
 
        test_mkdir -c1 $DIR/$tdir
@@ -4271,8 +4507,8 @@ test_51f() {
        local max=100000
        local ulimit_old=$(ulimit -n)
        local spare=20 # number of spare fd's for scripts/libraries, etc.
-       local mdt=$(lfs getstripe -M $DIR/$tdir)
-       local numfree=$(lfs df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
+       local mdt=$($LFS getstripe -m $DIR/$tdir)
+       local numfree=$($LFS df -i $DIR/$tdir | awk '/MDT:'$mdt'/ { print $4 }')
 
        echo "MDT$mdt numfree=$numfree, max=$max"
        [[ $numfree -gt $max ]] && numfree=$max || numfree=$((numfree * 7 / 8))
@@ -4339,9 +4575,9 @@ test_52b() {
 run_test 52b "immutable flag test (should return errors) ======="
 
 test_53() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        local param
        local param_seq
@@ -4405,7 +4641,7 @@ test_53() {
 run_test 53 "verify that MDS and OSTs agree on pre-creation ===="
 
 test_54a() {
-       perl -MSocket -e ';' || { skip "no Socket perl module installed" && return; }
+       perl -MSocket -e ';' || skip "no Socket perl module installed"
 
        $SOCKETSERVER $DIR/socket ||
                error "$SOCKETSERVER $DIR/socket failed: $?"
@@ -4449,11 +4685,12 @@ cleanup_54c() {
 }
 
 test_54c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        loopdev="$DIR/loop54c"
 
        find_loop_dev
-       [ -z "$LOOPNUM" ] && echo "couldn't find empty loop device" && return
+       [ -z "$LOOPNUM" ] && skip_env "couldn't find empty loop device"
        trap cleanup_54c EXIT
        mknod $loopdev b 7 $LOOPNUM
        echo "make a loop file system with $DIR/$tfile on $loopdev ($LOOPNUM)."
@@ -4553,16 +4790,19 @@ test_56a() {
        $LFS getstripe --obd wrong_uuid $dir 2>&1 | grep -q "unknown obduuid" ||
                error "$LFS getstripe --obd wrong_uuid: should return error"
 
-       [[ $OSTCOUNT -lt 2 ]] &&
-               skip_env "skip '$LFS getstripe --obd' tests: $OSTCOUNT < 2" &&
-               return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        local ostidx=1
        local obduuid=$(ostuuid_from_index $ostidx)
        local found=$($LFS getstripe -r --obd $obduuid $dir |
-                     egrep -c "obdidx|l_ost_idx")
+               grep 'lmm_stripe_offset:' | grep -c " $ostidx\$")
+
+       filenum=$($LFS getstripe -ir $dir | grep -c "^$ostidx\$")
+       [[ $($LFS getstripe -id $dir) -ne $ostidx ]] ||
+               ((filenum--))
+       [[ $($LFS getstripe -id $dir/dir) -ne $ostidx ]] ||
+               ((filenum--))
 
-       filenum=$($LFS getstripe -ir $dir | grep "^$ostidx\$" | wc -l)
        [[ $found -eq $filenum ]] ||
                error "$LFS getstripe --obd: found $found expect $filenum"
        [[ $($LFS getstripe -r -v --obd $obduuid $dir |
@@ -4596,12 +4836,14 @@ test_56b() {
 run_test 56b "check $LFS getdirstripe"
 
 test_56c() {
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
        local ost_idx=0
        local ost_name=$(ostname_from_index $ost_idx)
        local old_status=$(ost_dev_status $ost_idx)
 
        [[ -z "$old_status" ]] ||
-               { skip_env "OST $ost_name is in $old_status status"; return 0; }
+               skip_env "OST $ost_name is in $old_status status"
 
        do_facet ost1 $LCTL set_param -n obdfilter.$ost_name.degraded=1
        sleep_maxage
@@ -4806,7 +5048,7 @@ run_test 56o "check lfs find -mtime for old files"
 
 test_56p() {
        [ $RUNAS_ID -eq $UID ] &&
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
 
        local dir=$DIR/$tdir
 
@@ -4830,7 +5072,7 @@ run_test 56p "check lfs find -uid and ! -uid"
 
 test_56q() {
        [ $RUNAS_ID -eq $UID ] &&
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
 
        local dir=$DIR/$tdir
 
@@ -4899,7 +5141,7 @@ test_56r() {
 run_test 56r "check lfs find -size works"
 
 test_56s() { # LU-611 #LU-9369
-       [[ $OSTCOUNT -lt 2 ]] && skip "need at least 2 OSTs" && return 0
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "need at least 2 OSTs"
 
        local dir=$DIR/$tdir
        local onestripe=$(((NUMDIRS + 1) * NUMFILES))
@@ -4956,11 +5198,11 @@ test_56t() { # LU-611 #LU-9369
 
        setup_56 $dir 0 $NUMDIRS
        for i in $(seq $NUMDIRS); do
-               $LFS setstripe -S 4M $dir/dir$i/$tfile
+               $LFS setstripe -S 8M $dir/dir$i/$tfile
        done
 
        local expected=$NUMDIRS
-       local cmd="$LFS find -S 4M $dir"
+       local cmd="$LFS find -S 8M $dir"
        local nums=$($cmd | wc -l)
 
        [ $nums -eq $expected ] || {
@@ -5062,25 +5304,26 @@ test_56u() { # LU-611
 run_test 56u "check lfs find -stripe-index works"
 
 test_56v() {
-       local MDT_IDX=0
+       local mdt_idx=0
        local dir=$DIR/$tdir
 
        setup_56 $dir $NUMFILES $NUMDIRS
 
-       UUID=$(mdtuuid_from_index $MDT_IDX $dir)
-       [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $MDT_IDX"
+       UUID=$(mdtuuid_from_index $mdt_idx $dir)
+       [ -z "$UUID" ] && error "mdtuuid_from_index cannot find MDT $mdt_idx"
 
-       for file in $($LFS find -mdt $UUID $dir); do
-               file_mdt_idx=$($LFS getstripe -M $file)
-               [ $file_mdt_idx -eq $MDT_IDX ] ||
-                       error "lfind -mdt $UUID != getstripe -M $file_mdt_idx"
+       for file in $($LFS find -m $UUID $dir); do
+               file_midx=$($LFS getstripe -m $file)
+               [ $file_midx -eq $mdt_idx ] ||
+                       error "lfs find -m $UUID != getstripe -m $file_midx"
        done
 }
-run_test 56v "check 'lfs find -mdt match with lfs getstripe -M' ======="
+run_test 56v "check 'lfs find -m match with lfs getstripe -m'"
 
 test_56w() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local dir=$DIR/$tdir
 
        setup_56 $dir $NUMFILES $NUMDIRS "-c $OSTCOUNT" "-c1"
@@ -5095,8 +5338,7 @@ test_56w() {
        local free_space=$($LCTL get_param -n lov.$FSNAME-clilov-*.kbytesavail |
                           head -n1)
        [[ $free_space -le $((required_space / 1024)) ]] &&
-               skip_env "need $required_space, have $free_space kbytes" &&
-               return
+               skip_env "need $required_space, have $free_space kbytes"
 
        local dd_bs=65536
        local dd_count=$((file_size / dd_bs))
@@ -5206,9 +5448,7 @@ test_56wb() {
        echo "done."
 
        echo -n "Detecting existing pools..."
-       while IFS='' read thispool; do
-               pool_list+=("$thispool")
-       done < <($LFS pool_list $MOUNT | awk -F '.' 'NR>=2 { print $2 }')
+       pool_list=($($LFS pool_list $FSNAME | grep "$FSNAME\." | cut -d. -f2))
 
        if [ ${#pool_list[@]} -gt 0 ]; then
                echo "${pool_list[@]}"
@@ -5274,6 +5514,7 @@ test_56wc() {
 
        echo -n "Creating test dir..."
        test_mkdir $DIR/$tdir &> /dev/null || error "cannot create dir"
+       local def_stripe_size=$($LFS getstripe -S $DIR/$tdir 2>/dev/null)
        $LFS setstripe -S 1M -c 1 "$DIR/$tdir" &> /dev/null ||
                error "cannot set stripe"
        echo "done"
@@ -5338,7 +5579,7 @@ test_56wc() {
        echo -n "Verifying restripe option uses parent stripe settings..."
        $LFS_MIGRATE -y -R "$file1" &> /dev/null ||
                error "migrate failed"
-       [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
+       [ $($LFS getstripe -S "$file1") -eq $def_stripe_size ] ||
                error "file not restriped to parent settings"
        [ $($LFS getstripe -c "$file1") -eq 1 ] ||
                error "file not restriped to parent settings"
@@ -5349,11 +5590,12 @@ test_56wc() {
        # Ensure striping is preserved if -R is not set, and no stripe
        # count or size is specified
        echo -n "Verifying striping size preserved when not specified..."
+       local orig_stripe_size=$($LFS getstripe -S "$file1" 2>/dev/null)
        $LFS setstripe -S 2M -c 1 "$DIR/$tdir" &> /dev/null ||
                error "cannot set stripe on parent directory"
        $LFS_MIGRATE -y "$file1" &> /dev/null ||
                error "migrate failed"
-       [ $($LFS getstripe -S "$file1") -eq 1048576 ] ||
+       [ $($LFS getstripe -S "$file1") -eq $orig_stripe_size ] ||
                error "file was restriped"
        echo "done."
 
@@ -5369,7 +5611,8 @@ test_56wc() {
 run_test 56wc "check unrecognized options for lfs_migrate are passed through"
 
 test_56wd() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        local file1=$DIR/$tdir/file1
 
        echo -n "Creating test dir..."
@@ -5407,8 +5650,8 @@ test_56wd() {
 run_test 56wd "check lfs_migrate --rsync and --no-rsync work"
 
 test_56x() {
-       check_swap_layouts_support && return 0
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       check_swap_layouts_support
 
        local dir=$DIR/$tdir
        local ref1=/etc/passwd
@@ -5428,8 +5671,8 @@ test_56x() {
 run_test 56x "lfs migration support"
 
 test_56xa() {
-       check_swap_layouts_support && return 0
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       check_swap_layouts_support
 
        local dir=$DIR/$tdir/$testnum
 
@@ -5494,8 +5737,7 @@ check_migrate_links() {
 
        echo "${#paths[*]}"
        if [ ${#paths[*]} -lt $total_count -a "$begin" -eq 2  ]; then
-                       echo "hard link list has unexpected size, skipping test"
-                       return 0
+                       skip "hard link list has unexpected size, skipping test"
        fi
        if [ ${#paths[*]} -ge $total_count -a "$begin" -ne 2  ]; then
                        error "link names should exceed xattrs size"
@@ -5538,6 +5780,9 @@ check_migrate_links() {
 }
 
 test_56xb() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55"
+
        local dir="$DIR/$tdir"
 
        test_mkdir "$dir" || error "cannot create dir $dir"
@@ -5561,8 +5806,7 @@ run_test 56xb "lfs migration hard link support"
 
 test_56y() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
-               skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
-               return
+               skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
 
        local res=""
        local dir=$DIR/$tdir
@@ -5618,7 +5862,7 @@ test_56z() { # LU-4824
 run_test 56z "lfs find should continue after an error"
 
 test_56aa() { # LU-5937
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        local dir=$DIR/$tdir
 
@@ -5626,19 +5870,42 @@ test_56aa() { # LU-5937
        $LFS setdirstripe -c$MDSCOUNT $dir/striped_dir
 
        createmany -o $dir/striped_dir/${tfile}- 1024
-       local dirs=$(lfs find --size +8k $dir/)
+       local dirs=$($LFS find --size +8k $dir/)
 
        [ -n "$dirs" ] || error "lfs find --size wrong under striped dir"
 }
 run_test 56aa "lfs find --size under striped dir"
 
+test_56ab() { # LU-10705
+       test_mkdir $DIR/$tdir
+       dd if=/dev/zero of=$DIR/$tdir/$tfile.1 bs=8k count=1 seek=2k
+       dd if=/dev/zero of=$DIR/$tdir/$tfile.2 bs=4k count=1 seek=4k
+       dd if=/dev/zero of=$DIR/$tdir/$tfile.3 bs=1M count=2 seek=16
+       # Flush writes to ensure valid blocks.  Need to be more thorough for
+       # ZFS, since blocks are not allocated/returned to client immediately.
+       sync_all_data
+       wait_zfs_commit ost1 2
+       cancel_lru_locks osc
+       ls -ls $DIR/$tdir
+
+       local files=$($LFS find --size +16M $DIR/$tdir | wc -l)
+
+       [[ $files == 3 ]] || error ">16M size files $files isn't 3 as expected"
+
+       files=$($LFS find --blocks +1M $DIR/$tdir | wc -l)
+       [[ $files == 1 ]] || error ">1M blocks files $files isn't 1 as expected"
+
+       rm -f $DIR/$tdir/$tfile.[123]
+}
+run_test 56ab "lfs find --blocks"
+
 test_56ba() {
        # Create composite files with one component
        local dir=$DIR/$tdir
 
-       setup_56 $dir/1Mfiles 5 1 "--component-end 1M"
+       setup_56 $dir/1Mfiles 5 1 "-S 1M --component-end 1M"
        # Create composite files with three components
-       setup_56 $dir/2Mfiles 5 2 "-E 2M -E 4M -E 6M"
+       setup_56 $dir/2Mfiles 5 2 "-E 2M -S 1M -E 4M -E 6M"
        # Create non-composite files
        createmany -o $dir/${tfile}- 10
 
@@ -5694,15 +5961,88 @@ test_56ba() {
 }
 run_test 56ba "test lfs find --component-end, -start, -count, and -flags"
 
+test_56ca() {
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
+               skip "Need MDS version at least 2.10.57"
+
+       local td=$DIR/$tdir
+       local tf=$td/$tfile
+       local dir
+       local nfiles
+       local cmd
+       local i
+       local j
+
+       # create mirrored directories and mirrored files
+       mkdir $td || error "mkdir $td failed"
+       $LFS mirror create -N3 $td || error "create mirrored dir $td failed"
+       createmany -o $tf- 10 || error "create $tf- failed"
+
+       for i in $(seq 2); do
+               dir=$td/dir$i
+               mkdir $dir || error "mkdir $dir failed"
+               $LFS mirror create -N$((3 + i)) $dir ||
+                       error "create mirrored dir $dir failed"
+               createmany -o $dir/$tfile- 10 ||
+                       error "create $dir/$tfile- failed"
+       done
+
+       # change the states of some mirrored files
+       echo foo > $tf-6
+       for i in $(seq 2); do
+               dir=$td/dir$i
+               for j in $(seq 4 9); do
+                       echo foo > $dir/$tfile-$j
+               done
+       done
+
+       # find mirrored files with specific mirror count
+       cmd="$LFS find --mirror-count 3 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 10 ]] || error "$cmd: $nfiles != 10 files"
+
+       cmd="$LFS find ! --mirror-count 3 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 20 ]] || error "$cmd: $nfiles != 20 files"
+
+       cmd="$LFS find --mirror-count +2 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+
+       cmd="$LFS find --mirror-count -6 --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+
+       # find mirrored files with specific file state
+       cmd="$LFS find --maxdepth 1 --mirror-state=^ro --type f $td"
+       [[ $($cmd) = $tf-6 ]] || error "$cmd: didn't return $tf-6"
+
+       cmd="$LFS find --mirror-state=ro --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 17 ]] || error "$cmd: $nfiles != 17 files"
+
+       cmd="$LFS find ! --mirror-state=ro --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
+
+       cmd="$LFS find --mirror-state=wp --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 13 ]] || error "$cmd: $nfiles != 13 files"
+
+       cmd="$LFS find ! --mirror-state=sp --type f $td"
+       nfiles=$($cmd | wc -l)
+       [[ $nfiles = 30 ]] || error "$cmd: $nfiles != 30 files"
+}
+run_test 56ca "check lfs find --mirror-count|-N and --mirror-state"
+
 test_57a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        # note test will not do anything if MDS is not local
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
-               skip "ldiskfs only test"
-               return
+               skip_env "ldiskfs only test"
        fi
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
        local MNTDEV="osd*.*MDT*.mntdev"
        DEV=$(do_facet $SINGLEMDS lctl get_param -n $MNTDEV)
        [ -z "$DEV" ] && error "can't access $MNTDEV"
@@ -5717,59 +6057,61 @@ test_57a() {
 run_test 57a "verify MDS filesystem created with large inodes =="
 
 test_57b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
-               skip "ldiskfs only test"
-               return
+               skip_env "ldiskfs only test"
        fi
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
        local dir=$DIR/$tdir
-
-       local FILECOUNT=100
-       local FILE1=$dir/f1
-       local FILEN=$dir/f$FILECOUNT
+       local filecount=100
+       local file1=$dir/f1
+       local fileN=$dir/f$filecount
 
        rm -rf $dir || error "removing $dir"
        test_mkdir -c1 $dir
-       local mdtidx=$($LFS getstripe -M $dir)
+       local mdtidx=$($LFS getstripe -m $dir)
        local mdtname=MDT$(printf %04x $mdtidx)
        local facet=mds$((mdtidx + 1))
 
-       echo "mcreating $FILECOUNT files"
-       createmany -m $dir/f 1 $FILECOUNT || \
-               error "creating files in $dir"
+       echo "mcreating $filecount files"
+       createmany -m $dir/f 1 $filecount || error "creating files in $dir"
 
        # verify that files do not have EAs yet
-       $GETSTRIPE $FILE1 2>&1 | grep -q "no stripe" || error "$FILE1 has an EA"
-       $GETSTRIPE $FILEN 2>&1 | grep -q "no stripe" || error "$FILEN has an EA"
+       $LFS getstripe $file1 2>&1 | grep -q "no stripe" ||
+               error "$file1 has an EA"
+       $LFS getstripe $fileN 2>&1 | grep -q "no stripe" ||
+               error "$fileN has an EA"
 
        sync
        sleep 1
        df $dir  #make sure we get new statfs data
-       local MDSFREE=$(do_facet $facet \
-               lctl get_param -n osd*.*$mdtname.kbytesfree)
-       local MDCFREE=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
+       local mdsfree=$(do_facet $facet \
+                       lctl get_param -n osd*.*$mdtname.kbytesfree)
+       local mdcfree=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
+       local file
+
        echo "opening files to create objects/EAs"
-       local FILE
-       for FILE in `seq -f $dir/f%g 1 $FILECOUNT`; do
-               $OPENFILE -f O_RDWR $FILE > /dev/null 2>&1 || error "opening $FILE"
+       for file in $(seq -f $dir/f%g 1 $filecount); do
+               $OPENFILE -f O_RDWR $file > /dev/null 2>&1 ||
+                       error "opening $file"
        done
 
        # verify that files have EAs now
-       $GETSTRIPE $FILE1 | grep -q "obdidx" || error "$FILE1 missing EA"
-       $GETSTRIPE $FILEN | grep -q "obdidx" || error "$FILEN missing EA"
+       $LFS getstripe $file1 | grep -q "obdidx" || error "$file1 missing EA"
+       $LFS getstripe $fileN | grep -q "obdidx" || error "$fileN missing EA"
 
        sleep 1  #make sure we get new statfs data
        df $dir
-       local MDSFREE2=$(do_facet $facet \
-               lctl get_param -n osd*.*$mdtname.kbytesfree)
-       local MDCFREE2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
-       if [[ $MDCFREE2 -lt $((MDCFREE - 16)) ]]; then
-               if [ "$MDSFREE" != "$MDSFREE2" ]; then
-                       error "MDC before $MDCFREE != after $MDCFREE2"
+       local mdsfree2=$(do_facet $facet \
+                        lctl get_param -n osd*.*$mdtname.kbytesfree)
+       local mdcfree2=$(lctl get_param -n mdc.*$mdtname-mdc-*.kbytesfree)
+
+       if [[ $mdcfree2 -lt $((mdcfree - 16)) ]]; then
+               if [ "$mdsfree" != "$mdsfree2" ]; then
+                       error "MDC before $mdcfree != after $mdcfree2"
                else
-                       echo "MDC before $MDCFREE != after $MDCFREE2"
+                       echo "MDC before $mdcfree != after $mdcfree2"
                        echo "unable to confirm if MDS has large inodes"
                fi
        fi
@@ -5778,15 +6120,17 @@ test_57b() {
 run_test 57b "default LOV EAs are stored inside large inodes ==="
 
 test_58() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [ -z "$(which wiretest 2>/dev/null)" ] &&
-                       skip_env "could not find wiretest" && return
+                       skip_env "could not find wiretest"
+
        wiretest
 }
 run_test 58 "verify cross-platform wire constants =============="
 
 test_59() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        echo "touch 130 files"
        createmany -o $DIR/f59- 130
        echo "rm 130 files"
@@ -5799,25 +6143,25 @@ run_test 59 "verify cancellation of llog records async ========="
 
 TEST60_HEAD="test_60 run $RANDOM"
 test_60a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
        do_facet mgs "! which run-llog.sh &> /dev/null" &&
                do_facet mgs "! ls run-llog.sh &> /dev/null" &&
-                       skip_env "missing subtest run-llog.sh" && return
+                       skip_env "missing subtest run-llog.sh"
 
        log "$TEST60_HEAD - from kernel mode"
        do_facet mgs "$LCTL set_param debug=warning; $LCTL dk > /dev/null"
-       do_facet mgs "sh run-llog.sh" || error "run-llog.sh failed"
+       do_facet mgs "bash run-llog.sh" || error "run-llog.sh failed"
        do_facet mgs $LCTL dk > $TMP/$tfile
 
        # LU-6388: test llog_reader
        local llog_reader=$(do_facet mgs "which llog_reader 2> /dev/null")
        llog_reader=${llog_reader:-$LUSTRE/utils/llog_reader}
        [ -z $(do_facet mgs ls -d $llog_reader 2> /dev/null) ] &&
-                       skip_env "missing llog_reader" && return
+                       skip_env "missing llog_reader"
        local fstype=$(facet_fstype mgs)
        [ $fstype != ldiskfs -a $fstype != zfs ] &&
-               skip_env "Only for ldiskfs or zfs type mgs" && return
+               skip_env "Only for ldiskfs or zfs type mgs"
 
        local mntpt=$(facet_mntpt mgs)
        local mgsdev=$(mgsdevname 1)
@@ -5887,6 +6231,8 @@ test_60a() {
 run_test 60a "llog_test run from kernel module and test llog_reader"
 
 test_60aa() {
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+
        # test old logid format
        if [ $(lustre_version_code mgs) -le $(version_code 3.1.53) ]; then
                do_facet mgs $LCTL dl | grep MGS
@@ -5902,8 +6248,33 @@ test_60aa() {
 }
 run_test 60aa "llog_print works with FIDs and simple names"
 
+test_60ab() {
+       # test llog_print with params
+
+       [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.51) ]] ||
+               skip "Need server version greater than 2.11.51"
+
+       local yaml
+       local orig_val
+
+       orig_val=$(do_facet mgs $LCTL get_param jobid_name)
+       do_facet mgs $LCTL set_param -P jobid_name="testname"
+
+       yaml=$(do_facet mgs $LCTL --device MGS llog_print params |
+           grep jobid_name | tail -n 1)
+
+       local param=`awk '{ print $10 }' <<< "$yaml"`
+       local val=`awk '{ print $12 }' <<< "$yaml"`
+       #return to the default
+       do_facet mgs $LCTL set_param -P jobid_name=$orig_val
+       [ $val = "testname" ] || error "bad value: $val"
+       [ $param = "jobid_name," ] || error "Bad param: $param"
+}
+run_test 60ab "llog_print params output values from set_param -P"
+
 test_60b() { # bug 6411
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        dmesg > $DIR/$tfile
        LLOG_COUNT=$(dmesg | awk "/$TEST60_HEAD/ { marker = 1; from_marker = 0; }
                                /llog.test/ {
@@ -5923,7 +6294,8 @@ test_60b() { # bug 6411
 run_test 60b "limit repeated messages from CERROR/CWARN ========"
 
 test_60c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        echo "create 5000 files"
        createmany -o $DIR/f60c- 5000
 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED  0x137
@@ -5934,9 +6306,9 @@ test_60c() {
 run_test 60c "unlink file when mds full"
 
 test_60d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       SAVEPRINTK=$(lctl get_param -n printk)
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
+       SAVEPRINTK=$(lctl get_param -n printk)
        # verify "lctl mark" is even working"
        MESSAGE="test message ID $RANDOM $$"
        $LCTL mark "$MESSAGE" || error "$LCTL mark failed"
@@ -5954,8 +6326,9 @@ test_60d() {
 run_test 60d "test printk console message masking"
 
 test_60e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        touch $DIR/$tfile
 #define OBD_FAIL_MDS_LLOG_CREATE_FAILED2  0x15b
        do_facet mds1 lctl set_param fail_loc=0x15b
@@ -5964,7 +6337,8 @@ test_60e() {
 run_test 60e "no space while new llog is being created"
 
 test_61() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        f="$DIR/f61"
        dd if=/dev/zero of=$f bs=$(page_size) count=1 || error "dd $f failed"
        cancel_lru_locks osc
@@ -5975,13 +6349,14 @@ run_test 61 "mmap() writes don't make sync hang ================"
 
 # bug 2330 - insufficient obd_match error checking causes LBUG
 test_62() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        f="$DIR/f62"
-        echo foo > $f
-        cancel_lru_locks osc
-        lctl set_param fail_loc=0x405
-        cat $f && error "cat succeeded, expect -EIO"
-        lctl set_param fail_loc=0
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       f="$DIR/f62"
+       echo foo > $f
+       cancel_lru_locks osc
+       lctl set_param fail_loc=0x405
+       cat $f && error "cat succeeded, expect -EIO"
+       lctl set_param fail_loc=0
 }
 # This test is now irrelevant (as of bug 10718 inclusion), we no longer
 # match every page all of the time.
@@ -5991,8 +6366,10 @@ test_62() {
 # Though this test is irrelevant anymore, it helped to reveal some
 # other grant bugs (LU-4482), let's keep it.
 test_63a() {   # was test_63
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       MAX_DIRTY_MB=`lctl get_param -n osc.*.max_dirty_mb | head -n 1`
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       MAX_DIRTY_MB=$(lctl get_param -n osc.*.max_dirty_mb | head -n 1)
+
        for i in `seq 10` ; do
                dd if=/dev/zero of=$DIR/f63 bs=8k &
                sleep 5
@@ -6007,7 +6384,8 @@ run_test 63a "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() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        debugsave
        lctl set_param debug=-1
 
@@ -6029,14 +6407,16 @@ test_63b() {
 run_test 63b "async write errors should be returned to fsync ==="
 
 test_64a () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        df $DIR
        lctl get_param -n osc.*[oO][sS][cC][_-]*.cur* | grep "[0-9]"
 }
 run_test 64a "verify filter grant calculations (in kernel) ====="
 
 test_64b () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        sh oos.sh $MOUNT || error "oos.sh failed: $?"
 }
 run_test 64b "check out-of-space detection on client"
@@ -6098,22 +6478,24 @@ grant_chunk() {
 
 test_64d() {
        [ $(lustre_version_code ost1) -lt $(version_code 2.10.56) ] &&
-               skip "OST < 2.10.55 doesn't limit grants enough" && return 0
+               skip "OST < 2.10.55 doesn't limit grants enough"
 
        local tgt=$($LCTL dl | grep "0000-osc-[^mM]" | awk '{print $4}')
+       local file=$DIR/$tfile
 
        [[ $($LCTL get_param osc.${tgt}.import |
-                   grep "connect_flags:.*grant_param") ]] || \
-                       { skip "no grant_param connect flag"; return; }
+            grep "connect_flags:.*grant_param") ]] ||
+               skip "no grant_param connect flag"
 
        local olddebug=$($LCTL get_param -n debug 2> /dev/null)
 
        $LCTL set_param debug="$OLDDEBUG" 2> /dev/null || true
 
        local max_cur_granted=$(($(want_grant $tgt) + $(grant_chunk $tgt)))
+       stack_trap "rm -f $file" EXIT
 
-       $SETSTRIPE $DIR/$tfile -i 0 -c 1
-       dd if=/dev/zero of=$DIR/$tfile bs=1M count=1000 &
+       $SETSTRIPE $file -i 0 -c 1
+       dd if=/dev/zero of=$file bs=1M count=1000 &
        ddpid=$!
 
        while true
@@ -6128,13 +6510,17 @@ test_64d() {
                [[ $? -ne 0 ]] && break;
                sleep 2
        done
+
+       rm -f $DIR/$tfile
+       wait_delete_completed
        $LCTL set_param debug="$olddebug" 2> /dev/null || true
 }
 run_test 64d "check grant limit exceed"
 
 # bug 1414 - set/get directories' stripe info
 test_65a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        touch $DIR/$tdir/f1
        $LVERIFY $DIR/$tdir $DIR/$tdir/f1 || error "lverify failed"
@@ -6142,7 +6528,8 @@ test_65a() {
 run_test 65a "directory with no stripe info"
 
 test_65b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
 
@@ -6154,8 +6541,9 @@ test_65b() {
 run_test 65b "directory setstripe -S stripe_size*2 -i 0 -c 1"
 
 test_65c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $OSTCOUNT -lt 2 ] && skip "need at least 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $OSTCOUNT -lt 2 ] && skip_env "need at least 2 OSTs"
+
        test_mkdir $DIR/$tdir
        local stripesize=$($GETSTRIPE -S $DIR/$tdir)
 
@@ -6167,7 +6555,8 @@ test_65c() {
 run_test 65c "directory setstripe -S stripe_size*4 -i 1 -c $((OSTCOUNT-1))"
 
 test_65d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        local STRIPECOUNT=$($GETSTRIPE -c $DIR/$tdir)
        local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
@@ -6188,11 +6577,12 @@ test_65d() {
 run_test 65d "directory setstripe -S stripe_size -c stripe_count"
 
 test_65e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
 
        $SETSTRIPE $DIR/$tdir || error "setstripe"
-        $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
+       $GETSTRIPE -v $DIR/$tdir | grep "Default" ||
                                        error "no stripe info failed"
        touch $DIR/$tdir/f6
        $LVERIFY $DIR/$tdir $DIR/$tdir/f6 || error "lverify failed"
@@ -6200,14 +6590,16 @@ test_65e() {
 run_test 65e "directory setstripe defaults"
 
 test_65f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/${tdir}f
        $RUNAS $SETSTRIPE $DIR/${tdir}f && error "setstripe succeeded" || true
 }
 run_test 65f "dir setstripe permission (should return error) ==="
 
 test_65g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
 
@@ -6220,7 +6612,8 @@ test_65g() {
 run_test 65g "directory setstripe -d"
 
 test_65h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        local STRIPESIZE=$($GETSTRIPE -S $DIR/$tdir)
 
@@ -6232,48 +6625,59 @@ test_65h() {
 }
 run_test 65h "directory stripe info inherit ===================="
 
-test_65i() { # bug6367
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        $SETSTRIPE -S 65536 -c -1 $MOUNT
-}
-run_test 65i "set non-default striping on root directory (bug 6367)="
+test_65i() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
-test_65ia() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GETSTRIPE $MOUNT || error "getstripe $MOUNT failed"
-}
-run_test 65ia "getstripe on -1 default directory striping"
+       save_layout_restore_at_exit $MOUNT
 
-test_65ib() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GETSTRIPE -v $MOUNT || error "getstripe -v $MOUNT failed"
-}
-run_test 65ib "getstripe -v on -1 default directory striping"
+       # bug6367: set non-default striping on root directory
+       $LFS setstripe -S 65536 -c -1 $MOUNT || error "error setting stripe"
 
-test_65ic() { # bug12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       # bug12836: getstripe on -1 default directory striping
+       $LFS getstripe $MOUNT || error "getstripe $MOUNT failed"
+
+       # bug12836: getstripe -v on -1 default directory striping
+       $LFS getstripe -v $MOUNT || error "getstripe -v $MOUNT failed"
+
+       # bug12836: new find on -1 default directory striping
        $LFS find -mtime -1 $MOUNT > /dev/null || error "find $MOUNT failed"
 }
-run_test 65ic "new find on -1 default directory striping"
+run_test 65i "various tests to set root directory striping"
 
 test_65j() { # bug6367
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $($LFS getstripe --component-count $MOUNT) -gt 1 ] &&
-               skip "don't delete default PFL layout" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        sync; sleep 1
+
        # if we aren't already remounting for each test, do so for this test
        if [ "$CLEANUP" = ":" -a "$I_MOUNTED" = "yes" ]; then
                cleanup || error "failed to unmount"
                setup
        fi
+
+       save_layout_restore_at_exit $MOUNT
+
        $SETSTRIPE -d $MOUNT || error "setstripe failed"
 }
 run_test 65j "set default striping on root directory (bug 6367)="
 
+cleaup_65k() {
+       rm -rf $DIR/$tdir
+       wait_delete_completed
+       do_facet $SINGLEMDS "lctl set_param -n \
+               osp.$ost*MDT0000.max_create_count=$max_count"
+       do_facet $SINGLEMDS "lctl set_param -n \
+               osp.$ost*MDT0000.create_count=$count"
+       do_facet $SINGLEMDS lctl --device  %$INACTIVE_OSC activate
+       echo $INACTIVE_OSC "is Activate"
+
+       wait_osc_import_state mds ost$ostnum FULL
+}
+
 test_65k() { # bug11679
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        local disable_precreate=true
        [ $(lustre_version_code $SINGLEMDS) -le $(version_code 2.8.54) ] &&
@@ -6313,7 +6717,8 @@ test_65k() { # bug11679
                        [ -f $DIR/$tdir/$idx ] && continue
                        echo "$SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx"
                        $SETSTRIPE -i $idx -c 1 $DIR/$tdir/$idx ||
-                               error "setstripe $idx should succeed"
+                               { cleanup_65k;
+                                 error "setstripe $idx should succeed"; }
                        rm -f $DIR/$tdir/$idx || error "rm $idx failed"
                done
                unlinkmany $DIR/$tdir/$tfile.$ostnum. 1000
@@ -6332,7 +6737,8 @@ test_65k() { # bug11679
 run_test 65k "validate manual striping works properly with deactivated OSCs"
 
 test_65l() { # bug 12836
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir -p $DIR/$tdir/test_dir
        $SETSTRIPE -c -1 $DIR/$tdir/test_dir
        $LFS find -mtime -1 $DIR/$tdir >/dev/null
@@ -6340,14 +6746,19 @@ test_65l() { # bug 12836
 run_test 65l "lfs find on -1 stripe dir ========================"
 
 test_65m() {
-       $RUNAS $SETSTRIPE -c 2 $MOUNT && error "setstripe should fail"
+       local layout=$(save_layout $MOUNT)
+       $RUNAS $SETSTRIPE -c 2 $MOUNT && {
+               restore_layout $MOUNT $layout
+               error "setstripe should fail by non-root users"
+       }
        true
 }
 run_test 65m "normal user can't set filesystem default stripe"
 
 # bug 2543 - update blocks count on client
 test_66() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        COUNT=${COUNT:-8}
        dd if=/dev/zero of=$DIR/f66 bs=1k count=$COUNT
        sync; sync_all_data; sync; sync_all_data
@@ -6368,8 +6779,8 @@ swap_used() {
 # bug5265, obdfilter oa2dentry return -ENOENT
 # #define OBD_FAIL_SRV_ENOENT 0x217
 test_69() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        f="$DIR/$tfile"
        $SETSTRIPE -c 1 -i 0 $f
@@ -6402,15 +6813,13 @@ test_71() {
 run_test 71 "Running dbench on lustre (don't segment fault) ===="
 
 test_72a() { # bug 5695 - Test that on 2.6 remove_suid works properly
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [ "$RUNAS_ID" = "$UID" ] &&
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
-
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
        # Check that testing environment is properly set up. Skip if not
-       FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS || {
+       FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_GID $RUNAS ||
                skip_env "User $RUNAS_ID does not exist - skipping"
-               return 0
-       }
+
        touch $DIR/$tfile
        chmod 777 $DIR/$tfile
        chmod ug+s $DIR/$tfile
@@ -6430,17 +6839,15 @@ run_test 72a "Test that remove suid works properly (bug5695) ===="
 test_72b() { # bug 24226 -- keep mode setting when size is not changing
        local perm
 
-       [ "$RUNAS_ID" = "$UID" ] && \
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
-       [ "$RUNAS_ID" -eq 0 ] && \
-               skip_env "RUNAS_ID = 0 -- skipping" && return
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ "$RUNAS_ID" = "$UID" ] &&
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
+       [ "$RUNAS_ID" -eq 0 ] &&
+               skip_env "RUNAS_ID = 0 -- skipping"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        # Check that testing environment is properly set up. Skip if not
-       FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS || {
+       FAIL_ON_ERROR=false check_runas_id_ret $RUNAS_ID $RUNAS_ID $RUNAS ||
                skip_env "User $RUNAS_ID does not exist - skipping"
-               return 0
-       }
+
        touch $DIR/${tfile}-f{g,u}
        test_mkdir $DIR/${tfile}-dg
        test_mkdir $DIR/${tfile}-du
@@ -6459,7 +6866,8 @@ run_test 72b "Test that we keep mode setting if without file data changed (bug 2
 
 # bug 3462 - multiple simultaneous MDC requests
 test_73() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/d73-1
        test_mkdir $DIR/d73-2
        multiop_bg_pause $DIR/d73-1/f73-1 O_c || return 1
@@ -6487,12 +6895,13 @@ test_73() {
 run_test 73 "multiple MDC requests (should not deadlock)"
 
 test_74a() { # bug 6149, 6184
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       touch $DIR/f74a
        #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
        $LCTL set_param fail_loc=0x8000030e
        # get any lock that won't be difficult - lookup works.
        ls $DIR/f74a
@@ -6503,7 +6912,8 @@ test_74a() { # bug 6149, 6184
 run_test 74a "ldlm_enqueue freed-export error path, ls (shouldn't LBUG)"
 
 test_74b() { # bug 13310
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        #define OBD_FAIL_LDLM_ENQUEUE_OLD_EXPORT 0x30e
        #
        # very important to OR with OBD_FAIL_ONCE (0x80000000) -- otherwise it
@@ -6518,7 +6928,8 @@ test_74b() { # bug 13310
 run_test 74b "ldlm_enqueue freed-export error path, touch (shouldn't LBUG)"
 
 test_74c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        #define OBD_FAIL_LDLM_NEW_LOCK
        $LCTL set_param fail_loc=0x319
        touch $DIR/$tfile && error "touch successful"
@@ -6532,8 +6943,10 @@ num_inodes() {
 }
 
 test_76() { # Now for bug 20433, added originally in bug 1443
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local CPUS=$(getconf _NPROCESSORS_ONLN 2>/dev/null)
+
        cancel_lru_locks osc
        BEFORE_INODES=$(num_inodes)
        echo "before inodes: $BEFORE_INODES"
@@ -6577,8 +6990,8 @@ set_checksums()
 
 export ORIG_CSUM_TYPE="`lctl get_param -n osc.*osc-[^mM]*.checksum_type |
                         sed 's/.*\[\(.*\)\].*/\1/g' | head -n1`"
-CKSUM_TYPES=${CKSUM_TYPES:-"crc32 adler"}
-[ "$ORIG_CSUM_TYPE" = "crc32c" ] && CKSUM_TYPES="$CKSUM_TYPES crc32c"
+CKSUM_TYPES=${CKSUM_TYPES:-$(lctl get_param -n osc.*osc-[^mM]*.checksum_type |
+                            tr -d [] | head -n1)}
 set_checksum_type()
 {
        lctl set_param -n osc.*osc-[^mM]*.checksum_type $1
@@ -6593,8 +7006,9 @@ setup_f77() {
 }
 
 test_77a() { # bug 10889
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+
        [ ! -f $F77_TMP ] && setup_f77
        set_checksums 1
        dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ || error "dd error"
@@ -6604,8 +7018,9 @@ test_77a() { # bug 10889
 run_test 77a "normal checksum read/write operation"
 
 test_77b() { # bug 10889
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+
        [ ! -f $F77_TMP ] && setup_f77
        #define OBD_FAIL_OSC_CHECKSUM_SEND       0x409
        $LCTL set_param fail_loc=0x80000409
@@ -6635,14 +7050,15 @@ cleanup_77c() {
        $LCTL set_param osc.*osc-[^mM]*.checksum_dump=0
        $check_ost &&
                do_facet ost1 $LCTL set_param obdfilter.*-OST*.checksum_dump=0
-       [ -n $osc_file_prefix ] && rm -f ${osc_file_prefix}*
-       $check_ost && [ -n $ost_file_prefix ] &&
+       [ -n "$osc_file_prefix" ] && rm -f ${osc_file_prefix}*
+       $check_ost && [ -n "$ost_file_prefix" ] &&
                do_facet ost1 rm -f ${ost_file_prefix}\*
 }
 
 test_77c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        local bad1
        local osc_file_prefix
@@ -6705,7 +7121,7 @@ test_77c() {
        [[ "$orig_cksum" == "$dump_cksum" ]] ||
                error "dump content does not match on Client"
 
-       $check_ost || { skip "No need to check cksum dump on OSS"; return 0; }
+       $check_ost || skip "No need to check cksum dump on OSS"
 
        # check cksum dump on OSS
        ost_file=$(do_facet ost1 ls ${ost_file_prefix}\*)
@@ -6720,8 +7136,9 @@ test_77c() {
 run_test 77c "checksum error on client read with debug"
 
 test_77d() { # bug 10889
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+
        #define OBD_FAIL_OSC_CHECKSUM_SEND       0x409
        $LCTL set_param fail_loc=0x80000409
        set_checksums 1
@@ -6742,8 +7159,9 @@ test_77d() { # bug 10889
 run_test 77d "checksum error on OST direct write, read"
 
 test_77f() { # bug 10889
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+
        set_checksums 1
        for algo in $CKSUM_TYPES; do
                cancel_lru_locks osc
@@ -6760,17 +7178,20 @@ test_77f() { # bug 10889
 run_test 77f "repeat checksum error on write (expect error)"
 
 test_77g() { # bug 10889
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        [ ! -f $F77_TMP ] && setup_f77
 
-       $SETSTRIPE -c 1 -i 0 $DIR/$tfile
+       local file=$DIR/$tfile
+       stack_trap "rm -f $file" EXIT
+
+       $SETSTRIPE -c 1 -i 0 $file
        #define OBD_FAIL_OST_CHECKSUM_RECEIVE       0x21a
        do_facet ost1 lctl set_param fail_loc=0x8000021a
        set_checksums 1
-       dd if=$F77_TMP of=$DIR/$tfile bs=1M count=$F77SZ ||
+       dd if=$F77_TMP of=$file bs=1M count=$F77SZ ||
                error "write error: rc=$?"
        do_facet ost1 lctl set_param fail_loc=0
        set_checksums 0
@@ -6779,33 +7200,51 @@ test_77g() { # bug 10889
        #define OBD_FAIL_OST_CHECKSUM_SEND          0x21b
        do_facet ost1 lctl set_param fail_loc=0x8000021b
        set_checksums 1
-       cmp $F77_TMP $DIR/$tfile || error "file compare failed"
+       cmp $F77_TMP $file || error "file compare failed"
        do_facet ost1 lctl set_param fail_loc=0
        set_checksums 0
 }
 run_test 77g "checksum error on OST write, read"
 
-test_77j() { # bug 13805
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       $GSS && skip "could not run with gss" && return
-       #define OBD_FAIL_OSC_CKSUM_ADLER_ONLY    0x40c
-       lctl set_param fail_loc=0x40c
-       remount_client $MOUNT
-       lctl set_param fail_loc=0
-       # wait async osc connect to finish and reflect updated state value
+test_77k() { # LU-10906
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       $GSS && skip_env "could not run with gss"
+
+       local cksum_param="osc.$FSNAME*.checksums"
+       local get_checksum="$LCTL get_param -n $cksum_param | head -n1"
+       local checksum
        local i
-       for (( i=0; i < OSTCOUNT; i++ )) ; do
-               wait_osc_import_state client ost$((i+1)) FULL
+
+       [ "$ORIG_CSUM" ] || ORIG_CSUM=$(eval $get_checksum)
+       stack_trap "wait_update $HOSTNAME '$get_checksum' $ORIG_CSUM" EXIT
+       stack_trap "do_facet mgs $LCTL set_param -P $cksum_param=$ORIG_CSUM" \
+               EXIT
+
+       for i in 0 1; do
+               do_facet mgs $LCTL set_param -P $cksum_param=$i ||
+                       error "failed to set checksum=$i on MGS"
+               wait_update $HOSTNAME "$get_checksum" $i
+               #remount
+               echo "remount client, checksum should be $i"
+               remount_client $MOUNT || "failed to remount client"
+               checksum=$(eval $get_checksum)
+               [ $checksum -eq $i ] || error "checksum($checksum) != $i"
        done
 
-       for VALUE in $(lctl get_param osc.*osc-[^mM]*.checksum_type); do
-               PARAM=$(echo ${VALUE[0]} | cut -d "=" -f1)
-               algo=$(lctl get_param -n $PARAM | sed 's/.*\[\(.*\)\].*/\1/g')
-               [ "$algo" = "adler" ] || error "algo set to $algo instead of adler"
+       for opt in "checksum" "nochecksum"; do
+               #remount with mount option
+               echo "remount client with option $opt, checksum should be $i"
+               umount_client $MOUNT || "failed to umount client"
+               mount_client $MOUNT "$MOUNT_OPTS,$opt" ||
+                       "failed to mount client with option '$opt'"
+               checksum=$(eval $get_checksum)
+               [ $checksum -eq $i ] || error "checksum($checksum) != $i"
+               i=$((i - 1))
        done
-       remount_client $MOUNT
+
+       remount_client $MOUNT || "failed to remount client"
 }
-run_test 77j "client only supporting ADLER32"
+run_test 77k "enable/disable checksum correctly"
 
 [ "$ORIG_CSUM" ] && set_checksums $ORIG_CSUM || true
 rm -f $F77_TMP
@@ -6817,8 +7256,8 @@ cleanup_test_78() {
 }
 
 test_78() { # bug 10901
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost || { skip_env "local OST" && return; }
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost || skip_env "local OST"
 
        NSEQ=5
        F78SIZE=$(($(awk '/MemFree:/ { print $2 }' /proc/meminfo) / 1024))
@@ -6843,7 +7282,7 @@ test_78() { # bug 10901
                head -n1)
        echo "Smallest OST: $SMALLESTOST"
        [[ $SMALLESTOST -lt 10240 ]] &&
-               skip "too small OSTSIZE, useless to run large O_DIRECT test" && return 0
+               skip "too small OSTSIZE, useless to run large O_DIRECT test"
 
        trap cleanup_test_78 EXIT
 
@@ -6864,12 +7303,13 @@ test_78() { # bug 10901
 run_test 78 "handle large O_DIRECT writes correctly ============"
 
 test_79() { # bug 12743
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        wait_delete_completed
 
-        BKTOTAL=$(calc_osc_kbytes kbytestotal)
-        BKFREE=$(calc_osc_kbytes kbytesfree)
-        BKAVAIL=$(calc_osc_kbytes kbytesavail)
+       BKTOTAL=$(calc_osc_kbytes kbytestotal)
+       BKFREE=$(calc_osc_kbytes kbytesfree)
+       BKAVAIL=$(calc_osc_kbytes kbytesavail)
 
         STRING=`df -P $MOUNT | tail -n 1 | awk '{print $2","$3","$4}'`
         DFTOTAL=`echo $STRING | cut -d, -f1`
@@ -6895,17 +7335,19 @@ test_79() { # bug 12743
 run_test 79 "df report consistency check ======================="
 
 test_80() { # bug 10718
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        # relax strong synchronous semantics for slow backends like ZFS
-        local soc="obdfilter.*.sync_on_lock_cancel"
-        local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
-        local hosts=
-        if [ "$soc_old" != "never" -a "$(facet_fstype ost1)" != "ldiskfs" ]; then
-                hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
-                          facet_active_host $host; done | sort -u)
-                do_nodes $hosts lctl set_param $soc=never
-        fi
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       # relax strong synchronous semantics for slow backends like ZFS
+       local soc="obdfilter.*.sync_on_lock_cancel"
+       local soc_old=$(do_facet ost1 lctl get_param -n $soc | head -n1)
+       local hosts=
+       if [ "$soc_old" != "never" ] &&
+               [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
+                       hosts=$(for host in $(seq -f "ost%g" 1 $OSTCOUNT); do
+                               facet_active_host $host; done | sort -u)
+                       do_nodes $hosts lctl set_param $soc=never
+       fi
 
         dd if=/dev/zero of=$DIR/$tfile bs=1M count=1 seek=1M
         sync; sleep 1; sync
@@ -6924,37 +7366,39 @@ test_80() { # bug 10718
 run_test 80 "Page eviction is equally fast at high offsets too  ===="
 
 test_81a() { # LU-456
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        remote_ost_nodsh && skip "remote OST with nodsh" && return
-        # define OBD_FAIL_OST_MAPBLK_ENOSPC    0x228
-        # MUST OR with the OBD_FAIL_ONCE (0x80000000)
-        do_facet ost1 lctl set_param fail_loc=0x80000228
-
-        # write should trigger a retry and success
-        $SETSTRIPE -i 0 -c 1 $DIR/$tfile
-        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
-        RC=$?
-        if [ $RC -ne 0 ] ; then
-                error "write should success, but failed for $RC"
-        fi
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
+       # define OBD_FAIL_OST_MAPBLK_ENOSPC    0x228
+       # MUST OR with the OBD_FAIL_ONCE (0x80000000)
+       do_facet ost1 lctl set_param fail_loc=0x80000228
+
+       # write should trigger a retry and success
+       $SETSTRIPE -i 0 -c 1 $DIR/$tfile
+       $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+       RC=$?
+       if [ $RC -ne 0 ] ; then
+               error "write should success, but failed for $RC"
+       fi
 }
 run_test 81a "OST should retry write when get -ENOSPC ==============="
 
 test_81b() { # LU-456
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        remote_ost_nodsh && skip "remote OST with nodsh" && return
-        # define OBD_FAIL_OST_MAPBLK_ENOSPC    0x228
-        # Don't OR with the OBD_FAIL_ONCE (0x80000000)
-        do_facet ost1 lctl set_param fail_loc=0x228
-
-        # write should retry several times and return -ENOSPC finally
-        $SETSTRIPE -i 0 -c 1 $DIR/$tfile
-        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
-        RC=$?
-        ENOSPC=28
-        if [ $RC -ne $ENOSPC ] ; then
-                error "dd should fail for -ENOSPC, but succeed."
-        fi
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
+       # define OBD_FAIL_OST_MAPBLK_ENOSPC    0x228
+       # Don't OR with the OBD_FAIL_ONCE (0x80000000)
+       do_facet ost1 lctl set_param fail_loc=0x228
+
+       # write should retry several times and return -ENOSPC finally
+       $SETSTRIPE -i 0 -c 1 $DIR/$tfile
+       $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+       RC=$?
+       ENOSPC=28
+       if [ $RC -ne $ENOSPC ] ; then
+               error "dd should fail for -ENOSPC, but succeed."
+       fi
 }
 run_test 81b "OST should return -ENOSPC when retry still fails ======="
 
@@ -6982,6 +7426,7 @@ run_test 82 "Basic grouplock test"
 
 test_83() {
        local sfile="/boot/System.map-$(uname -r)"
+       [ ! -f $sfile ] && skip "No $sfile found"
        # define OBD_FAIL_LLITE_PTASK_IO_FAIL 0x140d
        $LCTL set_param fail_loc=0x140d
        cp $sfile $DIR/$tfile || error "write failed"
@@ -6992,8 +7437,8 @@ test_83() {
 run_test 83 "Short write in ptask ==============================="
 
 test_99() {
-       [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs" &&
-               return
+       [ -z "$(which cvs 2>/dev/null)" ] && skip_env "could not find cvs"
+
        test_mkdir $DIR/$tdir.cvsroot
        chown $RUNAS_ID $DIR/$tdir.cvsroot
 
@@ -7023,15 +7468,13 @@ test_99() {
 run_test 99 "cvs strange file/directory operations"
 
 test_100() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ "$NETTYPE" =~ tcp ]] ||
-               { skip "TCP secure port test, not useful for NETTYPE=$NETTYPE" &&
-                       return ; }
-
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip_env "TCP secure port test, not useful for NETTYPE=$NETTYPE"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        remote_servers ||
-               { skip "useless for local single node setup" && return; }
+               skip "useless for local single node setup"
 
        netstat -tna | ( rc=1; while read PROT SND RCV LOCAL REMOTE STAT; do
                [ "$PROT" != "tcp" ] && continue
@@ -7075,8 +7518,9 @@ cleanup_101a() {
 }
 
 test_101a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -ge 2 ] && skip "needs < 2 MDTs" && return #LU-4322
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -ge 2 ] && skip_env "needs < 2 MDTs" #LU-4322
+
        local s
        local discard
        local nreads=10000
@@ -7164,10 +7608,12 @@ ra_check_101() {
 }
 
 test_101b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        local STRIPE_SIZE=1048576
        local STRIDE_SIZE=$((STRIPE_SIZE*OSTCOUNT))
+
        if [ $SLOW == "yes" ]; then
                local FILE_LENGTH=$((STRIDE_SIZE * 64))
        else
@@ -7197,7 +7643,8 @@ test_101b() {
 run_test 101b "check stride-io mode read-ahead ================="
 
 test_101c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local STRIPE_SIZE=1048576
        local FILE_LENGTH=$((STRIPE_SIZE*100))
        local nreads=10000
@@ -7235,14 +7682,15 @@ set_read_ahead() {
 }
 
 test_101d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local file=$DIR/$tfile
        local sz_MB=${FILESIZE_101d:-500}
        local ra_MB=${READAHEAD_MB:-40}
 
        local free_MB=$(($(df -P $DIR | tail -n 1 | awk '{ print $4 }') / 1024))
        [ $free_MB -lt $sz_MB ] &&
-               skip "Need free space ${sz_MB}M, have ${free_MB}M" && return
+               skip "Need free space ${sz_MB}M, have ${free_MB}M"
 
        echo "Create test file $file size ${sz_MB}M, ${free_MB}M free"
        $SETSTRIPE -c -1 $file || error "setstripe failed"
@@ -7278,7 +7726,8 @@ test_101d() {
 run_test 101d "file read with and without read-ahead enabled"
 
 test_101e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local file=$DIR/$tfile
        local size_KB=500  #KB
        local count=100
@@ -7287,7 +7736,7 @@ test_101e() {
        local free_KB=$(df -P $DIR | tail -n 1 | awk '{ print $4 }')
        local need_KB=$((count * size_KB))
        [[ $free_KB -le $need_KB ]] &&
-               skip_env "Need free space $need_KB, have $free_KB" && return
+               skip_env "Need free space $need_KB, have $free_KB"
 
        echo "Creating $count ${size_KB}K test files"
        for ((i = 0; i < $count; i++)); do
@@ -7317,7 +7766,7 @@ test_101e() {
 run_test 101e "check read-ahead for small read(1k) for small files(500k)"
 
 test_101f() {
-       which iozone || { skip "no iozone installed" && return; }
+       which iozone || skip_env "no iozone installed"
 
        local old_debug=$($LCTL get_param debug)
        old_debug=${old_debug#*=}
@@ -7350,6 +7799,7 @@ run_test 101f "check mmap read performance"
 test_101g_brw_size_test() {
        local mb=$1
        local pages=$((mb * 1048576 / $(page_size)))
+       local file=$DIR/$tfile
 
        $LCTL set_param osc.*.max_pages_per_rpc=${mb}M ||
                { error "unable to set max_pages_per_rpc=${mb}M"; return 1; }
@@ -7358,14 +7808,15 @@ test_101g_brw_size_test() {
                        return 2
        done
 
+       stack_trap "rm -f $file" EXIT
        $LCTL set_param -n osc.*.rpc_stats=0
 
        # 10 RPCs should be enough for the test
        local count=10
-       dd if=/dev/zero of=$DIR/$tfile bs=${mb}M count=$count ||
+       dd if=/dev/zero of=$file bs=${mb}M count=$count ||
                { error "dd write ${mb} MB blocks failed"; return 3; }
        cancel_lru_locks osc
-       dd of=/dev/null if=$DIR/$tfile bs=${mb}M count=$count ||
+       dd of=/dev/null if=$file bs=${mb}M count=$count ||
                { error "dd write ${mb} MB blocks failed"; return 4; }
 
        # calculate number of full-sized read and write RPCs
@@ -7382,6 +7833,8 @@ test_101g_brw_size_test() {
 }
 
 test_101g() {
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
        local rpcs
        local osts=$(get_facets OST)
        local list=$(comma_list $(osts_nodes))
@@ -7458,17 +7911,16 @@ cleanup_test102() {
 }
 
 test_102a() {
-       local testfile=$DIR/$tfile
-
-       touch $testfile
-
-       [ "$UID" != 0 ] && skip_env "must run as root" && return
+       [ "$UID" != 0 ] && skip "must run as root"
        [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep xattr)" ] &&
-               skip_env "must have user_xattr" && return
+               skip_env "must have user_xattr"
 
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip_env "could not find setfattr" && return
+               skip_env "could not find setfattr"
+
+       local testfile=$DIR/$tfile
 
+       touch $testfile
        echo "set/get xattr..."
        setfattr -n trusted.name1 -v value1 $testfile ||
                error "setfattr -n trusted.name1=value1 $testfile failed"
@@ -7521,11 +7973,11 @@ run_test 102a "user xattr test =================================="
 
 test_102b() {
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip_env "could not find setfattr" && return
+               skip_env "could not find setfattr"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        # b10930: get/set/list trusted.lov xattr
        echo "get/set/list trusted.lov xattr ..."
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
        local testfile=$DIR/$tfile
        $SETSTRIPE -S 65536 -i 1 -c $OSTCOUNT $testfile ||
                error "setstripe failed"
@@ -7552,11 +8004,11 @@ run_test 102b "getfattr/setfattr for trusted.lov EAs ============"
 
 test_102c() {
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip_env "could not find setfattr" && return
+               skip_env "could not find setfattr"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        # b10930: get/set/list lustre.lov xattr
        echo "get/set/list lustre.lov xattr ..."
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
        test_mkdir $DIR/$tdir
        chown $RUNAS_ID $DIR/$tdir
        local testfile=$DIR/$tdir/$tfile
@@ -7613,8 +8065,9 @@ have_xattrs_include() {
 }
 
 test_102d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        XINC=$(have_xattrs_include)
        setup_test102
        tar xf $TMP/f102.tar -C $DIR/$tdir --xattrs $XINC
@@ -7624,8 +8077,9 @@ test_102d() {
 run_test 102d "tar restore stripe info from tarfile,not keep osts"
 
 test_102f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        XINC=$(have_xattrs_include)
        setup_test102
        test_mkdir $DIR/$tdir.restore
@@ -7638,21 +8092,19 @@ test_102f() {
 run_test 102f "tar copy files, not keep osts"
 
 grow_xattr() {
-       local xsize=${1:-1024}  # in bytes
-       local file=$DIR/$tfile
-
        [ -z "$(lctl get_param -n mdc.*.connect_flags | grep xattr)" ] &&
-               skip "must have user_xattr" && return 0
+               skip "must have user_xattr"
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip_env "could not find setfattr" && return 0
+               skip_env "could not find setfattr"
        [ -z "$(which getfattr 2>/dev/null)" ] &&
-               skip_env "could not find getfattr" && return 0
-
-       touch $file
+               skip_env "could not find getfattr"
 
+       local xsize=${1:-1024}  # in bytes
+       local file=$DIR/$tfile
        local value="$(generate_string $xsize)"
-
        local xbig=trusted.big
+
+       touch $file
        log "save $xbig on $file"
        setfattr -n $xbig -v $value $file ||
                error "saving $xbig on $file failed"
@@ -7684,14 +8136,16 @@ test_102h() { # bug 15777
 run_test 102h "grow xattr from inside inode to external block"
 
 test_102ha() {
-       large_xattr_enabled || { skip "large_xattr disabled" && return; }
+       large_xattr_enabled || skip_env "ea_inode feature disabled"
+
        grow_xattr $(max_xattr_size)
 }
 run_test 102ha "grow xattr from inside inode to external inode"
 
 test_102i() { # bug 17038
        [ -z "$(which getfattr 2>/dev/null)" ] &&
-               skip "could not find getfattr" && return
+               skip "could not find getfattr"
+
        touch $DIR/$tfile
        ln -s $DIR/$tfile $DIR/${tfile}link
        getfattr -n trusted.lov $DIR/$tfile ||
@@ -7704,8 +8158,9 @@ test_102i() { # bug 17038
 run_test 102i "lgetxattr test on symbolic link ============"
 
 test_102j() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+
        XINC=$(have_xattrs_include)
        setup_test102 "$RUNAS"
        chown $RUNAS_ID $DIR/$tdir
@@ -7717,7 +8172,8 @@ run_test 102j "non-root tar restore stripe info from tarfile, not keep osts ==="
 
 test_102k() {
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip "could not find setfattr" && return
+               skip "could not find setfattr"
+
        touch $DIR/$tfile
        # b22187 just check that does not crash for regular file.
        setfattr -n trusted.lov $DIR/$tfile
@@ -7745,7 +8201,7 @@ run_test 102k "setfattr without parameter of value shouldn't cause a crash"
 
 test_102l() {
        [ -z "$(which getfattr 2>/dev/null)" ] &&
-               skip "could not find getfattr" && return
+               skip "could not find getfattr"
 
        # LU-532 trusted. xattr is invisible to non-root
        local testfile=$DIR/$tfile
@@ -7791,11 +8247,10 @@ getxattr() { # getxattr path name
 
 test_102n() { # LU-4101 mdt: protect internal xattrs
        [ -z "$(which setfattr 2>/dev/null)" ] &&
-               skip "could not find setfattr" && return
+               skip "could not find setfattr"
        if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.50) ]
        then
                skip "MDT < 2.5.50 allows setxattr on internal trusted xattrs"
-               return
        fi
 
        local file0=$DIR/$tfile.0
@@ -7873,10 +8328,10 @@ test_102n() { # LU-4101 mdt: protect internal xattrs
 run_test 102n "silently ignore setxattr on internal trusted xattrs"
 
 test_102p() { # LU-4703 setxattr did not check ownership
-       local testfile=$DIR/$tfile
-
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.56) ] &&
-               skip "MDS needs to be at least 2.5.56" && return
+               skip "MDS needs to be at least 2.5.56"
+
+       local testfile=$DIR/$tfile
 
        touch $testfile
 
@@ -7893,14 +8348,16 @@ run_test 102p "check setxattr(2) correctly fails without permission"
 
 test_102q() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) ] &&
-               skip "MDS needs to be at least 2.6.92" && return
+               skip "MDS needs to be at least 2.6.92"
+
        orphan_linkea_check $DIR/$tfile || error "orphan_linkea_check"
 }
 run_test 102q "flistxattr should not return trusted.link EAs for orphans"
 
 test_102r() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.93) ] &&
-               skip "MDS needs to be at least 2.6.93" && return
+               skip "MDS needs to be at least 2.6.93"
+
        touch $DIR/$tfile || error "touch"
        setfattr -n user.$(basename $tfile) $DIR/$tfile || error "setfattr"
        getfattr -n user.$(basename $tfile) $DIR/$tfile || error "getfattr"
@@ -7930,6 +8387,56 @@ test_102r() {
 }
 run_test 102r "set EAs with empty values"
 
+test_102s() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
+               skip "MDS needs to be at least 2.11.52"
+
+       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+       save_lustre_params client "llite.*.xattr_cache" > $save
+
+       for cache in 0 1; do
+               lctl set_param llite.*.xattr_cache=$cache
+
+               rm -f $DIR/$tfile
+               touch $DIR/$tfile || error "touch"
+               for prefix in lustre security system trusted user; do
+                       # Note getxattr() may fail with 'Operation not
+                       # supported' or 'No such attribute' depending
+                       # on prefix and cache.
+                       getfattr -n $prefix.n102s $DIR/$tfile &&
+                               error "getxattr '$prefix.n102s' should fail (cache = $cache)"
+               done
+       done
+
+       restore_lustre_params < $save
+}
+run_test 102s "getting nonexistent xattrs should fail"
+
+test_102t() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
+               skip "MDS needs to be at least 2.11.52"
+
+       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
+       save_lustre_params client "llite.*.xattr_cache" > $save
+
+       for cache in 0 1; do
+               lctl set_param llite.*.xattr_cache=$cache
+
+               for buf_size in 0 256; do
+                       rm -f $DIR/$tfile
+                       touch $DIR/$tfile || error "touch"
+                       setfattr -n user.multiop $DIR/$tfile
+                       $MULTIOP $DIR/$tfile oa$buf_size ||
+                               error "cannot get zero length xattr value (buf_size = $buf_size)"
+               done
+       done
+
+       restore_lustre_params < $save
+}
+run_test 102t "zero length xattr values handled correctly"
+
 run_acl_subtest()
 {
     $LUSTRE/tests/acl/run $LUSTRE/tests/acl/$1.test
@@ -7937,13 +8444,13 @@ run_acl_subtest()
 }
 
 test_103a() {
-       [ "$UID" != 0 ] && skip_env "must run as root" && return
+       [ "$UID" != 0 ] && skip "must run as root"
+       $GSS && skip_env "could not run under gss"
        [ -z "$(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl)" ] &&
-               skip "must have acl enabled" && return
+               skip_env "must have acl enabled"
        [ -z "$(which setfacl 2>/dev/null)" ] &&
-               skip_env "could not find setfacl" && return
-       $GSS && skip "could not run under gss" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip_env "could not find setfacl"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        gpasswd -a daemon bin                           # LU-5641
        do_facet $SINGLEMDS gpasswd -a daemon bin       # LU-5641
@@ -8011,7 +8518,37 @@ test_103a() {
                fi
        done
 }
-run_test 103a "acl test ========================================="
+run_test 103a "acl test"
+
+test_103b() {
+       local U
+
+       for U in {0..511}; do
+               {
+               local O=$(printf "%04o" $U)
+
+               umask $(printf "%04o" $((511 ^ $O)))
+               $LFS setstripe -c 1 $DIR/$tfile.s$O
+               local S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.s$O))
+
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe $DIR/$tfile.s$O '$S' != '$O'"
+
+               $LFS setstripe -E16M -c 1 -E1G -S4M $DIR/$tfile.p$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.p$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -E $DIR/$tfile.p$O '$S' != '$O'"
+
+               $LFS setstripe -N2 -c 1 $DIR/$tfile.m$O
+               S=$(printf "%04o" 0$(stat -c%a $DIR/$tfile.m$O))
+               (( $S == ($O & 0666) )) ||
+                       error "lfs setstripe -N2 $DIR/$tfile.m$O '$S' != '$O'"
+               rm -f $DIR/$tfile.[smp]$0
+               } &
+       done
+       wait
+}
+run_test 103b "umask lfs setstripe"
 
 test_103c() {
        mkdir -p $DIR/$tdir
@@ -8026,7 +8563,8 @@ test_103c() {
 run_test 103c "'cp -rp' won't set empty acl"
 
 test_104a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        touch $DIR/$tfile
        lfs df || error "lfs df failed"
        lfs df -ih || error "lfs df -ih failed"
@@ -8048,9 +8586,10 @@ test_104a() {
 run_test 104a "lfs df [-ih] [path] test ========================="
 
 test_104b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [ $RUNAS_ID -eq $UID ] &&
-               skip_env "RUNAS_ID = UID = $UID -- skipping" && return
+               skip_env "RUNAS_ID = UID = $UID -- skipping"
+
        chmod 666 /dev/obd
        denied_cnt=$(($($RUNAS $LFS check servers 2>&1 |
                        grep "Permission denied" | wc -l)))
@@ -8095,9 +8634,10 @@ test_105c() {
 run_test 105c "lockf when mounted without -o flock test"
 
 test_105d() { # bug 15924
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
-       flock_is_enabled || { skip "mount w/o flock enabled" && return; }
+       flock_is_enabled || skip_env "mount w/o flock enabled"
        #define OBD_FAIL_LDLM_CP_CB_WAIT  0x315
        $LCTL set_param fail_loc=0x80000315
        flocks_test 2 $DIR/$tdir
@@ -8105,7 +8645,8 @@ test_105d() { # bug 15924
 run_test 105d "flock race (should not freeze) ========"
 
 test_105e() { # bug 22660 && 22040
-       flock_is_enabled || { skip "mount w/o flock enabled" && return; }
+       flock_is_enabled || skip_env "mount w/o flock enabled"
+
        touch $DIR/$tfile
        flocks_test 3 $DIR/$tfile
 }
@@ -8119,12 +8660,13 @@ test_106() { #bug 10921
 run_test 106 "attempt exec of dir followed by chown of that dir"
 
 test_107() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        CDIR=`pwd`
-        cd $DIR
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
-        local file=core
-        rm -f $file
+       CDIR=`pwd`
+       local file=core
+
+       cd $DIR
+       rm -f $file
 
         local save_pattern=$(sysctl -n kernel.core_pattern)
         local save_uses_pid=$(sysctl -n kernel.core_uses_pid)
@@ -8171,8 +8713,8 @@ run_test 110 "filename length checking"
 # Purpose: To verify dynamic thread (OSS) creation.
 #
 test_115() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        # Lustre does not stop service threads once they are started.
        # Reset number of running threads to default.
@@ -8298,10 +8840,9 @@ free_min_max () {
 }
 
 test_116a() { # was previously test_116()
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        echo -n "Free space priority "
        do_facet $SINGLEMDS lctl get_param -n lo*.*-mdtlov.qos_prio_free |
@@ -8309,12 +8850,10 @@ test_116a() { # was previously test_116()
        declare -a AVAIL
        free_min_max
 
-       [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip" && return
-       [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip" \
-               && return
+       [ $MINV -eq 0 ] && skip "no free space in OST$MINI, skip"
+       [ $MINV -gt 10000000 ] && skip "too much free space in OST$MINI, skip"
        trap simple_cleanup_common EXIT
 
-
        # Check if we need to generate uneven OSTs
        test_mkdir -p $DIR/$tdir/OST${MINI}
        local FILL=$((MINV / 4))
@@ -8359,9 +8898,8 @@ test_116a() { # was previously test_116()
                echo "ok"
        else
                echo "failed - QOS mode won't be used"
-               skip "QOS imbalance criteria not met"
                simple_cleanup_common
-               return
+               skip "QOS imbalance criteria not met"
        fi
 
        MINI1=$MINI
@@ -8423,13 +8961,13 @@ test_116a() { # was previously test_116()
 run_test 116a "stripe QOS: free space balance ==================="
 
 test_116b() { # LU-2093
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
 #define OBD_FAIL_MDS_OSC_CREATE_FAIL     0x147
        local old_rr=$(do_facet $SINGLEMDS lctl get_param -n \
                       lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr | head -1)
-       [ -z "$old_rr" ] && skip "no QOS" && return 0
+       [ -z "$old_rr" ] && skip "no QOS"
        do_facet $SINGLEMDS lctl set_param \
                lo*.$FSNAME-MDT0000-mdtlov.qos_threshold_rr=0
        mkdir -p $DIR/$tdir
@@ -8444,13 +8982,14 @@ run_test 116b "QoS shouldn't LBUG if not enough OSTs found on the 2nd pass"
 
 test_117() # bug 10891
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
-        #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
-        lctl set_param fail_loc=0x21e
-        > $DIR/$tfile || error "truncate failed"
-        lctl set_param fail_loc=0
-        echo "Truncate succeeded."
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=1
+       #define OBD_FAIL_OST_SETATTR_CREDITS 0x21e
+       lctl set_param fail_loc=0x21e
+       > $DIR/$tfile || error "truncate failed"
+       lctl set_param fail_loc=0
+       echo "Truncate succeeded."
        rm -f $DIR/$tfile
 }
 run_test 117 "verify osd extend =========="
@@ -8480,7 +9019,8 @@ reset_async() {
 
 test_118a() #bug 11710
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        reset_async
 
        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
@@ -8497,8 +9037,8 @@ run_test 118a "verify O_SYNC works =========="
 
 test_118b()
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_async
 
@@ -8534,12 +9074,12 @@ run_test 118b "Reclaim dirty pages on fatal error =========="
 
 test_118c()
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        # for 118c, restore the original resend count, LU-1940
        [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] &&
                                set_resend_count $OLD_RESENDCOUNT
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_async
 
@@ -8586,8 +9126,8 @@ run_test 118c "Fsync blocks on EROFS until dirty pages are flushed =========="
 
 test_118d()
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        reset_async
 
@@ -8625,11 +9165,12 @@ test_118d()
 run_test 118d "Fsync validation inject a delay of the bulk =========="
 
 test_118f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        reset_async
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       reset_async
 
-        #define OBD_FAIL_OSC_BRW_PREP_REQ2        0x40a
-        lctl set_param fail_loc=0x8000040a
+       #define OBD_FAIL_OSC_BRW_PREP_REQ2        0x40a
+       lctl set_param fail_loc=0x8000040a
 
        # Should simulate EINVAL error which is fatal
         $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
@@ -8661,7 +9202,8 @@ test_118f() {
 run_test 118f "Simulate unrecoverable OSC side error =========="
 
 test_118g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        reset_async
 
        #define OBD_FAIL_OSC_BRW_PREP_REQ        0x406
@@ -8697,10 +9239,10 @@ test_118g() {
 run_test 118g "Don't stay in wait if we got local -ENOMEM  =========="
 
 test_118h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
-        reset_async
+       reset_async
 
        #define OBD_FAIL_OST_BRW_WRITE_BULK      0x20e
         set_nodes_failloc "$(osts_nodes)" 0x20e
@@ -8735,10 +9277,10 @@ run_test 118h "Verify timeout in handling recoverables errors  =========="
 [ "$SLOW" = "no" ] && [ -n "$OLD_RESENDCOUNT" ] && set_resend_count $OLD_RESENDCOUNT
 
 test_118i() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
-        reset_async
+       reset_async
 
        #define OBD_FAIL_OST_BRW_WRITE_BULK      0x20e
         set_nodes_failloc "$(osts_nodes)" 0x20e
@@ -8776,10 +9318,10 @@ run_test 118i "Fix error before timeout in recoverable error  =========="
 [ "$SLOW" = "no" ] && set_resend_count 4
 
 test_118j() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
-        reset_async
+       reset_async
 
        #define OBD_FAIL_OST_BRW_WRITE_BULK2     0x220
         set_nodes_failloc "$(osts_nodes)" 0x220
@@ -8813,8 +9355,8 @@ run_test 118j "Simulate unrecoverable OST side error =========="
 
 test_118k()
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OSTs with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OSTs with nodsh"
 
        #define OBD_FAIL_OST_BRW_WRITE_BULK      0x20e
        set_nodes_failloc "$(osts_nodes)" 0x20e
@@ -8834,10 +9376,10 @@ test_118k()
 }
 run_test 118k "bio alloc -ENOMEM and IO TERM handling ========="
 
-test_118l()
+test_118l() # LU-646
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       # LU-646
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        $MULTIOP $DIR/$tdir Dy || error "fsync dir failed"
        rm -rf $DIR/$tdir
@@ -8846,7 +9388,8 @@ run_test 118l "fsync dir"
 
 test_118m() # LU-3066
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        $MULTIOP $DIR/$tdir DY || error "fdatasync dir failed"
        rm -rf $DIR/$tdir
@@ -8860,8 +9403,8 @@ test_118n()
        local begin
        local end
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OSTs with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OSTs with nodsh"
 
        # Sleep to avoid a cached response.
        #define OBD_STATFS_CACHE_SECONDS 1
@@ -8901,14 +9444,14 @@ run_test 119a "Short directIO read must return actual read amount"
 
 test_119b() # bug 11737
 {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
-        $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
-        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"
-        rm -f $DIR/$tfile
+       $SETSTRIPE -c 2 $DIR/$tfile || error "setstripe failed"
+       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"
+       rm -f $DIR/$tfile
 }
 run_test 119b "Sparse directIO read must return actual read amount"
 
@@ -8923,7 +9466,8 @@ run_test 119c "Testing for direct read hitting hole"
 
 test_119d() # bug 15950
 {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
         MAX_RPCS_IN_FLIGHT=`$LCTL get_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight`
         $LCTL set_param -n osc.*OST0000-osc-[^mM]*.max_rpcs_in_flight 1
         BSIZE=1048576
@@ -8948,11 +9492,11 @@ test_119d() # bug 15950
 run_test 119d "The DIO path should try to send a new rpc once one is completed"
 
 test_120a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        test_mkdir $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
+               skip_env "no early lock cancel on server"
 
        lru_resize_disable mdc
        lru_resize_disable osc
@@ -8980,11 +9524,12 @@ test_120a() {
 run_test 120a "Early Lock Cancel: mkdir test"
 
 test_120b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        test_mkdir $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
+               skip_env "no early lock cancel on server"
+
        lru_resize_disable mdc
        lru_resize_disable osc
        cancel_lru_locks mdc
@@ -9008,11 +9553,12 @@ test_120b() {
 run_test 120b "Early Lock Cancel: create test"
 
 test_120c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        test_mkdir -c1 $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
+               skip "no early lock cancel on server"
+
        lru_resize_disable mdc
        lru_resize_disable osc
        test_mkdir -c1 $DIR/$tdir/d1
@@ -9039,11 +9585,12 @@ test_120c() {
 run_test 120c "Early Lock Cancel: link test"
 
 test_120d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        test_mkdir -c1 $DIR/$tdir
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
+               skip_env "no early lock cancel on server"
+
        lru_resize_disable mdc
        lru_resize_disable osc
        touch $DIR/$tdir
@@ -9068,10 +9615,11 @@ test_120d() {
 run_test 120d "Early Lock Cancel: setattr test"
 
 test_120e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip_env "no early lock cancel on server"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local dlmtrace_set=false
 
        test_mkdir -c1 $DIR/$tdir
@@ -9111,10 +9659,11 @@ test_120e() {
 run_test 120e "Early Lock Cancel: unlink test"
 
 test_120f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip_env "no early lock cancel on server"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        test_mkdir -c1 $DIR/$tdir
        lru_resize_disable mdc
        lru_resize_disable osc
@@ -9151,10 +9700,11 @@ test_120f() {
 run_test 120f "Early Lock Cancel: rename test"
 
 test_120g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q early_lock_cancel ||
-               { skip "no early lock cancel on server"; return 0; }
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip_env "no early lock cancel on server"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        lru_resize_disable mdc
        lru_resize_disable osc
        count=10000
@@ -9197,7 +9747,8 @@ test_120g() {
 run_test 120g "Early Lock Cancel: performance test"
 
 test_121() { #bug #10589
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -rf $DIR/$tfile
        writes=$(LANG=C dd if=/dev/zero of=$DIR/$tfile count=1 2>&1 | awk -F '+' '/out$/ {print $1}')
 #define OBD_FAIL_LDLM_CANCEL_RACE        0x310
@@ -9211,7 +9762,8 @@ test_121() { #bug #10589
 run_test 121 "read cancel race ========="
 
 test_123a() { # was test 123, statahead(bug 11401)
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        SLOWOK=0
        if ! grep -q "processor.*: 1" /proc/cpuinfo; then
                log "testing UP system. Performance may be lower than expected."
@@ -9294,7 +9846,8 @@ test_123a() { # was test 123, statahead(bug 11401)
 run_test 123a "verify statahead work"
 
 test_123b () { # statahead(bug 15027)
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        createmany -o $DIR/$tdir/$tfile-%d 1000
 
@@ -9314,10 +9867,12 @@ test_123b () { # statahead(bug 15027)
 run_test 123b "not panic with network error in statahead enqueue (bug 15027)"
 
 test_124a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
-               { skip "no lru resize on server"; return 0; }
+               skip_env "no lru resize on server"
+
        local NR=2000
+
        test_mkdir $DIR/$tdir
 
        log "create $NR files at $DIR/$tdir"
@@ -9341,21 +9896,19 @@ test_124a() {
         done
 
        if [[ -z "$NSDIR" || $LRU_SIZE -lt $(default_lru_size) ]]; then
-                skip "Not enough cached locks created!"
-                return 0
-        fi
-        log "LRU=$LRU_SIZE"
+               skip "Not enough cached locks created!"
+       fi
+       log "LRU=$LRU_SIZE"
 
-        local SLEEP=30
+       local SLEEP=30
 
-        # We know that lru resize allows one client to hold $LIMIT locks
-        # for 10h. After that locks begin to be killed by client.
-        local MAX_HRS=10
+       # We know that lru resize allows one client to hold $LIMIT locks
+       # for 10h. After that locks begin to be killed by client.
+       local MAX_HRS=10
        local LIMIT=$($LCTL get_param -n $NSDIR.pool.limit)
        log "LIMIT=$LIMIT"
        if [ $LIMIT -lt $LRU_SIZE ]; then
-           skip "Limit is too small $LIMIT"
-           return 0
+               skip "Limit is too small $LIMIT"
        fi
 
         # Make LVF so higher that sleeping for $SLEEP is enough to _start_
@@ -9416,9 +9969,9 @@ get_max_pool_limit()
 }
 
 test_124b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
-               { skip "no lru resize on server"; return 0; }
+               skip_env "no lru resize on server"
 
        LIMIT=$(get_max_pool_limit)
 
@@ -9491,9 +10044,9 @@ test_124b() {
 run_test 124b "lru resize (performance test) ======================="
 
 test_124c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        $LCTL get_param -n mdc.*.connect_flags | grep -q lru_resize ||
-               { skip "no lru resize on server"; return 0; }
+               skip_env "no lru resize on server"
 
        # cache ununsed locks on client
        local nr=100
@@ -9524,10 +10077,11 @@ run_test 124c "LRUR cancel very aged locks"
 
 test_125() { # 13358
        $LCTL get_param -n llite.*.client_type | grep -q local ||
-               { skip "must run as local client"; return; }
+               skip "must run as local client"
        $LCTL get_param -n mdc.*-mdc-*.connect_flags | grep -q acl ||
-               { skip "must have acl enabled"; return; }
-       [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
+               skip_env "must have acl enabled"
+       [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
+
        test_mkdir $DIR/$tdir
        $LFS setstripe -S 65536 -c -1 $DIR/$tdir || error "setstripe failed"
        setfacl -R -m u:bin:rwx $DIR/$tdir || error "setfacl $DIR/$tdir failed"
@@ -9536,10 +10090,10 @@ test_125() { # 13358
 run_test 125 "don't return EPROTO when a dir has a non-default striping and ACLs"
 
 test_126() { # bug 12829/13455
+       $GSS && skip_env "must run as gss disabled"
        $LCTL get_param -n llite.*.client_type | grep -q local ||
-               { skip "must run as local client"; return; }
-       [ "$UID" != 0 ] && skip_env "$TESTNAME (must run as root)" && return
-       $GSS && skip "must run as gss disabled" && return
+               skip "must run as local client"
+       [ "$UID" != 0 ] && skip "must run as root, not UID $UID"
 
        $RUNAS -u 0 -g 1 touch $DIR/$tfile || error "touch failed"
        gid=`ls -n $DIR/$tfile | awk '{print $4}'`
@@ -9549,15 +10103,16 @@ test_126() { # bug 12829/13455
 run_test 126 "check that the fsgid provided by the client is taken into account"
 
 test_127a() { # bug 15521
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
-        $LCTL set_param osc.*.stats=0
-        FSIZE=$((2048 * 1024))
-        dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
-        cancel_lru_locks osc
-        dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       $SETSTRIPE -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
+       $LCTL set_param osc.*.stats=0
+       FSIZE=$((2048 * 1024))
+       dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
+       cancel_lru_locks osc
+       dd if=$DIR/$tfile of=/dev/null bs=$FSIZE
 
-        $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
+       $LCTL get_param osc.*0000-osc-*.stats | grep samples > $DIR/${tfile}.tmp
         while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
                 echo "got $COUNT $NAME"
                 [ ! $MIN ] && error "Missing min value for $NAME proc entry"
@@ -9588,15 +10143,17 @@ test_127a() { # bug 15521
 run_test 127a "verify the client stats are sane"
 
 test_127b() { # bug LU-333
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        $LCTL set_param llite.*.stats=0
-        FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
-        # perform 2 reads and writes so MAX is different from SUM.
-        dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
-        dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
-        cancel_lru_locks osc
-        dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
-        dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       $LCTL set_param llite.*.stats=0
+       FSIZE=65536 # sized fixed to match PAGE_SIZE for most clients
+
+       # perform 2 reads and writes so MAX is different from SUM.
+       dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
+       dd if=/dev/zero of=$DIR/$tfile bs=$FSIZE count=1
+       cancel_lru_locks osc
+       dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
+       dd if=$DIR/$tfile of=/dev/null bs=$FSIZE count=1
 
         $LCTL get_param llite.*.stats | grep samples > $TMP/${tfile}.tmp
         while read NAME COUNT SAMP UNIT MIN MAX SUM SUMSQ; do
@@ -9671,15 +10228,14 @@ check_mds_dmesg() {
 }
 
 test_129() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.56) ]] ||
-               { skip "Need MDS version with at least 2.5.56"; return 0; }
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+               skip "Need MDS version with at least 2.5.56"
        if [ "$(facet_fstype $SINGLEMDS)" != ldiskfs ]; then
-               skip "ldiskfs only test"
-               return
+               skip_env "ldiskfs only test"
        fi
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local ENOSPC=28
        local EFBIG=27
        local has_warning=false
@@ -9741,8 +10297,7 @@ cleanup_130() {
 
 test_130a() {
        local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
-               return
+       [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
 
        trap cleanup_130 EXIT RETURN
 
@@ -9755,7 +10310,7 @@ test_130a() {
        filefrag -ves $fm_file
        RC=$?
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
-               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
+               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
        [ $RC != 0 ] && error "filefrag $fm_file failed"
 
        filefrag_op=$(filefrag -ve -k $fm_file |
@@ -9790,11 +10345,10 @@ test_130a() {
 run_test 130a "FIEMAP (1-stripe file)"
 
 test_130b() {
-       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
 
        local filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP" &&
-               return
+       [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
 
        trap cleanup_130 EXIT RETURN
 
@@ -9802,7 +10356,7 @@ test_130b() {
        $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
                        error "setstripe on $fm_file"
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
-               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
+               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
 
        dd if=/dev/zero of=$fm_file bs=1M count=$OSTCOUNT ||
                error "dd failed on $fm_file"
@@ -9850,18 +10404,17 @@ test_130b() {
 run_test 130b "FIEMAP ($OSTCOUNT-stripe file)"
 
 test_130c() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
-               return
+       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
 
        trap cleanup_130 EXIT RETURN
 
        local fm_file=$DIR/$tfile
        $SETSTRIPE -S 65536 -c 2 $fm_file || error "setstripe on $fm_file"
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
-               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
+               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
 
        dd if=/dev/zero of=$fm_file seek=1 bs=1M count=1 ||
                        error "dd failed on $fm_file"
@@ -9916,11 +10469,10 @@ test_130c() {
 run_test 130c "FIEMAP (2-stripe file with hole)"
 
 test_130d() {
-       [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs" && return
+       [[ $OSTCOUNT -lt 3 ]] && skip_env "needs >= 3 OSTs"
 
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
-               return
+       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
 
        trap cleanup_130 EXIT RETURN
 
@@ -9928,7 +10480,7 @@ test_130d() {
        $SETSTRIPE -S 65536 -c $OSTCOUNT $fm_file ||
                        error "setstripe on $fm_file"
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
-               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
+               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
 
        local actual_stripe_count=$($GETSTRIPE -c $fm_file)
        dd if=/dev/zero of=$fm_file bs=1M count=$actual_stripe_count ||
@@ -9977,17 +10529,17 @@ test_130d() {
 run_test 130d "FIEMAP (N-stripe file)"
 
 test_130e() {
-       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs" && return
+       [[ $OSTCOUNT -lt 2 ]] && skip_env "needs >= 2 OSTs"
 
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" && return
+       [ -n "$filefrag_op" ] && skip_env "filefrag does not support FIEMAP"
 
        trap cleanup_130 EXIT RETURN
 
        local fm_file=$DIR/$tfile
        $SETSTRIPE -S 131072 -c 2 $fm_file || error "setstripe on $fm_file"
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $fm_file) + 1)))" = "zfs" ] &&
-               skip "ORI-366/LU-1941: FIEMAP unimplemented on ZFS" && return
+               skip_env "ORI-366/LU-1941: FIEMAP unimplemented on ZFS"
 
        NUM_BLKS=512
        EXPECTED_LEN=$(( (NUM_BLKS / 2) * 64 ))
@@ -10041,8 +10593,7 @@ run_test 130e "FIEMAP (test continuation FIEMAP calls)"
 
 test_130f() {
        filefrag_op=$(filefrag -e 2>&1 | grep "invalid option")
-       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP" &&
-               return
+       [ -n "$filefrag_op" ] && skip "filefrag does not support FIEMAP"
 
        local fm_file=$DIR/$tfile
        $MULTIOP $fm_file oO_RDWR:O_CREAT:O_LOV_DELAY_CREATE:T33554432c ||
@@ -10134,13 +10685,14 @@ check_stats() {
 }
 
 test_133a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
-               { skip "MDS doesn't support rename stats"; return; }
+               skip_env "MDS doesn't support rename stats"
+
        local testdir=$DIR/${tdir}/stats_testdir
+
        mkdir -p $DIR/${tdir}
 
        # clear stats.
@@ -10181,10 +10733,12 @@ test_133a() {
 run_test 133a "Verifying MDT stats ========================================"
 
 test_133b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local testdir=$DIR/${tdir}/stats_testdir
+
        mkdir -p ${testdir} || error "mkdir failed"
        touch ${testdir}/${tfile} || error "touch failed"
        cancel_lru_locks mdc
@@ -10202,6 +10756,9 @@ test_133b() {
                ls -l ${testdir}/${tfile} > /dev/null|| error "ls failed"
                check_stats $SINGLEMDS "getattr" 1
        fi
+       # Sleep to avoid a cached response.
+       #define OBD_STATFS_CACHE_SECONDS 1
+       sleep 2
        $LFS df || error "lfs failed"
        check_stats $SINGLEMDS "statfs" 1
 
@@ -10210,10 +10767,12 @@ test_133b() {
 run_test 133b "Verifying extra MDT stats =================================="
 
 test_133c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local testdir=$DIR/$tdir/stats_testdir
+
        test_mkdir -p $testdir
 
        # verify obdfilter stats.
@@ -10287,28 +10846,30 @@ size_in_KMGT() {
 }
 
 get_rename_size() {
-    local size=$1
-    local context=${2:-.}
-    local sample=$(do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats |
+       local size=$1
+       local context=${2:-.}
+       local sample=$(do_facet $SINGLEMDS $LCTL \
+               get_param mdt.$FSNAME-MDT0000.rename_stats |
                grep -A1 $context |
                awk '/ '${size}'/ {print $4}' | sed -e "s/,//g")
-    echo $sample
+       echo $sample
 }
 
 test_133d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        do_facet $SINGLEMDS $LCTL list_param mdt.*.rename_stats ||
-       { skip "MDS doesn't support rename stats"; return; }
+               skip_env "MDS doesn't support rename stats"
 
        local testdir1=$DIR/${tdir}/stats_testdir1
        local testdir2=$DIR/${tdir}/stats_testdir2
+       mkdir -p $DIR/${tdir}
 
        do_facet $SINGLEMDS $LCTL set_param mdt.*.rename_stats=clear
 
-       mkdir -p ${testdir1} || error "mkdir failed"
-       mkdir -p ${testdir2} || error "mkdir failed"
+       lfs mkdir -i 0 -c 1 ${testdir1} || error "mkdir failed"
+       lfs mkdir -i 0 -c 1 ${testdir2} || error "mkdir failed"
 
        createmany -o $testdir1/test 512 || error "createmany failed"
 
@@ -10329,7 +10890,9 @@ test_133d() {
        echo "source rename dir size: ${testdir1_size}"
        echo "target rename dir size: ${testdir2_size}"
 
-       local cmd="do_facet $SINGLEMDS $LCTL get_param mdt.*.rename_stats"
+       local cmd="do_facet $SINGLEMDS $LCTL "
+       cmd+="get_param mdt.$FSNAME-MDT0000.rename_stats"
+
        eval $cmd || error "$cmd failed"
        local samedir=$($cmd | grep 'same_dir')
        local same_sample=$(get_rename_size $testdir1_size)
@@ -10372,9 +10935,10 @@ test_133d() {
 run_test 133d "Verifying rename_stats ========================================"
 
 test_133e() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local testdir=$DIR/${tdir}/stats_testdir
        local ctr f0 f1 bs=32768 count=42 sum
 
@@ -10419,9 +10983,19 @@ run_test 133e "Verifying OST {read,write}_bytes nid stats ================="
 
 proc_regexp="/{proc,sys}/{fs,sys,kernel/debug}/{lustre,lnet}/"
 
+# Some versions of find (4.5.11, 4.5.14) included in CentOS 7.3-7.5 do
+# not honor the -ignore_readdir_race option correctly. So we call
+# error_ignore() rather than error() in these cases. See LU-11152.
+error_133() {
+       if (find --version; do_facet mds1 find --version) |
+               grep -q '\b4\.5\.1[1-4]\b'; then
+               error_ignore LU-11152 "$@"
+       else
+               error "$@"
+       fi
+}
+
 test_133f() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
        # First without trusting modes.
        local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
        echo "proc_dirs='$proc_dirs'"
@@ -10431,10 +11005,27 @@ test_133f() {
        # Second verifying readability.
        $LCTL get_param -R '*' &> /dev/null || error "proc file read failed"
 
+       # Verifing writability with badarea_io.
+       find $proc_dirs \
+               -ignore_readdir_race \
+               -type f \
+               -not -name force_lbug \
+               -not -name changelog_mask \
+               -exec badarea_io '{}' \; ||
+                       error_133 "find $proc_dirs failed"
+}
+run_test 133f "Check reads/writes of client lustre proc files with bad area io"
+
+test_133g() {
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
        # eventually, this can also be replaced with "lctl get_param -R",
        # but not until that option is always available on the server
        local facet
        for facet in mds1 ost1; do
+               [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
+                       skip_noexit "Too old lustre on $facet"
                local facet_proc_dirs=$(do_facet $facet \
                                        \\\ls -d $proc_regexp 2>/dev/null)
                echo "${facet}_proc_dirs='$facet_proc_dirs'"
@@ -10448,40 +11039,14 @@ test_133f() {
                        -type f \
                        -exec cat '{}' \\\; &> /dev/null ||
                                error "proc file read failed"
-       done
-}
-run_test 133f "Check for LBUGs/Oopses/unreadable files in /proc"
 
-test_133g() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       # Second verifying writability.
-       local proc_dirs=$(eval \ls -d $proc_regexp 2>/dev/null)
-       echo "proc_dirs='$proc_dirs'"
-       [ -n "$proc_dirs" ] || error "no proc_dirs on $HOSTNAME"
-       find $proc_dirs \
-               -ignore_readdir_race \
-               -type f \
-               -not -name force_lbug \
-               -not -name changelog_mask \
-               -exec badarea_io '{}' \; ||
-               error "find $proc_dirs failed"
-
-       local facet
-       for facet in mds1 ost1; do
-               [ $(lustre_version_code $facet) -le $(version_code 2.5.54) ] &&
-                       skip "Too old lustre on $facet" && continue
-               local facet_proc_dirs=$(do_facet $facet \
-                                       \\\ls -d $proc_regexp 2> /dev/null)
-               echo "${facet}_proc_dirs='$facet_proc_dirs'"
-               [ -z "$facet_proc_dirs" ] && error "no proc_dirs on $facet"
                do_facet $facet find $facet_proc_dirs \
                        -ignore_readdir_race \
                        -type f \
                        -not -name force_lbug \
                        -not -name changelog_mask \
                        -exec badarea_io '{}' \\\; ||
-                               error "$facet find $facet_proc_dirs failed"
+                               error_133 "$facet find $facet_proc_dirs failed"
        done
 
        # remount the FS in case writes/reads /proc break the FS
@@ -10489,15 +11054,16 @@ test_133g() {
        setup || error "failed to setup"
        true
 }
-run_test 133g "Check for Oopses on bad io area writes/reads in /proc"
+run_test 133g "Check reads/writes of server lustre proc files with bad area io"
 
 test_133h() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.9.54) ]] &&
-               skip "Need MDS version at least 2.9.54" && return
+               skip "Need MDS version at least 2.9.54"
 
        local facet
+
        for facet in client mds1 ost1; do
                local facet_proc_dirs=$(do_facet $facet \
                                        \\\ls -d $proc_regexp 2> /dev/null)
@@ -10520,9 +11086,9 @@ test_133h() {
 run_test 133h "Proc files should end with newlines"
 
 test_134a() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
-               skip "Need MDS version at least 2.7.54" && return
+               skip "Need MDS version at least 2.7.54"
 
        mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
        cancel_lru_locks mdc
@@ -10556,9 +11122,9 @@ test_134a() {
 run_test 134a "Server reclaims locks when reaching lock_reclaim_threshold"
 
 test_134b() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.54) ]] &&
-               skip "Need MDS version at least 2.7.54" && return
+               skip "Need MDS version at least 2.7.54"
 
        mkdir -p $DIR/$tdir || error "failed to create $DIR/$tdir"
        cancel_lru_locks mdc
@@ -10597,7 +11163,8 @@ test_134b() {
 run_test 134b "Server rejects lock request when reaching lock_limit_mb"
 
 test_140() { #bug-17379
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir $DIR/$tdir
        cd $DIR/$tdir || error "Changing to $DIR/$tdir"
        cp $(which stat) . || error "Copying stat to $DIR/$tdir"
@@ -10636,7 +11203,8 @@ test_140() { #bug-17379
 run_test 140 "Check reasonable stack depth (shouldn't LBUG) ===="
 
 test_150() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local TF="$TMP/$tfile"
 
        dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
@@ -10724,30 +11292,27 @@ function set_cache() {
 }
 
 test_151() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        local CPAGES=3
        local list=$(comma_list $(osts_nodes))
 
        # check whether obdfilter is cache capable at all
        if ! get_osd_param $list '' read_cache_enable >/dev/null; then
-               echo "not cache-capable obdfilter"
-               return 0
+               skip "not cache-capable obdfilter"
        fi
 
        # check cache is enabled on all obdfilters
        if get_osd_param $list '' read_cache_enable | grep 0; then
-               echo "oss cache is disabled"
-               return 0
+               skip "oss cache is disabled"
        fi
 
        set_osd_param $list '' writethrough_cache_enable 1
 
        # check write cache is enabled on all obdfilters
        if get_osd_param $list '' writethrough_cache_enable | grep 0; then
-               echo "oss write cache is NOT enabled"
-               return 0
+               skip "oss write cache is NOT enabled"
        fi
 
        roc_hit_init
@@ -10790,10 +11355,11 @@ test_151() {
 run_test 151 "test cache on oss and controls ==============================="
 
 test_152() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        local TF="$TMP/$tfile"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
-        # simulate ENOMEM during write
+       local TF="$TMP/$tfile"
+
+       # simulate ENOMEM during write
 #define OBD_FAIL_OST_NOMEM      0x226
         lctl set_param fail_loc=0x80000226
         dd if=/dev/urandom of=$TF bs=6096 count=1 || error "dd failed"
@@ -10842,11 +11408,9 @@ dot_lustre_fid_permission_check() {
        rm -f $test_dir/$tfile.1
        echo "truncate fid $fid"
        $TRUNCATE $ffid 777 || error "truncate $ffid failed."
-       if [ $MDSCOUNT -lt 2 ]; then #FIXME when cross-MDT hard link is working
-               echo "link fid $fid"
-               ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
-       fi
-       if [ -n $(lctl get_param -n mdc.*-mdc-*.connect_flags | grep acl) ]; then
+       echo "link fid $fid"
+       ln -f $ffid $test_dir/tfile.lnk || error "link $ffid failed."
+       if [[ $($LCTL get_param -n mdc.*-mdc-*.connect_flags) =~ acl ]]; then
                echo "setfacl fid $fid"
                setfacl -R -m u:bin:rwx $ffid || error "setfacl $ffid failed."
                echo "getfacl fid $fid"
@@ -10946,7 +11510,7 @@ dot_lustre_fid_permission_check() {
 
 test_154A() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
-               skip "Need MDS version at least 2.4.1" && return
+               skip "Need MDS version at least 2.4.1"
 
        local tf=$DIR/$tfile
        touch $tf
@@ -10964,7 +11528,7 @@ run_test 154A "lfs path2fid and fid2path basic checks"
 
 test_154B() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
-               skip "Need MDS version at least 2.4.1" && return
+               skip "Need MDS version at least 2.4.1"
 
        mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
        touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
@@ -10986,11 +11550,11 @@ test_154B() {
 run_test 154B "verify the ll_decode_linkea tool"
 
 test_154a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
-               { skip "Need MDS version at least 2.2.51"; return 0; }
-       [ -z "$(which setfacl)" ] && skip "must have setfacl tool" && return
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+               skip "Need MDS version at least 2.2.51"
+       [ -z "$(which setfacl)" ] && skip_env "must have setfacl tool"
 
        cp /etc/hosts $DIR/$tfile
 
@@ -11016,12 +11580,11 @@ test_154a() {
 run_test 154a "Open-by-FID"
 
 test_154b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
-               { skip "Need MDS version at least 2.2.51"; return 0; }
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
-
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.2.51"
 
        local remote_dir=$DIR/$tdir/remote_dir
        local MDTIDX=1
@@ -11045,7 +11608,7 @@ run_test 154b "Open-by-FID for remote directory"
 
 test_154c() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
-               skip "Need MDS version at least 2.4.1" && return
+               skip "Need MDS version at least 2.4.1"
 
        touch $DIR/$tfile.1 $DIR/$tfile.2 $DIR/$tfile.3
        local FID1=$($LFS path2fid $DIR/$tfile.1)
@@ -11072,9 +11635,9 @@ test_154c() {
 run_test 154c "lfs path2fid and fid2path multiple arguments"
 
 test_154d() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.53) ]] &&
-               skip "Need MDS version at least 2.5.53" && return
+               skip "Need MDS version at least 2.5.53"
 
        if remote_mds; then
                nid=$($LCTL list_nids | sed  "s/\./\\\./g")
@@ -11108,7 +11671,7 @@ run_test 154d "Verify open file fid"
 test_154e()
 {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.50) ]] &&
-               skip "Need MDS version at least 2.6.50" && return
+               skip "Need MDS version at least 2.6.50"
 
        if ls -a $MOUNT | grep -q '^\.lustre$'; then
                error ".lustre returned by readdir"
@@ -11117,7 +11680,8 @@ test_154e()
 run_test 154e ".lustre is not returned by readdir"
 
 test_154f() {
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
+
        # create parent directory on a single MDT to avoid cross-MDT hardlinks
        test_mkdir -p -c1 $DIR/$tdir/d
        # test dirs inherit from its stripe
@@ -11196,10 +11760,10 @@ run_test 154f "get parent fids by reading link ea"
 
 test_154g()
 {
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.92) && \
           $(lustre_version_code client) -gt $(version_code 2.6.99) ]] ||
-               { skip "Need MDS version at least 2.6.92"; return 0; }
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+               skip "Need MDS version at least 2.6.92"
 
        mkdir -p $DIR/$tdir
        llapi_fid_test -d $DIR/$tdir
@@ -11233,33 +11797,33 @@ test_155_small_load() {
 }
 
 test_155_big_load() {
-    remote_ost_nodsh && skip "remote OST with nodsh" && return
-    local temp=$TMP/$tfile
-    local file=$DIR/$tfile
+       remote_ost_nodsh && skip "remote OST with nodsh"
+
+       local temp=$TMP/$tfile
+       local file=$DIR/$tfile
 
-    free_min_max
-    local cache_size=$(do_facet ost$((MAXI+1)) \
-        "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
-    local large_file_size=$((cache_size * 2))
+       free_min_max
+       local cache_size=$(do_facet ost$((MAXI+1)) \
+               "awk '/cache/ {sum+=\\\$4} END {print sum}' /proc/cpuinfo")
+       local large_file_size=$((cache_size * 2))
 
-    echo "OSS cache size: $cache_size KB"
-    echo "Large file size: $large_file_size KB"
+       echo "OSS cache size: $cache_size KB"
+       echo "Large file size: $large_file_size KB"
 
-    [ $MAXV -le $large_file_size ] && \
-        skip_env "max available OST size needs > $large_file_size KB" && \
-        return 0
+       [ $MAXV -le $large_file_size ] &&
+               skip_env "max available OST size needs > $large_file_size KB"
 
-    $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
+       $SETSTRIPE $file -c 1 -i $MAXI || error "$SETSTRIPE $file failed"
 
-    dd if=/dev/urandom of=$temp bs=$large_file_size count=1k || \
-        error "dd of=$temp bs=$large_file_size count=1k failed"
-    cp $temp $file
-    ls -lh $temp $file
-    cancel_lru_locks osc
-    cmp $temp $file || error "$temp $file differ"
+       dd if=/dev/urandom of=$temp bs=$large_file_size count=1k ||
+               error "dd of=$temp bs=$large_file_size count=1k failed"
+       cp $temp $file
+       ls -lh $temp $file
+       cancel_lru_locks osc
+       cmp $temp $file || error "$temp $file differ"
 
-    rm -f $temp $file
-    true
+       rm -f $temp $file
+       true
 }
 
 save_writethrough() {
@@ -11270,8 +11834,10 @@ save_writethrough() {
 }
 
 test_155a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read on
@@ -11283,8 +11849,10 @@ test_155a() {
 run_test 155a "Verify small file correctness: read cache:on write_cache:on"
 
 test_155b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read on
@@ -11296,8 +11864,10 @@ test_155b() {
 run_test 155b "Verify small file correctness: read cache:on write_cache:off"
 
 test_155c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read off
@@ -11309,8 +11879,10 @@ test_155c() {
 run_test 155c "Verify small file correctness: read cache:off write_cache:on"
 
 test_155d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read off
@@ -11322,8 +11894,10 @@ test_155d() {
 run_test 155d "Verify small file correctness: read cache:off write_cache:off"
 
 test_155e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read on
@@ -11335,8 +11909,10 @@ test_155e() {
 run_test 155e "Verify big file correctness: read cache:on write_cache:on"
 
 test_155f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read on
@@ -11348,8 +11924,10 @@ test_155f() {
 run_test 155f "Verify big file correctness: read cache:on write_cache:off"
 
 test_155g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read off
@@ -11361,8 +11939,10 @@ test_155g() {
 run_test 155g "Verify big file correctness: read cache:off write_cache:on"
 
 test_155h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
+
        save_writethrough $p
 
        set_cache read off
@@ -11374,19 +11954,18 @@ test_155h() {
 run_test 155h "Verify big file correctness: read cache:off write_cache:off"
 
 test_156() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ "$(facet_fstype ost1)" = "zfs" -a \
+          $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
+               skip "LU-1956/LU-2261: stats not implemented on OSD ZFS"
+
        local CPAGES=3
        local BEFORE
        local AFTER
        local file="$DIR/$tfile"
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
 
-       [ "$(facet_fstype ost1)" = "zfs" -a \
-          $(lustre_version_code ost1 -lt $(version_code 2.6.93)) ] &&
-               skip "LU-1956/LU-2261: stats not implemented on OSD ZFS" &&
-               return
-
        save_writethrough $p
        roc_hit_init
 
@@ -11520,177 +12099,154 @@ test_156() {
 }
 run_test 156 "Verification of tunables"
 
-#Changelogs
-cleanup_changelog () {
-       trap 0
-       echo "Deregistering changelog client $CL_USER"
-       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
-}
-
-err17935 () {
-       if [[ $MDSCOUNT -gt 1 ]]; then
-               error_ignore bz17935 $*
-       else
-               error $*
-       fi
-}
-
-changelog_chmask()
-{
-       local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
-
-       MASK=$(do_facet $SINGLEMDS $LCTL get_param $CL_MASK_PARAM| grep -c "$1")
-
-       if [ $MASK -eq 1 ]; then
-               do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="-$1"
-       else
-               do_facet $SINGLEMDS $LCTL set_param $CL_MASK_PARAM="+$1"
-       fi
-}
-
-changelog_extract_field() {
-       local mdt=$1
-       local cltype=$2
-       local file=$3
-       local identifier=$4
-
-       $LFS changelog $mdt | gawk "/$cltype.*$file$/ {
-               print gensub(/^.* "$identifier'(\[[^\]]*\]).*$/,"\\1",1)}' |
-               tail -1
-}
-
 test_160a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
-               { skip "Need MDS version at least 2.2.0"; return; }
+               skip "Need MDS version at least 2.2.0"
 
-       local CL_USERS="mdd.$MDT0.changelog_users"
-       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
-       trap cleanup_changelog EXIT
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
+       changelog_register || error "changelog_register failed"
+       local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
+       changelog_users $SINGLEMDS | grep -q $cl_user ||
+               error "User $cl_user not found in changelog_users"
 
        # change something
        test_mkdir -p $DIR/$tdir/pics/2008/zachy
-       touch $DIR/$tdir/pics/2008/zachy/timestamp
-       cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg
+       changelog_clear 0 || error "changelog_clear failed"
+       touch $DIR/$tdir/pics/2008/zachy/$tfile                 # open 1
+       cp /etc/hosts $DIR/$tdir/pics/2008/zachy/pic1.jpg       # open 2
        mv $DIR/$tdir/pics/2008/zachy $DIR/$tdir/pics/zach
        ln $DIR/$tdir/pics/zach/pic1.jpg $DIR/$tdir/pics/2008/portland.jpg
        ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
        rm $DIR/$tdir/pics/desktop.jpg
 
-       $LFS changelog $MDT0 | tail -5
+       changelog_dump | tail -10
 
        echo "verifying changelog mask"
-       changelog_chmask "MKDIR"
-       changelog_chmask "CLOSE"
+       changelog_chmask "-MKDIR"
+       changelog_chmask "-CLOSE"
 
-       test_mkdir -p $DIR/$tdir/pics/zach/sofia
-       echo "zzzzzz" > $DIR/$tdir/pics/zach/file
+       test_mkdir -p $DIR/$tdir/pics/zach/sofia                # not logged
+       echo "zzzzzz" > $DIR/$tdir/pics/zach/file               # not logged
 
-       changelog_chmask "MKDIR"
-       changelog_chmask "CLOSE"
+       changelog_chmask "+MKDIR"
+       changelog_chmask "+CLOSE"
 
-       test_mkdir -p $DIR/$tdir/pics/2008/sofia
-       echo "zzzzzz" > $DIR/$tdir/pics/zach/file
+       test_mkdir -p $DIR/$tdir/pics/2008/sofia                # mkdir 1
+       echo "zzzzzz" > $DIR/$tdir/pics/zach/file               # open 3
 
-       $LFS changelog $MDT0
-       MKDIRS=$($LFS changelog $MDT0 | tail -5 | grep -c "MKDIR")
-       CLOSES=$($LFS changelog $MDT0 | tail -5 | grep -c "CLOSE")
-       [ $MKDIRS -eq 1 ] || err17935 "MKDIR changelog mask count $DIRS != 1"
-       [ $CLOSES -eq 1 ] || err17935 "CLOSE changelog mask count $DIRS != 1"
+       changelog_dump | tail -10
+       MKDIRS=$(changelog_dump | grep -c "MKDIR")
+       CLOSES=$(changelog_dump | grep -c "CLOSE")
+       [ $MKDIRS -eq 1 ] || error "MKDIR changelog mask count $MKDIRS != 1"
+       [ $CLOSES -eq 3 ] || error "CLOSE changelog mask count $CLOSES != 3"
 
        # verify contents
        echo "verifying target fid"
-       fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "t=")
-       fidf=$($LFS path2fid $DIR/$tdir/pics/zach/timestamp)
+       local fidc=$(changelog_extract_field "CREAT" "$tfile" "t=")
+       local fidf=$($LFS path2fid $DIR/$tdir/pics/zach/$tfile)
        [ "$fidc" == "$fidf" ] ||
-               err17935 "fid in changelog $fidc != file fid $fidf"
+               error "changelog '$tfile' fid $fidc != file fid $fidf"
        echo "verifying parent fid"
-       fidc=$(changelog_extract_field $MDT0 "CREAT" "timestamp" "p=")
-       fidf=$($LFS path2fid $DIR/$tdir/pics/zach)
-       [ "$fidc" == "$fidf" ] ||
-               err17935 "pfid in changelog $fidc != dir fid $fidf"
-
-       USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 5))
-       USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       echo "verifying user clear: $(( $USER_REC1 + 5 )) == $USER_REC2"
-       [ $USER_REC2 == $(($USER_REC1 + 5)) ] ||
-               err17935 "user index expected $(($USER_REC1 + 5)) is $USER_REC2"
-
-       MIN_REC=$($GET_CL_USERS |
-               awk 'min == "" || $2 < min {min = $2}; END {print min}')
-       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
-       echo "verifying min purge: $(( $MIN_REC + 1 )) == $FIRST_REC"
-       [ $FIRST_REC == $(($MIN_REC + 1)) ] ||
-               err17935 "first index should be $(($MIN_REC + 1)) is $FIRST_REC"
+       # The FID returned from the Changelog may be the directory shard on
+       # a different MDT, and not the FID returned by path2fid on the parent.
+       # Instead of comparing FIDs, verify that fid2path(fidp) is correct,
+       # since this is what will matter when recreating this file in the tree.
+       local fidp=$(changelog_extract_field "CREAT" "$tfile" "p=")
+       local pathp=$($LFS fid2path $MOUNT "$fidp")
+       [ "${pathp%/}" == "$DIR/$tdir/pics/zach" ] ||
+               error "changelog fid2path($fidc) $pathp != $DIR/$tdir/pics/zach"
+
+       echo "getting records for $cl_user"
+       changelog_users $SINGLEMDS
+       local user_rec1=$(changelog_user_rec $SINGLEMDS $cl_user)
+       local nclr=3
+       __changelog_clear $SINGLEMDS $cl_user +$nclr ||
+               error "changelog_clear failed"
+       local user_rec2=$(changelog_user_rec $SINGLEMDS $cl_user)
+       echo "verifying user clear: $user_rec1 + $nclr == $user_rec2"
+       [ $user_rec2 == $((user_rec1 + nclr)) ] ||
+               error "user index expect $user_rec1 + $nclr != $user_rec2"
+
+       local min0_rec=$(changelog_users $SINGLEMDS |
+               awk 'min == "" || $2 < min { min = $2 }; END { print min }')
+       local first_rec=$($LFS changelog $(facet_svc $SINGLEMDS) |
+                         awk '{ print $1; exit; }')
+
+       changelog_dump | tail -n 5
+       echo "verifying user min purge: $min0_rec + 1 == $first_rec"
+       [ $first_rec == $((min0_rec + 1)) ] ||
+               error "first index should be $min0_rec + 1 not $first_rec"
 
        # LU-3446 changelog index reset on MDT restart
-       local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
-       CUR_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
-       stop $SINGLEMDS || error "Fail to stop MDT."
-       start $SINGLEMDS $MDT_DEV $MDS_MOUNT_OPTS || error "Fail to start MDT."
-       CUR_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
-       echo "verifying index survives MDT restart: $CUR_REC1 == $CUR_REC2"
-       [ $CUR_REC1 == $CUR_REC2 ] ||
-               err17935 "current index should be $CUR_REC1 is $CUR_REC2"
-
-       echo "verifying user deregister"
-       cleanup_changelog
-       $GET_CL_USERS | grep -q $CL_USER &&
-               error "User $CL_USER still in changelog_users"
-
-       USERS=$(( $($GET_CL_USERS | wc -l) - 2 ))
-       if [ $CL_USER -eq 0 ]; then
-               LAST_REC1=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
+       local cur_rec1=$(changelog_users $SINGLEMDS |
+                        awk '/^current.index:/ { print $NF }')
+       changelog_clear 0 ||
+               error "clear all changelog records for $cl_user failed"
+       stop $SINGLEMDS || error "Fail to stop $SINGLEMDS"
+       start $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) $MDS_MOUNT_OPTS ||
+               error "Fail to start $SINGLEMDS"
+       local cur_rec2=$(changelog_users $SINGLEMDS |
+                        awk '/^current.index:/ { print $NF }')
+       echo "verifying index survives MDT restart: $cur_rec1 == $cur_rec2"
+       [ $cur_rec1 == $cur_rec2 ] ||
+               error "current index should be $cur_rec1 not $cur_rec2"
+
+       echo "verifying users from this test are deregistered"
+       changelog_deregister || error "changelog_deregister failed"
+       changelog_users $SINGLEMDS | grep -q $cl_user &&
+               error "User '$cl_user' still in changelog_users"
+
+       # lctl get_param -n mdd.*.changelog_users
+       # current index: 144
+       # ID    index (idle seconds)
+       # cl3   144 (2)
+       if ! changelog_users $SINGLEMDS | grep "^cl"; then
+               # this is the normal case where all users were deregistered
+               # make sure no new records are added when no users are present
+               local last_rec1=$(changelog_users $SINGLEMDS |
+                                 awk '/^current.index:/ { print $NF }')
                touch $DIR/$tdir/chloe
-               LAST_REC2=$($GET_CL_USERS | head -n1 | cut -f3 -d' ')
-               echo "verify changelogs are off: $LAST_REC1 == $LAST_REC2"
-               [ $LAST_REC1 == $LAST_REC2 ] || error "changelogs not off"
+               local last_rec2=$(changelog_users $SINGLEMDS |
+                                 awk '/^current.index:/ { print $NF }')
+               echo "verify changelogs are off: $last_rec1 == $last_rec2"
+               [ $last_rec1 == $last_rec2 ] || error "changelogs not off"
        else
-               echo "$CL_USER other changelog users; can't verify off"
+               # any changelog users must be leftovers from a previous test
+               changelog_users $SINGLEMDS
+               echo "other changelog users; can't verify off"
        fi
 }
 run_test 160a "changelog sanity"
 
 test_160b() { # LU-3587
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.0) ] ||
-               { skip "Need MDS version at least 2.2.0"; return; }
+               skip "Need MDS version at least 2.2.0"
 
-       local CL_USERS="mdd.$MDT0.changelog_users"
-       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
-       trap cleanup_changelog EXIT
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
+       changelog_register || error "changelog_register failed"
+       local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
+       changelog_users $SINGLEMDS | grep -q $cl_user ||
+               error "User '$cl_user' not found in changelog_users"
 
-       local LONGNAME1=$(str_repeat a 255)
-       local LONGNAME2=$(str_repeat b 255)
+       local longname1=$(str_repeat a 255)
+       local longname2=$(str_repeat b 255)
 
        cd $DIR
        echo "creating very long named file"
-       touch $LONGNAME1 || error "create of $LONGNAME1 failed"
-       echo "moving very long named file"
-       mv $LONGNAME1 $LONGNAME2
+       touch $longname1 || error "create of '$longname1' failed"
+       echo "renaming very long named file"
+       mv $longname1 $longname2
 
-       $LFS changelog $MDT0 | grep RENME
-       rm -f $LONGNAME2
-       cleanup_changelog
+       changelog_dump | grep RENME | tail -n 5
+       rm -f $longname2
 }
 run_test 160b "Verify that very long rename doesn't crash in changelog"
 
 test_160c() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        local rc=0
        local server_version=$(lustre_version_code $SINGLEMDS)
@@ -11698,84 +12254,63 @@ test_160c() {
        [[ $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
+               skip "Need MDS version at least 2.5.58 or 2.5.2+"
 
        # Registration step
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       trap cleanup_changelog EXIT
+       changelog_register || error "changelog_register failed"
 
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
        $MCREATE $DIR/$tdir/foo_160c
-       changelog_chmask "TRUNC"
+       changelog_chmask "-TRUNC"
        $TRUNCATE $DIR/$tdir/foo_160c 200
-       changelog_chmask "TRUNC"
+       changelog_chmask "+TRUNC"
        $TRUNCATE $DIR/$tdir/foo_160c 199
-       $LFS changelog $MDT0
-       TRUNCS=$($LFS changelog $MDT0 | tail -5 | grep -c "TRUNC")
-       [ $TRUNCS -eq 1 ] || err17935 "TRUNC changelog mask count $TRUNCS != 1"
-       $LFS changelog_clear $MDT0 $CL_USER 0
-
-       # Deregistration step
-       cleanup_changelog
+       changelog_dump | tail -n 5
+       local truncs=$(changelog_dump | tail -n 5 | grep -c TRUNC)
+       [ $truncs -eq 1 ] || error "TRUNC changelog mask count $truncs != 1"
 }
 run_test 160c "verify that changelog log catch the truncate event"
 
 test_160d() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-
-       local server_version=$(lustre_version_code mds1)
-       local CL_MASK_PARAM="mdd.$MDT0.changelog_mask"
-
-       [[ $server_version -ge $(version_code 2.7.60) ]] ||
-               { skip "Need MDS version at least 2.7.60+"; return; }
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]] ||
+               skip "Need MDS version at least 2.7.60"
 
        # Registration step
-       CL_USER=$(do_facet mds1 $LCTL --device $MDT0 \
-               changelog_register -n)
+       changelog_register || error "changelog_register failed"
 
-       trap cleanup_changelog EXIT
        mkdir -p $DIR/$tdir/migrate_dir
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_clear 0 || error "changelog_clear failed"
 
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir || error "migrate fails"
-       $LFS changelog $MDT0
-       MIGRATES=$($LFS changelog $MDT0 | tail -5 | grep -c "MIGRT")
-       $LFS changelog_clear $MDT0 $CL_USER 0
-       [ $MIGRATES -eq 1 ] ||
-               error "MIGRATE changelog mask count $MIGRATES != 1"
-
-       # Deregistration step
-       cleanup_changelog
+       changelog_dump | tail -n 5
+       local migrates=$(changelog_dump | grep -c "MIGRT")
+       [ $migrates -eq 1 ] || error "MIGRATE changelog count $migrates != 1"
 }
 run_test 160d "verify that changelog log catch the migrate event"
 
 test_160e() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        # Create a user
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
-       trap cleanup_changelog EXIT
+       changelog_register || error "changelog_register failed"
 
        # Delete a future user (expect fail)
-       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister cl77
+       local MDT0=$(facet_svc $SINGLEMDS)
+       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister "cl77"
        local rc=$?
 
        if [ $rc -eq 0 ]; then
                error "Deleted non-existant user cl77"
        elif [ $rc -ne 2 ]; then
-               error "changelog_deregister failed with $rc, " \
-                       "expected 2 (ENOENT)"
+               error "changelog_deregister failed with $rc, expect 2 (ENOENT)"
        fi
 
        # Clear to a bad index (1 billion should be safe)
-       $LFS changelog_clear $MDT0 $CL_USER 1000000000
+       $LFS changelog_clear $MDT0 "${CL_USERS[$SINGLEMDS]%% *}" 1000000000
        rc=$?
 
        if [ $rc -eq 0 ]; then
@@ -11784,190 +12319,459 @@ test_160e() {
                error "changelog_clear failed with $rc, expected 22 (EINVAL)"
        fi
 }
-run_test 160e "changelog negative testing"
-
-cleanup_160f() {
-       trap 0
-       do_facet $SINGLEMDS $LCTL set_param fail_loc=0 fail_val=0
-       echo "Deregistering changelog client $CL_USER"
-       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER
-       echo "Deregistering changelog client $CL_USER2"
-       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $CL_USER2
-       restore_lustre_params < $save_params
-       rm -f $save_params
-}
+run_test 160e "changelog negative testing (should return errors)"
 
 test_160f() {
-       # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
-       # should be set by default
-
-       local CL_USERS="mdd.$MDT0.changelog_users"
-       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
-       local save_params="$TMP/sanity-$TESTNAME.parameters"
-
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_max_idle_time" > $save_params
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
+               { skip "Need MDS version at least 2.10.56"; return 0; }
 
-       trap cleanup_160f EXIT
+       local mdts=$(comma_list $(mdts_nodes))
 
        # Create a user
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
-       CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER2"
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
-       $GET_CL_USERS | grep -q $CL_USER2 ||
-               error "User $CL_USER2 not found in changelog_users"
-
-       # generate some changelogs to accumulate
-       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
-       touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
-       touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
-       rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+       changelog_register || error "first changelog_register failed"
+       changelog_register || error "second changelog_register failed"
+       local cl_users
+       declare -A cl_user1
+       declare -A cl_user2
+       local user_rec1
+       local user_rec2
+       local i
+
+       # generate some changelog records to accumulate on each MDT
+       test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
+       createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/$tfile failed"
 
        # check changelogs have been generated
-       nbcl=$($LFS changelog $MDT0 | wc -l)
+       local nbcl=$(changelog_dump | wc -l)
        [[ $nbcl -eq 0 ]] && error "no changelogs found"
 
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_max_idle_time=10
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_min_gc_interval=2
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_min_free_cat_entries=3
+       for param in "changelog_max_idle_time=10" \
+                    "changelog_gc=1" \
+                    "changelog_min_gc_interval=2" \
+                    "changelog_min_free_cat_entries=3"; do
+               local MDT0=$(facet_svc $SINGLEMDS)
+               local var="${param%=*}"
+               local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
+
+               stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
+               do_nodes $mdts $LCTL set_param mdd.*.$param
+       done
+
+       # force cl_user2 to be idle (1st part)
+       sleep 9
 
        # simulate changelog catalog almost full
-#define OBD_FAIL_CAT_FREE_RECORDS                  0x1313
-       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
-       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+       #define OBD_FAIL_CAT_FREE_RECORDS       0x1313
+       do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
+
+       for i in $(seq $MDSCOUNT); do
+               cl_users=(${CL_USERS[mds$i]})
+               cl_user1[mds$i]="${cl_users[0]}"
+               cl_user2[mds$i]="${cl_users[1]}"
+
+               [ -n "${cl_user1[mds$i]}" ] ||
+                       error "mds$i: no user registered"
+               [ -n "${cl_user2[mds$i]}" ] ||
+                       error "mds$i: only ${cl_user2[mds$i]} is registered"
+
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               __changelog_clear mds$i ${cl_user1[mds$i]} +2
+               user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
+                    "$user_rec1 + 2 == $user_rec2"
+               [ $((user_rec1 + 2)) == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user1[mds$i]} index expected " \
+                             "$user_rec1 + 2, but is $user_rec2"
+               user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user2[mds$i]} not registered"
+               [ $user_rec1 == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user2[mds$i]} index expected " \
+                             "$user_rec1, but is $user_rec2"
+       done
 
-       sleep 6
-       USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 2))
-       USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       echo "verifying user clear: $(( $USER_REC1 + 2 )) == $USER_REC2"
-       [ $USER_REC2 == $(($USER_REC1 + 2)) ] ||
-               error "user index expected $(($USER_REC1 + 2)) is $USER_REC2"
-       sleep 5
+       # force cl_user2 to be idle (2nd part) and to reach
+       # changelog_max_idle_time
+       sleep 2
 
        # generate one more changelog to trigger fail_loc
-       rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+       createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/${tfile}bis failed"
 
        # ensure gc thread is done
-       wait_update_facet $SINGLEMDS \
-                         "ps -e -o comm= | grep chlg_gc_thread" "" 20
-
-       # check user still registered
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
-       # check user2 unregistered
-       $GET_CL_USERS | grep -q $CL_USER2 &&
-               error "User $CL_USER2 still found in changelog_users"
-
-       # check changelogs are present and starting at $USER_REC2 + 1
-       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
-       echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
-       [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
-               error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+       for i in $(mdts_nodes); do
+               wait_update $i \
+                       "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
+                       error "$i: GC-thread not done"
+       done
 
-       cleanup_160f
+       local first_rec
+       for i in $(seq $MDSCOUNT); do
+               # check cl_user1 still registered
+               changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               # check cl_user2 unregistered
+               changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
+                       error "mds$i: User ${cl_user2[mds$i]} still registered"
+
+               # check changelogs are present and starting at $user_rec1 + 1
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               first_rec=$($LFS changelog $(facet_svc mds$i) |
+                           awk '{ print $1; exit; }')
+
+               echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
+               [ $((user_rec1 + 1)) == $first_rec ] ||
+                       error "mds$i: first index should be $user_rec1 + 1, " \
+                             "but is $first_rec"
+       done
 }
 run_test 160f "changelog garbage collect (timestamped users)"
 
 test_160g() {
-       # do_facet $SINGLEMDS $LCTL set_param mdd.$MDT0.changelog_gc=1
-       # should be set by default
-
-       local CL_USERS="mdd.$MDT0.changelog_users"
-       local GET_CL_USERS="do_facet $SINGLEMDS $LCTL get_param -n $CL_USERS"
-       local save_params="$TMP/sanity-$TESTNAME.parameters"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
+               skip "Need MDS version at least 2.10.56"
 
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_max_idle_indexes" > $save_params
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_min_gc_interval" >> $save_params
-       save_lustre_params $SINGLEMDS \
-               "mdd.$MDT0.changelog_min_free_cat_entries" >> $save_params
+       local mdts=$(comma_list $(mdts_nodes))
 
-       trap cleanup_160f EXIT
-
-#define OBD_FAIL_TIME_IN_CHLOG_USER                 0x1314
-       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1314
+       #define OBD_FAIL_TIME_IN_CHLOG_USER     0x1314
+       do_nodes $mdts $LCTL set_param fail_loc=0x1314
 
        # Create a user
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
-       CL_USER2=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       echo "Registered as changelog user $CL_USER2"
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
-       $GET_CL_USERS | grep -q $CL_USER2 ||
-               error "User $CL_USER2 not found in changelog_users"
-
-       # generate some changelogs to accumulate
-       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
-       touch $DIR/$tdir/$tfile || error "touch $DIR/$tdir/$tfile failed"
-       touch $DIR/$tdir/${tfile}2 || error "touch $DIR/$tdir/${tfile}2 failed"
-       rm -f $DIR/$tdir/$tfile || error "rm -f $tfile failed"
+       changelog_register || error "first changelog_register failed"
+       changelog_register || error "second changelog_register failed"
+       local cl_users
+       declare -A cl_user1
+       declare -A cl_user2
+       local user_rec1
+       local user_rec2
+       local i
+
+       # generate some changelog records to accumulate on each MDT
+       test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
+       createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/$tfile failed"
 
        # check changelogs have been generated
-       nbcl=$($LFS changelog $MDT0 | wc -l)
+       local nbcl=$(changelog_dump | wc -l)
        [[ $nbcl -eq 0 ]] && error "no changelogs found"
 
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_max_idle_indexes=$((nbcl - 1))
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_min_gc_interval=2
-       do_facet $SINGLEMDS $LCTL set_param \
-               mdd.$MDT0.changelog_min_free_cat_entries=3
+       for param in "changelog_max_idle_indexes=$((nbcl / 2))" \
+                    "changelog_gc=1" \
+                    "changelog_min_gc_interval=2" \
+                    "changelog_min_free_cat_entries=3"; do
+               local MDT0=$(facet_svc $SINGLEMDS)
+               local var="${param%=*}"
+               local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
+
+               stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
+               do_nodes $mdts $LCTL set_param mdd.*.$param ||
+                       error "unable to set mdd.*.$param"
+       done
 
        # simulate changelog catalog almost full
-#define OBD_FAIL_CAT_FREE_RECORDS                  0x1313
-       do_facet $SINGLEMDS $LCTL set_param fail_loc=0x1313
-       do_facet $SINGLEMDS $LCTL set_param fail_val=3
+       #define OBD_FAIL_CAT_FREE_RECORDS       0x1313
+       do_nodes $mdts $LCTL set_param fail_loc=0x1313 fail_val=3
+
+       for i in $(seq $MDSCOUNT); do
+               cl_users=(${CL_USERS[mds$i]})
+               cl_user1[mds$i]="${cl_users[0]}"
+               cl_user2[mds$i]="${cl_users[1]}"
+
+               [ -n "${cl_user1[mds$i]}" ] ||
+                       error "mds$i: no user registered"
+               [ -n "${cl_user2[mds$i]}" ] ||
+                       error "mds$i: only ${cl_user1[mds$i]} is registered"
+
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               __changelog_clear mds$i ${cl_user1[mds$i]} +2
+               user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
+                    "$user_rec1 + 2 == $user_rec2"
+               [ $((user_rec1 + 2)) == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user1[mds$i]} index expected " \
+                             "$user_rec1 + 2, but is $user_rec2"
+               user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user2[mds$i]} not registered"
+               [ $user_rec1 == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user2[mds$i]} index expected " \
+                             "$user_rec1, but is $user_rec2"
+       done
 
-       USER_REC1=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       $LFS changelog_clear $MDT0 $CL_USER $(($USER_REC1 + 3))
-       USER_REC2=$($GET_CL_USERS | awk "\$1 == \"$CL_USER\" {print \$2}")
-       echo "verifying user clear: $(( $USER_REC1 + 3 )) == $USER_REC2"
-       [ $USER_REC2 == $(($USER_REC1 + 3)) ] ||
-               error "user index expected $(($USER_REC1 + 3)) is $USER_REC2"
+       # ensure we are past the previous changelog_min_gc_interval set above
+       sleep 2
 
        # generate one more changelog to trigger fail_loc
-       rm -rf $DIR/$tdir || error "rm -rf $tdir failed"
+       createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/${tfile}bis failed"
 
        # ensure gc thread is done
-       wait_update_facet $SINGLEMDS \
-                         "ps -e -o comm= | grep chlg_gc_thread" "" 20
+       for i in $(mdts_nodes); do
+               wait_update $i \
+                       "ps -e -o comm= | grep chlg_gc_thread" "" 20 ||
+                       error "$i: GC-thread not done"
+       done
 
-       # check user still registered
-       $GET_CL_USERS | grep -q $CL_USER ||
-               error "User $CL_USER not found in changelog_users"
-       # check user2 unregistered
-       $GET_CL_USERS | grep -q $CL_USER2 &&
-               error "User $CL_USER2 still found in changelog_users"
+       local first_rec
+       for i in $(seq $MDSCOUNT); do
+               # check cl_user1 still registered
+               changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               # check cl_user2 unregistered
+               changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
+                       error "mds$i: User ${cl_user2[mds$i]} still registered"
+
+               # check changelogs are present and starting at $user_rec1 + 1
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               first_rec=$($LFS changelog $(facet_svc mds$i) |
+                           awk '{ print $1; exit; }')
+
+               echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
+               [ $((user_rec1 + 1)) == $first_rec ] ||
+                       error "mds$i: first index should be $user_rec1 + 1, " \
+                             "but is $first_rec"
+       done
+}
+run_test 160g "changelog garbage collect (old users)"
+
+test_160h() {
+       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
+               { skip "Need MDS version at least 2.10.56"; return 0; }
+
+       local mdts=$(comma_list $(mdts_nodes))
+
+       # Create a user
+       changelog_register || error "first changelog_register failed"
+       changelog_register || error "second changelog_register failed"
+       local cl_users
+       declare -A cl_user1
+       declare -A cl_user2
+       local user_rec1
+       local user_rec2
+       local i
+
+       # generate some changelog records to accumulate on each MDT
+       test_mkdir -c $MDSCOUNT $DIR/$tdir || error "test_mkdir $tdir failed"
+       createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/$tfile failed"
 
-       # check changelogs are present and starting at $USER_REC2 + 1
-       FIRST_REC=$($LFS changelog $MDT0 | head -n1 | awk '{print $1}')
-       echo "verifying min purge: $(( $USER_REC2 + 1 )) == $FIRST_REC"
-       [ $FIRST_REC == $(($USER_REC2 + 1)) ] ||
-               error "first index should be $(($USER_REC2 + 1)) is $FIRST_REC"
+       # check changelogs have been generated
+       local nbcl=$(changelog_dump | wc -l)
+       [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+       for param in "changelog_max_idle_time=10" \
+                    "changelog_gc=1" \
+                    "changelog_min_gc_interval=2"; do
+               local MDT0=$(facet_svc $SINGLEMDS)
+               local var="${param%=*}"
+               local old=$(do_facet mds1 "$LCTL get_param -n mdd.$MDT0.$var")
+
+               stack_trap "do_nodes $mdts $LCTL set_param mdd.*.$var=$old" EXIT
+               do_nodes $mdts $LCTL set_param mdd.*.$param
+       done
+
+       # force cl_user2 to be idle (1st part)
+       sleep 9
+
+       for i in $(seq $MDSCOUNT); do
+               cl_users=(${CL_USERS[mds$i]})
+               cl_user1[mds$i]="${cl_users[0]}"
+               cl_user2[mds$i]="${cl_users[1]}"
+
+               [ -n "${cl_user1[mds$i]}" ] ||
+                       error "mds$i: no user registered"
+               [ -n "${cl_user2[mds$i]}" ] ||
+                       error "mds$i: only ${cl_user2[mds$i]} is registered"
+
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               __changelog_clear mds$i ${cl_user1[mds$i]} +2
+               user_rec2=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               echo "mds$i: verifying user ${cl_user1[mds$i]} clear: " \
+                    "$user_rec1 + 2 == $user_rec2"
+               [ $((user_rec1 + 2)) == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user1[mds$i]} index expected " \
+                             "$user_rec1 + 2, but is $user_rec2"
+               user_rec2=$(changelog_user_rec mds$i ${cl_user2[mds$i]})
+               [ -n "$user_rec2" ] ||
+                       error "mds$i: User ${cl_user2[mds$i]} not registered"
+               [ $user_rec1 == $user_rec2 ] ||
+                       error "mds$i: user ${cl_user2[mds$i]} index expected " \
+                             "$user_rec1, but is $user_rec2"
+       done
+
+       # force cl_user2 to be idle (2nd part) and to reach
+       # changelog_max_idle_time
+       sleep 2
 
-       cleanup_160f
+       # force each GC-thread start and block then
+       # one per MDT/MDD, set fail_val accordingly
+       #define OBD_FAIL_FORCE_GC_THREAD 0x1316
+       do_nodes $mdts $LCTL set_param fail_loc=0x1316
+
+       # generate more changelogs to trigger fail_loc
+       createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/${tfile}bis failed"
+
+       # stop MDT to stop GC-thread, should be done in back-ground as it will
+       # block waiting for the thread to be released and exit
+       declare -A stop_pids
+       for i in $(seq $MDSCOUNT); do
+               stop mds$i &
+               stop_pids[mds$i]=$!
+       done
+
+       for i in $(mdts_nodes); do
+               local facet
+               local nb=0
+               local facets=$(facets_up_on_host $i)
+
+               for facet in ${facets//,/ }; do
+                       if [[ $facet == mds* ]]; then
+                               nb=$((nb + 1))
+                       fi
+               done
+               # ensure each MDS's gc threads are still present and all in "R"
+               # state (OBD_FAIL_FORCE_GC_THREAD effect!)
+               [[ $(do_node $i pgrep chlg_gc_thread | wc -l) -eq $nb ]] ||
+                       error "$i: expected $nb GC-thread"
+               wait_update $i \
+                       "ps -C chlg_gc_thread -o state --no-headers | uniq" \
+                       "R" 20 ||
+                       error "$i: GC-thread not found in R-state"
+               # check umounts of each MDT on MDS have reached kthread_stop()
+               [[ $(do_node $i pgrep umount | wc -l) -eq $nb ]] ||
+                       error "$i: expected $nb umount"
+               wait_update $i \
+                       "ps -C umount -o state --no-headers | uniq" "D" 20 ||
+                       error "$i: umount not found in D-state"
+       done
+
+       # release all GC-threads
+       do_nodes $mdts $LCTL set_param fail_loc=0
+
+       # wait for MDT stop to complete
+       for i in $(seq $MDSCOUNT); do
+               wait ${stop_pids[mds$i]} || error "mds$i: stop failed"
+       done
+
+       # XXX
+       # may try to check if any orphan changelog records are present
+       # via ldiskfs/zfs and llog_reader...
+
+       # re-start/mount MDTs
+       for i in $(seq $MDSCOUNT); do
+               start mds$i $(mdsdevname $i) $MDS_MOUNT_OPTS ||
+                       error "Fail to start mds$i"
+       done
+
+       local first_rec
+       for i in $(seq $MDSCOUNT); do
+               # check cl_user1 still registered
+               changelog_users mds$i | grep -q "${cl_user1[mds$i]}" ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               # check cl_user2 unregistered
+               changelog_users mds$i | grep -q "${cl_user2[mds$i]}" &&
+                       error "mds$i: User ${cl_user2[mds$i]} still registered"
+
+               # check changelogs are present and starting at $user_rec1 + 1
+               user_rec1=$(changelog_user_rec mds$i ${cl_user1[mds$i]})
+               [ -n "$user_rec1" ] ||
+                       error "mds$i: User ${cl_user1[mds$i]} not registered"
+               first_rec=$($LFS changelog $(facet_svc mds$i) |
+                           awk '{ print $1; exit; }')
+
+               echo "mds$i: verifying first index $user_rec1 + 1 == $first_rec"
+               [ $((user_rec1 + 1)) == $first_rec ] ||
+                       error "mds$i: first index should be $user_rec1 + 1, " \
+                             "but is $first_rec"
+       done
 }
-run_test 160g "changelog garbage collect (old users)"
+run_test 160h "changelog gc thread stop upon umount, orphan records delete " \
+             "during mount"
+
+test_160i() {
+
+       local mdts=$(comma_list $(mdts_nodes))
+
+       changelog_register || error "first changelog_register failed"
+
+       # generate some changelog records to accumulate on each MDT
+       test_mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
+       createmany -m $DIR/$tdir/$tfile $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/$tfile failed"
+
+       # check changelogs have been generated
+       local nbcl=$(changelog_dump | wc -l)
+       [[ $nbcl -eq 0 ]] && error "no changelogs found"
+
+       # simulate race between register and unregister
+       # XXX as fail_loc is set per-MDS, with DNE configs the race
+       # simulation will only occur for one MDT per MDS and for the
+       # others the normal race scenario will take place
+       #define CFS_FAIL_CHLOG_USER_REG_UNREG_RACE          0x1315
+       do_nodes $mdts $LCTL set_param fail_loc=0x10001315
+       do_nodes $mdts $LCTL set_param fail_val=1
+
+       # unregister 1st user
+       changelog_deregister &
+       local pid1=$!
+       # wait some time for deregister work to reach race rdv
+       sleep 2
+       # register 2nd user
+       changelog_register || error "2nd user register failed"
+
+       wait $pid1 || error "1st user deregister failed"
+
+       local i
+       local last_rec
+       declare -A LAST_REC
+       for i in $(seq $MDSCOUNT); do
+               if changelog_users mds$i | grep "^cl"; then
+                       # make sure new records are added with one user present
+                       LAST_REC[mds$i]=$(changelog_users $SINGLEMDS |
+                                         awk '/^current.index:/ { print $NF }')
+               else
+                       error "mds$i has no user registered"
+               fi
+       done
+
+       # generate more changelog records to accumulate on each MDT
+       createmany -m $DIR/$tdir/${tfile}bis $((MDSCOUNT * 2)) ||
+               error "create $DIR/$tdir/${tfile}bis failed"
+
+       for i in $(seq $MDSCOUNT); do
+               last_rec=$(changelog_users $SINGLEMDS |
+                          awk '/^current.index:/ { print $NF }')
+               echo "verify changelogs are on: $last_rec != ${LAST_REC[mds$i]}"
+               [ $last_rec != ${LAST_REC[mds$i]} ] ||
+                       error "changelogs are off on mds$i"
+       done
+}
+run_test 160i "changelog user register/unregister race"
 
 test_161a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        test_mkdir -c1 $DIR/$tdir
        cp /etc/hosts $DIR/$tdir/$tfile
        test_mkdir -c1 $DIR/$tdir/foo1
@@ -11979,39 +12783,36 @@ test_161a() {
        local FID=$($LFS path2fid $DIR/$tdir/$tfile | tr -d '[]')
        if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
                $LFS fid2path $DIR $FID
-               err17935 "bad link ea"
+               error "bad link ea"
        fi
-    # middle
-    rm $DIR/$tdir/foo2/zachary
-    # last
-    rm $DIR/$tdir/foo2/thor
-    # first
-    rm $DIR/$tdir/$tfile
-    # rename
-    mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
-    if [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ]
-       then
-       $LFS fid2path $DIR $FID
-       err17935 "bad link rename"
-    fi
-    rm $DIR/$tdir/foo2/maggie
+       # middle
+       rm $DIR/$tdir/foo2/zachary
+       # last
+       rm $DIR/$tdir/foo2/thor
+       # first
+       rm $DIR/$tdir/$tfile
+       # rename
+       mv $DIR/$tdir/foo1/sofia $DIR/$tdir/foo2/maggie
+       [ "$($LFS fid2path $FSNAME --link 1 $FID)" != "$tdir/foo2/maggie" ] &&
+               { $LFS fid2path $DIR $FID; error "bad link rename"; }
+       rm $DIR/$tdir/foo2/maggie
 
        # overflow the EA
-       local longname=filename_avg_len_is_thirty_two_
+       local longname=$tfile.avg_len_is_thirty_two_
+       stack_trap "unlinkmany $DIR/$tdir/foo2/$longname 1000 || \
+               error_noexit 'failed to unlink many hardlinks'" EXIT
        createmany -l$DIR/$tdir/foo1/luna $DIR/$tdir/foo2/$longname 1000 ||
                error "failed to hardlink many files"
        links=$($LFS fid2path $DIR $FID | wc -l)
        echo -n "${links}/1000 links in link EA"
-       [[ $links -gt 60 ]] ||
-               err17935 "expected at least 60 links in link EA"
-       unlinkmany $DIR/$tdir/foo2/$longname 1000 ||
-               error "failed to unlink many hardlinks"
+       [[ $links -gt 60 ]] || error "expected at least 60 links in link EA"
 }
 run_test 161a "link ea sanity"
 
 test_161b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "skipping remote directory test" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "skipping remote directory test"
+
        local MDTIDX=1
        local remote_dir=$DIR/$tdir/remote_dir
 
@@ -12031,7 +12832,7 @@ test_161b() {
                     tr -d ']')
        if [ "$($LFS fid2path $DIR $FID | wc -l)" != "5" ]; then
                $LFS fid2path $DIR $FID
-               err17935 "bad link ea"
+               error "bad link ea"
        fi
        # middle
        rm $remote_dir/foo2/zachary
@@ -12044,7 +12845,7 @@ test_161b() {
        local link_path=$($LFS fid2path $FSNAME --link 1 $FID)
        if [ "$DIR/$link_path" != "$remote_dir/foo2/maggie" ]; then
                $LFS fid2path $DIR $FID
-               err17935 "bad link rename"
+               error "bad link rename"
        fi
        rm $remote_dir/foo2/maggie
 
@@ -12055,47 +12856,43 @@ test_161b() {
        links=$($LFS fid2path $DIR $FID | wc -l)
        echo -n "${links}/1000 links in link EA"
        [[ ${links} -gt 60 ]] ||
-               err17935 "expected at least 60 links in link EA"
+               error "expected at least 60 links in link EA"
        unlinkmany $remote_dir/foo2/$longname 1000 ||
        error "failed to unlink many hardlinks"
 }
 run_test 161b "link ea sanity under remote directory"
 
 test_161c() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.1.5) ]] &&
-               skip "Need MDS version at least 2.1.5" && return
+               skip "Need MDS version at least 2.1.5"
 
        # define CLF_RENAME_LAST 0x0001
        # rename overwrite a target having nlink = 1 (changelog flag 0x1)
-       CL_USER=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
+       changelog_register || error "changelog_register failed"
 
-       trap cleanup_changelog EXIT
        rm -rf $DIR/$tdir
-       mkdir -p $DIR/$tdir
+       test_mkdir -i $((MDSCOUNT - 1)) $DIR/$tdir
        touch $DIR/$tdir/foo_161c
        touch $DIR/$tdir/bar_161c
        mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
-       $LFS changelog $MDT0 | grep RENME
-       local flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | \
-               cut -f5 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_dump | grep RENME | tail -n 5
+       local flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
+       changelog_clear 0 || error "changelog_clear failed"
        if [ x$flags != "x0x1" ]; then
                error "flag $flags is not 0x1"
        fi
-       echo "rename overwrite a target having nlink = 1," \
-               "changelog record has flags of $flags"
 
+       echo "rename overwrite target with nlink = 1, changelog flags=$flags"
        # rename overwrite a target having nlink > 1 (changelog flag 0x0)
        touch $DIR/$tdir/foo_161c
        touch $DIR/$tdir/bar_161c
        ln $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
        mv -f $DIR/$tdir/foo_161c $DIR/$tdir/bar_161c
-       $LFS changelog $MDT0 | grep RENME
-       flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_dump | grep RENME | tail -n 5
+       flags=$(changelog_dump | grep "RENME.*bar_161c" | cut -f5 -d' ')
+       changelog_clear 0 || error "changelog_clear failed"
        if [ x$flags != "x0x0" ]; then
                error "flag $flags is not 0x0"
        fi
@@ -12105,9 +12902,9 @@ test_161c() {
        # rename doesn't overwrite a target (changelog flag 0x0)
        touch $DIR/$tdir/foo_161c
        mv -f $DIR/$tdir/foo_161c $DIR/$tdir/foo2_161c
-       $LFS changelog $MDT0 | grep RENME
-       flags=$($LFS changelog $MDT0 | grep RENME | tail -1 | cut -f5 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_dump | grep RENME | tail -n 5
+       flags=$(changelog_dump | grep RENME | tail -1 | cut -f5 -d' ')
+       changelog_clear 0 || error "changelog_clear failed"
        if [ x$flags != "x0x0" ]; then
                error "flag $flags is not 0x0"
        fi
@@ -12117,9 +12914,9 @@ test_161c() {
        # define CLF_UNLINK_LAST 0x0001
        # unlink a file having nlink = 1 (changelog flag 0x1)
        rm -f $DIR/$tdir/foo2_161c
-       $LFS changelog $MDT0 | grep UNLNK
-       flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_dump | grep UNLNK | tail -n 5
+       flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
+       changelog_clear 0 || error "changelog_clear failed"
        if [ x$flags != "x0x1" ]; then
                error "flag $flags is not 0x1"
        fi
@@ -12129,29 +12926,23 @@ test_161c() {
        # unlink a file having nlink > 1 (changelog flag 0x0)
        ln -f $DIR/$tdir/bar_161c $DIR/$tdir/foobar_161c
        rm -f $DIR/$tdir/foobar_161c
-       $LFS changelog $MDT0 | grep UNLNK
-       flags=$($LFS changelog $MDT0 | grep UNLNK | tail -1 | cut -f5 -d' ')
-       $LFS changelog_clear $MDT0 $CL_USER 0
+       changelog_dump | grep UNLNK | tail -n 5
+       flags=$(changelog_dump | grep UNLNK | tail -1 | cut -f5 -d' ')
+       changelog_clear 0 || error "changelog_clear failed"
        if [ x$flags != "x0x0" ]; then
                error "flag $flags is not 0x0"
        fi
-       echo "unlink a file having nlink > 1," \
-               "changelog record has flags of $flags"
-       cleanup_changelog
+       echo "unlink a file having nlink > 1, changelog record flags '$flags'"
 }
 run_test 161c "check CL_RENME[UNLINK] changelog record flags"
 
 test_161d() {
-       local user
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local pid
        local fid
 
-       # cleanup previous run
-       rm -rf $DIR/$tdir/$tfile
-
-       user=$(do_facet $SINGLEMDS $LCTL --device $MDT0 \
-               changelog_register -n)
-       [[ $? -eq 0 ]] || error "changelog_register failed"
+       changelog_register || error "changelog_register failed"
 
        # work in a standalone dir to avoid locking on $DIR/$MOUNT to
        # interfer with $MOUNT/.lustre/fid/ access
@@ -12174,7 +12965,7 @@ test_161d() {
        [[ $? -eq 0 ]] || error "create should be blocked"
 
        local tempfile=$(mktemp)
-       fid=$(changelog_extract_field $MDT0 "CREAT" "$tfile" "t=")
+       fid=$(changelog_extract_field "CREAT" "$tfile" "t=")
        cat $MOUNT/.lustre/fid/$fid 2>/dev/null >$tempfile || error "cat failed"
        # some delay may occur during ChangeLog publishing and file read just
        # above, that could allow file write to happen finally
@@ -12184,35 +12975,28 @@ test_161d() {
 
        wait $pid
        [[ $? -eq 0 ]] || error "create failed"
-
-       $LFS changelog_clear $MDT0 $user 0
-       do_facet $SINGLEMDS $LCTL --device $MDT0 changelog_deregister $user
 }
 run_test 161d "create with concurrent .lustre/fid access"
 
 check_path() {
-    local expected=$1
-    shift
-    local fid=$2
+       local expected="$1"
+       shift
+       local fid="$2"
 
-    local path=$(${LFS} fid2path $*)
-    # Remove the '//' indicating a remote directory
-    path=$(echo $path | sed 's#//#/#g')
-    RC=$?
+       local path
+       path=$($LFS fid2path "$@")
+       local rc=$?
 
-    if [ $RC -ne 0 ]; then
-       err17935 "path looked up of $expected failed. Error $RC"
-       return $RC
-    elif [ "${path}" != "${expected}" ]; then
-       err17935 "path looked up \"${path}\" instead of \"${expected}\""
-       return 2
-    fi
-    echo "fid $fid resolves to path $path (expected $expected)"
+       if [ $rc -ne 0 ]; then
+               error "path looked up of '$expected' failed: rc=$rc"
+       elif [ "$path" != "$expected" ]; then
+               error "path looked up '$path' instead of '$expected'"
+       else
+               echo "FID '$fid' resolves to path '$path' as expected"
+       fi
 }
 
 test_162a() { # was test_162
-       # Make changes to filesystem
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        test_mkdir -p -c1 $DIR/$tdir/d2
        touch $DIR/$tdir/d2/$tfile
        touch $DIR/$tdir/d2/x1
@@ -12220,52 +13004,43 @@ test_162a() { # was test_162
        test_mkdir -p -c1 $DIR/$tdir/d2/a/b/c
        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 ||
-               error "check path $tdir/d2/$tfile failed"
+       local fid=$($LFS path2fid $DIR/$tdir/d2/$tfile | tr -d '[]')
+       check_path "$tdir/d2/$tfile" $FSNAME "$fid" --link 0
 
        # 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 ||
-               error "check path $tdir/d2/p/q/r/slink failed"
+       fid=$($LFS path2fid $DIR/$tdir/d2/p/q/r/slink | tr -d '[]')
+       check_path "$tdir/d2/p/q/r/slink" $FSNAME "$fid" --link 0
 
        # 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 ||
-               error "check path $tdir/d2/p/q/r/slink.wrong failed"
+       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
 
        # 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 '[]')
+       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 ||
-               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"
+       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
 
        # hardlink count: check that there are 2 links
-       # Doesnt work with CMD yet: 17935
-       ${LFS} fid2path $DIR $FID | wc -l | grep -q 2 || \
-               err17935 "expected 2 links"
+       local nlinks=$($LFS fid2path $DIR "$fid" | wc -l)
+       [ $nlinks -eq 2 ] || error "expect 2 links, found $nlinks"
 
        # 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 ||
-               error "check path $DIR/$tdir/d2/a/b/c/new_file failed"
-
-       return 0
+       check_path "$tdir/d2/a/b/c/new_file" $FSNAME $fid --link 0
 }
 run_test 162a "path lookup sanity"
 
 test_162b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        mkdir $DIR/$tdir
-       $LFS setdirstripe -i0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                                error "create striped dir failed"
 
        local FID=$($LFS getdirstripe $DIR/$tdir/striped_dir |
@@ -12279,13 +13054,11 @@ test_162b() {
        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"
+               check_path "$tdir/striped_dir/f$i" $FSNAME $FID --link 0
 
                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"
+               check_path "$tdir/striped_dir/d$i" $FSNAME $FID --link 0
        done
 
        return 0
@@ -12295,26 +13068,26 @@ run_test 162b "striped directory path lookup sanity"
 # LU-4239: Verify fid2path works with paths 100 or more directories deep
 test_162c() {
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.51) ]] &&
-               skip "Need MDS version at least 2.7.51" && return
-       test_mkdir $DIR/$tdir.local
-       test_mkdir $DIR/$tdir.remote
+               skip "Need MDS version at least 2.7.51"
+
        local lpath=$tdir.local
        local rpath=$tdir.remote
 
+       test_mkdir $DIR/$lpath
+       test_mkdir $DIR/$rpath
+
        for ((i = 0; i <= 101; i++)); do
                lpath="$lpath/$i"
                mkdir $DIR/$lpath
                FID=$($LFS path2fid $DIR/$lpath | tr -d '[]') ||
                        error "get fid for local directory $DIR/$lpath failed"
-               check_path "$DIR/$lpath" $MOUNT $FID --link 0 ||
-                       error "check path for local directory $DIR/$lpath failed"
+               check_path "$DIR/$lpath" $MOUNT $FID --link 0
 
                rpath="$rpath/$i"
                test_mkdir $DIR/$rpath
                FID=$($LFS path2fid $DIR/$rpath | tr -d '[]') ||
                        error "get fid for remote directory $DIR/$rpath failed"
-               check_path "$DIR/$rpath" $MOUNT $FID --link 0 ||
-                       error "check path for remote directory $DIR/$rpath failed"
+               check_path "$DIR/$rpath" $MOUNT $FID --link 0
        done
 
        return 0
@@ -12339,7 +13112,7 @@ test_169() {
 run_test 169 "parallel read and truncate should not deadlock"
 
 test_170() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        $LCTL clear     # bug 18514
        $LCTL debug_daemon start $TMP/${tfile}_log_good
@@ -12394,21 +13167,22 @@ test_170() {
 run_test 170 "test lctl df to handle corrupted log ====================="
 
 test_171() { # bug20592
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-#define OBD_FAIL_PTLRPC_DUMP_LOG         0x50e
-        $LCTL set_param fail_loc=0x50e
-        $LCTL set_param fail_val=3000
-        multiop_bg_pause $DIR/$tfile O_s || true
-        local MULTIPID=$!
-        kill -USR1 $MULTIPID
-        # cause log dump
-        sleep 3
-        wait $MULTIPID
-        if dmesg | grep "recursive fault"; then
-                error "caught a recursive fault"
-        fi
-        $LCTL set_param fail_loc=0
-        true
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       #define OBD_FAIL_PTLRPC_DUMP_LOG         0x50e
+       $LCTL set_param fail_loc=0x50e
+       $LCTL set_param fail_val=3000
+       multiop_bg_pause $DIR/$tfile O_s || true
+       local MULTIPID=$!
+       kill -USR1 $MULTIPID
+       # cause log dump
+       sleep 3
+       wait $MULTIPID
+       if dmesg | grep "recursive fault"; then
+               error "caught a recursive fault"
+       fi
+       $LCTL set_param fail_loc=0
+       true
 }
 run_test 171 "test libcfs_debug_dumplog_thread stuck in do_exit() ======"
 
@@ -12473,70 +13247,77 @@ obdecho_test() {
 }
 
 test_180a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       local rc=0
-       local rmmod_local=0
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
 
        if ! module_loaded obdecho; then
-           load_module obdecho/obdecho
-           rmmod_local=1
+               load_module obdecho/obdecho &&
+                       stack_trap "rmmod obdecho" EXIT ||
+                       error "unable to load obdecho on client"
        fi
 
        local osc=$($LCTL dl | grep -v mdt | awk '$3 == "osc" {print $4; exit}')
-       local host=$(lctl get_param -n osc.$osc.import |
-                            awk '/current_connection:/ {print $2}' )
-       local target=$(lctl get_param -n osc.$osc.import |
-                            awk '/target:/ {print $2}' )
+       local host=$($LCTL get_param -n osc.$osc.import |
+                    awk '/current_connection:/ { print $2 }' )
+       local target=$($LCTL get_param -n osc.$osc.import |
+                      awk '/target:/ { print $2 }' )
        target=${target%_UUID}
 
-       [[ -n $target ]]  && { setup_obdecho_osc $host $target || rc=1; } || rc=1
-       [ $rc -eq 0 ] && { obdecho_test ${target}_osc client || rc=2; }
-       [[ -n $target ]] && cleanup_obdecho_osc $target
-       [ $rmmod_local -eq 1 ] && rmmod obdecho
-       return $rc
+       if [ -n "$target" ]; then
+               setup_obdecho_osc $host $target &&
+                       stack_trap "cleanup_obdecho_osc $target" EXIT ||
+                       { error "obdecho setup failed with $?"; return; }
+
+               obdecho_test ${target}_osc client ||
+                       error "obdecho_test failed on ${target}_osc"
+       else
+               $LCTL get_param osc.$osc.import
+               error "there is no osc.$osc.import target"
+       fi
 }
 run_test 180a "test obdecho on osc"
 
 test_180b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       local rc=0
-       local rmmod_remote=0
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
-               rmmod_remote=true || error "failed to load module obdecho"
-       target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ {print $4;exit}')
-       [[ -n $target ]] && { obdecho_test $target ost1 || rc=1; }
-       $rmmod_remote && do_facet ost1 "rmmod obdecho"
-       return $rc
+               stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
+               error "failed to load module obdecho"
+
+       local target=$(do_facet ost1 $LCTL dl |
+                      awk '/obdfilter/ { print $4; exit; }')
+
+       if [ -n "$target" ]; then
+               obdecho_test $target ost1 || error "obdecho_test failed with $?"
+       else
+               do_facet ost1 $LCTL dl
+               error "there is no obdfilter target on ost1"
+       fi
 }
 run_test 180b "test obdecho directly on obdfilter"
 
 test_180c() { # LU-2598
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.0) ]] &&
-               skip "Need MDS version at least 2.4.0" && return
-
-       local rc=0
-       local rmmod_remote=false
-       local pages=16384 # 64MB bulk I/O RPC size
-       local target
+               skip "Need MDS version at least 2.4.0"
 
        do_rpc_nodes $(facet_active_host ost1) load_module obdecho/obdecho &&
-               rmmod_remote=true || error "failed to load module obdecho"
+               stack_trap "do_facet ost1 rmmod obdecho" EXIT ||
+               error "failed to load module obdecho"
+
+       local target=$(do_facet ost1 $LCTL dl |
+                      awk '/obdfilter/ { print $4; exit; }')
 
-       target=$(do_facet ost1 $LCTL dl | awk '/obdfilter/ { print $4 }' |
-               head -n1)
        if [ -n "$target" ]; then
-               obdecho_test "$target" ost1 "$pages" || rc=${PIPESTATUS[0]}
+               local pages=16384 # 64MB bulk I/O RPC size
+
+               obdecho_test "$target" ost1 "$pages" ||
+                       error "obdecho_test with pages=$pages failed with $?"
        else
-               echo "there is no obdfilter target on ost1"
-               rc=2
+               do_facet ost1 $LCTL dl
+               error "there is no obdfilter target on ost1"
        fi
-       $rmmod_remote && do_facet ost1 "rmmod obdecho" || true
-       return $rc
 }
 run_test 180c "test huge bulk I/O size on obdfilter, don't LASSERT"
 
@@ -12588,11 +13369,11 @@ test_182() {
 run_test 182 "Test parallel modify metadata operations ================"
 
 test_183() { # LU-2275
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.56) ]] &&
-               skip "Need MDS version at least 2.3.56" && return
+               skip "Need MDS version at least 2.3.56"
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
        mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
        echo aaa > $DIR/$tdir/$tfile
 
@@ -12615,7 +13396,7 @@ run_test 183 "No crash or request leak in case of strange dispositions ========"
 
 # test suite 184 is for LU-2016, LU-2017
 test_184a() {
-       check_swap_layouts_support && return 0
+       check_swap_layouts_support
 
        dir0=$DIR/$tdir/$testnum
        test_mkdir -p -c1 $dir0
@@ -12646,7 +13427,7 @@ test_184a() {
 run_test 184a "Basic layout swap"
 
 test_184b() {
-       check_swap_layouts_support && return 0
+       check_swap_layouts_support
 
        dir0=$DIR/$tdir/$testnum
        mkdir -p $dir0 || error "creating dir $dir0"
@@ -12677,8 +13458,8 @@ run_test 184b "Forbidden layout swap (will generate errors)"
 
 test_184c() {
        local cmpn_arg=$(cmp -n 2>&1 | grep "invalid option")
-       [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n" && return
-       check_swap_layouts_support && return 0
+       [ -n "$cmpn_arg" ] && skip_env "cmp does not support -n"
+       check_swap_layouts_support
 
        local dir0=$DIR/$tdir/$testnum
        mkdir -p $dir0 || error "creating dir $dir0"
@@ -12725,9 +13506,9 @@ test_184c() {
 run_test 184c "Concurrent write and layout swap"
 
 test_184d() {
-       check_swap_layouts_support && return 0
+       check_swap_layouts_support
        [ -z "$(which getfattr 2>/dev/null)" ] &&
-               skip "no getfattr command" && return 0
+               skip_env "no getfattr command"
 
        local file1=$DIR/$tdir/$tfile-1
        local file2=$DIR/$tdir/$tfile-2
@@ -12760,10 +13541,10 @@ run_test 184d "allow stripeless layouts swap"
 
 test_184e() {
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.94) ]] ||
-               { skip "Need MDS version at least 2.6.94"; return 0; }
-       check_swap_layouts_support && return 0
+               skip "Need MDS version at least 2.6.94"
+       check_swap_layouts_support
        [ -z "$(which getfattr 2>/dev/null)" ] &&
-               skip "no getfattr command" && return 0
+               skip_env "no getfattr command"
 
        local file1=$DIR/$tdir/$tfile-1
        local file2=$DIR/$tdir/$tfile-2
@@ -12797,7 +13578,7 @@ run_test 184e "Recreate layout after stripeless layout swaps"
 test_185() { # LU-2441
        # LU-3553 - no volatile file support in old servers
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.60) ]] ||
-               { skip "Need MDS version at least 2.3.60"; return 0; }
+               skip "Need MDS version at least 2.3.60"
 
        mkdir -p $DIR/$tdir || error "creating dir $DIR/$tdir"
        touch $DIR/$tdir/spoo
@@ -12832,9 +13613,9 @@ test_185() { # LU-2441
 run_test 185 "Volatile file support"
 
 test_187a() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
-               skip "Need MDS version at least 2.3.0" && return
+               skip "Need MDS version at least 2.3.0"
 
        local dir0=$DIR/$tdir/$testnum
        mkdir -p $dir0 || error "creating dir $dir0"
@@ -12853,9 +13634,9 @@ test_187a() {
 run_test 187a "Test data version change"
 
 test_187b() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.3.0) ] &&
-               skip "Need MDS version at least 2.3.0" && return
+               skip "Need MDS version at least 2.3.0"
 
        local dir0=$DIR/$tdir/$testnum
        mkdir -p $dir0 || error "creating dir $dir0"
@@ -12871,9 +13652,9 @@ test_187b() {
 run_test 187b "Test data version change on volatile file"
 
 test_200() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
 
        local POOL=${POOL:-cea1}
        local POOL_ROOT=${POOL_ROOT:-$DIR/d200.pools}
@@ -13050,6 +13831,7 @@ else
                JOBENV=FAKE_JOBID
        fi
 fi
+LUSTRE_JOBID_SIZE=31 # plus NUL terminator
 
 verify_jobstats() {
        local cmd=($1)
@@ -13068,16 +13850,16 @@ verify_jobstats() {
        [ "$JOBENV" = "FAKE_JOBID" ] &&
                FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
 
-       JOBVAL=${!JOBENV}
+       JOBVAL=${!JOBENV:0:$LUSTRE_JOBID_SIZE}
 
        [ "$JOBENV" = "nodelocal" ] && {
-               FAKE_JOBID=id.$testnum.$(basename ${cmd[0]}).$RANDOM
+               FAKE_JOBID=id.$testnum.%e.$RANDOM
                $LCTL set_param jobid_name=$FAKE_JOBID
-               JOBVAL=$FAKE_JOBID
+               JOBVAL=${FAKE_JOBID/\%e/$(basename ${cmd[0]})}
        }
 
        log "Test: ${cmd[*]}"
-       log "Using JobID environment variable $JOBENV=$JOBVAL"
+       log "Using JobID environment $($LCTL get_param -n jobid_var)=$JOBVAL"
 
        if [ $JOBENV = "FAKE_JOBID" ]; then
                FAKE_JOBID=$JOBVAL ${cmd[*]}
@@ -13088,8 +13870,10 @@ verify_jobstats() {
        # all files are created on OST0000
        for facet in $facets; do
                local stats="*.$(convert_facet2label $facet).job_stats"
+
+               # strip out libtool wrappers for in-tree executables
                if [ $(do_facet $facet lctl get_param $stats |
-                      grep -c $JOBVAL) -ne 1 ]; then
+                      sed -e 's/\.lt-/./' | grep -c $JOBVAL) -ne 1 ]; then
                        do_facet $facet lctl get_param $stats
                        error "No jobstats for $JOBVAL found on $facet::$stats"
                fi
@@ -13097,47 +13881,37 @@ verify_jobstats() {
 }
 
 jobstats_set() {
-       trap 0
-       NEW_JOBENV=${1:-$OLD_JOBENV}
-       do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$NEW_JOBENV
-       wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $NEW_JOBENV
-}
+       local new_jobenv=$1
 
-cleanup_205() {
-       trap 0
-       do_facet $SINGLEMDS \
-               $LCTL set_param mdt.*.job_cleanup_interval=$OLD_INTERVAL
-       [ $OLD_JOBENV != $JOBENV ] && jobstats_set $OLD_JOBENV
-       cleanup_changelog
+       do_facet mgs $LCTL conf_param $FSNAME.sys.jobid_var=$new_jobenv
+       wait_update $HOSTNAME "$LCTL get_param -n jobid_var" $new_jobenv
 }
 
 test_205() { # Job stats
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.1) ]] ||
-               { skip "Need MDS version with at least 2.7.1"; return 0; }
-
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-
+               skip "Need MDS version with at least 2.7.1"
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
        [ -z "$(lctl get_param -n mdc.*.connect_flags | grep jobstats)" ] &&
-               skip "Server doesn't support jobstats" && return 0
-       [[ $JOBID_VAR = disable ]] && skip "jobstats is disabled" && return
+               skip "Server doesn't support jobstats"
+       [[ $JOBID_VAR = disable ]] && skip_env "jobstats is disabled"
 
-       OLD_JOBENV=$($LCTL get_param -n jobid_var)
-       if [ $OLD_JOBENV != $JOBENV ]; then
-               jobstats_set $JOBENV
-               trap cleanup_205 EXIT
-       fi
+       local old_jobenv=$($LCTL get_param -n jobid_var)
+       [ $old_jobenv != $JOBENV ] && jobstats_set $JOBENV
+       stack_trap "do_facet mgs \
+               $LCTL conf_param $FSNAME.sys.jobid_var=$old_jobenv" EXIT
 
-       CL_USER=$(do_facet $SINGLEMDS lctl --device $MDT0 changelog_register -n)
-       echo "Registered as changelog user $CL_USER"
+       changelog_register
 
-       OLD_INTERVAL=$(do_facet $SINGLEMDS \
-                      lctl get_param -n mdt.*.job_cleanup_interval)
-       local interval_new=5
+       local old_interval=$(do_facet $SINGLEMDS lctl get_param -n \
+                               mdt.*.job_cleanup_interval | head -n 1)
+       local new_interval=5
        do_facet $SINGLEMDS \
-               $LCTL set_param mdt.*.job_cleanup_interval=$interval_new
+               $LCTL set_param mdt.*.job_cleanup_interval=$new_interval
+       stack_trap "do_facet $SINGLEMDS \
+               $LCTL set_param mdt.*.job_cleanup_interval=$old_interval" EXIT
        local start=$SECONDS
 
        local cmd
@@ -13179,7 +13953,7 @@ test_205() { # Job stats
        cmd="mv -f $DIR/$tfile $DIR/$tdir.rename"
        verify_jobstats "$cmd" "$SINGLEMDS"
        # jobstats expiry - sleep until old stats should be expired
-       local left=$((interval_new + 5 - (SECONDS - start)))
+       local left=$((new_interval + 5 - (SECONDS - start)))
        [ $left -ge 0 ] && wait_update_facet $SINGLEMDS \
                "lctl get_param *.*.job_stats | grep -c 'job_id.*mkdir'" \
                        "0" $left
@@ -13189,10 +13963,9 @@ test_205() { # Job stats
            grep -c "job_id.*mkdir") -gt 1 ] && error "old jobstats not expired"
 
        # Ensure that jobid are present in changelog (if supported by MDS)
-       if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ]
-       then
-               $LFS changelog $MDT0 | tail -9
-               jobids=$($LFS changelog $MDT0 | tail -9 | grep -c "j=")
+       if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.52) ];then
+               changelog_dump | tail -10
+               jobids=$(changelog_dump | tail -9 | grep -c "j=")
                [ $jobids -eq 9 ] ||
                        error "Wrong changelog jobid count $jobids != 9"
 
@@ -13200,13 +13973,17 @@ test_205() { # Job stats
                JOBENV="disable"
                jobstats_set $JOBENV
                touch $DIR/$tfile
-               $LFS changelog $MDT0 | tail -1
-               jobids=$($LFS changelog $MDT0 | tail -1 | grep -c "j=")
+               changelog_dump | grep $tfile
+               jobids=$(changelog_dump | grep $tfile | tail -1 | grep -c "j=")
                [ $jobids -eq 0 ] ||
                        error "Unexpected jobids when jobid_var=$JOBENV"
        fi
 
-       cleanup_205
+       lctl set_param jobid_var=USER jobid_name="S.%j.%e.%u.%h.E"
+       JOBENV="JOBCOMPLEX"
+       JOBCOMPLEX="S.$USER.touch.$(id -u).$(hostname).E"
+
+       verify_jobstats "touch $DIR/$tfile" $SINGLEMDS
 }
 run_test 205 "Verify job stats"
 
@@ -13261,9 +14038,9 @@ test_208() {
        # for now as only exclusive open is supported. After generic lease
        # is done, this test suite should be revised. - Jinshan
 
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.52) ]] ||
-               { skip "Need MDS version at least 2.4.52"; return 0; }
+               skip "Need MDS version at least 2.4.52"
 
        echo "==== test 1: verify get lease work"
        $MULTIOP $DIR/$tfile oO_CREAT:O_RDWR:eRE+eU || error "get lease error"
@@ -13310,7 +14087,7 @@ run_test 208 "Exclusive open"
 
 test_209() {
        [ -z "$(lctl get_param -n mdc.*.connect_flags | grep disp_stripe)" ] &&
-               skip_env "must have disp_stripe" && return
+               skip_env "must have disp_stripe"
 
        touch $DIR/$tfile
        sync; sleep 5; sync;
@@ -13409,7 +14186,8 @@ check_lnet_proc_entry() {
 }
 
 test_215() { # for bugs 18102, 21079, 21517
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local N='(0|[1-9][0-9]*)'       # non-negative numeric
        local P='[1-9][0-9]*'           # positive numeric
        local I='(0|-?[1-9][0-9]*|NA)'  # any numeric (0 | >0 | <0) or NA if no value
@@ -13488,8 +14266,8 @@ test_215() { # for bugs 18102, 21079, 21517
 run_test 215 "lnet exists and has proper content - bugs 18102, 21079, 21517"
 
 test_216() { # bug 20317
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        local node
        local facets=$(get_facets OST)
@@ -13532,7 +14310,8 @@ test_216() { # bug 20317
 run_test 216 "check lockless direct write updates file size and kms correctly"
 
 test_217() { # bug 22430
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local node
        local nid
 
@@ -13563,21 +14342,22 @@ test_218() {
        log "removing the temporary file"
        rm -rf $DIR/$tfile || error "tmp file removal failed"
 }
-run_test 218 "parallel read and truncate should not deadlock ======================="
+run_test 218 "parallel read and truncate should not deadlock"
 
 test_219() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        # write one partial page
-        dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
-        # set no grant so vvp_io_commit_write will do sync write
-        $LCTL set_param fail_loc=0x411
-        # write a full page at the end of file
-        dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
-
-        $LCTL set_param fail_loc=0
-        dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
-        $LCTL set_param fail_loc=0x411
-        dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       # write one partial page
+       dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1
+       # set no grant so vvp_io_commit_write will do sync write
+       $LCTL set_param fail_loc=0x411
+       # write a full page at the end of file
+       dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=1 conv=notrunc
+
+       $LCTL set_param fail_loc=0
+       dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 seek=3
+       $LCTL set_param fail_loc=0x411
+       dd if=/dev/zero of=$DIR/$tfile bs=1024 count=1 seek=2 conv=notrunc
 
        # LU-4201
        dd if=/dev/zero of=$DIR/$tfile-2 bs=1024 count=1
@@ -13586,10 +14366,11 @@ test_219() {
 run_test 219 "LU-394: Write partial won't cause uncontiguous pages vec at LND"
 
 test_220() { #LU-325
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+
        local OSTIDX=0
 
        # create on MDT0000 so the last_id and next_id are correct
@@ -13654,20 +14435,22 @@ test_220() { #LU-325
 run_test 220 "preallocated MDS objects still used if ENOSPC from OST"
 
 test_221() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        dd if=`which date` of=$MOUNT/date oflag=sync
-        chmod +x $MOUNT/date
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       dd if=`which date` of=$MOUNT/date oflag=sync
+       chmod +x $MOUNT/date
 
-        #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE  0x1401
-        $LCTL set_param fail_loc=0x80001401
+       #define OBD_FAIL_LLITE_FAULT_TRUNC_RACE  0x1401
+       $LCTL set_param fail_loc=0x80001401
 
-        $MOUNT/date > /dev/null
-        rm -f $MOUNT/date
+       $MOUNT/date > /dev/null
+       rm -f $MOUNT/date
 }
 run_test 221 "make sure fault and truncate race to not cause OOM"
 
 test_222a () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -rf $DIR/$tdir
        test_mkdir $DIR/$tdir
        $LFS setstripe -c 1 -i 0 $DIR/$tdir
@@ -13683,7 +14466,8 @@ test_222a () {
 run_test 222a "AGL for ls should not trigger CLIO lock failure"
 
 test_222b () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -rf $DIR/$tdir
        test_mkdir $DIR/$tdir
        $LFS setstripe -c 1 -i 0 $DIR/$tdir
@@ -13698,7 +14482,8 @@ test_222b () {
 run_test 222b "AGL for rmdir should not trigger CLIO lock failure"
 
 test_223 () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        rm -rf $DIR/$tdir
        test_mkdir $DIR/$tdir
        $LFS setstripe -c 1 -i 0 $DIR/$tdir
@@ -13714,30 +14499,32 @@ test_223 () {
 run_test 223 "osc reenqueue if without AGL lock granted ======================="
 
 test_224a() { # LU-1039, MRP-303
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB   0x508
-        $LCTL set_param fail_loc=0x508
-        dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
-        $LCTL set_param fail_loc=0
-        df $DIR
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB   0x508
+       $LCTL set_param fail_loc=0x508
+       dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1 conv=fsync
+       $LCTL set_param fail_loc=0
+       df $DIR
 }
 run_test 224a "Don't panic on bulk IO failure"
 
 test_224b() { # LU-1039, MRP-303
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
-        cancel_lru_locks osc
-        #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2   0x515
-        $LCTL set_param fail_loc=0x515
-        dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
-        $LCTL set_param fail_loc=0
-        df $DIR
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
+       dd if=/dev/zero of=$DIR/$tfile bs=4096 count=1
+       cancel_lru_locks osc
+       #define OBD_FAIL_PTLRPC_CLIENT_BULK_CB2   0x515
+       $LCTL set_param fail_loc=0x515
+       dd of=/dev/null if=$DIR/$tfile bs=4096 count=1
+       $LCTL set_param fail_loc=0
+       df $DIR
 }
 run_test 224b "Don't panic on bulk IO failure"
 
 test_224c() { # LU-6441
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
        save_writethrough $p
@@ -13779,62 +14566,56 @@ run_test 224c "Don't hang if one of md lost during large bulk RPC"
 
 MDSSURVEY=${MDSSURVEY:-$(which mds-survey 2>/dev/null || true)}
 test_225a () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        if [ -z ${MDSSURVEY} ]; then
-             skip_env "mds-survey not found" && return
+               skip_env "mds-survey not found"
        fi
+       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
+               skip "Need MDS version at least 2.2.51"
 
-       [ $MDSCOUNT -ge 2 ] &&
-               skip "skipping now for more than one MDT" && return
-
-       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
-            { skip "Need MDS version at least 2.2.51"; return; }
-
-       local mds=$(facet_host $SINGLEMDS)
-       local target=$(do_nodes $mds 'lctl dl' | \
-                      awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
+       local mds=$(facet_host $SINGLEMDS)
+       local target=$(do_nodes $mds 'lctl dl' |
+                      awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
 
-       local cmd1="file_count=1000 thrhi=4"
-       local cmd2="dir_count=2 layer=mdd stripe_count=0"
-       local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
-       local cmd="$cmd1 $cmd2 $cmd3"
+       local cmd1="file_count=1000 thrhi=4"
+       local cmd2="dir_count=2 layer=mdd stripe_count=0"
+       local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
+       local cmd="$cmd1 $cmd2 $cmd3"
 
-       rm -f ${TMP}/mds_survey*
-       echo + $cmd
-       eval $cmd || error "mds-survey with zero-stripe failed"
-       cat ${TMP}/mds_survey*
-       rm -f ${TMP}/mds_survey*
+       rm -f ${TMP}/mds_survey*
+       echo + $cmd
+       eval $cmd || error "mds-survey with zero-stripe failed"
+       cat ${TMP}/mds_survey*
+       rm -f ${TMP}/mds_survey*
 }
 run_test 225a "Metadata survey sanity with zero-stripe"
 
 test_225b () {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
        if [ -z ${MDSSURVEY} ]; then
-             skip_env "mds-survey not found" && return
+               skip_env "mds-survey not found"
        fi
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ] ||
-           { skip "Need MDS version at least 2.2.51"; return; }
-
+               skip "Need MDS version at least 2.2.51"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        if [ $($LCTL dl | grep -c osc) -eq 0 ]; then
-             skip_env "Need to mount OST to test" && return
+               skip_env "Need to mount OST to test"
        fi
 
-       local mds=$(facet_host $SINGLEMDS)
-       local target=$(do_nodes $mds 'lctl dl' | \
-                      awk "{if (\$2 == \"UP\" && \$3 == \"mdt\") {print \$4}}")
+       local mds=$(facet_host $SINGLEMDS)
+       local target=$(do_nodes $mds 'lctl dl' |
+                      awk '{ if ($2 == "UP" && $3 == "mdt") { print $4 }}')
 
-       local cmd1="file_count=1000 thrhi=4"
-       local cmd2="dir_count=2 layer=mdd stripe_count=1"
-       local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
-       local cmd="$cmd1 $cmd2 $cmd3"
+       local cmd1="file_count=1000 thrhi=4"
+       local cmd2="dir_count=2 layer=mdd stripe_count=1"
+       local cmd3="rslt_loc=${TMP} targets=\"$mds:$target\" $MDSSURVEY"
+       local cmd="$cmd1 $cmd2 $cmd3"
 
-       rm -f ${TMP}/mds_survey*
-       echo + $cmd
-       eval $cmd || error "mds-survey with stripe_count failed"
-       cat ${TMP}/mds_survey*
-       rm -f ${TMP}/mds_survey*
+       rm -f ${TMP}/mds_survey*
+       echo + $cmd
+       eval $cmd || error "mds-survey with stripe_count failed"
+       cat ${TMP}/mds_survey*
+       rm -f ${TMP}/mds_survey*
 }
 run_test 225b "Metadata survey sanity with stripe_count = 1"
 
@@ -13882,10 +14663,11 @@ test_226a () {
 run_test 226a "call path2fid and fid2path on files of all type"
 
 test_226b () {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       rm -rf $DIR/$tdir
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local MDTIDX=1
 
+       rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
        $LFS setdirstripe -i $MDTIDX $DIR/$tdir/remote_dir ||
                error "create remote directory failed"
@@ -13906,8 +14688,9 @@ run_test 226b "call path2fid and fid2path on files of all type under remote dir"
 # LU-1299 Executing or running ldd on a truncated executable does not
 # cause an out-of-memory condition.
 test_227() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ -z "$(which ldd)" ] && skip "should have ldd tool" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ -z "$(which ldd)" ] && skip_env "should have ldd tool"
+
        dd if=$(which date) of=$MOUNT/date bs=1k count=1
        chmod +x $MOUNT/date
 
@@ -13919,10 +14702,10 @@ run_test 227 "running truncated executable does not cause OOM"
 
 # LU-1512 try to reuse idle OI blocks
 test_228a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
+               skip_env "ldiskfs only test"
 
        local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
        local myDIR=$DIR/$tdir
@@ -13961,10 +14744,10 @@ test_228a() {
 run_test 228a "try to reuse idle OI blocks"
 
 test_228b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
+               skip_env "ldiskfs only test"
 
        local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
        local myDIR=$DIR/$tdir
@@ -14011,10 +14794,10 @@ run_test 228b "idle OI blocks can be reused after MDT restart"
 
 #LU-1881
 test_228c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
+               skip_env "ldiskfs only test"
 
        local MDT_DEV=$(mdsdevname ${SINGLEMDS//mds/})
        local myDIR=$DIR/$tdir
@@ -14057,11 +14840,10 @@ test_228c() {
 run_test 228c "NOT shrink the last entry in OI index node to recycle idle leaf"
 
 test_229() { # LU-2482, LU-3448
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.53) ] &&
-               skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53" &&
-               return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
+               skip "No HSM $(lustre_build_version $SINGLEMDS) MDS < 2.4.53"
 
        rm -f $DIR/$tfile
 
@@ -14090,33 +14872,35 @@ test_229() { # LU-2482, LU-3448
 run_test 229 "getstripe/stat/rm/attr changes work on released files"
 
 test_230a() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local MDTIDX=1
 
        test_mkdir $DIR/$tdir
        test_mkdir -i0 -c1 $DIR/$tdir/test_230_local
-       local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230_local)
+       local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230_local)
        [ $mdt_idx -ne 0 ] &&
                error "create local directory on wrong MDT $mdt_idx"
 
        $LFS mkdir -i $MDTIDX $DIR/$tdir/test_230 ||
                        error "create remote directory failed"
-       local mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230)
+       local mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230)
        [ $mdt_idx -ne $MDTIDX ] &&
                error "create remote directory on wrong MDT $mdt_idx"
 
        createmany -o $DIR/$tdir/test_230/t- 10 ||
                error "create files on remote directory failed"
-       mdt_idx=$($GETSTRIPE -M $DIR/$tdir/test_230/t-0)
+       mdt_idx=$($LFS getstripe -m $DIR/$tdir/test_230/t-0)
        [ $mdt_idx -ne $MDTIDX ] && error "create files on wrong MDT $mdt_idx"
        rm -r $DIR/$tdir || error "unlink remote directory failed"
 }
 run_test 230a "Create remote directory and files under the remote directory"
 
 test_230b() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local MDTIDX=1
        local mdt_index
        local i
@@ -14163,14 +14947,14 @@ test_230b() {
        echo "migratate to MDT1, then checking.."
        for ((i = 0; i < 10; i++)); do
                for file in $(find $migrate_dir/dir_${i}); do
-                       mdt_index=$($LFS getstripe -M $file)
+                       mdt_index=$($LFS getstripe -m $file)
                        [ $mdt_index == $MDTIDX ] ||
                                error "$file is not on MDT${MDTIDX}"
                done
        done
 
        # the multiple link file should still in MDT0
-       mdt_index=$($LFS getstripe -M $migrate_dir/$tfile)
+       mdt_index=$($LFS getstripe -m $migrate_dir/$tfile)
        [ $mdt_index == 0 ] ||
                error "$file is not on MDT${MDTIDX}"
 
@@ -14227,7 +15011,7 @@ test_230b() {
 
        echo "migrate back to MDT0, checking.."
        for file in $(find $migrate_dir); do
-               mdt_index=$($LFS getstripe -M $file)
+               mdt_index=$($LFS getstripe -m $file)
                [ $mdt_index == $MDTIDX ] ||
                        error "$file is not on MDT${MDTIDX}"
        done
@@ -14279,9 +15063,10 @@ test_230b() {
 run_test 230b "migrate directory"
 
 test_230c() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        local MDTIDX=1
        local mdt_index
        local file
@@ -14323,7 +15108,7 @@ test_230c() {
 
        echo "Finish migration, then checking.."
        for file in $(find $migrate_dir); do
-               mdt_index=$($LFS getstripe -M $file)
+               mdt_index=$($LFS getstripe -m $file)
                [ $mdt_index == $MDTIDX ] ||
                        error "$file is not on MDT${MDTIDX}"
        done
@@ -14333,8 +15118,9 @@ test_230c() {
 run_test 230c "check directory accessiblity if migration is failed"
 
 test_230d() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local MDTIDX=1
        local mdt_index
        local migrate_dir=$DIR/$tdir/migrate_dir
@@ -14355,7 +15141,7 @@ test_230d() {
 
        echo "Finish migration, then checking.."
        for file in $(find $migrate_dir); do
-               mdt_index=$($LFS getstripe -M $file)
+               mdt_index=$($LFS getstripe -m $file)
                [ $mdt_index == $MDTIDX ] ||
                        error "$file is not on MDT${MDTIDX}"
        done
@@ -14365,8 +15151,9 @@ test_230d() {
 run_test 230d "check migrate big directory"
 
 test_230e() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local i
        local j
        local a_fid
@@ -14382,22 +15169,22 @@ test_230e() {
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
                error "migrate dir fails"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
        [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 0 ] || error "a is not on MDT0"
 
        $LFS migrate -m 1 $DIR/$tdir/other_dir ||
                error "migrate dir fails"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir)
        [ $mdt_index == 1 ] || error "other_dir is not on MDT1"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 1 ] || error "a is not on MDT1"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/other_dir/b)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/other_dir/b)
        [ $mdt_index == 1 ] || error "b is not on MDT1"
 
        a_fid=$($LFS path2fid $DIR/$tdir/migrate_dir/a)
@@ -14410,8 +15197,9 @@ test_230e() {
 run_test 230e "migrate mulitple local link files"
 
 test_230f() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local a_fid
        local ln_fid
 
@@ -14426,15 +15214,15 @@ test_230f() {
        # a should be migrated to MDT1, since no other links on MDT0
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
                error "#1 migrate dir fails"
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
        [ $mdt_index == 1 ] || error "migrate_dir is not on MDT1"
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 1 ] || error "a is not on MDT1"
 
        # a should stay on MDT1, because it is a mulitple link file
        $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
                error "#2 migrate dir fails"
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 1 ] || error "a is not on MDT1"
 
        $LFS migrate -m 1 $DIR/$tdir/migrate_dir ||
@@ -14450,7 +15238,7 @@ test_230f() {
        # a should be migrated to MDT0, since no other links on MDT1
        $LFS migrate -m 0 $DIR/$tdir/migrate_dir ||
                error "#4 migrate dir fails"
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir/a)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir/a)
        [ $mdt_index == 0 ] || error "a is not on MDT0"
 
        rm -rf $DIR/$tdir || error "rm dir failed after migration"
@@ -14458,8 +15246,8 @@ test_230f() {
 run_test 230f "migrate mulitple remote link files"
 
 test_230g() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        mkdir -p $DIR/$tdir/migrate_dir
 
@@ -14470,10 +15258,11 @@ test_230g() {
 run_test 230g "migrate dir to non-exist MDT"
 
 test_230h() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.64) ] &&
-               skip "Need MDS version at least 2.7.64" && return
+               skip "Need MDS version at least 2.7.64"
+
        local mdt_index
 
        mkdir -p $DIR/$tdir/migrate_dir
@@ -14487,18 +15276,18 @@ test_230h() {
        $LFS migrate -m1 $DIR/$tdir/migrate_dir/.. ||
                error "migrating $tdir fail"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir)
        [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
 
-       mdt_index=$($LFS getstripe -M $DIR/$tdir/migrate_dir)
+       mdt_index=$($LFS getstripe -m $DIR/$tdir/migrate_dir)
        [ $mdt_index == 1 ] || error "$mdt_index != 1 after migration"
 
 }
 run_test 230h "migrate .. and root"
 
 test_230i() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        mkdir -p $DIR/$tdir/migrate_dir
 
@@ -14588,6 +15377,9 @@ test_232a() {
 run_test 232a "failed lock should not block umount"
 
 test_232b() {
+       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.58) ] ||
+               skip "Need MDS version at least 2.10.58"
+
        mkdir -p $DIR/$tdir
        $LFS setstripe -c1 -i0 $DIR/$tdir/$tfile
        dd if=/dev/zero of=$DIR/$tdir/$tfile bs=1M count=1
@@ -14610,10 +15402,11 @@ run_test 232b "failed data version lock should not block umount"
 
 test_233a() {
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.64) ] ||
-       { skip "Need MDS version at least 2.3.64"; return; }
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+               skip "Need MDS version at least 2.3.64"
+       [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
 
        local fid=$($LFS path2fid $MOUNT)
+
        stat $MOUNT/.lustre/fid/$fid > /dev/null ||
                error "cannot access $MOUNT using its FID '$fid'"
 }
@@ -14621,10 +15414,11 @@ run_test 233a "checking that OBF of the FS root succeeds"
 
 test_233b() {
        [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.90) ] ||
-       { skip "Need MDS version at least 2.5.90"; return; }
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
+               skip "Need MDS version at least 2.5.90"
+       [ -n "$FILESET" ] && skip_env "SKIP due to FILESET set"
 
        local fid=$($LFS path2fid $MOUNT/.lustre)
+
        stat $MOUNT/.lustre/fid/$fid > /dev/null ||
                error "cannot access $MOUNT/.lustre using its FID '$fid'"
 
@@ -14638,7 +15432,7 @@ test_234() {
        local p="$TMP/sanityN-$TESTNAME.parameters"
        save_lustre_params client "llite.*.xattr_cache" > $p
        lctl set_param llite.*.xattr_cache 1 ||
-               { skip "xattr cache is not supported"; return 0; }
+               skip_env "xattr cache is not supported"
 
        mkdir -p $DIR/$tdir || error "mkdir failed"
        touch $DIR/$tdir/$tfile || error "touch failed"
@@ -14656,7 +15450,8 @@ run_test 234 "xattr cache should not crash on ENOMEM"
 
 test_235() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.52) ] &&
-               skip "Need MDS version at least 2.4.52" && return
+               skip "Need MDS version at least 2.4.52"
+
        flock_deadlock $DIR/$tfile
        local RC=$?
        case $RC in
@@ -14672,14 +15467,14 @@ run_test 235 "LU-1715: flock deadlock detection does not work properly"
 
 #LU-2935
 test_236() {
-       check_swap_layouts_support && return 0
-       test_mkdir -c1 $DIR/$tdir
+       check_swap_layouts_support
 
        local ref1=/etc/passwd
        local ref2=/etc/group
        local file1=$DIR/$tdir/f1
        local file2=$DIR/$tdir/f2
 
+       test_mkdir -c1 $DIR/$tdir
        $SETSTRIPE -c 1 $file1 || error "cannot setstripe on '$file1': rc = $?"
        cp $ref1 $file1 || error "cp $ref1 $file1 failed: rc = $?"
        $SETSTRIPE -c 2 $file2 || error "cannot setstripe on '$file2': rc = $?"
@@ -14718,7 +15513,7 @@ test_238() {
        [[ $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; }
+               skip "Need MDS version at least 2.5.58 or 2.5.2+"
 
        touch $DIR/$tfile
        ln $DIR/$tfile $DIR/$tfile.lnk
@@ -14735,9 +15530,10 @@ test_238() {
 }
 run_test 238 "Verify linkea consistency"
 
-test_239() {
+test_239A() { # was test_239
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.5.60) ] &&
-               skip "Need MDS version at least 2.5.60" && return
+               skip "Need MDS version at least 2.5.60"
+
        local list=$(comma_list $(mdts_nodes))
 
        mkdir -p $DIR/$tdir
@@ -14749,10 +15545,11 @@ test_239() {
                        osp.*MDT*.sync_in_flight" | calc_sum)
        [ "$changes" -eq 0 ] || error "$changes not synced"
 }
-run_test 239 "osp_sync test"
+run_test 239A "osp_sync test"
 
 test_239a() { #LU-5297
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        touch $DIR/$tfile
        #define OBD_FAIL_OSP_CHECK_INVALID_REC     0x2100
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2100
@@ -14762,7 +15559,8 @@ test_239a() { #LU-5297
 run_test 239a "process invalid osp sync record correctly"
 
 test_239b() { #LU-5297
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        touch $DIR/$tfile1
        #define OBD_FAIL_OSP_CHECK_ENOMEM     0x2101
        do_facet $SINGLEMDS $LCTL set_param fail_loc=0x2101
@@ -14776,8 +15574,8 @@ test_239b() { #LU-5297
 run_test 239b "process osp sync record with ENOMEM error correctly"
 
 test_240() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        mkdir -p $DIR/$tdir
 
@@ -14832,7 +15630,8 @@ test_241b() {
 run_test 241b "dio vs dio"
 
 test_242() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        mkdir -p $DIR/$tdir
        touch $DIR/$tdir/$tfile
 
@@ -14888,9 +15687,10 @@ test_245() {
 run_test 245 "check mdc connection flag/data: multiple modify RPCs"
 
 test_246() { # LU-7371
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
        [ $(lustre_version_code ost1) -lt $(version_code 2.7.62) ] &&
-               skip "Need OST version >= 2.7.62" && return 0
+               skip "Need OST version >= 2.7.62"
+
        do_facet ost1 $LCTL set_param fail_val=4095
 #define OBD_FAIL_OST_READ_SIZE         0x234
        do_facet ost1 $LCTL set_param fail_loc=0x234
@@ -14912,7 +15712,7 @@ cleanup_247() {
 test_247a() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import |
                grep -q subtree ||
-               { skip "Fileset feature is not supported"; return; }
+               skip_env "Fileset feature is not supported"
 
        local submount=${MOUNT}_$tdir
 
@@ -14930,7 +15730,7 @@ run_test 247a "mount subdir as fileset"
 
 test_247b() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
-               { skip "Fileset feature is not supported"; return; }
+               skip_env "Fileset feature is not supported"
 
        local submount=${MOUNT}_$tdir
 
@@ -14945,7 +15745,7 @@ run_test 247b "mount subdir that dose not exist"
 
 test_247c() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
-               { skip "Fileset feature is not supported"; return; }
+               skip_env "Fileset feature is not supported"
 
        local submount=${MOUNT}_$tdir
 
@@ -14962,7 +15762,7 @@ run_test 247c "running fid2path outside root"
 
 test_247d() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import | grep -q subtree ||
-               { skip "Fileset feature is not supported"; return; }
+               skip "Fileset feature is not supported"
 
        local submount=${MOUNT}_$tdir
 
@@ -14981,7 +15781,7 @@ run_test 247d "running fid2path inside root"
 test_247e() {
        lctl get_param -n mdc.$FSNAME-MDT0000*.import |
                grep -q subtree ||
-               { skip "Fileset feature is not supported"; return; }
+               skip "Fileset feature is not supported"
 
        local submount=${MOUNT}_$tdir
 
@@ -14995,14 +15795,14 @@ run_test 247e "mount .. as fileset"
 
 test_248() {
        local fast_read_sav=$($LCTL get_param -n llite.*.fast_read 2>/dev/null)
-       [ -z "$fast_read_sav" ] && skip "no fast read support" && return
+       [ -z "$fast_read_sav" ] && skip "no fast read support"
 
        # create a large file for fast read verification
        dd if=/dev/zero of=$DIR/$tfile bs=1M count=128 > /dev/null 2>&1
 
        # make sure the file is created correctly
        $CHECKSTAT -s $((128*1024*1024)) $DIR/$tfile ||
-               { rm -f $DIR/$tfile; skip "file creation error" && return; }
+               { rm -f $DIR/$tfile; skip "file creation error"; }
 
        echo "Test 1: verify that fast read is 4 times faster on cache read"
 
@@ -15047,12 +15847,11 @@ test_248() {
 run_test 248 "fast read verification"
 
 test_249() { # LU-7890
-       rm -f $DIR/$tfile
-       $SETSTRIPE -c 1 $DIR/$tfile
-
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.53) ] &&
-       skip "Need at least version 2.8.54"
+               skip "Need at least version 2.8.54"
 
+       rm -f $DIR/$tfile
+       $SETSTRIPE -c 1 $DIR/$tfile
        # Offset 2T == 4k * 512M
        dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 seek=512M ||
                error "dd to 2T offset failed"
@@ -15061,7 +15860,7 @@ run_test 249 "Write above 2T file size"
 
 test_250() {
        [ "$(facet_fstype ost$(($($GETSTRIPE -i $DIR/$tfile) + 1)))" = "zfs" ] \
-        && skip "no 16TB file size limit on ZFS" && return
+        && skip "no 16TB file size limit on ZFS"
 
        $SETSTRIPE -c 1 $DIR/$tfile
        # ldiskfs extent file size limit is (16TB - 4KB - 1) bytes
@@ -15091,6 +15890,13 @@ test_251() {
 run_test 251 "Handling short read and write correctly"
 
 test_252() {
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
+            "$(facet_fstype mds1)" != "ldiskfs" ]; then
+               skip_env "ldiskfs only test"
+       fi
+
        local tgt
        local dev
        local out
@@ -15098,14 +15904,6 @@ test_252() {
        local num
        local gen
 
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-       if [ "$(facet_fstype ost1)" != "ldiskfs" -o \
-            "$(facet_fstype mds1)" != "ldiskfs" ]; then
-               skip "ldiskfs only test"
-               return
-       fi
-
        # check lr_reader on OST0000
        tgt=ost1
        dev=$(facet_device $tgt)
@@ -15121,8 +15919,7 @@ test_252() {
        tgt=mds1
        dev=$(facet_device $tgt)
        if ! do_facet $tgt $LR_READER -h | grep -q OPTIONS; then
-               echo "$LR_READER does not support additional options"
-               return 0
+               skip "$LR_READER does not support additional options"
        fi
        out=$(do_facet $tgt $LR_READER -c $dev)
        [ $? -eq 0 ] || error "$LR_READER failed on target $tgt device $dev"
@@ -15171,21 +15968,20 @@ test_253_fill_ost() {
 }
 
 test_253() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+
        local ostidx=0
        local rc=0
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       remote_mgs_nodsh && skip "remote MGS with nodsh" && return
-
        local ost_name=$($LFS osts |
                sed -n 's/^'$ostidx': \(.*\)_UUID .*/\1/p')
        # on the mdt's osc
        local mdtosc_proc1=$(get_mdtosc_proc_path $SINGLEMDS $ost_name)
        do_facet $SINGLEMDS $LCTL get_param -n \
                osp.$mdtosc_proc1.reserved_mb_high ||
-               { skip  "remote MDS does not support reserved_mb_high" &&
-                 return; }
+               skip  "remote MDS does not support reserved_mb_high"
 
        rm -rf $DIR/$tdir
        wait_mds_ost_sync
@@ -15273,19 +16069,19 @@ test_253() {
 run_test 253 "Check object allocation limit"
 
 test_254() {
-       local cl_user
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       do_facet $SINGLEMDS $LCTL get_param -n mdd.$MDT0.changelog_size ||
+               skip "MDS does not support changelog_size"
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       do_facet mds1 $LCTL get_param -n mdd.$MDT0.changelog_size ||
-               { skip "MDS does not support changelog_size" && return; }
+       local cl_user
+       local MDT0=$(facet_svc $SINGLEMDS)
 
-       cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
-       echo "Registered as changelog user $cl_user"
+       changelog_register || error "changelog_register failed"
 
-       $LFS changelog_clear $MDT0 $cl_user 0
+       changelog_clear 0 || error "changelog_clear failed"
 
-       local size1=$(do_facet mds1 \
+       local size1=$(do_facet $SINGLEMDS \
                      $LCTL get_param -n mdd.$MDT0.changelog_size)
        echo "Changelog size $size1"
 
@@ -15300,16 +16096,12 @@ test_254() {
        ln -s $DIR/$tdir/pics/2008/portland.jpg $DIR/$tdir/pics/desktop.jpg
        rm $DIR/$tdir/pics/desktop.jpg
 
-       local size2=$(do_facet mds1 \
+       local size2=$(do_facet $SINGLEMDS \
                      $LCTL get_param -n mdd.$MDT0.changelog_size)
        echo "Changelog size after work $size2"
 
-       do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
-
-       if (( size2 <= size1 )); then
-               error "Changelog size after work should be greater than original"
-       fi
-       return 0
+       (( $size2 > $size1 )) ||
+               error "new Changelog size=$size2 less than old size=$size1"
 }
 run_test 254 "Check changelog size"
 
@@ -15428,16 +16220,16 @@ ladvise_willread_performance()
 
 test_255a() {
        [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
-               skip "lustre < 2.8.54 does not support ladvise " && return
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+               skip "lustre < 2.8.54 does not support ladvise "
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        lfs setstripe -c -1 -i 0 $DIR/$tfile || error "$tfile failed"
 
        ladvise_no_type willread $DIR/$tfile &&
-               skip "willread ladvise is not supported" && return
+               skip "willread ladvise is not supported"
 
        ladvise_no_ioctl $DIR/$tfile &&
-               skip "ladvise ioctl is not supported" && return
+               skip "ladvise ioctl is not supported"
 
        local size_mb=100
        local size=$((size_mb * 1048576))
@@ -15514,22 +16306,21 @@ facet_meminfo() {
 }
 
 test_255b() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
+               skip "lustre < 2.8.54 does not support ladvise "
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        lfs setstripe -c 1 -i 0 $DIR/$tfile
 
        ladvise_no_type dontneed $DIR/$tfile &&
-               skip "dontneed ladvise is not supported" && return
+               skip "dontneed ladvise is not supported"
 
        ladvise_no_ioctl $DIR/$tfile &&
-               skip "ladvise ioctl is not supported" && return
-
-       [ $(lustre_version_code ost1) -lt $(version_code 2.8.54) ] &&
-               skip "lustre < 2.8.54 does not support ladvise" && return
+               skip "ladvise ioctl is not supported"
 
        ! $LFS ladvise -a dontneed $DIR/$tfile &&
                [ "$(facet_fstype ost1)" = "zfs" ] &&
-               skip "zfs-osd does not support 'ladvise dontneed'" && return
+               skip "zfs-osd does not support 'ladvise dontneed'"
 
        local size_mb=100
        local size=$((size_mb * 1048576))
@@ -15540,6 +16331,9 @@ test_255b() {
        dd if=/dev/zero of=$DIR/$tfile bs=1048576 count=$size_mb ||
                error "dd to $DIR/$tfile failed"
 
+       #force write to complete before dropping OST cache & checking memory
+       sync
+
        local total=$(facet_meminfo ost1 MemTotal)
        echo "Total memory: $total KiB"
 
@@ -15575,21 +16369,21 @@ test_255b() {
 run_test 255b "check 'lfs ladvise -a dontneed'"
 
 test_255c() {
+       [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
+               skip "lustre < 2.10.53 does not support lockahead"
+
        local count
        local new_count
        local difference
        local i
        local rc
 
-       [ $(lustre_version_code ost1) -lt $(version_code 2.10.50) ] &&
-               skip "lustre < 2.10.53 does not support lockahead" && return
-
        test_mkdir -p $DIR/$tdir
        $SETSTRIPE -i 0 $DIR/$tdir
 
        #test 10 returns only success/failure
        i=10
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15601,7 +16395,7 @@ test_255c() {
                $LCTL get_param -n ost.OSS.ost.stats)
        count=$(echo "$count" | grep ldlm_extent_enqueue | awk '{ print $2 }')
 
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
@@ -15627,7 +16421,7 @@ test_255c() {
                count=$($LCTL get_param -n \
                       ldlm.namespaces.$FSNAME-OST0000*osc-f*.lock_unused_count)
 
-               lockahead_test -d $DIR/$tdir -t $i
+               lockahead_test -d $DIR/$tdir -t $i -f $tfile
                rc=$?
                if [ $rc -eq 255 ]; then
                        error "Ladvise test ${i} failed, ${rc}"
@@ -15650,89 +16444,74 @@ test_255c() {
 
        #test 22 returns only success/failure
        i=22
-       lockahead_test -d $DIR/$tdir -t $i
+       lockahead_test -d $DIR/$tdir -t $i -f $tfile
        rc=$?
        if [ $rc -eq 255 ]; then
                error "Ladvise test${i} failed, ${rc}"
        fi
-
 }
 run_test 255c "suite of ladvise lockahead tests"
 
 test_256() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
+               skip "ldiskfs only test"
+       changelog_users $SINGLEMDS | grep "^cl" &&
+               skip "active changelog user"
+
        local cl_user
        local cat_sl
        local mdt_dev
 
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
-       [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
-
        mdt_dev=$(mdsdevname 1)
        echo $mdt_dev
-       cl_user=$(do_facet mds1 \
-       "$LCTL get_param -n mdd.$MDT0.changelog_users | grep cl")
-       if [[ -n $cl_user ]]; then
-               skip "active changelog user"
-               return
-       fi
 
-       cl_user=$(do_facet mds1 $LCTL --device $MDT0 changelog_register -n)
-       echo "Registered as changelog user $cl_user"
+       changelog_register || error "changelog_register failed"
 
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
 
-       $LFS changelog_clear $MDT0 $cl_user 0
+       changelog_clear 0 || error "changelog_clear failed"
 
        # change something
        touch $DIR/$tdir/{1..10}
 
        # stop the MDT
-       stop mds1 || error "Fail to stop MDT."
+       stop $SINGLEMDS || error "Fail to stop MDT"
 
        # remount the MDT
-       start mds1 $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT."
+
+       start $SINGLEMDS $mdt_dev $MDS_MOUNT_OPTS || error "Fail to start MDT"
 
        #after mount new plainllog is used
        touch $DIR/$tdir/{11..19}
-       do_facet mds1 sync
-       local TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
-       cat_sl=$(do_facet mds1 \
-       "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
-        llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       do_facet mds1 rm $TEMP256FILE
-
-       if (( cat_sl != 2 )); then
-               do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
-               error "Changelog catalog has wrong number of slots $cat_sl"
-       fi
+       local tmpfile=$(mktemp -u $tfile.XXXXXX)
+       cat_sl=$(do_facet $SINGLEMDS "sync; \
+                $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
+                llog_reader $tmpfile | grep -c type=1064553b")
+       do_facet $SINGLEMDS llog_reader $tmpfile
 
-       $LFS changelog_clear $MDT0 $cl_user 0
+       [ $cat_sl != 2 ] && error "Changelog catalog has $cat_sl != 2 slots"
 
-       do_facet mds1 sync
-       TEMP256FILE=$(mktemp -u TEMP256XXXXXX)
-       cat_sl=$(do_facet mds1 \
-       "$DEBUGFS -R \\\"dump changelog_catalog $TEMP256FILE\\\" $mdt_dev; \
-        llog_reader $TEMP256FILE | grep \\\"type=1064553b\\\" | wc -l")
-       do_facet mds1 rm $TEMP256FILE
+       changelog_clear 0 || error "changelog_clear failed"
 
-       do_facet mds1 $LCTL --device $MDT0 changelog_deregister $cl_user
+       cat_sl=$(do_facet $SINGLEMDS "sync; \
+                $DEBUGFS -c -R 'dump changelog_catalog $tmpfile' $mdt_dev; \
+                llog_reader $tmpfile | grep -c type=1064553b; rm -f $tmpfile")
 
        if (( cat_sl == 2 )); then
                error "Empty plain llog was not deleted from changelog catalog"
-       fi
-       if (( cat_sl != 1 )); then
-               error "Active plain llog shouldn\`t be deleted from catalog"
+       elif (( cat_sl != 1 )); then
+               error "Active plain llog shouldn't be deleted from catalog"
        fi
 }
 run_test 256 "Check llog delete for empty and not full state"
 
 test_257() {
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       remote_mds_nodsh && skip "remote MDS with nodsh"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
-               skip "Need MDS version at least 2.8.55" && return
+               skip "Need MDS version at least 2.8.55"
 
        test_mkdir $DIR/$tdir
 
@@ -15741,7 +16520,7 @@ test_257() {
        stat $DIR/$tdir
 
 #define OBD_FAIL_MDS_XATTR_REP                 0x161
-       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local mdtidx=$($LFS getstripe -m $DIR/$tdir)
        local facet=mds$((mdtidx + 1))
        set_nodes_failloc $(facet_active_host $facet) 0x80000161
        getfattr -n trusted.name1 $DIR/$tdir 2> /dev/null
@@ -15785,6 +16564,45 @@ test_258b() {
 }
 run_test 258b "verify i_mutex security behavior"
 
+test_259() {
+       local file=$DIR/$tfile
+       local before
+       local after
+
+       [ "$(facet_fstype mds1)" != "ldiskfs" ] &&
+               skip "ldiskfs only test" && return
+
+       stack_trap "rm -f $file" EXIT
+
+       wait_delete_completed
+       before=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
+       echo "before: $before"
+
+       $LFS setstripe -i 0 -c 1 $file
+       dd if=/dev/zero of=$file bs=1M count=10 || error "couldn't write"
+       sync_all_data
+       after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
+       echo "after write: $after"
+
+#define OBD_FAIL_OSD_FAIL_AT_TRUNCATE          0x2301
+       do_facet ost1 $LCTL set_param fail_loc=0x2301
+       $TRUNCATE $file 0
+       after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
+       echo "after truncate: $after"
+
+       stop ost1
+       do_facet ost1 $LCTL set_param fail_loc=0
+       start ost1 $(ostdevname 1) $OST_MOUNT_OPTS || error "cannot start ost1"
+       sleep 2
+       after=$(do_facet ost1 "$LCTL get_param -n osd-*.*OST0000.kbytesfree")
+       echo "after restart: $after"
+       [ $((after - before)) -ge $(fs_log_size ost1) ] &&
+               error "missing truncate?"
+
+       return 0
+}
+run_test 259 "crash at delayed truncate"
+
 test_260() {
 #define OBD_FAIL_MDC_CLOSE               0x806
        $LCTL set_param fail_loc=0x80000806
@@ -15795,9 +16613,8 @@ run_test 260 "Check mdc_close fail"
 
 ### Data-on-MDT sanity tests ###
 test_270a() {
-
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        # create DoM file
        local dom=$DIR/$tdir/dom_file
@@ -15819,7 +16636,7 @@ test_270a() {
        [ $($LFS getstripe -c $dom) == 0 ] || error "bad stripe count"
        [ $($LFS getstripe -S $dom) == 1048576 ] || error "bad stripe size"
 
-       local mdtidx=$($GETSTRIPE -M $dom)
+       local mdtidx=$($LFS getstripe -m $dom)
        local mdtname=MDT$(printf %04x $mdtidx)
        local facet=mds$((mdtidx + 1))
        local space_check=1
@@ -15895,7 +16712,7 @@ run_test 270a "DoM: basic functionality tests"
 
 test_270b() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        local dom=$DIR/$tdir/dom_file
        local max_size=1048576
@@ -15920,7 +16737,7 @@ run_test 270b "DoM: maximum size overflow checks for DoM-only file"
 
 test_270c() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
        $LFS setstripe -E 1024K -L mdt $DIR/$tdir
@@ -15949,7 +16766,7 @@ run_test 270c "DoM: DoM EA inheritance tests"
 
 test_270d() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir
        $LFS setstripe -E 1024K -L mdt $DIR/$tdir
@@ -15971,7 +16788,7 @@ run_test 270d "DoM: change striping from DoM to RAID0"
 
 test_270e() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        mkdir -p $DIR/$tdir/dom
        mkdir -p $DIR/$tdir/norm
@@ -16012,7 +16829,7 @@ run_test 270e "DoM: lfs find with DoM files test"
 
 test_270f() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        local mdtname=${FSNAME}-MDT0000-mdtlov
        local dom=$DIR/$tdir/dom_file
@@ -16032,7 +16849,9 @@ test_270f() {
                error "Can't set directory default striping"
 
        # exceed maximum stripe size
-       $LFS setstripe -E $(($dom_limit * 2)) -L mdt $dom &&
+       $LFS setstripe -E $((dom_limit * 2)) -L mdt $dom ||
+               error "Can't create file with $((dom_limit * 2)) DoM stripe"
+       [ $($LFS getstripe -S $dom) -eq $((dom_limit * 2)) ] &&
                error "Able to create DoM component size more than LOD limit"
 
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=0
@@ -16040,6 +16859,19 @@ test_270f() {
                                                lod.$mdtname.dom_stripesize)
        [ 0 -eq ${dom_current} ] ||
                error "Can't set zero DoM stripe limit"
+       rm $dom
+
+       # attempt to create DoM file on server with disabled DoM should
+       # remove DoM entry from layout and be succeed
+       $LFS setstripe -E $dom_limit -L mdt -E -1 $dom ||
+               error "Can't create DoM file (DoM is disabled)"
+       [ $($LFS getstripe -L $dom) == "mdt" ] &&
+               error "File has DoM component while DoM is disabled"
+       rm $dom
+
+       # attempt to create DoM file with only DoM stripe should return error
+       $LFS setstripe -E $dom_limit -L mdt $dom &&
+               error "Able to create DoM-only file while DoM is disabled"
 
        # too low values to be aligned with smallest stripe size 64K
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=30000
@@ -16048,6 +16880,10 @@ test_270f() {
        [ 30000 -eq ${dom_current} ] &&
                error "Can set too small DoM stripe limit"
 
+       # 64K is a minimal stripe size in Lustre, expect limit of that size
+       [ 65536 -eq ${dom_current} ] ||
+               error "Limit is not set to 64K but ${dom_current}"
+
        do_facet mds1 $LCTL set_param -n lod.$mdtname.dom_stripesize=2147483648
        dom_current=$(do_facet mds1 $LCTL get_param -n \
                                                lod.$mdtname.dom_stripesize)
@@ -16061,7 +16897,9 @@ test_270f() {
                error "Can't create DoM component size after limit change"
        do_facet mds1 $LCTL set_param -n \
                                lod.$mdtname.dom_stripesize=$((dom_limit / 2))
-       $LFS setstripe -E $dom_limit -L mdt ${dom}_big &&
+       $LFS setstripe -E $dom_limit -L mdt ${dom}_big ||
+               error "Can't create DoM file after limit decrease"
+       [ $($LFS getstripe -S ${dom}_big) -eq $((dom_limit / 2)) ] ||
                error "Can create big DoM component after limit decrease"
        touch ${dom}_def ||
                error "Can't create file with old default layout"
@@ -16073,7 +16911,7 @@ run_test 270f "DoM: maximum DoM stripe size checks"
 
 test_271a() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        local dom=$DIR/$tdir/dom
 
@@ -16094,7 +16932,7 @@ run_test 271a "DoM: data is cached for read after write"
 
 test_271b() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+               skip "Need MDS version at least 2.10.55"
 
        local dom=$DIR/$tdir/dom
 
@@ -16113,80 +16951,320 @@ test_271b() {
        [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
        rm -f $dom
 }
-run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
+run_test 271b "DoM: no glimpse RPC for stat (DoM only file)"
+
+test_271ba() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55"
+
+       local dom=$DIR/$tdir/dom
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $dom
+
+       lctl set_param -n mdc.*.stats=clear
+       lctl set_param -n osc.*.stats=clear
+       dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
+       cancel_lru_locks mdc
+       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
+       # second stat to check size is cached on client
+       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
+       local gls=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       local gls=$(lctl get_param -n osc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
+       rm -f $dom
+}
+run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
+
+test_271c() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55"
+
+       local dom=$DIR/$tdir/dom
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
+
+       local mdtidx=$($LFS getstripe -m $DIR/$tdir)
+       local facet=mds$((mdtidx + 1))
+
+       cancel_lru_locks mdc
+       do_facet $facet lctl set_param -n mdt.*.dom_lock=0
+       createmany -o $dom 1000
+       lctl set_param -n mdc.*.stats=clear
+       smalliomany -w $dom 1000 200
+       lctl get_param -n mdc.*.stats
+       local enq=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_ibits_enqueue/ {print $2}')
+       # Each file has 1 open, 1 IO enqueues, total 2000
+       # but now we have also +1 getxattr for security.capability, total 3000
+       [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
+       unlinkmany $dom 1000
+
+       cancel_lru_locks mdc
+       do_facet $facet lctl set_param -n mdt.*.dom_lock=1
+       createmany -o $dom 1000
+       lctl set_param -n mdc.*.stats=clear
+       smalliomany -w $dom 1000 200
+       lctl get_param -n mdc.*.stats
+       local enq_2=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_ibits_enqueue/ {print $2}')
+       # Expect to see reduced amount of RPCs by 1000 due to single enqueue
+       # for OPEN and IO lock.
+       [ $((enq - enq_2)) -ge 1000 ] ||
+               error "Too many enqueues $enq_2, expected about $((enq - 1000))"
+       unlinkmany $dom 1000
+       return 0
+}
+run_test 271c "DoM: IO lock at open saves enqueue RPCs"
+
+cleanup_271def_tests() {
+       trap 0
+       rm -f $1
+}
+
+test_271d() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] &&
+               skip "Need MDS version at least 2.10.57" && return
+
+       local dom=$DIR/$tdir/dom
+       local tmp=$TMP/$tfile
+       trap "cleanup_271def_tests $tmp" EXIT
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
+
+       local mdtidx=$($GETSTRIPE -M $DIR/$tdir)
+       local facet=mds$((mdtidx + 1))
+
+       cancel_lru_locks mdc
+       dd if=/dev/urandom of=$tmp bs=1000 count=1
+       dd if=$tmp of=$dom bs=1000 count=1
+       cancel_lru_locks mdc
+
+       cat /etc/hosts >> $tmp
+       lctl set_param -n mdc.*.stats=clear
+
+       # append data to the same file it should update local page
+       echo "Append to the same page"
+       cat /etc/hosts >> $dom
+       local num=$(lctl get_param -n mdc.*.stats |
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats |
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats |
+               awk '/req_waittime/ {print $2}')
+
+       [ -z $num ] || error "$num READ RPC occured"
+       [ $ra == $rw ] || error "$((ra - rw)) resend occured"
+       echo "... DONE"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
+
+       cancel_lru_locks mdc
+       lctl set_param -n mdc.*.stats=clear
+
+       echo "Open and read file"
+       cat $dom > /dev/null
+       local num=$(lctl get_param -n mdc.*.stats |
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats |
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats |
+               awk '/req_waittime/ {print $2}')
+
+       [ -z $num ] || error "$num READ RPC occured"
+       [ $ra == $rw ] || error "$((ra - rw)) resend occured"
+       echo "... DONE"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
+
+       return 0
+}
+run_test 271d "DoM: read on open (1K file in reply buffer)"
 
-test_271ba() {
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+test_271e() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] &&
+               skip "Need MDS version at least 2.10.57" && return
 
        local dom=$DIR/$tdir/dom
+       local tmp=$TMP/${tfile}.data
+       trap "cleanup_271def_tests $tmp" EXIT
 
        mkdir -p $DIR/$tdir
 
-       $LFS setstripe -E 1024K -L mdt -E EOF $dom
+       $LFS setstripe -E 1024K -L mdt $DIR/$tdir
+
+       local mdtidx=$($GETSTRIPE -M $DIR/$tdir)
+       local facet=mds$((mdtidx + 1))
 
+       cancel_lru_locks mdc
+       dd if=/dev/urandom of=$tmp bs=30K count=1
+       dd if=$tmp of=$dom bs=30K count=1
+       cancel_lru_locks mdc
+       cat /etc/hosts >> $tmp
        lctl set_param -n mdc.*.stats=clear
-       lctl set_param -n osc.*.stats=clear
-       dd if=/dev/zero of=$dom bs=2048K count=1 || return 1
+
+       echo "Append to the same page"
+       cat /etc/hosts >> $dom
+
+       local num=$(lctl get_param -n mdc.*.stats | \
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_waittime/ {print $2}')
+
+       [ -z $num ] || error "$num READ RPC occured"
+       # Reply buffer can be adjusted for larger buffer by resend
+       echo "... DONE with $((ra - rw)) resends"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
+
        cancel_lru_locks mdc
-       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
-       # second stat to check size is cached on client
-       $CHECKSTAT -t file -s 2097152 $dom || error "stat"
-       local gls=$(lctl get_param -n mdc.*.stats |
-                       awk '/ldlm_glimpse/ {print $2}')
-       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
-       local gls=$(lctl get_param -n osc.*.stats |
-                       awk '/ldlm_glimpse/ {print $2}')
-       [ -z $gls ] || error "Unexpected $gls OSC glimpse RPCs"
-       rm -f $dom
-}
-run_test 271ba "DoM: no glimpse RPC for stat (combined file)"
+       lctl set_param -n mdc.*.stats=clear
 
-test_271c() {
-       # test to be enabled with lock_convert
-       skip "skipped until lock convert will be implemented" && return
+       echo "Open and read file"
+       cat $dom > /dev/null
+       local num=$(lctl get_param -n mdc.*.stats | \
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_waittime/ {print $2}')
 
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
-               skip "Need MDS version at least 2.10.55" && return
+       [ -z $num ] || error "$num READ RPC occured"
+       # Reply buffer can be adjusted for larger buffer by resend
+       echo "... DONE with $((ra - rw)) resends"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
+
+       return 0
+}
+run_test 271e "DoM: read on open (30K file with reply buffer adjusting)"
+
+test_271f() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.57) ] &&
+               skip "Need MDS version at least 2.10.57" && return
 
        local dom=$DIR/$tdir/dom
+       local tmp=$TMP/$tfile
+       trap "cleanup_271def_tests $tmp" EXIT
 
        mkdir -p $DIR/$tdir
 
        $LFS setstripe -E 1024K -L mdt $DIR/$tdir
 
-       local mdtidx=$($LFS getstripe -M $DIR/$tdir)
+       local mdtidx=$($GETSTRIPE -M $DIR/$tdir)
        local facet=mds$((mdtidx + 1))
 
        cancel_lru_locks mdc
-       do_facet $facet lctl set_param -n mdt.*.dom_lock=0
-       createmany -o $dom 1000
+       dd if=/dev/urandom of=$tmp bs=200000 count=1
+       dd if=$tmp of=$dom bs=200000 count=1
+       cancel_lru_locks mdc
+       cat /etc/hosts >> $tmp
        lctl set_param -n mdc.*.stats=clear
-       smalliomany -w $dom 1000 200
-       lctl get_param -n mdc.*.stats
-       local enq=$(lctl get_param -n mdc.*.stats |
-                       awk '/ldlm_ibits_enqueue/ {print $2}')
-       # Each file has 1 open, 1 IO enqueues, total 2000
-       # but now we have also +1 getxattr for security.capability, total 3000
-       [ $enq -ge 2000 ] || error "Too few enqueues $enq, expected > 2000"
-       unlinkmany $dom 1000
+
+       echo "Append to the same page"
+       cat /etc/hosts >> $dom
+       local num=$(lctl get_param -n mdc.*.stats | \
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_waittime/ {print $2}')
+
+       [ -z $num ] || error "$num READ RPC occured"
+       [ $ra == $rw ] || error "$((ra - rw)) resend occured"
+       echo "... DONE"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
 
        cancel_lru_locks mdc
-       do_facet $facet lctl set_param -n mdt.*.dom_lock=1
-       createmany -o $dom 1000
        lctl set_param -n mdc.*.stats=clear
-       smalliomany -w $dom 1000 200
-       lctl get_param -n mdc.*.stats
-       local enq_2=$(lctl get_param -n mdc.*.stats |
-                       awk '/ldlm_ibits_enqueue/ {print $2}')
-       # Expect to see reduced amount of RPCs by 1000 due to single enqueue
-       # for OPEN and IO lock.
-       [ $((enq - enq_2)) -ge 1000 ] ||
-               error "Too many enqueues $enq_2, expected about $((enq - 1000))"
-       unlinkmany $dom 1000
+
+       echo "Open and read file"
+       cat $dom > /dev/null
+       local num=$(lctl get_param -n mdc.*.stats | \
+               awk '/ost_read/ {print $2}')
+       local ra=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_active/ {print $2}')
+       local rw=$(lctl get_param -n mdc.*.stats | \
+               awk '/req_waittime/ {print $2}')
+
+       [ $num -eq 1 ] || error "expect 1 READ RPC, $num occured"
+       [ $ra == $rw ] || error "$((ra - rw)) resend occured"
+       echo "... DONE"
+
+       # compare content
+       cmp $tmp $dom || error "file miscompare"
+
        return 0
 }
-run_test 271c "DoM: IO lock at open saves enqueue RPCs"
+run_test 271f "DoM: read on open (200K file and read tail)"
+
+test_275() {
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       [ $(lustre_version_code ost1) -lt $(version_code 2.10.57) ] &&
+               skip "Need OST version >= 2.10.57"
+
+       local file=$DIR/$tfile
+       local oss
+
+       oss=$(comma_list $(osts_nodes))
+
+       dd if=/dev/urandom of=$file bs=1M count=2 ||
+               error "failed to create a file"
+       cancel_lru_locks osc
+
+       #lock 1
+       dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
+               error "failed to read a file"
+
+#define OBD_FAIL_LDLM_PAUSE_CANCEL2      0x31f
+       $LCTL set_param fail_loc=0x8000031f
+
+       cancel_lru_locks osc &
+       sleep 1
+
+#define OBD_FAIL_LDLM_PROLONG_PAUSE      0x32b
+       do_nodes $oss $LCTL set_param fail_loc=0x8000032b
+       #IO takes another lock, but matches the PENDING one
+       #and places it to the IO RPC
+       dd if=$file of=/dev/null bs=1M count=1 iflag=direct ||
+               error "failed to read a file with PENDING lock"
+}
+run_test 275 "Read on a canceled duplicate lock"
+
+test_276() {
+       remote_ost_nodsh && skip "remote OST with nodsh"
+       local pid
+
+       do_facet ost1 "(while true; do \
+               $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \
+               done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" &
+       pid=$!
+
+       for LOOP in $(seq 20); do
+               stop ost1
+               start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
+       done
+       kill -9 $pid
+       do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \
+               rm $TMP/sanity_276_pid"
+}
+run_test 276 "Race between mount and obd_statfs"
 
 cleanup_test_300() {
        trap 0
@@ -16202,7 +17280,7 @@ test_striped_dir() {
        SAVE_UMASK=$(umask)
        trap cleanup_test_300 RETURN EXIT
 
-       $LFS setdirstripe -i $mdt_index -c 2 -t all_char -m 755 \
+       $LFS setdirstripe -i $mdt_index -c 2 -H all_char -o 755 \
                                                $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
@@ -16262,9 +17340,9 @@ test_striped_dir() {
 
 test_300a() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
-               skip "skipped for lustre < 2.7.0" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "skipped for lustre < 2.7.0"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        test_striped_dir 0 || error "failed on striped dir on MDT0"
        test_striped_dir 1 || error "failed on striped dir on MDT0"
@@ -16273,31 +17351,28 @@ run_test 300a "basic striped dir sanity test"
 
 test_300b() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
-               skip "skipped for lustre < 2.7.0" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "skipped for lustre < 2.7.0"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local i
        local mtime1
        local mtime2
        local mtime3
 
-       test_mkdir $DIR/$tdir
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       test_mkdir $DIR/$tdir || error "mkdir fail"
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
-       for ((i=0; i<10; i++)); do
+       for i in {0..9}; do
                mtime1=$(stat -c %Y $DIR/$tdir/striped_dir)
                sleep 1
-               touch $DIR/$tdir/striped_dir/file_$i ||
-                                       error "touch error $i"
+               touch $DIR/$tdir/striped_dir/file_$i || error "touch error $i"
                mtime2=$(stat -c %Y $DIR/$tdir/striped_dir)
-               [ $mtime1 -eq $mtime2 ] &&
-                       error "mtime not change after create"
+               [ $mtime1 -eq $mtime2 ] && error "mtime unchanged after create"
                sleep 1
-               rm -f $DIR/$tdir/striped_dir/file_$i ||
-                                       error "unlink error $i"
+               rm -f $DIR/$tdir/striped_dir/file_$i || error "unlink error $i"
                mtime3=$(stat -c %Y $DIR/$tdir/striped_dir)
-               [ $mtime2 -eq $mtime3 ] &&
-                       error "mtime did not change after unlink"
+               [ $mtime2 -eq $mtime3 ] && error "mtime unchanged after unlink"
        done
        true
 }
@@ -16305,9 +17380,10 @@ run_test 300b "check ctime/mtime for striped dir"
 
 test_300c() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
-               skip "skipped for lustre < 2.7.0" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "skipped for lustre < 2.7.0"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local file_count
 
        mkdir -p $DIR/$tdir
@@ -16330,9 +17406,10 @@ run_test 300c "chown && check ls under striped directory"
 
 test_300d() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.0) ] &&
-               skip "skipped for lustre < 2.7.0" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "skipped for lustre < 2.7.0"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local stripe_count
        local file
 
@@ -16340,7 +17417,7 @@ test_300d() {
        $SETSTRIPE -c 2 $DIR/$tdir
 
        #local striped directory
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
        createmany -o $DIR/$tdir/striped_dir/f 10 ||
                error "create 10 files failed"
@@ -16352,7 +17429,7 @@ test_300d() {
                error "create 10 files failed"
 
        for file in $(find $DIR/$tdir); do
-               stripe_count=$($GETSTRIPE -c $file)
+               stripe_count=$($LFS getstripe -c $file)
                [ $stripe_count -eq 2 ] ||
                        error "wrong stripe $stripe_count for $file"
        done
@@ -16363,15 +17440,16 @@ run_test 300d "check default stripe under striped directory"
 
 test_300e() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+
        local stripe_count
        local file
 
        mkdir -p $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        touch $DIR/$tdir/striped_dir/a
@@ -16382,13 +17460,13 @@ test_300e() {
        mkdir $DIR/$tdir/striped_dir/dir_b
        mkdir $DIR/$tdir/striped_dir/dir_c
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_a ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_a ||
                error "set striped adir under striped dir error"
 
        $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_b ||
                error "set striped bdir under striped dir error"
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir/stp_c ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir/stp_c ||
                error "set striped cdir under striped dir error"
 
        mrename $DIR/$tdir/striped_dir/dir_a $DIR/$tdir/striped_dir/dir_b ||
@@ -16408,20 +17486,21 @@ test_300e() {
 run_test 300e "check rename under striped directory"
 
 test_300f() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local stripe_count
        local file
 
        rm -rf $DIR/$tdir
        mkdir -p $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
-       $LFS setdirstripe -i 0 -c 2 -t all_char $DIR/$tdir/striped_dir1 ||
+       $LFS setdirstripe -i 0 -c 2 -H all_char $DIR/$tdir/striped_dir1 ||
                error "set striped dir error"
 
        touch $DIR/$tdir/striped_dir/a
@@ -16497,9 +17576,10 @@ test_300_check_default_striped_dir()
 }
 
 test_300g() {
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local dir
        local stripe_count
        local stripe_index
@@ -16548,15 +17628,15 @@ test_300g() {
 run_test 300g "check default striped directory for normal directory"
 
 test_300h() {
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local dir
        local stripe_count
 
        mkdir $DIR/$tdir
-       $LFS setdirstripe -i 0 -c $MDSCOUNT -t all_char \
-                                       $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        test_300_check_default_striped_dir striped_dir $MDSCOUNT 1
@@ -16578,16 +17658,17 @@ test_300h() {
 run_test 300h "check default striped directory for striped directory"
 
 test_300i() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local stripe_count
        local file
 
        mkdir $DIR/$tdir
 
-       $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        createmany -o $DIR/$tdir/striped_dir/f- 10 ||
@@ -16632,10 +17713,11 @@ test_300i() {
 run_test 300i "client handle unknown hash type striped directory"
 
 test_300j() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local stripe_count
        local file
 
@@ -16643,7 +17725,7 @@ test_300j() {
 
        #define OBD_FAIL_SPLIT_UPDATE_REC       0x1702
        $LCTL set_param fail_loc=0x1702
-       $LFS setdirstripe -i 0 -c$MDSCOUNT -t all_char $DIR/$tdir/striped_dir ||
+       $LFS setdirstripe -i 0 -c$MDSCOUNT -H all_char $DIR/$tdir/striped_dir ||
                error "set striped dir error"
 
        createmany -o $DIR/$tdir/striped_dir/f- 10 ||
@@ -16658,10 +17740,11 @@ test_300j() {
 run_test 300j "test large update record"
 
 test_300k() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local stripe_count
        local file
 
@@ -16683,10 +17766,11 @@ test_300k() {
 run_test 300k "test large striped directory"
 
 test_300l() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local stripe_index
 
        test_mkdir -p $DIR/$tdir/striped_dir
@@ -16706,10 +17790,10 @@ test_300l() {
 run_test 300l "non-root user to create dir under striped dir with stale layout"
 
 test_300m() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -ge 2 ] && skip_env "Only for single MDT"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -ge 2 ] && skip "Only for single MDT" && return
+               skip "Need MDS version at least 2.7.55"
 
        mkdir -p $DIR/$tdir/striped_dir
        $LFS setdirstripe -D -c 1 $DIR/$tdir/striped_dir ||
@@ -16748,11 +17832,11 @@ cleanup_300n() {
 }
 
 test_300n() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip "Need MDS version at least 2.7.55"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        local stripe_index
        local list=$(comma_list $(mdts_nodes))
@@ -16791,10 +17875,11 @@ test_300n() {
 run_test 300n "non-root user to create dir under striped dir with default EA"
 
 test_300o() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.7.55) ] &&
-               skip "Need MDS version at least 2.7.55" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+               skip "Need MDS version at least 2.7.55"
+
        local numfree1
        local numfree2
 
@@ -16804,14 +17889,12 @@ test_300o() {
        numfree2=$(lctl get_param -n mdc.*MDT0001*.filesfree)
        if [ $numfree1 -lt 66000 -o $numfree2 -lt 66000 ]; then
                skip "not enough free inodes $numfree1 $numfree2"
-               return
        fi
 
        numfree1=$(lctl get_param -n mdc.*MDT0000-mdc-*.kbytesfree)
        numfree2=$(lctl get_param -n mdc.*MDT0001-mdc-*.kbytesfree)
        if [ $numfree1 -lt 300000 -o $numfree2 -lt 300000 ]; then
                skip "not enough free space $numfree1 $numfree2"
-               return
        fi
 
        $LFS setdirstripe -c2 $DIR/$tdir/striped_dir ||
@@ -16829,16 +17912,16 @@ test_300o() {
 run_test 300o "unlink big sub stripe(> 65000 subdirs)"
 
 test_300p() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        mkdir -p $DIR/$tdir
 
        #define OBD_FAIL_OUT_ENOSPC     0x1704
        do_facet mds2 lctl set_param fail_loc=0x80001704
-       $LFS setdirstripe -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 &&
-                       error "create striped directory should fail"
+       $LFS setdirstripe -i 0 -c2 $DIR/$tdir/bad_striped_dir > /dev/null 2>&1 \
+                && error "create striped directory should fail"
 
        [ -e $DIR/$tdir/bad_striped_dir ] && error "striped dir exists"
 
@@ -16848,8 +17931,8 @@ test_300p() {
 run_test 300p "create striped directory without space"
 
 test_300q() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
 
        local fd=$(free_fd)
        local cmd="exec $fd<$tdir"
@@ -16871,7 +17954,8 @@ prepare_remote_file() {
        mkdir $DIR/$tdir/src_dir ||
                error "create remote source failed"
 
-       cp /etc/hosts $DIR/$tdir/src_dir/a || error
+       cp /etc/hosts $DIR/$tdir/src_dir/a ||
+                error "cp to remote source failed"
        touch $DIR/$tdir/src_dir/a
 
        $LFS mkdir -i 1 $DIR/$tdir/tgt_dir ||
@@ -16893,8 +17977,9 @@ prepare_remote_file() {
 }
 
 test_310a() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local remote_file=$DIR/$tdir/tgt_dir/b
 
        mkdir -p $DIR/$tdir
@@ -16902,14 +17987,16 @@ test_310a() {
        prepare_remote_file || error "prepare remote file failed"
 
        #open-unlink file
-       $OPENUNLINK $remote_file $remote_file || error
-       $CHECKSTAT -a $remote_file || error
+       $OPENUNLINK $remote_file $remote_file ||
+               error "openunlink $remote_file failed"
+       $CHECKSTAT -a $remote_file || error "$remote_file exists"
 }
 run_test 310a "open unlink remote file"
 
 test_310b() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 4 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 4 MDTs"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+
        local remote_file=$DIR/$tdir/tgt_dir/b
 
        mkdir -p $DIR/$tdir
@@ -16923,8 +18010,9 @@ test_310b() {
 run_test 310b "unlink remote file with multiple links while open"
 
 test_310c() {
-       [[ $MDSCOUNT -lt 4 ]] && skip "needs >= 4 MDTs" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [[ $MDSCOUNT -lt 4 ]] && skip_env "needs >= 4 MDTs"
+
        local remote_file=$DIR/$tdir/tgt_dir/b
 
        mkdir -p $DIR/$tdir
@@ -16943,10 +18031,11 @@ run_test 310c "open-unlink remote file with multiple links"
 
 #LU-4825
 test_311() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.54) ] &&
-               skip "lustre < 2.8.54 does not contain LU-4825 fix" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip "lustre < 2.8.54 does not contain LU-4825 fix"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        local old_iused=$($LFS df -i | grep OST0000 | awk '{ print $3 }')
 
@@ -17029,10 +18118,9 @@ zfs_object_blksz() {
 }
 
 test_312() { # LU-4856
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-
+       remote_ost_nodsh && skip "remote OST with nodsh"
        [ $(facet_fstype ost1) = "zfs" ] ||
-               { skip "the test only applies to zfs" && return; }
+               skip_env "the test only applies to zfs"
 
        local max_blksz=$(do_facet ost1 \
                          $ZFS get -p recordsize $(facet_device ost1) |
@@ -17097,7 +18185,7 @@ test_312() { # LU-4856
 run_test 312 "make sure ZFS adjusts its block size by write pattern"
 
 test_313() {
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        local file=$DIR/$tfile
        rm -f $file
@@ -17113,6 +18201,8 @@ test_313() {
 run_test 313 "io should fail after last_rcvd update fail"
 
 test_314() {
+       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs"
+
        $SETSTRIPE -c 2 -i 0 $DIR/$tfile || error "setstripe failed"
        do_facet ost1 "$LCTL set_param fail_loc=0x720"
        rm -f $DIR/$tfile
@@ -17139,6 +18229,86 @@ test_315() { # LU-618
 }
 run_test 315 "read should be accounted"
 
+test_316() {
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       large_xattr_enabled || skip_env "ea_inode feature disabled"
+
+       rm -rf $DIR/$tdir/d
+       mkdir -p $DIR/$tdir/d
+       chown nobody $DIR/$tdir/d
+       touch $DIR/$tdir/d/file
+
+       $LFS mv -M1 $DIR/$tdir/d || error "lfs mv failed"
+}
+run_test 316 "lfs mv"
+
+test_317() {
+       local trunc_sz
+       local grant_blk_size
+
+       if [ "$(facet_fstype $facet)" == "zfs" ]; then
+               skip "LU-10370: no implementation for ZFS" && return
+       fi
+
+       stack_trap "rm -f $DIR/$tfile" EXIT
+       grant_blk_size=$($LCTL get_param osc.$FSNAME*.import |
+                       awk '/grant_block_size:/ { print $2; exit; }')
+       #
+       # Create File of size 5M. Truncate it to below size's and verify
+       # blocks count.
+       #
+       dd if=/dev/zero of=$DIR/$tfile bs=5M count=1 conv=fsync ||
+               error "Create file : $DIR/$tfile"
+
+       for trunc_sz in 2097152 4097 4000 509 0; do
+               $TRUNCATE $DIR/$tfile $trunc_sz ||
+                       error "truncate $tfile to $trunc_sz failed"
+               local sz=$(stat --format=%s $DIR/$tfile)
+               local blk=$(stat --format=%b $DIR/$tfile)
+               local trunc_blk=$((((trunc_sz + (grant_blk_size - 1) ) /
+                                    grant_blk_size) * 8))
+
+               if [[ $blk -ne $trunc_blk ]]; then
+                       $(which stat) $DIR/$tfile
+                       error "Expected Block $trunc_blk got $blk for $tfile"
+               fi
+
+               $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
+                       error "Expected Size $trunc_sz got $sz for $tfile"
+       done
+
+       #
+       # sparse file test
+       # Create file with a hole and write actual two blocks. Block count
+       # must be 16.
+       #
+       dd if=/dev/zero of=$DIR/$tfile bs=$grant_blk_size count=2 seek=5 \
+               conv=fsync || error "Create file : $DIR/$tfile"
+
+       # Calculate the final truncate size.
+       trunc_sz=$(($(stat --format=%s $DIR/$tfile) - (grant_blk_size + 1)))
+
+       #
+       # truncate to size $trunc_sz bytes. Strip the last block
+       # The block count must drop to 8
+       #
+       $TRUNCATE $DIR/$tfile $trunc_sz ||
+               error "truncate $tfile to $trunc_sz failed"
+
+       local trunc_bsz=$((grant_blk_size / $(stat --format=%B $DIR/$tfile)))
+       sz=$(stat --format=%s $DIR/$tfile)
+       blk=$(stat --format=%b $DIR/$tfile)
+
+       if [[ $blk -ne $trunc_bsz ]]; then
+               $(which stat) $DIR/$tfile
+               error "Expected Block $trunc_bsz got $blk for $tfile"
+       fi
+
+       $CHECKSTAT -s $trunc_sz $DIR/$tfile ||
+               error "Expected Size $trunc_sz got $sz for $tfile"
+}
+run_test 317 "Verify blocks get correctly update after truncate"
+
 test_fake_rw() {
        local read_write=$1
        if [ "$read_write" = "write" ]; then
@@ -17198,33 +18368,32 @@ test_fake_rw() {
        rm -f $DIR/$tfile
 }
 test_399a() { # LU-7655 for OST fake write
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
+       remote_ost_nodsh && skip "remote OST with nodsh"
 
        test_fake_rw write
 }
 run_test 399a "fake write should not be slower than normal write"
 
 test_399b() { # LU-8726 for OST fake read
-       remote_ost_nodsh && skip "remote OST with nodsh" && return
-
+       remote_ost_nodsh && skip "remote OST with nodsh"
        if [ "$(facet_fstype ost1)" != "ldiskfs" ]; then
-               skip "ldiskfs only test" && return 0
+               skip_env "ldiskfs only test"
        fi
+
        test_fake_rw read
 }
 run_test 399b "fake read should not be slower than normal read"
 
 test_400a() { # LU-1606, was conf-sanity test_74
+       if ! which $CC > /dev/null 2>&1; then
+               skip_env "$CC is not installed"
+       fi
+
        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/include"
@@ -17253,7 +18422,6 @@ test_400b() { # LU-1606, LU-5011
 
        if ! which $CC > /dev/null 2>&1; then
                skip_env "$CC is not installed"
-               return 0
        fi
 
        for header in $prefix/*.h; do
@@ -17274,8 +18442,8 @@ run_test 400b "packaged headers can be compiled"
 
 test_401a() { #LU-7437
        local printf_arg=$(find -printf 2>&1 | grep "unrecognized:")
-       [ -n "$printf_arg" ] && skip_env "find does not support -printf" &&
-               return
+       [ -n "$printf_arg" ] && skip_env "find does not support -printf"
+
        #count the number of parameters by "list_param -R"
        local params=$($LCTL list_param -R '*' 2>/dev/null | wc -l)
        #count the number of parameters by listing proc files
@@ -17374,9 +18542,9 @@ test_402() {
                $server_version -lt $(version_code 2.7.50) ]] ||
        [[ $server_version -ge $(version_code 2.7.2) &&
                $server_version -lt $(version_code 2.7.11) ]] ||
-               { skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+";
-                       return; }
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip "Need MDS version 2.7.2+ or 2.7.18.4+ or 2.7.66+"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
+
        $LFS setdirstripe -i 0 $DIR/$tdir || error "setdirstripe -i 0 failed"
 #define OBD_FAIL_MDS_FLD_LOOKUP 0x15c
        do_facet mds1 "lctl set_param fail_loc=0x8000015c"
@@ -17417,9 +18585,9 @@ run_test 403 "i_nlink should not drop to zero due to aliasing"
 test_404() { # LU-6601
        local server_version=$(lustre_version_code $SINGLEMDS)
        [[ $server_version -ge $(version_code 2.8.53) ]] ||
-               { skip "Need server version newer than 2.8.52"; return 0; }
+               skip "Need server version newer than 2.8.52"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
        local mosps=$(do_facet $SINGLEMDS $LCTL dl |
                awk '/osp .*-osc-MDT/ { print $4}')
 
@@ -17448,9 +18616,8 @@ run_test 404 "validate manual {de}activated works properly for OSPs"
 test_405() {
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.6.92) -o \
        [ $(lustre_version_code client) -lt $(version_code 2.6.99) ] &&
-               skip "Layout swap lock is not supported" && return
-
-       check_swap_layouts_support && return 0
+               skip "Layout swap lock is not supported"
+       check_swap_layouts_support
 
        test_mkdir $DIR/$tdir
        swap_lock_test -d $DIR/$tdir ||
@@ -17459,17 +18626,14 @@ test_405() {
 run_test 405 "Various layout swap lock tests"
 
 test_406() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       [ $OSTCOUNT -lt 2 ] && skip "needs >= 2 OSTs" && return
-       [ -n "$FILESET" ] && skip "SKIP due to FILESET set" && return
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
+       [ -n "$FILESET" ] && skip "SKIP due to FILESET set"
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.50) ] &&
-               skip "Need MDS version at least 2.8.50" && return
+               skip "Need MDS version at least 2.8.50"
 
-       local def_stripe_count=$($GETSTRIPE -c $MOUNT)
-       local def_stripe_size=$($GETSTRIPE -S $MOUNT)
-       local def_stripe_offset=$($GETSTRIPE -i $MOUNT)
-       local def_pool=$($GETSTRIPE -p $MOUNT)
+       local def_stripe_size=$($LFS getstripe -S $MOUNT)
        local test_pool=$TESTNAME
 
        if ! combined_mgs_mds ; then
@@ -17479,60 +18643,51 @@ test_406() {
        pool_add_targets $test_pool 0 $(($OSTCOUNT - 1)) 1 ||
                error "pool_add_targets failed"
 
+       save_layout_restore_at_exit $MOUNT
+
        # parent set default stripe count only, child will stripe from both
        # parent and fs default
-       $SETSTRIPE -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
+       $LFS setstripe -c 1 -i 1 -S $((def_stripe_size * 2)) -p $test_pool $MOUNT ||
                error "setstripe $MOUNT failed"
        $LFS mkdir -c $MDSCOUNT $DIR/$tdir || error "mkdir $tdir failed"
-       $SETSTRIPE -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
+       $LFS setstripe -c $OSTCOUNT $DIR/$tdir || error "setstripe $tdir failed"
        for i in $(seq 10); do
                local f=$DIR/$tdir/$tfile.$i
                touch $f || error "touch failed"
-               local count=$($GETSTRIPE -c $f)
+               local count=$($LFS getstripe -c $f)
                [ $count -eq $OSTCOUNT ] ||
                        error "$f stripe count $count != $OSTCOUNT"
-               local offset=$($GETSTRIPE -i $f)
+               local offset=$($LFS getstripe -i $f)
                [ $offset -eq 1 ] || error "$f stripe offset $offset != 1"
-               local size=$($GETSTRIPE -S $f)
+               local size=$($LFS getstripe -S $f)
                [ $size -eq $((def_stripe_size * 2)) ] ||
                        error "$f stripe size $size != $((def_stripe_size * 2))"
-               local pool=$($GETSTRIPE -p $f)
+               local pool=$($LFS getstripe -p $f)
                [ $pool == $test_pool ] || error "$f pool $pool != $test_pool"
        done
 
        # change fs default striping, delete parent default striping, now child
        # will stripe from new fs default striping only
-       $SETSTRIPE -c 1 -S $def_stripe_size -i 0 $MOUNT ||
+       $LFS setstripe -c 1 -S $def_stripe_size -i 0 $MOUNT ||
                error "change $MOUNT default stripe failed"
-       $SETSTRIPE -c 0 $DIR/$tdir || error "delete $tdir default stripe failed"
+       $LFS setstripe -c 0 $DIR/$tdir ||
+               error "delete $tdir default stripe failed"
        for i in $(seq 11 20); do
                local f=$DIR/$tdir/$tfile.$i
                touch $f || error "touch $f failed"
-               local count=$($GETSTRIPE -c $f)
+               local count=$($LFS getstripe -c $f)
                [ $count -eq 1 ] || error "$f stripe count $count != 1"
-               local offset=$($GETSTRIPE -i $f)
+               local offset=$($LFS getstripe -i $f)
                [ $offset -eq 0 ] || error "$f stripe offset $offset != 0"
-               local size=$($GETSTRIPE -S $f)
+               local size=$($LFS getstripe -S $f)
                [ $size -eq $def_stripe_size ] ||
                        error "$f stripe size $size != $def_stripe_size"
-               local pool=$($GETSTRIPE -p $f)
+               local pool=$($LFS getstripe -p $f)
                [ $pool == $test_pool ] || error "$f pool $pool isn't set"
-
        done
 
        unlinkmany $DIR/$tdir/$tfile. 1 20
 
-       # restore FS default striping
-       if [ -z $def_pool ]; then
-               $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
-                       -i $def_stripe_offset $MOUNT ||
-                       error "restore default striping failed"
-       else
-               $SETSTRIPE -c $def_stripe_count -S $def_stripe_size \
-                       -i $def_stripe_offset -p $def_pool $MOUNT ||
-                       error "restore default striping with $def_pool failed"
-       fi
-
        local f=$DIR/$tdir/$tfile
        pool_remove_all_targets $test_pool $f
        pool_remove $test_pool $f
@@ -17544,10 +18699,10 @@ test_406() {
 run_test 406 "DNE support fs default striping"
 
 test_407() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.55) ]] &&
-               skip "Need MDS version at least 2.8.55" && return
-       remote_mds_nodsh && skip "remote MDS with nodsh" && return
+               skip "Need MDS version at least 2.8.55"
+       remote_mds_nodsh && skip "remote MDS with nodsh"
 
        $LFS mkdir -i 0 -c 1 $DIR/$tdir.0 ||
                error "$LFS mkdir -i 0 -c 1 $tdir.0 failed"
@@ -17588,9 +18743,7 @@ run_test 408 "drop_caches should not hang due to page leaks"
 
 test_409()
 {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDTs for this test" && return
-
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        check_mount_and_prep
 
        mkdir -p $DIR/$tdir || error "(0) Fail to mkdir"
@@ -17621,7 +18774,7 @@ run_test 409 "Large amount of cross-MDTs hard links on the same file"
 test_410()
 {
        [[ $(lustre_version_code client) -lt $(version_code 2.9.59) ]] &&
-               skip "Need client version at least 2.9.59" && return
+               skip "Need client version at least 2.9.59"
 
        # Create a file, and stat it from the kernel
        local testfile=$DIR/$tfile
@@ -17651,7 +18804,7 @@ test_411() {
        local cg_basedir=/sys/fs/cgroup/memory
        # LU-9966
        test -f "$cg_basedir/memory.kmem.limit_in_bytes" ||
-               { skip "no setup for cgroup"; return; }
+               skip "no setup for cgroup"
 
        dd if=/dev/zero of=$DIR/$tfile bs=1M count=100 conv=fsync ||
                error "test file creation failed"
@@ -17675,29 +18828,115 @@ test_411() {
 run_test 411 "Slab allocation error with cgroup does not LBUG"
 
 test_412() {
-       [ $MDSCOUNT -lt 2 ] &&
-               skip "We need at least 2 MDTs for this test" && return
-
+       [ $MDSCOUNT -lt 2 ] && skip_env "needs >= 2 MDTs"
        if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
-               skip "Need server version at least 2.10.55" & exit 0
+               skip "Need server version at least 2.10.55"
        fi
 
        $LFS mkdir -i $((MDSCOUNT - 1)),$((MDSCOUNT - 2)) $DIR/$tdir ||
                error "mkdir failed"
        $LFS getdirstripe $DIR/$tdir
-       stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
+       local stripe_index=$($LFS getdirstripe -i $DIR/$tdir)
        [ $stripe_index -eq $((MDSCOUNT - 1)) ] ||
                error "expect $((MDSCOUT - 1)) get $stripe_index"
-       stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
+       local stripe_count=$($LFS getdirstripe -T $DIR/$tdir)
        [ $stripe_count -eq 2 ] ||
                error "expect 2 get $stripe_count"
 }
 run_test 412 "mkdir on specific MDTs"
 
+test_413() {
+       [ $MDSCOUNT -lt 2 ] &&
+               skip "We need at least 2 MDTs for this test"
+
+       if [ $(lustre_version_code mds1) -lt $(version_code 2.10.55) ]; then
+               skip "Need server version at least 2.10.55"
+       fi
+
+       mkdir $DIR/$tdir || error "mkdir failed"
+
+       # find MDT that is the most full
+       local max=$($LFS df | grep MDT |
+               awk 'BEGIN { a=0 }
+                       { sub("%", "", $5)
+                         if (0+$5 >= a)
+                         {
+                               a = $5
+                               b = $6
+                         }
+                       }
+                    END { split(b, c, ":")
+                          sub("]", "", c[2])
+                          print c[2]
+                        }')
+
+       for i in $(seq $((MDSCOUNT - 1))); do
+               $LFS mkdir -c $i $DIR/$tdir/d$i ||
+                       error "mkdir d$i failed"
+               $LFS getdirstripe $DIR/$tdir/d$i
+               local stripe_index=$($LFS getdirstripe -i $DIR/$tdir/d$i)
+               [ $stripe_index -ne $max ] ||
+                       error "don't expect $max"
+       done
+}
+run_test 413 "mkdir on less full MDTs"
+
+test_414() {
+#define OBD_FAIL_PTLRPC_BULK_ATTACH      0x521
+       $LCTL set_param fail_loc=0x80000521
+       dd if=/dev/zero of=$DIR/$tfile bs=2M count=1 oflag=sync
+       rm -f $DIR/$tfile
+}
+run_test 414 "simulate ENOMEM in ptlrpc_register_bulk()"
+
+test_415() {
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       [ $(lustre_version_code mds1) -lt $(version_code 2.11.52) ] &&
+               skip "Need server version at least 2.11.52"
+
+       # LU-11102
+       local total
+       local setattr_pid
+       local start_time
+       local end_time
+       local duration
+
+       total=500
+       # this test may be slow on ZFS
+       [ "$(facet_fstype mds1)" == "zfs" ] && total=100
+
+       # though this test is designed for striped directory, let's test normal
+       # directory too since lock is always saved as CoS lock.
+       test_mkdir $DIR/$tdir || error "mkdir $tdir"
+       createmany -o $DIR/$tdir/$tfile. $total || error "createmany"
+
+       (
+               while true; do
+                       touch $DIR/$tdir
+               done
+       ) &
+       setattr_pid=$!
+
+       start_time=$(date +%s)
+       for i in $(seq $total); do
+               mrename $DIR/$tdir/$tfile.$i $DIR/$tdir/$tfile-new.$i \
+                       > /dev/null
+       done
+       end_time=$(date +%s)
+       duration=$((end_time - start_time))
+
+       kill -9 $setattr_pid
+
+       echo "rename $total files took $duration sec"
+       [ $duration -lt 100 ] || error "rename took $duration sec"
+}
+run_test 415 "lock revoke is not missing"
+
 prep_801() {
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
-               skip "Need server version at least 2.9.55" & exit 0
+               skip "Need server version at least 2.9.55"
+
        start_full_debug_logging
 }
 
@@ -17865,7 +19104,7 @@ test_801b() {
 run_test 801b "modification will be blocked by write barrier"
 
 test_801c() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
 
        prep_801
 
@@ -17922,7 +19161,9 @@ test_802() {
 
        [[ $(lustre_version_code mds1) -lt $(version_code 2.9.55) ]] ||
        [[ $(lustre_version_code ost1) -lt $(version_code 2.9.55) ]] &&
-               skip "Need server version at least 2.9.55" & exit 0
+               skip "Need server version at least 2.9.55"
+
+       [[ $ENABLE_QUOTA ]] && skip "Quota enabled for read-only test"
 
        mkdir $DIR/$tdir || error "(1) fail to mkdir"
 
@@ -17963,9 +19204,9 @@ test_802() {
 run_test 802 "simulate readonly device"
 
 test_803() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
-               skip "MDS needs to be newer than 2.10.54" && return
+               skip "MDS needs to be newer than 2.10.54"
 
        mkdir -p $DIR/$tdir
        # Create some objects on all MDTs to trigger related logs objects
@@ -17975,7 +19216,7 @@ test_803() {
                        error "Fail to create $DIR/$tdir/dir${idx}"
        done
 
-       sync; sleep 5
+       sync; sleep 3
        echo "before create:"
        $LFS df -i $MOUNT
        local before_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
@@ -17985,7 +19226,7 @@ test_803() {
                        error "Fail to create $DIR/$tdir/foo$i"
        done
 
-       sync; sleep 5
+       sync; sleep 3
        echo "after create:"
        $LFS df -i $MOUNT
        local after_used=$($LFS df -i | grep MDT0000_UUID | awk '{print $3}')
@@ -17998,6 +19239,7 @@ test_803() {
                        error "Fail to remove $DIR/$tdir/foo$i"
        done
 
+       sleep 3 # avoid MDT return cached statfs
        wait_delete_completed
        echo "after unlink:"
        $LFS df -i $MOUNT
@@ -18010,12 +19252,11 @@ test_803() {
 run_test 803 "verify agent object for remote object"
 
 test_804() {
-       [[ $MDSCOUNT -lt 2 ]] && skip "needs >= 2 MDTs" && return
+       [[ $MDSCOUNT -lt 2 ]] && skip_env "needs >= 2 MDTs"
        [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.54) ] &&
-               skip "MDS needs to be newer than 2.10.54" && return
-
+               skip "MDS needs to be newer than 2.10.54"
        [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return 0
+               skip_env "ldiskfs only test"
 
        mkdir -p $DIR/$tdir
        $LFS mkdir -c 1 -i 1 $DIR/$tdir/dir0 ||
@@ -18093,17 +19334,240 @@ test_804() {
 }
 run_test 804 "verify agent entry for remote entry"
 
+cleanup_805() {
+       do_facet $SINGLEMDS zfs set quota=$old $fsset
+       unlinkmany $DIR/$tdir/f- 1000000
+       trap 0
+}
+
+test_805() {
+       local zfs_version=$(do_node $SINGLEMDS cat /sys/module/zfs/version)
+       [ "$(facet_fstype mds1)" != "zfs" ] &&
+               skip "ZFS specific test"
+       [ $(version_code $zfs_version) -lt $(version_code 0.7.2) ] &&
+               skip "netfree not implemented before 0.7"
+       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.57) ]] ||
+               skip "Need MDS version at least 2.10.57"
+
+       local fsset
+       local freekb
+       local usedkb
+       local old
+       local quota
+       local pref="osd-zfs.lustre-MDT0000."
+
+       # limit available space on MDS dataset to meet nospace issue
+       # quickly. then ZFS 0.7.2 can use reserved space if asked
+       # properly (using netfree flag in osd_declare_destroy()
+       fsset=$(do_facet $SINGLEMDS lctl get_param -n $pref.mntdev)
+       old=$(do_facet $SINGLEMDS zfs get -H quota $fsset | \
+               gawk '{print $3}')
+       freekb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytesfree)
+       usedkb=$(do_facet $SINGLEMDS lctl get_param -n $pref.kbytestotal)
+       let "usedkb=usedkb-freekb"
+       let "freekb=freekb/2"
+       if let "freekb > 5000"; then
+               let "freekb=5000"
+       fi
+       do_facet $SINGLEMDS zfs set quota=$(((usedkb+freekb)*1024)) $fsset
+       trap cleanup_805 EXIT
+       mkdir $DIR/$tdir
+       $LFS setstripe -E 1M -L mdt $DIR/$tdir || error "DoM not working"
+       createmany -m $DIR/$tdir/f- 1000000 && error "ENOSPC wasn't met"
+       rm -rf $DIR/$tdir || error "not able to remove"
+       do_facet $SINGLEMDS zfs set quota=$old $fsset
+       trap 0
+}
+run_test 805 "ZFS can remove from full fs"
+
+# Size-on-MDS test
+check_lsom_data()
+{
+       local file=$1
+       local size=$($LFS getsom -s $file)
+       local expect=$(stat -c %s $file)
+
+       [[ $size == $expect ]] ||
+               error "$file expected size: $expect, got: $size"
+
+       local blocks=$($LFS getsom -b $file)
+       expect=$(stat -c %b $file)
+       [[ $blocks == $expect ]] ||
+               error "$file expected blocks: $expect, got: $blocks"
+}
+
+check_lsom_size()
+{
+       local size=$($LFS getsom -s $1)
+       local expect=$2
+
+       [[ $size == $expect ]] ||
+               error "$file expected size: $expect, got: $size"
+}
+
+test_806() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
+               skip "Need MDS version at least 2.11.52" && return
+
+       local bs=1048576
+
+       touch $DIR/$tfile || error "touch $tfile failed"
+
+       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
+       save_lustre_params client "llite.*.xattr_cache" > $save
+       lctl set_param llite.*.xattr_cache=0
+       stack_trap "restore_lustre_params < $save" EXIT
+
+       # single-threaded write
+       echo "Test SOM for single-threaded write"
+       dd if=/dev/zero of=$DIR/$tfile bs=$bs count=1 ||
+               error "write $tfile failed"
+       check_lsom_size $DIR/$tfile $bs
+
+       local num=32
+       local size=$(($num * $bs))
+       local offset=0
+       local i
+
+       echo "Test SOM for single client muti-threaded($num) write"
+       $TRUNCATE $DIR/$tfile 0
+       for ((i = 0; i < $num; i++)); do
+               $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
+               local pids[$i]=$!
+               offset=$((offset + $bs))
+       done
+       for (( i=0; i < $num; i++ )); do
+               wait ${pids[$i]}
+       done
+       check_lsom_size $DIR/$tfile $size
+
+       $TRUNCATE $DIR/$tfile 0
+       for ((i = 0; i < $num; i++)); do
+               offset=$((offset - $bs))
+               $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
+               local pids[$i]=$!
+       done
+       for (( i=0; i < $num; i++ )); do
+               wait ${pids[$i]}
+       done
+       check_lsom_size $DIR/$tfile $size
+
+       # multi-client wirtes
+       num=$(get_node_count ${CLIENTS//,/ })
+       size=$(($num * $bs))
+       offset=0
+       i=0
+
+       echo "Test SOM for muti-client ($num) writes"
+       $TRUNCATE $DIR/$tfile 0
+       for client in ${CLIENTS//,/ }; do
+               do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
+               local pids[$i]=$!
+               i=$((i + 1))
+               offset=$((offset + $bs))
+       done
+       for (( i=0; i < $num; i++ )); do
+               wait ${pids[$i]}
+       done
+       check_lsom_size $DIR/$tfile $offset
+
+       i=0
+       $TRUNCATE $DIR/$tfile 0
+       for client in ${CLIENTS//,/ }; do
+               offset=$((offset - $bs))
+               do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
+               local pids[$i]=$!
+               i=$((i + 1))
+       done
+       for (( i=0; i < $num; i++ )); do
+               wait ${pids[$i]}
+       done
+       check_lsom_size $DIR/$tfile $size
+
+       # verify truncate
+       echo "Test SOM for truncate"
+       $TRUNCATE $DIR/$tfile 1048576
+       check_lsom_size $DIR/$tfile 1048576
+       $TRUNCATE $DIR/$tfile 1234
+       check_lsom_size $DIR/$tfile 1234
+
+       # verify SOM blocks count
+       echo "Verify SOM block count"
+       $TRUNCATE $DIR/$tfile 0
+       $MULTIOP $DIR/$tfile oO_TRUNC:O_RDWR:w1048576YSc ||
+               error "failed to write file $tfile"
+       check_lsom_data $DIR/$tfile
+}
+run_test 806 "Verify Lazy Size on MDS"
+
+test_807() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.52) ] &&
+               skip "Need MDS version at least 2.11.52" && return
+
+       # Registration step
+       changelog_register || error "changelog_register failed"
+       local cl_user="${CL_USERS[$SINGLEMDS]%% *}"
+       changelog_users $SINGLEMDS | grep -q $cl_user ||
+               error "User $cl_user not found in changelog_users"
+
+       local save="$TMP/$TESTSUITE-$TESTNAME.parameters"
+       save_lustre_params client "llite.*.xattr_cache" > $save
+       lctl set_param llite.*.xattr_cache=0
+       stack_trap "restore_lustre_params < $save" EXIT
+
+       rm -rf $DIR/$tdir || error "rm $tdir failed"
+       mkdir -p $DIR/$tdir || error "mkdir $tdir failed"
+       touch $DIR/$tdir/trunc || error "touch $tdir/trunc failed"
+       $TRUNCATE $DIR/$tdir/trunc 1024 || error "truncate $tdir/trunc failed"
+       $TRUNCATE $DIR/$tdir/trunc 1048576 ||
+               error "truncate $tdir/trunc failed"
+
+       local bs=1048576
+       dd if=/dev/zero of=$DIR/$tdir/single_dd bs=$bs count=1 ||
+               error "write $tfile failed"
+
+       # multi-client wirtes
+       local num=$(get_node_count ${CLIENTS//,/ })
+       local offset=0
+       local i=0
+
+       echo "Test SOM for muti-client ($num) writes"
+       touch $DIR/$tfile || error "touch $tfile failed"
+       $TRUNCATE $DIR/$tfile 0
+       for client in ${CLIENTS//,/ }; do
+               do_node $client $MULTIOP $DIR/$tfile Oz${offset}w${bs}c &
+               local pids[$i]=$!
+               i=$((i + 1))
+               offset=$((offset + $bs))
+       done
+       for (( i=0; i < $num; i++ )); do
+               wait ${pids[$i]}
+       done
+
+       sleep 5
+       $LSOM_SYNC -u $cl_user -m $FSNAME-MDT0000 $MOUNT
+       check_lsom_data $DIR/$tdir/trunc
+       check_lsom_data $DIR/$tdir/single_dd
+       check_lsom_data $DIR/$tfile
+
+       rm -rf $DIR/$tdir
+       # Deregistration step
+       changelog_deregister || error "changelog_deregister failed"
+}
+run_test 807 "verify LSOM syncing tool"
+
 #
 # tests that do cleanup/setup should be run at the end
 #
 
 test_900() {
-       [ $PARALLEL == "yes" ] && skip "skip parallel run" && return
-        local ls
-        #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG   0x903
-        $LCTL set_param fail_loc=0x903
+       [ $PARALLEL == "yes" ] && skip "skip parallel run"
+       local ls
+
+       #define OBD_FAIL_MGC_PAUSE_PROCESS_LOG   0x903
+       $LCTL set_param fail_loc=0x903
 
-        cancel_lru_locks MGC
+       cancel_lru_locks MGC
 
        FAIL_ON_ERROR=true cleanup
        FAIL_ON_ERROR=true setup