Whamcloud - gitweb
LU-14090 mgs: no local logs flag
[fs/lustre-release.git] / lustre / tests / conf-sanity.sh
index 49403bc..f540da2 100644 (file)
@@ -4,32 +4,36 @@ set -e
 
 ONLY=${ONLY:-"$*"}
 
-# bug number for skipped test:
-ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT"
+SRCDIR=$(dirname $0)
+PTLDEBUG=${PTLDEBUG:--1}
+LUSTRE=${LUSTRE:-$(dirname $0)/..}
+. $LUSTRE/tests/test-framework.sh
+init_test_env $@
+init_logging
+
+#                                  tool to create lustre filesystem images
+ALWAYS_EXCEPT="$CONF_SANITY_EXCEPT 32newtarball"
+
+# bug number for skipped test: LU-11915
+ALWAYS_EXCEPT="$ALWAYS_EXCEPT  110 115"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-# bug number for skipped test:
-# a tool to create lustre filesystem images
-ALWAYS_EXCEPT="32newtarball $ALWAYS_EXCEPT"
 if $SHARED_KEY; then
-# bug number for skipped tests:                LU-9795 (all below)
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT   0       31      32a     32d     35a"
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT   53a     53b     54b     76a     76b"
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT   76c     76d     78      103"
+       # bug number for skipped tests: LU-9795 (all below)
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT   84      86      103"
 fi
 
-SRCDIR=$(dirname $0)
-PATH=$PWD/$SRCDIR:$SRCDIR:$SRCDIR/../utils:$PATH
+if ! combined_mgs_mds; then
+       # bug number for skipped test: LU-11991         LU-11990
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  32a 32b 32c 32d 32e      66"
+       # bug number for skipped test: LU-9897  LU-12032
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  84       123F"
+fi
 
-PTLDEBUG=${PTLDEBUG:--1}
-SAVE_PWD=$PWD
-LUSTRE=${LUSTRE:-$(dirname $0)/..}
-RLUSTRE=${RLUSTRE:-$LUSTRE}
-export MULTIOP=${MULTIOP:-multiop}
+#                                  8  22  40  165  (min)
+[ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69 106 111"
 
-. $LUSTRE/tests/test-framework.sh
-init_test_env $@
-. ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
+build_test_filter
 
 # use small MDS + OST size to speed formatting time
 # do not use too small MDSSIZE/OSTSIZE, which affect the default journal size
@@ -37,9 +41,9 @@ init_test_env $@
 STORED_MDSSIZE=$MDSSIZE
 STORED_OSTSIZE=$OSTSIZE
 MDSSIZE=200000
-[ $(facet_fstype $SINGLEMDS) = "zfs" ] && MDSSIZE=400000
+[ "$mds1_FSTYPE" = zfs ] && MDSSIZE=400000
 OSTSIZE=200000
-[ $(facet_fstype ost1) = "zfs" ] && OSTSIZE=400000
+[ "$ost1_FSTYPE" = zfs ] && OSTSIZE=400000
 
 fs2mds_HOST=$mds_HOST
 fs2ost_HOST=$ost_HOST
@@ -49,34 +53,15 @@ MDSDEV1_2=$fs2mds_DEV
 OSTDEV1_2=$fs2ost_DEV
 OSTDEV2_2=$fs3ost_DEV
 
-if ! combined_mgs_mds; then
-       # bug number for skipped test: LU-9860 LU-9860 LU-9860
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  43b     53b     54b"
-       # bug number for skipped test: LU-9875 LU-9879 LU-9879 LU-9879 LU-9879
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  70e     80      84      87      100"
-       # bug number for skipped test: LU-8110 LU-9879 LU-9879 LU-9879
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT  102     104     105     107"
-fi
-
 # pass "-E lazy_itable_init" to mke2fs to speed up the formatting time
 if [[ "$LDISKFS_MKFS_OPTS" != *lazy_itable_init* ]]; then
        LDISKFS_MKFS_OPTS=$(csa_add "$LDISKFS_MKFS_OPTS" -E lazy_itable_init)
 fi
 
-[ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
-# bug number for skipped test:
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT"
-# UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
-
-init_logging
-
 #
 require_dsh_mds || exit 0
 require_dsh_ost || exit 0
 
-#                                  8  22   (min)"
-[ "$SLOW" = "no" ] && EXCEPT_SLOW="45 69"
-
 assert_DIR
 
 gen_config() {
@@ -84,7 +69,7 @@ gen_config() {
        # and stop to generate the startup logs.
        start_mds
        start_ost
-        wait_osc_import_state mds ost FULL
+       wait_osc_import_state mds ost FULL
        stop_ost
        stop_mds
 }
@@ -108,7 +93,7 @@ writeconf_or_reformat() {
 }
 
 reformat() {
-        formatall
+       formatall
 }
 
 start_mgs () {
@@ -126,6 +111,16 @@ start_mdt() {
        start $facet ${dev} $MDS_MOUNT_OPTS $@ || return 94
 }
 
+stop_mdt_no_force() {
+       local num=$1
+       local facet=mds$num
+       local dev=$(mdsdevname $num)
+       shift 1
+
+       echo "stop mds service on `facet_active_host $facet`"
+       stop $facet || return 97
+}
+
 stop_mdt() {
        local num=$1
        local facet=mds$num
@@ -143,6 +138,9 @@ start_mds() {
        for num in $(seq $MDSCOUNT); do
                start_mdt $num $@ || return 94
        done
+       for num in $(seq $MDSCOUNT); do
+               wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds${num} FULL
+       done
 }
 
 start_mgsmds() {
@@ -160,14 +158,15 @@ stop_mds() {
 }
 
 stop_mgs() {
-       echo "stop mgs service on `facet_active_host mgs`"
-       # These tests all use non-failover stop
-       stop mgs -f  || return 97
+       echo "stop mgs service on `facet_active_host mgs`"
+       # These tests all use non-failover stop
+       stop mgs -f  || return 97
 }
 
 start_ost() {
        echo "start ost1 service on `facet_active_host ost1`"
        start ost1 $(ostdevname 1) $OST_MOUNT_OPTS $@ || return 95
+       wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost1 FULL
 }
 
 stop_ost() {
@@ -179,6 +178,7 @@ stop_ost() {
 start_ost2() {
        echo "start ost2 service on `facet_active_host ost2`"
        start ost2 $(ostdevname 2) $OST_MOUNT_OPTS $@ || return 92
+       wait_clients_import_state ${CLIENTS:-$HOSTNAME} ost2 FULL
 }
 
 stop_ost2() {
@@ -188,16 +188,11 @@ stop_ost2() {
 }
 
 mount_client() {
-       local MOUNTPATH=$1
-       echo "mount $FSNAME on ${MOUNTPATH}....."
-       zconf_mount $(hostname) $MOUNTPATH || return 96
-}
+       local mountpath=$1
+       local mountopt="$2"
 
-remount_client() {
-       local mountopt="remount,$1"
-       local MOUNTPATH=$2
-       echo "remount '$1' lustre on ${MOUNTPATH}....."
-       zconf_mount $(hostname) $MOUNTPATH "$mountopt" || return 96
+       echo "mount $FSNAME ${mountopt:+with opts $mountopt} on $mountpath....."
+       zconf_mount $HOSTNAME $mountpath $mountopt || return 96
 }
 
 umount_client() {
@@ -262,8 +257,8 @@ check_mount() {
        do_facet client "cp /etc/passwd $DIR/a" || return 71
        do_facet client "rm $DIR/a" || return 72
        # make sure lustre is actually mounted (touch will block,
-        # but grep won't, so do it after)
-        do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
+       # but grep won't, so do it after)
+       do_facet client "grep $MOUNT' ' /proc/mounts > /dev/null" || return 73
        echo "setup single mount lustre success"
 }
 
@@ -275,7 +270,9 @@ check_mount2() {
        echo "setup double mount lustre success"
 }
 
-build_test_filter
+generate_name() {
+       cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $1 | head -n 1
+}
 
 if [ "$ONLY" == "setup" ]; then
        setup
@@ -475,10 +472,7 @@ test_5e() {
 run_test 5e "delayed connect, don't crash (bug 10268)"
 
 test_5f() {
-       if combined_mgs_mds ; then
-               skip "needs separate mgs and mds"
-               return 0
-       fi
+       combined_mgs_mds && skip "needs separate mgs and mds"
 
        grep " $MOUNT " /etc/mtab &&
                error false "unexpected entry in mtab before mount" && return 10
@@ -513,8 +507,8 @@ run_test 5f "mds down, cleanup after failed mount (bug 2712)"
 
 test_5g() {
        modprobe lustre
-       [ $(lustre_version_code client) -lt $(version_code 2.9.53) ] &&
-               { skip "automount of debugfs missing before 2.9.53" && return 0; }
+       [ "$CLIENT_VERSION" -lt $(version_code 2.9.53) ] &&
+               skip "automount of debugfs missing before 2.9.53"
        umount /sys/kernel/debug
        $LCTL get_param -n devices | egrep -v "error" && \
                error "lctl can't access debugfs data"
@@ -522,6 +516,32 @@ test_5g() {
 }
 run_test 5g "handle missing debugfs"
 
+test_5h() {
+       setup
+
+       stop mds1
+       #define OBD_FAIL_MDS_FS_SETUP            0x135
+       do_facet mds1 "$LCTL set_param fail_loc=0x80000135"
+       start_mdt 1 && error "start mdt should fail"
+       start_mdt 1 || error "start mdt failed"
+       client_up || error "client_up failed"
+       cleanup
+}
+run_test 5h "start mdt failure at mdt_fs_setup()"
+
+test_5i() {
+       setup
+
+       stop mds1
+       #define OBD_FAIL_QUOTA_INIT              0xA05
+       do_facet mds1 "$LCTL set_param fail_loc=0x80000A05"
+       start_mdt 1 && error "start mdt should fail"
+       start_mdt 1 || error "start mdt failed"
+       client_up || error "client_up failed"
+       cleanup
+}
+run_test 5i "start mdt failure at mdt_quota_init()"
+
 test_6() {
        setup
        manual_umount_client
@@ -580,9 +600,8 @@ run_test 9 "test ptldebug and subsystem for mkfs"
 #
 
 test_17() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        setup
@@ -609,9 +628,8 @@ test_17() {
 run_test 17 "Verify failed mds_postsetup won't fail assertion (2936) (should return errs)"
 
 test_18() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
@@ -650,7 +668,7 @@ test_18() {
                        log "use file $MDSDEV with MIN=$MIN"
        fi
 
-       [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS" && return
+       [ -z "$OK" ] && skip_env "$MDSDEV too small for ${MIN}kB MDS"
 
        echo "mount mds with large journal..."
 
@@ -696,10 +714,10 @@ test_20() {
        mount_client $MOUNT || error "mount_client $MOUNT failed"
        check_mount || error "check_mount failed"
        rm -f $DIR/$tfile || error "remove $DIR/$tfile failed."
-       remount_client ro $MOUNT || error "remount_client with ro failed"
+       mount_client $MOUNT remount,ro || error "remount client with ro failed"
        touch $DIR/$tfile && error "$DIR/$tfile created incorrectly"
        [ -e $DIR/$tfile ] && error "$DIR/$tfile exists incorrectly"
-       remount_client rw $MOUNT || error "remount_client with rw failed"
+       mount_client $MOUNT remount,rw || error "remount client with rw failed"
        touch $DIR/$tfile || error "touch $DIR/$tfile failed"
        MCNT=$(grep -c $MOUNT' ' /etc/mtab)
        [ "$MCNT" -ne 1 ] && error "$MOUNT in /etc/mtab $MCNT times"
@@ -741,12 +759,10 @@ test_21c() {
 run_test 21c "start mds between two osts, stop mds last"
 
 test_21d() {
-        if combined_mgs_mds ; then
-                skip "need separate mgs device" && return 0
-        fi
-        stopall
+       combined_mgs_mds && skip "need separate mgs device"
 
-        reformat
+       stopall
+       reformat
 
        start_mgs || error "unable to start MGS"
        start_ost || error "unable to start OST1"
@@ -754,12 +770,18 @@ test_21d() {
        start_mds || error "MDS start failed"
        wait_osc_import_state mds ost2 FULL
 
+       local zkeeper=${KEEP_ZPOOL}
+       stack_trap "KEEP_ZPOOL=$zkeeper" EXIT
+       KEEP_ZPOOL="true"
+
        stop_ost || error "Unable to stop OST1"
        stop_ost2 || error "Unable to stop OST2"
        stop_mds || error "Unable to stop MDS"
        stop_mgs
        #writeconf to remove all ost2 traces for subsequent tests
        writeconf_or_reformat
+       KEEP_ZPOOL="${zkeeper}"
+
        start_mgs || error "unable to start MGS"
 }
 run_test 21d "start mgs then ost and then mds"
@@ -774,7 +796,7 @@ cleanup_21e() {
 test_21e() { # LU-5863
        if [[ -z "$fs3ost_DEV" || -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
                is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
-               skip_env "mixed loopback and real device not working" && return
+               skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -920,7 +942,7 @@ test_24a() {
 
        if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" ]; then
                is_blkdev $SINGLEMDS $MDSDEV &&
-               skip_env "mixed loopback and real device not working" && return
+               skip_env "mixed loopback and real device not working"
        fi
 
        [ -n "$ost1_HOST" ] && fs2ost_HOST=$ost1_HOST
@@ -984,12 +1006,14 @@ run_test 24a "Multiple MDTs on a single node"
 
 test_24b() {
        local MDSDEV=$(mdsdevname ${SINGLEMDS//mds/})
+       combined_mgs_mds ||
+               skip "needs combined MGT and MDT device"
 
        if [ -z "$fs2mds_DEV" ]; then
                local dev=${SINGLEMDS}_dev
                local MDSDEV=${!dev}
                is_blkdev $SINGLEMDS $MDSDEV &&
-               skip_env "mixed loopback and real device not working" && return
+               skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -998,15 +1022,17 @@ test_24b() {
        add fs2mds $(mkfs_opts mds1 ${fs2mdsdev} ) --mgs --fsname=${FSNAME}2 \
                --reformat $fs2mdsdev $fs2mdsvdev || exit 10
        setup
-       start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS &&
+       start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && {
+               cleanup
                error "start MDS should fail"
+       }
        stop fs2mds -f
        cleanup || error "cleanup failed with rc $?"
 }
 run_test 24b "Multiple MGSs on a single node (should return err)"
 
 test_25() {
-       setup
+       setup_noconfig
        check_mount || error "check_mount failed"
        local MODULES=$($LCTL modules | awk '{ print $2 }')
        rmmod $MODULES 2>/dev/null || true
@@ -1032,6 +1058,7 @@ test_26() {
 run_test 26 "MDT startup failure cleans LOV (should return errs)"
 
 test_27a() {
+       cleanup
        start_ost || error "Unable to start OST1"
        start_mds || error "Unable to start MDS"
        echo "Requeue thread should have started: "
@@ -1045,7 +1072,7 @@ run_test 27a "Reacquire MGS lock if OST started first"
 
 test_27b() {
        # FIXME. ~grev
-       setup
+       setup_noconfig
        local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
                        awk '($3 ~ "mdt" && $4 ~ "MDT0000") { print $4 }')
 
@@ -1062,32 +1089,45 @@ test_27b() {
 run_test 27b "Reacquire MGS lock after failover"
 
 test_28A() { # was test_28
-       setup
-       TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
-       PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
-       ORIG=$($LCTL get_param -n $TEST)
-       FINAL=$(($ORIG + 1))
-       set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
-       FINAL=$(($FINAL + 1))
-       set_persistent_param_and_check client "$TEST" "$PARAM" $FINAL
+       setup_noconfig
+
+       local TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
+       local PARAM="$FSNAME.llite.max_read_ahead_whole_mb"
+       local orig=$($LCTL get_param -n $TEST)
+       local max=$($LCTL get_param -n \
+                       llite.$FSNAME-*.max_read_ahead_per_file_mb)
+
+       orig=${orig%%.[0-9]*}
+       max=${max%%.[0-9]*}
+       echo "ORIG:$orig MAX:$max"
+       [[ $max -le $orig ]] && orig=$((max - 3))
+       echo "ORIG:$orig MAX:$max"
+
+       local final=$((orig + 1))
+
+       set_persistent_param_and_check client "$TEST" "$PARAM" $final
+       final=$((final + 1))
+       set_persistent_param_and_check client "$TEST" "$PARAM" $final
        umount_client $MOUNT || error "umount_client $MOUNT failed"
        mount_client $MOUNT || error "mount_client $MOUNT failed"
-       RESULT=$($LCTL get_param -n $TEST)
-       if [ $RESULT -ne $FINAL ]; then
-               error "New config not seen: wanted $FINAL got $RESULT"
+
+       local result=$($LCTL get_param -n $TEST)
+
+       if [ $result -ne $final ]; then
+               error "New config not seen: wanted $final got $result"
        else
-               echo "New config success: got $RESULT"
+               echo "New config success: got $result"
        fi
-       set_persistent_param_and_check client "$TEST" "$PARAM" $ORIG
+       set_persistent_param_and_check client "$TEST" "$PARAM" $orig
        cleanup || error "cleanup failed with rc $?"
 }
 run_test 28A "permanent parameter setting"
 
 test_28a() { # LU-4221
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.5.52) ]] ||
-               { skip "Need OST version at least 2.5.52" && return 0; }
-       [ "$(facet_fstype ost1)" = "zfs" ] &&
-               skip "LU-4221: no such proc params for ZFS OSTs" && return
+       [[ "$OST1_VERSION" -ge $(version_code 2.5.52) ]] ||
+               skip "Need OST version at least 2.5.52"
+       [ "$ost1_FSTYPE" = zfs ] &&
+               skip "LU-4221: no such proc params for ZFS OSTs"
 
        local name
        local param
@@ -1096,7 +1136,7 @@ test_28a() { # LU-4221
        local new
        local device="$FSNAME-OST0000"
 
-       setup
+       setup_noconfig
 
        # In this test we will set three kinds of proc parameters with
        # lctl set_param -P or lctl conf_param:
@@ -1132,21 +1172,21 @@ test_28a() { # LU-4221
 run_test 28a "set symlink parameters permanently with lctl"
 
 test_29() {
-       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
-        setup > /dev/null 2>&1
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs"
+       setup_noconfig > /dev/null 2>&1
        start_ost2 || error "Unable to start OST2"
        sleep 10
 
        local PARAM="$FSNAME-OST0001.osc.active"
        # With lctl set_param -P the value $PROC_ACT will be sent to
-       # all nodes. The [^M] filter out the ability to set active
+       # all nodes. The [!M] filter out the ability to set active
        # on the MDS servers which is tested with wait_osp_* below.
        # For ost_server_uuid that only exist on client so filtering
        # is safe.
-       local PROC_ACT="osc.$FSNAME-OST0001-osc-*.active"
-       local PROC_UUID="osc.$FSNAME-OST0001-osc-[!M]*.ost_server_uuid"
+       local PROC_ACT="os[cp].$FSNAME-OST0001-osc-[^M]*.active"
+       local PROC_UUID="os[cp].$FSNAME-OST0001-osc-[^M]*.ost_server_uuid"
 
-        ACTV=$($LCTL get_param -n $PROC_ACT)
+       ACTV=$($LCTL get_param -n $PROC_ACT)
        DEAC=$((1 - $ACTV))
        set_persistent_param_and_check client $PROC_ACT $PARAM $DEAC
        # also check ost_server_uuid status
@@ -1164,12 +1204,15 @@ test_29() {
        # test new client starts deactivated
        umount_client $MOUNT || error "umount_client $MOUNT failed"
        mount_client $MOUNT || error "mount_client $MOUNT failed"
-       RESULT=$($LCTL get_param -n $PROC_UUID | grep DEACTIV | grep NEW)
-       if [ -z "$RESULT" ]; then
-               error "New client start active: $(lctl get_param -n $PROC_UUID)"
-       else
-               echo "New client success: got $RESULT"
-       fi
+
+       # the 2nd and 3rd field of ost_server_uuid do not update at the same
+       # time when using lctl set_param -P
+       wait_update_facet client                                        \
+               "$LCTL get_param -n $PROC_UUID | awk '{print \\\$3 }'"  \
+               "DEACTIVATED" ||
+               error "New client start active: $($LCTL get_param -n $PROC_UUID)"
+
+       echo "New client success: got '$($LCTL get_param -n $PROC_UUID)'"
 
        # make sure it reactivates
        set_persistent_param_and_check client $PROC_ACT $PARAM $ACTV
@@ -1183,7 +1226,7 @@ test_29() {
 run_test 29 "permanently remove an OST"
 
 test_30a() {
-       setup
+       setup_noconfig
 
        echo Big config llog
        TEST="llite.$FSNAME-*.max_read_ahead_whole_mb"
@@ -1201,7 +1244,7 @@ test_30a() {
        pass
 
        echo Erase parameter setting
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD -d $TEST" ||
                        error "Erase param $TEST failed"
        else
@@ -1213,6 +1256,8 @@ test_30a() {
        mount_client $MOUNT || error "mount_client $MOUNT failed"
        FINAL=$($LCTL get_param -n $TEST)
        echo "deleted (default) value=$FINAL, orig=$ORIG"
+       ORIG=${ORIG%%.[0-9]*}
+       FINAL=${FINAL%%.[0-9]*}
        # assumes this parameter started at the default value
        [ "$FINAL" -eq "$ORIG" ] || fail "Deleted value=$FINAL, orig=$ORIG"
 
@@ -1221,7 +1266,7 @@ test_30a() {
 run_test 30a "Big config llog and permanent parameter deletion"
 
 test_30b() {
-       setup
+       setup_noconfig
 
        local orignids=$($LCTL get_param -n \
                osc.$FSNAME-OST0000-osc-[^M]*.import | grep failover_nids)
@@ -1240,7 +1285,7 @@ test_30b() {
 
        local TEST="$LCTL get_param -n osc.$FSNAME-OST0000-osc-[^M]*.import |
                grep failover_nids | sed -n 's/.*\($NEW\).*/\1/p'"
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                PARAM="osc.$FSNAME-OST0000-osc-[^M]*.import"
                echo "Setting $PARAM from $TEST to $NEW"
                do_facet mgs "$PERM_CMD $PARAM='connection=$NEW'" ||
@@ -1262,7 +1307,7 @@ test_30b() {
        [ $NIDCOUNT -eq $((orignidcount + 1)) ] ||
                error "Failover nid not added"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD -d osc.$FSNAME-OST0000-osc-*.import"
        else
                do_facet mgs "$PERM_CMD -d $FSNAME-OST0000.failover.node" ||
@@ -1308,7 +1353,6 @@ test_32newtarball() {
        local dst=.
        local src=/etc/rc.d
        local tmp=$TMP/t32_image_create
-       local server_version=$(lustre_version_code $SINGLEMDS)
        local remote_dir
        local striped_dir
        local pushd_dir
@@ -1339,7 +1383,7 @@ test_32newtarball() {
 
        setupall
 
-       [[ $server_version -ge $(version_code 2.3.50) ]] ||
+       [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
                $LFS quotacheck -ug /mnt/$FSNAME
        $LFS setquota -u $T32_QID -b 0 -B $T32_BLIMIT -i 0 -I $T32_ILIMIT \
                /mnt/$FSNAME
@@ -1351,7 +1395,7 @@ test_32newtarball() {
                $LFS mkdir -i 1 $remote_dir
                tar cf - -C $tmp/src . | tar xf - -C $remote_dir
 
-               if [[ $server_version -ge $(version_code 2.7.0) ]]; then
+               if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
                        striped_dir=/mnt/$FSNAME/striped_dir_old
                        $LFS mkdir -i 1 -c 2 $striped_dir
                        tar cf - -C $tmp/src . | tar xf - -C $striped_dir
@@ -1367,7 +1411,7 @@ test_32newtarball() {
        pushd_dir=/mnt/$FSNAME
        if [[ $MDSCOUNT -ge 2 ]]; then
                pushd_dir=$remote_dir
-               if [[ $server_version -ge $(version_code 2.7.0) ]]; then
+               if [[ "$MDS1_VERSION" -ge $(version_code 2.7.0) ]]; then
                        pushd $striped_dir
                        ls -Rni --time-style=+%s >$tmp/img/list2
                        popd
@@ -1382,7 +1426,7 @@ test_32newtarball() {
        $LCTL get_param -n version | head -n 1 |
                sed -e 's/^lustre: *//' >$tmp/img/commit
 
-       [[ $server_version -ge $(version_code 2.3.50) ]] ||
+       [[ "$MDS1_VERSION" -ge $(version_code 2.3.50) ]] ||
                $LFS quotaon -ug /mnt/$FSNAME
        $LFS quota -u $T32_QID -v /mnt/$FSNAME
        $LFS quota -v -u $T32_QID /mnt/$FSNAME |
@@ -1396,6 +1440,16 @@ test_32newtarball() {
        echo $T32_BLIMIT > $tmp/img/blimit
        echo $T32_ILIMIT > $tmp/img/ilimit
 
+       $MULTIOP /mnt/$FSNAME/orph_file Ouw_c&
+       pid=$!
+       sync
+       stop_mdt_no_force 1
+       debugfs -R "ls /PENDING" ${MDSDEV1:-$MDSDEV}
+       cp ${MDSDEV1:-$MDSDEV} $tmp/img
+       start_mdt 1
+       kill -s USR1 $pid
+       wait $pid
+
        stopall
 
        pushd $tmp/src
@@ -1409,7 +1463,6 @@ test_32newtarball() {
        uname -r >$tmp/img/kernel
        uname -m >$tmp/img/arch
 
-       mv ${MDSDEV1:-$MDSDEV} $tmp/img
        for num in $(seq 2 $MDSCOUNT); do
                local devname=$(mdsdevname $num)
                local facet=mds$num
@@ -1423,7 +1476,7 @@ test_32newtarball() {
                          sed -e 's/\./_/g')    # E.g., "1.8.7" -> "1_8"
        dst=$(cd $dst; pwd)
        pushd $tmp/img
-       tar cjvf $dst/disk$version-$(facet_fstype $SINGLEMDS).tar.bz2 -S *
+       tar cjvf $dst/disk$version-"$mds1_FSTYPE".tar.bz2 -S *
        popd
 
        rm -r $tmp
@@ -1435,34 +1488,24 @@ test_32newtarball() {
 # variable "tarballs".
 #
 t32_check() {
+       [ "$CLIENTONLY" ] && skip "Client-only testing"
+
        local node=$(facet_active_host $SINGLEMDS)
        local r="do_node $node"
 
-       if [ "$CLIENTONLY" ]; then
-               skip "Client-only testing"
-               exit 0
-       fi
-
-       if ! $r which $TUNEFS; then
-               skip_env "tunefs.lustre required on $node"
-               exit 0
-       fi
+       ! $r which "$TUNEFS" && skip_env "tunefs.lustre required on $node"
 
-       local IMGTYPE=$(facet_fstype $SINGLEMDS)
+       local IMGTYPE="$mds1_FSTYPE"
 
        tarballs=$($r find $RLUSTRE/tests -maxdepth 1 \
                   -name \'disk*-$IMGTYPE.tar.bz2\')
 
-       if [ -z "$tarballs" ]; then
-               skip "No applicable tarballs found"
-               exit 0
-       fi
+       [ -z "$tarballs" ] && skip "No applicable tarballs found"
 }
 
 t32_test_cleanup() {
        local tmp=$TMP/t32
        local facet=$SINGLEMDS
-       local fstype=$(facet_fstype $facet)
        local rc=$?
 
        if $shall_cleanup_lustre; then
@@ -1480,7 +1523,7 @@ t32_test_cleanup() {
 
        $r rm -rf $tmp
        rm -rf $tmp
-       if [[ $fstype == zfs ]]; then
+       if [[ "$mds1_FSTYPE" == zfs ]]; then
                local poolname
                local poolname_list="t32fs-mdt1 t32fs-ost1"
 
@@ -1510,20 +1553,19 @@ t32_reload_modules() {
        local node=$1
        local all_removed=false
        local i=0
-       local fstype=$(facet_fstype $SINGLEMDS)
 
-       [ $fstype == "zfs" ] && do_rpc_nodes $node "service zed stop"
+       [ "$mds1_FSTYPE" == zfs ] && do_rpc_nodes $node "service zed stop"
 
        while ((i < 20)); do
                echo "Unloading modules on $node: Attempt $i"
-               do_rpc_nodes $node $LUSTRE_RMMOD $fstype &&
+               do_rpc_nodes $node $LUSTRE_RMMOD "$mds1_FSTYPE" &&
                        all_removed=true
                do_rpc_nodes $node check_mem_leak || return 1
                if $all_removed; then
                        do_rpc_nodes $node load_modules
                        return 0
                fi
-               if [ $fstype == "zfs" ]; then
+               if [ "$mds1_FSTYPE" == zfs ]; then
                        do_rpc_nodes $node "$ZPOOL status -v"
                fi
                sleep 5
@@ -1557,7 +1599,6 @@ t32_verify_quota() {
        local facet=$1
        local fsname=$2
        local mnt=$3
-       local fstype=$(facet_fstype $SINGLEMDS)
        local qval
        local cmd
 
@@ -1565,7 +1606,7 @@ t32_verify_quota() {
        # lustre will estimate the object count usage. This fails quota
        # verification in 32b. The object quota usage should be accurate after
        # zfs-0.7.0 is released.
-       [ $fstype == "zfs" ] && {
+       [ "$mds1_FSTYPE" == zfs ] && {
                local zfs_version=$(do_facet $facet cat /sys/module/zfs/version)
 
                [ $(version_code $zfs_version) -lt $(version_code 0.7.0) ] && {
@@ -1613,11 +1654,11 @@ t32_verify_quota() {
        }
 
        set_persistent_param_and_check $facet \
-               "osd-$fstype.$fsname-MDT0000.quota_slave.enabled" \
+               "osd-$mds1_FSTYPE.$fsname-MDT0000.quota_slave.enabled" \
                "$fsname.quota.mdt" ug
 
        set_persistent_param_and_check $facet \
-               "osd-$fstype.$fsname-OST0000.quota_slave.enabled" \
+               "osd-$mds1_FSTYPE.$fsname-OST0000.quota_slave.enabled" \
                "$fsname.quota.ost" ug
 
        chmod 0777 $mnt
@@ -1643,6 +1684,7 @@ t32_test() {
        local writeconf=$2
        local dne_upgrade=${dne_upgrade:-"no"}
        local dom_upgrade=${dom_upgrade:-"no"}
+       local project_upgrade=${project_upgrade:-"no"}
        local ff_convert=${ff_convert:-"no"}
        local shall_cleanup_mdt=false
        local shall_cleanup_mdt1=false
@@ -1666,7 +1708,6 @@ t32_test() {
        local nrpcs_orig
        local nrpcs
        local list
-       local fstype=$(facet_fstype $SINGLEMDS)
        local mdt_dev=$tmp/mdt
        local mdt2_dev=$tmp/mdt2
        local ost_dev=$tmp/ost
@@ -1710,12 +1751,12 @@ t32_test() {
        # - ost device img version < 2.3.64
        # - ost server version >= 2.5
        [ $(version_code $img_commit) -ge $(version_code 2.3.64) -o \
-               $(lustre_version_code ost1) -lt $(version_code 2.5.0) ] &&
+               "$OST1_VERSION" -lt $(version_code 2.5.0) ] &&
                        ff_convert="no"
 
        ! $r test -f $mdt2_dev || mdt2_is_available=true
 
-       if [[ $fstype == zfs ]]; then
+       if [[ "$mds1_FSTYPE" == zfs ]]; then
                # import pool first
                local poolname
                local poolname_list="t32fs-mdt1 t32fs-ost1"
@@ -1740,6 +1781,16 @@ t32_test() {
                                error_noexit "import zfs pool failed"
                                return 1
                        }
+       elif [ "$project_upgrade" != "no" ]; then
+               ! $r tune2fs -O project $mdt_dev &&
+                       error_noexit "enable project on mdt0 failed" &&
+                               return 1
+               $mdt2_is_available && ! $r tune2fs "-O project" $mdt2_dev &&
+                       error_noexit "enable project on mdt failed" &&
+                               return 1
+               ! $r tune2fs -O project $ost_dev &&
+                       error_noexit "enable project on mdt failed" &&
+                               return 1
        fi
 
        $r $LCTL set_param debug="$PTLDEBUG"
@@ -1760,7 +1811,7 @@ t32_test() {
 
        if [ "$writeconf" ]; then
                mopts=writeconf
-               if [ $fstype == "ldiskfs" ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mopts="loop,$mopts"
                        $r $TUNEFS --quota $mdt_dev || {
                                $r losetup -a
@@ -1777,15 +1828,15 @@ t32_test() {
                fi
        else
                if [ -n "$($LCTL list_nids | grep -v '\(tcp\|lo\)[[:digit:]]*$')" ]; then
-                       [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
-                       { skip "LU-2200: Cannot run over Inifiniband w/o lctl replace_nids "
-                               "(Need MGS version at least 2.3.59)"; return 0; }
+                       [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
+                       skip "LU-2200: Cannot run over IB w/o lctl replace_nids "
+                               "(Need MGS version at least 2.3.59)"
 
                        local osthost=$(facet_active_host ost1)
                        local ostnid=$(do_node $osthost $LCTL list_nids | head -1)
 
                        mopts=nosvc
-                       if [ $fstype == "ldiskfs" ]; then
+                       if [ "$mds1_FSTYPE" == ldiskfs ]; then
                                mopts="loop,$mopts"
                        fi
                        $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt
@@ -1795,7 +1846,7 @@ t32_test() {
                fi
 
                mopts=exclude=$fsname-OST0000
-               if [ $fstype == "ldiskfs" ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mopts="loop,$mopts"
                fi
        fi
@@ -1827,7 +1878,7 @@ t32_test() {
                local fs2mdsvdev=$(mdsvdevname 1_2)
 
                echo "mkfs new MDT on ${fs2mdsdev}...."
-               if [ $(facet_fstype mds1) == ldiskfs ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mkfsoptions="--mkfsoptions=\\\"-J size=8\\\""
                fi
 
@@ -1837,7 +1888,7 @@ t32_test() {
                        return 1
                }
 
-               [[ $(facet_fstype mds1) != zfs ]] || import_zpool mds1
+               [[ "$mds1_FSTYPE" != zfs ]] || import_zpool mds1
 
                $r $TUNEFS --dryrun $fs2mdsdev || {
                        error_noexit "tunefs.lustre before mounting the MDT"
@@ -1871,7 +1922,7 @@ t32_test() {
        }
        if [ "$writeconf" ]; then
                mopts=mgsnode=$nid,$writeconf
-               if [ $fstype == "ldiskfs" ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mopts="loop,$mopts"
                        $r $TUNEFS --quota $ost_dev || {
                                $r losetup -a
@@ -1881,7 +1932,7 @@ t32_test() {
                fi
        else
                mopts=mgsnode=$nid
-               if [ $fstype == "ldiskfs" ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mopts="loop,$mopts"
                fi
        fi
@@ -1901,7 +1952,7 @@ t32_test() {
                return 1
        fi
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                $r $PERM_CMD osc.$fsname-OST0000*.import=connection=$nid || {
                        error_noexit "Setting OST \"failover.node\""
                        return 1
@@ -1960,7 +2011,7 @@ t32_test() {
                return 1
        }
 
-       if [ "$ff_convert" != "no" -a $(facet_fstype ost1) == "ldiskfs" ]; then
+       if [ "$ff_convert" != "no" -a "$ost1_FSTYPE" == ldiskfs ]; then
                $r $LCTL lfsck_start -M $fsname-OST0000 || {
                        error_noexit "Start OI scrub on OST0"
                        return 1
@@ -1985,7 +2036,7 @@ t32_test() {
        fi
 
        if [ "$dne_upgrade" != "no" ]; then
-               if [[ $PERM_CMD = *"set_param -P"* ]]; then
+               if [[ $PERM_CMD == *"set_param -P"* ]]; then
                        $r $PERM_CMD mdc.$fsname-MDT0001*.import=connection=$nid || {
                                error_noexit "Setting MDT1 \"failover.node\""
                                return 1
@@ -2119,9 +2170,9 @@ t32_test() {
                        $LFS setdirstripe -D -c2 $tmp/mnt/lustre/striped_dir
 
                        pushd $tmp/mnt/lustre
-                       tar -cf - . --exclude=./striped_dir \
-                                   --exclude=./striped_dir_old \
-                                   --exclude=./remote_dir |
+                       tar -c --exclude=./striped_dir \
+                               --exclude=./striped_dir_old \
+                               --exclude=./remote_dir -f - .|
                                tar -xvf - -C striped_dir 1>/dev/null || {
                                error_noexit "cp to striped dir failed"
                                return 1
@@ -2240,7 +2291,7 @@ t32_test() {
                fi
 
                # migrate files/dirs to remote MDT, then move them back
-               if [ $(lustre_version_code mds1) -ge $(version_code 2.7.50) -a \
+               if [ "$MDS1_VERSION" -ge $(version_code 2.7.50) -a \
                     $dne_upgrade != "no" ]; then
                        $r $LCTL set_param -n   \
                                mdt.${fsname}*.enable_remote_dir=1 2>/dev/null
@@ -2300,12 +2351,32 @@ t32_test() {
                }
                shall_cleanup_lustre=false
        else
+               $MOUNT_CMD $nid:/$fsname $tmp/mnt/lustre || {
+                       error_noexit "Mounting the client"
+                       return 1
+               }
+
+               if [ "$mds1_FSTYPE" == ldiskfs -a \
+                   "$project_upgrade" != "no" ]; then
+                       ! $LFS project -d -p 1 $tmp/mnt/lustre/* &&
+                               error_noexit "set project failed" &&
+                                       return 1
+               fi
+
+               [[ $(do_facet mds1 pgrep orph_.*-MDD | wc -l) == 0 ]] ||
+                       error "MDD orphan cleanup thread not quit"
+
+               umount $tmp/mnt/lustre || {
+                       error_noexit "Unmounting the client"
+                       return 1
+               }
+
                if [[ "$dne_upgrade" != "no" ]] || $mdt2_is_available; then
                        $r $UMOUNT $tmp/mnt/mdt1 || {
                                error_noexit "Unmounting the MDT2"
                                return 1
                        }
-                       if [[ $fstype == zfs ]]; then
+                       if [[ "$mds1_FSTYPE" == zfs ]]; then
                            $r "$ZPOOL export t32fs-mdt2"
                        fi
                        shall_cleanup_mdt1=false
@@ -2315,7 +2386,7 @@ t32_test() {
                        error_noexit "Unmounting the MDT"
                        return 1
                }
-               if [[ $fstype == zfs ]]; then
+               if [[ "$mds1_FSTYPE" == zfs ]]; then
                    $r "$ZPOOL export t32fs-mdt1"
                fi
                shall_cleanup_mdt=false
@@ -2324,7 +2395,7 @@ t32_test() {
                        error_noexit "Unmounting the OST"
                        return 1
                }
-               if [[ $fstype == zfs ]]; then
+               if [[ "$mds1_FSTYPE" == zfs ]]; then
                    $r "$ZPOOL export t32fs-ost1"
                fi
                shall_cleanup_ost=false
@@ -2334,7 +2405,7 @@ t32_test() {
                        return 1
                }
 
-               if [[ $fstype == zfs ]]; then
+               if [[ "$mds1_FSTYPE" == zfs ]]; then
                        local poolname=t32fs-mdt1
                        $r "modprobe zfs;
                            $ZPOOL list -H $poolname >/dev/null 2>&1 ||
@@ -2353,7 +2424,7 @@ t32_test() {
                }
 
                mopts=exclude=$fsname-OST0000
-               if [ $fstype == "ldiskfs" ]; then
+               if [ "$mds1_FSTYPE" == ldiskfs ]; then
                        mopts="loop,$mopts"
                fi
                $r $MOUNT_CMD -o $mopts $mdt_dev $tmp/mnt/mdt || {
@@ -2371,6 +2442,7 @@ test_32a() {
 
        t32_check
        for tarball in $tarballs; do
+               banner "testing $tarball upgrade"
                t32_test $tarball || let "rc += $?"
        done
        return $rc
@@ -2384,6 +2456,7 @@ test_32b() {
 
        t32_check
        for tarball in $tarballs; do
+               banner "testing $tarball upgrade with writeconf"
                t32_test $tarball writeconf || let "rc += $?"
        done
        return $rc
@@ -2395,12 +2468,13 @@ test_32c() {
        local tarball
        local rc=0
 
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        t32_check
        for tarball in $tarballs; do
                # Do not support 1_8 and 2_1 direct upgrade to DNE2 anymore */
-               echo $tarball | grep "1_8" && continue
-               echo $tarball | grep "2_1" && continue
+               [[ "$tarball" =~ "1_8" ]] && echo "skip $tarball" && continue
+               [[ "$tarball" =~ "2_1" ]] && echo "skip $tarball" && continue
+               banner "testing $tarball upgrade with DNE"
                load_modules
                dne_upgrade=yes t32_test $tarball writeconf || rc=$?
        done
@@ -2415,15 +2489,21 @@ test_32d() {
 
        t32_check
        for tarball in $tarballs; do
-               ff_convert=yes t32_test $tarball || rc=$?
+               banner "testing $tarball upgrade with ff convert and project upgrade"
+               project_upgrade="no"
+               [[ "$MDS1_VERSION" -ge $(version_code 2.13.54) ]] &&
+                       [[ "$tarball" =~ "disk2_4-ldiskfs" ]] &&
+                               project_upgrade="yes"
+               project_upgrade=$project_upgrade ff_convert=yes t32_test \
+                       $tarball || rc=$?
        done
        return $rc
 }
-run_test 32d "convert ff test"
+run_test 32d "convert ff and project quota upgrade test"
 
 test_32e() {
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.56) ]] ||
-               { skip "Need MDS version at least 2.10.56"; return 0; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.10.56) ]] ||
+               skip "Need MDS version at least 2.10.56"
 
        local tarballs
        local tarball
@@ -2431,8 +2511,9 @@ test_32e() {
 
        t32_check
        for tarball in $tarballs; do
-               echo $tarball | grep "2_9" || continue
+               [[ "$tarball" =~ "2_9" ]] || continue
                #load_modules
+               banner "testing $tarball upgrade with DoM"
                dom_upgrade=yes t32_test $tarball writeconf || let "rc += $?"
        done
        return $rc
@@ -2450,8 +2531,7 @@ test_33a() { # bug 12333, was test_33
                local dev=${SINGLEMDS}_dev
                local MDSDEV=${!dev}
                is_blkdev $SINGLEMDS $MDSDEV &&
-                       skip_env "mixed loopback and real device not working" &&
-                       return
+                       skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -2459,7 +2539,7 @@ test_33a() { # bug 12333, was test_33
        local fs2mdsvdev=$(mdsvdevname 1_2)
        local fs2ostvdev=$(ostvdevname 1_2)
 
-       if [ $(facet_fstype mds1) == ldiskfs ]; then
+       if [ "$mds1_FSTYPE" == ldiskfs ]; then
                mkfsoptions="--mkfsoptions=\\\"-J size=8\\\"" # See bug 17931.
        fi
 
@@ -2477,7 +2557,7 @@ test_33a() { # bug 12333, was test_33
        start fs2mds $fs2mdsdev $MDS_MOUNT_OPTS && trap cleanup_fs2 EXIT INT
        start fs2ost $fs2ostdev $OST_MOUNT_OPTS
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD timeout=200" ||
                        error "$PERM_CMD timeout=200 failed"
        else
@@ -2489,7 +2569,8 @@ test_33a() { # bug 12333, was test_33
        echo "ok."
 
        cp /etc/hosts $MOUNT2/ || error "copy /etc/hosts $MOUNT2/ failed"
-       $GETSTRIPE $MOUNT2/hosts || error "$GETSTRIPE $MOUNT2/hosts failed"
+       $LFS getstripe $MOUNT2/hosts ||
+               error "$LFS getstripe $MOUNT2/hosts failed"
 
        umount $MOUNT2
        stop fs2ost -f
@@ -2558,7 +2639,7 @@ test_35a() { # bug 12459
        local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
                awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD \
                              mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
                        error "Setting mdc.*${device}*.import=connection=\
@@ -2609,7 +2690,7 @@ test_35a() { # bug 12459
 run_test 35a "Reconnect to the last active server first"
 
 test_35b() { # bug 18674
-       remote_mds || { skip "local MDS" && return 0; }
+       remote_mds || skip "local MDS"
        setup
 
        debugsave
@@ -2623,7 +2704,7 @@ test_35b() { # bug 18674
        local device=$(do_facet $SINGLEMDS "$LCTL get_param -n devices" |
                awk '($3 ~ "mdt" && $4 ~ "MDT") { print $4 }' | head -1)
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                do_facet mgs "$PERM_CMD \
                              mdc.*${device}*.import=connection=$(h2nettype $FAKENID)" ||
                        error "Set mdc.*${device}*.import=connection=\
@@ -2699,10 +2780,10 @@ test_35b() { # bug 18674
 run_test 35b "Continue reconnection retries, if the active server is busy"
 
 test_36() { # 12743
-       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs"
 
        [ "$ost_HOST" = "`hostname`" -o "$ost1_HOST" = "`hostname`" ] ||
-               { skip "remote OST" && return 0; }
+               skip "remote OST"
 
        local rc=0
        local FSNAME2=test1234
@@ -2712,7 +2793,7 @@ test_36() { # 12743
 
        if [ -z "$fs2ost_DEV" -o -z "$fs2mds_DEV" -o -z "$fs3ost_DEV" ]; then
                is_blkdev $SINGLEMDS $MDSDEV &&
-               skip_env "mixed loopback and real device not working" && return
+                       skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -2722,6 +2803,7 @@ test_36() { # 12743
        local fs2ostvdev=$(ostvdevname 1_2)
        local fs3ostvdev=$(ostvdevname 2_2)
 
+       load_modules
        add fs2mds $(mkfs_opts mds1 ${fs2mdsdev}) --mgs --fsname=${FSNAME2} \
                --reformat $fs2mdsdev $fs2mdsvdev || exit 10
        # XXX after we support non 4K disk blocksize in ldiskfs, specify a
@@ -2787,9 +2869,8 @@ test_37() {
        local opts=$MDS_MOUNT_OPTS
        local rc=0
 
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        echo "MDS :     $mdsdev"
@@ -2803,6 +2884,8 @@ test_37() {
        if ! do_facet $SINGLEMDS test -b $mdsdev; then
                opts=$(csa_add "$opts" -o loop)
        fi
+
+       load_modules
        mount_op=$(do_facet $SINGLEMDS mount -v -t lustre $opts \
                $mdsdev_sym $mntpt 2>&1)
        rc=${PIPESTATUS[0]}
@@ -2820,7 +2903,6 @@ test_37() {
 run_test 37 "verify set tunables works for symlink device"
 
 test_38() { # bug 14222
-       local fstype=$(facet_fstype $SINGLEMDS)
        local mntpt=$(facet_mntpt $SINGLEMDS)
 
        setup
@@ -2915,14 +2997,12 @@ test_40() { # bug 15759
 run_test 40 "race during service thread startup"
 
 test_41a() { #bug 14134
-       if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
+       if [ "$mds1_FSTYPE" == ldiskfs ] &&
           ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
                skip "Loop devices does not work with nosvc option"
-               return
        fi
 
-       combined_mgs_mds ||
-               { skip "needs combined MGT and MDT device" && return 0; }
+       combined_mgs_mds || skip "needs combined MGT and MDT device"
 
        start_mdt 1 -o nosvc -n
        if [ $MDSCOUNT -ge 2 ]; then
@@ -2946,13 +3026,12 @@ test_41a() { #bug 14134
 run_test 41a "mount mds with --nosvc and --nomgs"
 
 test_41b() {
-       if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
+       if [ "$mds1_FSTYPE" == ldiskfs ] &&
           ! do_facet $SINGLEMDS test -b $(mdsdevname 1); then
                skip "Loop devices does not work with nosvc option"
-               return
        fi
 
-       ! combined_mgs_mds && skip "needs combined mgs device" && return 0
+       ! combined_mgs_mds && skip "needs combined mgs device"
 
        stopall
        reformat
@@ -2980,15 +3059,14 @@ test_41b() {
 run_test 41b "mount mds with --nosvc and --nomgs on first mount"
 
 test_41c() {
-       local server_version=$(lustre_version_code $SINGLEMDS)
        local oss_list=$(comma_list $(osts_nodes))
 
-       [[ $server_version -ge $(version_code 2.6.52) ]] ||
-       [[ $server_version -ge $(version_code 2.5.26) &&
-          $server_version -lt $(version_code 2.5.50) ]] ||
-       [[ $server_version -ge $(version_code 2.5.4) &&
-          $server_version -lt $(version_code 2.5.11) ]] ||
-               { skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"; return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.6.52) ]] ||
+       [[ "$MDS1_VERSION" -ge $(version_code 2.5.26) &&
+          "$MDS1_VERSION" -lt $(version_code 2.5.50) ]] ||
+       [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
+          "$MDS1_VERSION" -lt $(version_code 2.5.11) ]] ||
+               skip "Need MDS version 2.5.4+ or 2.5.26+ or 2.6.52+"
 
        # ensure mds1 ost1 have been created even if running sub-test standalone
        cleanup
@@ -3007,14 +3085,13 @@ test_41c() {
 
        local mds1dev=$(mdsdevname 1)
        local mds1mnt=$(facet_mntpt mds1)
-       local mds1fstype=$(facet_fstype mds1)
        local mds1opts=$MDS_MOUNT_OPTS
 
-       if [ $mds1fstype == ldiskfs ] &&
+       if [ "$mds1_FSTYPE" == ldiskfs ] &&
           ! do_facet mds1 test -b $mds1dev; then
                mds1opts=$(csa_add "$mds1opts" -o loop)
        fi
-       if [[ $mds1fstype == zfs ]]; then
+       if [[ "$mds1_FSTYPE" == zfs ]]; then
                import_zpool mds1 || return ${PIPESTATUS[0]}
        fi
 
@@ -3053,14 +3130,13 @@ test_41c() {
 
        local ost1dev=$(ostdevname 1)
        local ost1mnt=$(facet_mntpt ost1)
-       local ost1fstype=$(facet_fstype ost1)
        local ost1opts=$OST_MOUNT_OPTS
 
-       if [ $ost1fstype == ldiskfs ] &&
+       if [ "$ost1_FSTYPE" == ldiskfs ] &&
           ! do_facet ost1 test -b $ost1dev; then
                ost1opts=$(csa_add "$ost1opts" -o loop)
        fi
-       if [[ $ost1fstype == zfs ]]; then
+       if [[ "$ost1_FSTYPE" == zfs ]]; then
                import_zpool ost1 || return ${PIPESTATUS[0]}
        fi
 
@@ -3130,7 +3206,7 @@ test_42() { #bug 14693
        setup
        check_mount || error "client was not mounted"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                PARAM="llite.$FSNAME-*.some_wrong_param"
        else
                PARAM="$FSNAME.llite.some_wrong_param"
@@ -3151,14 +3227,13 @@ test_42() { #bug 14693
 run_test 42 "allow client/server mount/unmount with invalid config param"
 
 test_43a() {
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.5.58) ]] ||
-               { skip "Need MDS version at least 2.5.58" && return 0; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.5.58) ]] ||
+               skip "Need MDS version at least 2.5.58"
        [ $UID -ne 0 -o $RUNAS_ID -eq 0 ] && skip_env "run as root"
 
        ID1=${ID1:-501}
        USER1=$(getent passwd | grep :$ID1:$ID1: | cut -d: -f1)
-       [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1" &&
-               return
+       [ -z "$USER1" ] && skip_env "missing user with uid=$ID1 gid=$ID1"
 
        setup
        chmod ugo+x $DIR || error "chmod 0 failed"
@@ -3303,12 +3378,12 @@ test_43a() {
 run_test 43a "check root_squash and nosquash_nids"
 
 test_43b() { # LU-5690
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.7.62) ]] ||
-               { skip "Need MGS version 2.7.62+"; return; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.7.62) ]] ||
+               skip "Need MGS version 2.7.62+"
 
        if [[ -z "$fs2mds_DEV" ]]; then
                is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
-               skip_env "mixed loopback and real device not working" && return
+               skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -3416,12 +3491,13 @@ test_46a() {
        #second client see all ost's
 
        mount_client $MOUNT2 || error "mount_client failed"
-       $SETSTRIPE -c -1 $MOUNT2 || error "$SETSTRIPE -c -1 $MOUNT2 failed"
-       $GETSTRIPE $MOUNT2 || error "$GETSTRIPE $MOUNT2 failed"
+       $LFS setstripe -c -1 $MOUNT2 ||
+               error "$LFS setstripe -c -1 $MOUNT2 failed"
+       $LFS getstripe $MOUNT2 || error "$LFS getstripe $MOUNT2 failed"
 
        echo "ok" > $MOUNT2/widestripe
-       $GETSTRIPE $MOUNT2/widestripe ||
-               error "$GETSTRIPE $MOUNT2/widestripe failed"
+       $LFS getstripe $MOUNT2/widestripe ||
+               error "$LFS getstripe $MOUNT2/widestripe failed"
        # fill acl buffer for avoid expand lsm to them
        awk -F : '{if (FNR < 25) { print "u:"$1":rwx" }}' /etc/passwd |
                while read acl; do
@@ -3487,27 +3563,25 @@ test_48() { # bz-17636 LU-7473
        setup_noconfig
        check_mount || error "check_mount failed"
 
-       $SETSTRIPE -c -1 $MOUNT || error "$SETSTRIPE -c -1 $MOUNT failed"
-       $GETSTRIPE $MOUNT || error "$GETSTRIPE $MOUNT failed"
+       $LFS setstripe -c -1 $MOUNT ||
+               error "$LFS setstripe -c -1 $MOUNT failed"
+       $LFS getstripe $MOUNT || error "$LFS getstripe $MOUNT failed"
 
        echo "ok" > $MOUNT/widestripe
-       $GETSTRIPE $MOUNT/widestripe ||
-               error "$GETSTRIPE $MOUNT/widestripe failed"
+       $LFS getstripe $MOUNT/widestripe ||
+               error "$LFS getstripe $MOUNT/widestripe failed"
 
        # In the future, we may introduce more EAs, such as selinux, enlarged
        # LOV EA, and so on. These EA will use some EA space that is shared by
        # ACL entries. So here we only check some reasonable ACL entries count,
        # instead of the max number that is calculated from the max_ea_size.
-       if [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.8.57) ];
-       then
+       if [ "$MDS1_VERSION" -lt $(version_code 2.8.57) ]; then
                count=28        # hard coded of RPC protocol
-       elif [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
-               count=4000      # max_num 4091 max_ea_size = 32768
-       elif ! large_xattr_enabled; then
-               count=450       # max_num 497 max_ea_size = 4012
+       elif large_xattr_enabled; then
+               count=4500      # max_num 8187 max_ea_size = 65452
+                               # not create too many (4500) to save test time
        else
-               count=4500      # max_num 8187 max_ea_size = 1048492
-                               # not create too much (>5000) to save test time
+               count=450       # max_num 497 max_ea_size = 4012
        fi
 
        echo "It is expected to hold at least $count ACL entries"
@@ -3775,19 +3849,19 @@ test_50f() {
 run_test 50f "normal statfs one server in down"
 
 test_50g() {
-       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
        setup
        start_ost2 || error "Unable to start OST2"
-        wait_osc_import_state mds ost2 FULL
+       wait_osc_import_state mds ost2 FULL
        wait_osc_import_ready client ost2
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                local PARAM="osc.${FSNAME}-OST0001*.active"
        else
                local PARAM="${FSNAME}-OST0001.osc.active"
        fi
 
-       $SETSTRIPE -c -1 $DIR/$tfile || error "$SETSTRIPE failed"
+       $LFS setstripe -c -1 $DIR/$tfile || error "$LFS setstripe failed"
        do_facet mgs $PERM_CMD $PARAM=0 || error "Unable to deactivate OST"
 
        umount_client $MOUNT || error "Unable to unmount client"
@@ -3809,9 +3883,9 @@ run_test 50g "deactivated OST should not cause panic"
 # LU-642
 test_50h() {
        # prepare MDT/OST, make OSC inactive for OST1
-       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >=2 OSTs"
 
-       [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
        do_facet ost1 "$TUNEFS --param osc.active=0 `ostdevname 1`" ||
                error "tunefs OST1 failed"
        start_mds  || error "Unable to start MDT"
@@ -3827,17 +3901,18 @@ test_50h() {
                "${FSNAME}-OST0000.osc.active" 1
 
        mkdir $DIR/$tdir/2 || error "mkdir $DIR/$tdir/2 failed"
-       $SETSTRIPE -c -1 -i 0 $DIR/$tdir/2 ||
-               error "$SETSTRIPE $DIR/$tdir/2 failed"
+       $LFS setstripe -c -1 -i 0 $DIR/$tdir/2 ||
+               error "$LFS setstripe $DIR/$tdir/2 failed"
        sleep 1 && echo "create a file after OST1 is activated"
-       # create some file
-       createmany -o $DIR/$tdir/2/$tfile-%d 1
+       # doing some io, shouldn't crash
+       dd if=/dev/zero of=$DIR/$tdir/2/$tfile-io bs=1M count=10
 
        # check OSC import is working
        stat $DIR/$tdir/2/* >/dev/null 2>&1 ||
                error "some OSC imports are still not connected"
 
        # cleanup
+       rm -rf $DIR/$tdir
        umount_client $MOUNT || error "Unable to umount client"
        stop_ost2 || error "Unable to stop OST2"
        cleanup_nocli || error "cleanup_nocli failed with $?"
@@ -3846,7 +3921,7 @@ run_test 50h "LU-642: activate deactivated OST"
 
 test_50i() {
        # prepare MDT/OST, make OSC inactive for OST1
-       [ "$MDSCOUNT" -lt "2" ] && skip_env "needs >= 2 MDTs" && return
+       [ "$MDSCOUNT" -lt "2" ] && skip "needs >= 2 MDTs"
 
        load_modules
        [ $(facet_fstype mds2) == zfs ] && import_zpool mds2
@@ -3859,7 +3934,7 @@ test_50i() {
 
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
 
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                $PERM_CMD mdc.${FSNAME}-MDT0001-mdc-*.active=0 &&
                        error "deactive MDC0 succeeds"
        else
@@ -3873,7 +3948,7 @@ test_50i() {
                "${FSNAME}-MDT0001.mdc.active" 1
 
        wait_clients_import_state ${CLIENTS:-$HOSTNAME} mds2 FULL
-       if [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.60) ]
+       if [ "$MDS1_VERSION" -ge $(version_code 2.7.60) ]
        then
                wait_dne_interconnect
        fi
@@ -3916,8 +3991,8 @@ test_51() {
        check_mount || error "check_mount failed"
 
        mkdir $MOUNT/$tdir || error "mkdir $MOUNT/$tdir failed"
-       $SETSTRIPE -c -1 $MOUNT/$tdir ||
-               error "$SETSTRIPE -c -1 $MOUNT/$tdir failed"
+       $LFS setstripe -c -1 $MOUNT/$tdir ||
+               error "$LFS setstripe -c -1 $MOUNT/$tdir failed"
        #define OBD_FAIL_MDS_REINT_DELAY         0x142
        do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x142"
        touch $MOUNT/$tdir/$tfile &
@@ -3982,9 +4057,8 @@ diff_files_xattrs()
 }
 
 test_52() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        start_mds || error "Unable to start MDS"
@@ -4005,7 +4079,7 @@ test_52() {
                error "Unable to create temporary file"
        sleep 1
 
-       $SETSTRIPE -c -1 -S 1M $DIR/$tdir || error "$SETSTRIPE failed"
+       $LFS setstripe -c -1 -S 1M $DIR/$tdir || error "$LFS setstripe failed"
 
        for (( i=0; i < nrfiles; i++ )); do
                multiop $DIR/$tdir/$tfile-$i Ow1048576w1048576w524288c ||
@@ -4032,7 +4106,7 @@ test_52() {
        if ! do_node $ost1node test -b $ost1_dev; then
                loop="-o loop"
        fi
-       do_node $ost1node mount -t $(facet_fstype ost1) $loop $ost1_dev \
+       do_node $ost1node mount -t "$ost1_FSTYPE" $loop $ost1_dev \
                $ost1mnt ||
                error "Unable to mount ost1 as ldiskfs"
 
@@ -4124,8 +4198,7 @@ thread_sanity() {
        fi
 
        [ $tmin -eq $tmax -a $tmin -eq $tstarted ] &&
-               skip_env "module parameter forced $facet thread count" &&
-               tmin=3 && tmax=$((3 * tmax))
+               skip_env "module parameter forced $facet thread count"
 
        # Check that we can change min/max
        do_facet $facet "$LCTL set_param \
@@ -4172,10 +4245,12 @@ thread_sanity() {
        setmodopts $modname "$oldvalue"
 
        # Check that $opts took
-       tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min")
-       tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max")
+       tmin=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_min" ||
+               echo 0)
+       tmax=$(do_facet $facet "$LCTL get_param -n ${paramp}.threads_max" ||
+               echo 0)
        tstarted=$(do_facet $facet \
-                  "$LCTL get_param -n ${paramp}.threads_started")
+                  "$LCTL get_param -n ${paramp}.threads_started" || echo 0)
        lassert 28 "$msg" '(($tstarted >= $tmin && $tstarted <= $tmax ))' ||
                return $?
        cleanup
@@ -4205,9 +4280,8 @@ test_53b() {
 run_test 53b "check MDS thread count params"
 
 test_54a() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        do_rpc_nodes $(facet_host ost1) run_llverdev $(ostdevname 1) -p ||
@@ -4217,9 +4291,8 @@ test_54a() {
 run_test 54a "test llverdev and partial verify of device"
 
 test_54b() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        setup
@@ -4235,9 +4308,8 @@ lov_objid_size()
 }
 
 test_55() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        local mdsdev=$(mdsdevname 1)
@@ -4269,12 +4341,11 @@ test_55() {
                stopall
        done
 
-       reformat
+       reformat_and_config
 }
 run_test 55 "check lov_objid size"
 
 test_56a() {
-       local server_version=$(lustre_version_code $SINGLEMDS)
        local mds_journal_size_orig=$MDSJOURNALSIZE
        local n
 
@@ -4293,12 +4364,12 @@ test_56a() {
        echo ok
        $LFS osts
 
-       if [[ $server_version -ge $(version_code 2.6.54) ]] ||
-          [[ $server_version -ge $(version_code 2.5.4) &&
-             $server_version -lt $(version_code 2.5.11) ]]; then
+       if [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
+          [[ "$MDS1_VERSION" -ge $(version_code 2.5.4) &&
+             "$MDS1_VERSION" -lt $(version_code 2.5.11) ]]; then
                wait_osc_import_state mds ost1 FULL
                wait_osc_import_state mds ost2 FULL
-               $SETSTRIPE --stripe-count=-1 $DIR/$tfile ||
+               $LFS setstripe --stripe-count=-1 $DIR/$tfile ||
                        error "Unable to setstripe $DIR/$tfile"
                n=$($LFS getstripe --stripe-count $DIR/$tfile)
                [ "$n" -eq 2 ] || error "Stripe count not two: $n"
@@ -4307,7 +4378,7 @@ test_56a() {
 
        stopall
        MDSJOURNALSIZE=$mds_journal_size_orig
-       reformat
+       reformat_and_config
 }
 run_test 56a "check big OST indexes and out-of-index-order start"
 
@@ -4319,11 +4390,11 @@ cleanup_56b() {
        stop mds2
        stop mds3
        stopall
-       reformat
+       reformat_and_config
 }
 
 test_56b() {
-       [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
+       [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
 
        trap cleanup_56b EXIT RETURN ERR
        stopall
@@ -4413,12 +4484,12 @@ test_57a() { # bug 22656
        local NID=$(do_facet ost1 "$LCTL get_param nis" |
                    tail -1 | awk '{print $1}')
        writeconf_or_reformat
-       [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
        do_facet ost1 "$TUNEFS --failnode=$NID `ostdevname 1`" ||
                error "tunefs failed"
        start_mgsmds
        start_ost && error "OST registration from failnode should fail"
-       reformat
+       cleanup
 }
 run_test 57a "initial registration from failnode should fail (should return errs)"
 
@@ -4427,12 +4498,12 @@ test_57b() {
        local NID=$(do_facet ost1 "$LCTL get_param nis" |
                    tail -1 | awk '{print $1}')
        writeconf_or_reformat
-       [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
        do_facet ost1 "$TUNEFS --servicenode=$NID `ostdevname 1`" ||
                error "tunefs failed"
        start_mgsmds
        start_ost || error "OST registration from servicenode should not fail"
-       reformat
+       cleanup
 }
 run_test 57b "initial registration from servicenode should not fail"
 
@@ -4460,7 +4531,7 @@ test_58() { # bug 22658
        # restart MDS with missing llog files
        start_mds || error "unable to start MDS"
        do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
-       reformat
+       cleanup
 }
 run_test 58 "missing llog files must not prevent MDT from mounting"
 
@@ -4498,13 +4569,12 @@ test_59() {
 run_test 59 "writeconf mount option"
 
 test_60() { # LU-471
-       local num
-
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
+       local num
+
        for num in $(seq $MDSCOUNT); do
                add mds${num} $(mkfs_opts mds${num} $(mdsdevname $num)) \
                        --mkfsoptions='\" -E stride=64 -O ^uninit_bg\"' \
@@ -4521,17 +4591,18 @@ test_60() { # LU-471
        echo $dump | grep uninit_bg > /dev/null && error "uninit_bg is set"
        # we set stride extended options
        echo $dump | grep stride > /dev/null || error "stride is not set"
-       reformat
+       stop_mds
+       reformat_and_config
 }
 run_test 60 "check mkfs.lustre --mkfsoptions -E -O options setting"
 
 test_61() { # LU-80
-       local lxattr=false
+       local lxattr=$(large_xattr_enabled)
 
-       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.1.53) ] ||
-               { skip "Need MDS version at least 2.1.53"; return 0; }
+       [ "$MDS1_VERSION" -ge $(version_code 2.1.53) ] ||
+               skip "Need MDS version at least 2.1.53"
 
-       if [ $(facet_fstype $SINGLEMDS) == ldiskfs ] &&
+       if [ "$mds1_FSTYPE" == ldiskfs ] &&
             ! large_xattr_enabled; then
                lxattr=true
 
@@ -4542,8 +4613,7 @@ test_61() { # LU-80
                done
        fi
 
-       combined_mgs_mds || stop_mgs || error "stopping MGS service failed"
-       setup_noconfig || error "setting up the filesystem failed"
+       setup || error "setting up the filesystem failed"
        client_up || error "starting client failed"
 
        local file=$DIR/$tfile
@@ -4553,7 +4623,7 @@ test_61() { # LU-80
        local small_value="bar"
 
        local name="trusted.big"
-       log "save large xattr $name on $file"
+       log "save large xattr of $(max_xattr_size) bytes on $name on $file"
        setfattr -n $name -v $large_value $file ||
                error "saving $name on $file failed"
 
@@ -4586,7 +4656,7 @@ test_61() { # LU-80
        log "remove large xattr $name from $file"
        setfattr -x $name $file || error "removing $name from $file failed"
 
-       if $lxattr; then
+       if $lxattr && [ "$mds1_FSTYPE" == ldiskfs ]; then
                stopall || error "stopping for e2fsck run"
                for num in $(seq $MDSCOUNT); do
                        run_e2fsck $(facet_active_host mds$num) \
@@ -4598,23 +4668,21 @@ test_61() { # LU-80
 
        # need to delete this file to avoid problems in other tests
        rm -f $file
-       stopall || error "stopping systems failed"
+       cleanup || error "stopping systems failed"
 }
 run_test 61 "large xattr"
 
 test_62() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
+       [[ "$MDS1_VERSION" -ge $(version_code 2.2.51) ]] ||
+               skip "Need MDS version at least 2.2.51"
 
        # MRP-118
        local mdsdev=$(mdsdevname 1)
        local ostdev=$(ostdevname 1)
 
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.2.51) ]] ||
-               { skip "Need MDS version at least 2.2.51"; return 0; }
-
        echo "disable journal for mds"
        do_facet mds1 $TUNE2FS -O ^has_journal $mdsdev || error "tune2fs failed"
        start_mds && error "MDT start should fail"
@@ -4627,9 +4695,8 @@ test_62() {
 run_test 62 "start with disabled journal"
 
 test_63() {
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ldiskfs
@@ -4637,7 +4704,10 @@ test_63() {
                           awk '/ldiskfs_inode_cache/ { print $5 / $6 }')
        if [ -z "$inode_slab" ]; then
                skip "ldiskfs module has not been loaded"
-               return
+       fi
+
+       if grep -q "CONFIG_DEBUG_LOCK_ALLOC=y" /boot/config-$(uname -r); then
+               skip "test is not compatible with CONFIG_DEBUG_LOCK_ALLOC=y"
        fi
 
        echo "$inode_slab ldiskfs inodes per page"
@@ -4646,7 +4716,7 @@ test_63() {
        # If kmalloc-128 is also 1 per page - this is a debug kernel
        # and so this is not an error.
        local kmalloc128=$(do_facet $SINGLEMDS "cat /proc/slabinfo" |
-                          awk '/^(kmalloc|size)-128 / { print $5 / $6 }')
+                          awk '/^(dma-kmalloc|size)-128 / { print $5 / $6 }')
        # 32 128-byte chunks in 4k
        [ "${kmalloc128%.*}" -lt "32" ] ||
                error "ldiskfs inode too big, only $inode_slab objs/page, " \
@@ -4671,8 +4741,8 @@ run_test 64 "check lfs df --lazy "
 
 test_65() { # LU-2237
        # Currently, the test is only valid for ldiskfs backend
-       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
+       [ "$mds1_FSTYPE" != ldiskfs ] &&
+               skip "ldiskfs only test"
 
        local devname=$(mdsdevname ${SINGLEMDS//mds/})
        local brpt=$(facet_mntpt brpt)
@@ -4696,7 +4766,7 @@ test_65() { # LU-2237
        # remove the "last_rcvd" file
        do_facet $SINGLEMDS "mkdir -p $brpt"
        do_facet $SINGLEMDS \
-               "mount -t $(facet_fstype $SINGLEMDS) $opts $devname $brpt"
+               "mount -t $mds1_FSTYPE $opts $devname $brpt"
        do_facet $SINGLEMDS "rm -f ${brpt}/last_rcvd"
        do_facet $SINGLEMDS "$UMOUNT $brpt"
 
@@ -4710,8 +4780,8 @@ test_65() { # LU-2237
 run_test 65 "re-create the lost last_rcvd file when server mount"
 
 test_66() {
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.3.59) ]] ||
-               { skip "Need MGS version at least 2.3.59"; return 0; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.3.59) ]] ||
+               skip "Need MGS version at least 2.3.59"
 
        setup
        local OST1_NID=$(do_facet ost1 $LCTL list_nids | head -1)
@@ -4756,6 +4826,8 @@ test_66() {
        echo "wrong nids list should not destroy the system"
        do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "wrong nids list" &&
                error "wrong parse"
+       do_facet mgs $LCTL replace_nids $FSNAME-OST0000 "asdfasdf, asdfadf" &&
+               error "wrong parse"
 
        echo "replace OST nid"
        do_facet mgs $LCTL replace_nids $FSNAME-OST0000 $OST1_NID ||
@@ -4769,6 +4841,14 @@ test_66() {
        do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 "wrong nids list" &&
                error "wrong parse"
 
+       local FAKE_NIDS="192.168.0.112@tcp1,192.168.0.112@tcp2"
+       local FAKE_FAILOVER="192.168.0.113@tcp1,192.168.0.113@tcp2"
+       local NIDS_AND_FAILOVER="$MDS_NID,$FAKE_NIDS:$FAKE_FAILOVER"
+       echo "set NIDs with failover"
+       do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $NIDS_AND_FAILOVER ||
+               error "replace nids failed"
+
+
        echo "replace MDS nid"
        do_facet mgs $LCTL replace_nids $FSNAME-MDT0000 $MDS_NID ||
                error "replace nids failed"
@@ -4789,7 +4869,7 @@ test_66() {
 
        check_mount || error "error after nid replace"
        cleanup || error "cleanup failed"
-       reformat
+       reformat_and_config
 }
 run_test 66 "replace nids"
 
@@ -4857,17 +4937,13 @@ test_68() {
        local START
        local END
 
-       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.4.53) ] ||
-               { skip "Need MDS version at least 2.4.53"; return 0; }
+       [ "$MDS1_VERSION" -ge $(version_code 2.4.53) ] ||
+               skip "Need MDS version at least 2.4.53"
 
        umount_client $MOUNT || error "umount client failed"
 
-       if ! combined_mgs_mds; then
-               start_mgs || error "start mgs failed"
-       fi
-
-       start_mdt 1 || error "MDT start failed"
-       start_ost || error "Unable to start OST1"
+       start_mgsmds
+       start_ost
 
        # START-END - the sequences we'll be reserving
        START=$(do_facet $SINGLEMDS \
@@ -4906,14 +4982,12 @@ run_test 68 "be able to reserve specific sequences in FLDB"
 # just "precreate" the missing objects. In the past it might try to recreate
 # millions of objects after an OST was reformatted
 test_69() {
-       local server_version=$(lustre_version_code $SINGLEMDS)
-
-       [[ $server_version -lt $(version_code 2.4.2) ]] &&
-               skip "Need MDS version at least 2.4.2" && return
+       [[ "$MDS1_VERSION" -lt $(version_code 2.4.2) ]] &&
+               skip "Need MDS version at least 2.4.2"
 
-       [[ $server_version -ge $(version_code 2.4.50) ]] &&
-       [[ $server_version -lt $(version_code 2.5.0) ]] &&
-               skip "Need MDS version at least 2.5.0" && return
+       [[ "$MDS1_VERSION" -ge $(version_code 2.4.50) ]] &&
+       [[ "$MDS1_VERSION" -lt $(version_code 2.5.0) ]] &&
+               skip "Need MDS version at least 2.5.0"
 
        setup
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
@@ -4922,7 +4996,7 @@ test_69() {
        local OSTNAME=$(ostname_from_index 0)
        local mdtosc_proc1=$(get_mdtosc_proc_path mds1 $OSTNAME)
        local last_id=$(do_facet mds1 $LCTL get_param -n \
-                       osc.$mdtosc_proc1.prealloc_last_id)
+                       osp.$mdtosc_proc1.prealloc_last_id)
 
        # Want to have OST LAST_ID over 5 * OST_MAX_PRECREATE to
        # verify that the LAST_ID recovery is working properly. If
@@ -4940,8 +5014,8 @@ test_69() {
                local ifree=$($LFS df -i $MOUNT | awk '/OST0000/ { print $4 }')
                log "On OST0, $ifree inodes available. Want $num_create."
 
-               $SETSTRIPE -i 0 $DIR/$tdir ||
-                       error "$SETSTRIPE -i 0 $DIR/$tdir failed"
+               $LFS setstripe -i 0 $DIR/$tdir ||
+                       error "$LFS setstripe -i 0 $DIR/$tdir failed"
                if [ $ifree -lt 10000 ]; then
                        files=$(( ifree - 50 ))
                else
@@ -4971,7 +5045,7 @@ test_69() {
 
        mount_client $MOUNT || error "mount client failed"
        touch $DIR/$tdir/$tfile-last || error "create file after reformat"
-       local idx=$($GETSTRIPE -i $DIR/$tdir/$tfile-last)
+       local idx=$($LFS getstripe -i $DIR/$tdir/$tfile-last)
        [ $idx -ne 0 ] && error "$DIR/$tdir/$tfile-last on $idx not 0" || true
 
        local iused=$($LFS df -i $MOUNT | awk '/OST0000/ { print $3 }')
@@ -4983,7 +5057,7 @@ test_69() {
 run_test 69 "replace an OST with the same index"
 
 test_70a() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        local MDTIDX=1
 
        cleanup || error "cleanup failed with $?"
@@ -5008,7 +5082,7 @@ test_70a() {
 run_test 70a "start MDT0, then OST, then MDT1"
 
 test_70b() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        local MDTIDX=1
 
        start_ost || error "OST0 start fail"
@@ -5029,7 +5103,7 @@ test_70b() {
 run_test 70b "start OST, MDT1, MDT0"
 
 test_70c() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        local MDTIDX=1
 
        start_mds || error "MDS start fail"
@@ -5053,7 +5127,7 @@ test_70c() {
 run_test 70c "stop MDT0, mkdir fail, create remote dir fail"
 
 test_70d() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        local MDTIDX=1
 
        start_mds || error "MDS start fail"
@@ -5080,12 +5154,14 @@ test_70d() {
 run_test 70d "stop MDT1, mkdir succeed, create remote dir fail"
 
 test_70e() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
 
-       [ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.62) ] ||
-               { skip "Need MDS version at least 2.7.62"; return 0; }
+       [ "$MDS1_VERSION" -ge $(version_code 2.7.62) ] ||
+               skip "Need MDS version at least 2.7.62"
 
-       cleanup || error "cleanup failed with $?"
+       reformat || error "reformat failed with $?"
+
+       load_modules
 
        local mdsdev=$(mdsdevname 1)
        local ostdev=$(ostdevname 1)
@@ -5094,6 +5170,10 @@ test_70e() {
        local opts_mds="$(mkfs_opts mds1 $mdsdev) --reformat $mdsdev $mdsvdev"
        local opts_ost="$(mkfs_opts ost1 $ostdev) --reformat $ostdev $ostvdev"
 
+       if ! combined_mgs_mds ; then
+               start_mgs
+       fi
+
        add mds1 $opts_mds || error "add mds1 failed"
        start_mdt 1 || error "start mdt1 failed"
        add ost1 $opts_ost || error "add ost1 failed"
@@ -5134,9 +5214,9 @@ test_70e() {
 run_test 70e "Sync-on-Cancel will be enabled by default on DNE"
 
 test_71a() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        if combined_mgs_mds; then
-               skip "needs separate MGS/MDT" && return
+               skip "needs separate MGS/MDT"
        fi
        local MDTIDX=1
 
@@ -5165,9 +5245,9 @@ test_71a() {
 run_test 71a "start MDT0 OST0, MDT1, OST1"
 
 test_71b() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
        if combined_mgs_mds; then
-               skip "needs separate MGS/MDT" && return
+               skip "needs separate MGS/MDT"
        fi
        local MDTIDX=1
 
@@ -5195,10 +5275,9 @@ test_71b() {
 run_test 71b "start MDT1, OST0, MDT0, OST1"
 
 test_71c() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       if combined_mgs_mds; then
-               skip "needs separate MGS/MDT" && return
-       fi
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       combined_mgs_mds && skip "needs separate MGS/MDT"
+
        local MDTIDX=1
 
        start_ost || error "OST0 start fail"
@@ -5226,10 +5305,9 @@ test_71c() {
 run_test 71c "start OST0, OST1, MDT1, MDT0"
 
 test_71d() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       if combined_mgs_mds; then
-               skip "needs separate MGS/MDT" && return
-       fi
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       combined_mgs_mds && skip "needs separate MGS/MDT"
+
        local MDTIDX=1
 
        start_ost || error "OST0 start fail"
@@ -5257,10 +5335,9 @@ test_71d() {
 run_test 71d "start OST0, MDT1, MDT0, OST1"
 
 test_71e() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       if combined_mgs_mds; then
-               skip "needs separate MGS/MDT" && return
-       fi
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       combined_mgs_mds && skip "needs separate MGS/MDT"
+
        local MDTIDX=1
 
        start_ost || error "OST0 start fail"
@@ -5288,14 +5365,17 @@ test_71e() {
 run_test 71e "start OST0, MDT1, OST1, MDT0"
 
 test_72() { #LU-2634
+       [ "$mds1_FSTYPE" != ldiskfs ] &&
+               skip "ldiskfs only test"
+
        local mdsdev=$(mdsdevname 1)
        local ostdev=$(ostdevname 1)
        local cmd="$E2FSCK -fnvd $mdsdev"
        local fn=3
        local add_options
 
-       [ "$(facet_fstype $SINGLEMDS)" != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
+       cleanup
+       load_modules
 
        if combined_mgs_mds; then
                add_options='--reformat'
@@ -5339,7 +5419,7 @@ test_72() { #LU-2634
 run_test 72 "test fast symlink with extents flag enabled"
 
 test_73() { #LU-3006
-       [ $(facet_fstype ost1) == zfs ] && import_zpool ost1
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
        do_facet ost1 "$TUNEFS --failnode=1.2.3.4@$NETTYPE $(ostdevname 1)" ||
                error "1st tunefs failed"
        start_mgsmds || error "start mds failed"
@@ -5348,20 +5428,20 @@ test_73() { #LU-3006
        $LCTL get_param -n osc.*OST0000-osc-[^M]*.import | grep failover_nids |
                grep 1.2.3.4@$NETTYPE || error "failover nids haven't changed"
        umount_client $MOUNT || error "umount client failed"
-       stopall
-       reformat
+       stop_ost
+       stop_mds
 }
 run_test 73 "failnode to update from mountdata properly"
 
 test_75() { # LU-2374
-       [[ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.4.1) ]] &&
-                       skip "Need MDS version at least 2.4.1" && return
+       [[ "$MDS1_VERSION" -lt $(version_code 2.4.1) ]] &&
+               skip "Need MDS version at least 2.4.1"
 
        local index=0
        local opts_mds="$(mkfs_opts mds1 $(mdsdevname 1)) \
-               --reformat $(mdsdevname 1) $(mdsvdevname 1)"
+               --replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
        local opts_ost="$(mkfs_opts ost1 $(ostdevname 1)) \
-               --reformat $(ostdevname 1) $(ostvdevname 1)"
+               --replace --reformat $(ostdevname 1) $(ostvdevname 1)"
 
        #check with default parameters
        add mds1 $opts_mds || error "add mds1 failed for default params"
@@ -5376,21 +5456,16 @@ test_75() { # LU-2374
 
        add mds1 $opts_mds || error "add mds1 failed for new params"
        add ost1 $opts_ost || error "add ost1 failed for new params"
-       if ! combined_mgs_mds; then
-               stop_mgs || error "stop mgs failed"
-       fi
-       reformat
+
+       reformat_and_config
        return 0
 }
 run_test 75 "The order of --index should be irrelevant"
 
 test_76a() {
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.4.52) ]] ||
-               { skip "Need MDS version at least 2.4.52" && return 0; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.4.52) ]] ||
+               skip "Need MDS version at least 2.4.52"
 
-       if ! combined_mgs_mds; then
-               start_mgs || error "start mgs failed"
-       fi
        setup
        local MDMB_PARAM="osc.*.max_dirty_mb"
        echo "Change MGS params"
@@ -5448,8 +5523,8 @@ test_76a() {
 run_test 76a "set permanent params with lctl across mounts"
 
 test_76b() { # LU-4783
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.5.57) ]] ||
-               { skip "Need MGS version at least 2.5.57" && return 0; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.5.57) ]] ||
+               skip "Need MGS version at least 2.5.57"
        stopall
        setupall
        do_facet mgs $LCTL get_param mgs.MGS.live.params ||
@@ -5459,8 +5534,8 @@ test_76b() { # LU-4783
 run_test 76b "verify params log setup correctly"
 
 test_76c() {
-       [[ $(lustre_version_code mgs) -ge $(version_code 2.8.54) ]] ||
-               { skip "Need MDS version at least 2.4.52" && return 0; }
+       [[ "$MGS_VERSION" -ge $(version_code 2.8.54) ]] ||
+               skip "Need MDS version at least 2.4.52"
        setupall
        local MASK_PARAM="mdd.*.changelog_mask"
        echo "Change changelog_mask"
@@ -5509,13 +5584,12 @@ test_76d() { #LU-9399
 run_test 76d "verify llite.*.xattr_cache can be set by 'lctl set_param -P' correctly"
 
 test_77() { # LU-3445
-       local server_version=$(lustre_version_code $SINGLEMDS)
-       [[ $server_version -ge $(version_code 2.8.55) ]] ||
-               { skip "Need MDS version 2.8.55+ "; return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.8.55) ]] ||
+               skip "Need MDS version 2.8.55+ "
 
        if [[ -z "$fs2ost_DEV" || -z "$fs2mds_DEV" ]]; then
                is_blkdev $SINGLEMDS $(mdsdevname ${SINGLEMDS//mds/}) &&
-               skip_env "mixed loopback and real device not working" && return
+               skip_env "mixed loopback and real device not working"
        fi
 
        local fs2mdsdev=$(mdsdevname 1_2)
@@ -5550,9 +5624,9 @@ test_77() { # LU-3445
 run_test 77 "comma-separated MGS NIDs and failover node NIDs"
 
 test_78() {
-       [[ $(facet_fstype $SINGLEMDS) != ldiskfs ||
-          $(facet_fstype ost1) != ldiskfs ]] &&
-               skip "ldiskfs only test" && return
+       [[ "$mds1_FSTYPE" != ldiskfs ||
+          "$ost1_FSTYPE" != ldiskfs ]] &&
+               skip "ldiskfs only test"
 
        # reformat the Lustre filesystem with a smaller size
        local saved_MDSCOUNT=$MDSCOUNT
@@ -5684,7 +5758,8 @@ test_78() {
        # check whether the MDT or OST filesystem was shrunk or not
        if ! $shrunk; then
                combined_mgs_mds || stop_mgs || error "(9) stop mgs failed"
-               reformat || error "(10) reformat Lustre filesystem failed"
+               reformat_and_config ||
+                       error "(10) reformat Lustre filesystem failed"
                return 0
        fi
 
@@ -5709,13 +5784,13 @@ test_78() {
 
        MDSCOUNT=$saved_MDSCOUNT
        OSTCOUNT=$saved_OSTCOUNT
-       reformat || error "(14) reformat Lustre filesystem failed"
+       reformat_and_config || error "(14) reformat Lustre filesystem failed"
 }
 run_test 78 "run resize2fs on MDT and OST filesystems"
 
 test_79() { # LU-4227
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.5.59) ]] ||
-               { skip "Need MDS version at least 2.5.59"; return 0; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.5.59) ]] ||
+               skip "Need MDS version at least 2.5.59"
 
        local mdsdev1=$(mdsdevname 1)
        local mdsvdev1=$(mdsvdevname 1)
@@ -5734,15 +5809,15 @@ test_79() { # LU-4227
        mgsnode_opt=$(echo $opts_mds2 |
                awk '{ for ( i = 1; i < NF; i++ )
                        if ( $i ~ "--mgsnode" ) { print $i; break } }')
-       [ -n $mgsnode_opt ] &&
+       [ -n "$mgsnode_opt" ] &&
                opts_mds2=$(echo $opts_mds2 | sed -e "s/$mgsnode_opt//")
 
        mgsnode_opt=$(echo $opts_ost1 |
                awk '{ for ( i = 1; i < NF; i++ )
                        if ( $i ~ "--mgsnode" ) { print $i; break } }')
-       [ -n $mgsnode_opt ] &&
+       [ -n "$mgsnode_opt" ] &&
                opts_ost1=$(echo $opts_ost1 | sed -e "s/$mgsnode_opt//")
-
+       load_modules
        # -MGS, format a mdt without --mgs option
        add mds1 $opts_mds1 $mdsdev1 $mdsvdev1 &&
                error "Must specify --mgs when formatting mdt combined with mgs"
@@ -5755,7 +5830,7 @@ test_79() { # LU-4227
        add ost1 $opts_ost1 $ostdev1 $ostvdev2 &&
                error "Must specify --mgsnode when formatting an ost"
 
-       reformat
+       reformat_and_config
 }
 run_test 79 "format MDT/OST without mgs option (should return errors)"
 
@@ -5771,7 +5846,9 @@ test_80() {
        start_ost2 || error "Failed to start OST2"
 
        do_facet ost1 "$LCTL set_param fail_loc=0"
-       stopall
+       stop_ost2
+       stop_ost
+       stop_mds
 }
 run_test 80 "mgc import reconnect race"
 
@@ -5802,16 +5879,19 @@ restore_ostindex() {
        done
        OSTCOUNT=$saved_ostcount
 
-       formatall
+       reformat
+       if ! combined_mgs_mds ; then
+               start_mgs
+       fi
 }
 
 # The main purpose of this test is to ensure the OST_INDEX_LIST functions as
 # expected. This test uses OST_INDEX_LIST to format OSTs with a randomly
 # assigned index and ensures we can mount such a formatted file system
 test_81() { # LU-4665
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
-               { skip "Need MDS version at least 2.6.54" && return; }
-       [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
+               skip "Need MDS version at least 2.6.54"
+       [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
 
        stopall
 
@@ -5849,8 +5929,16 @@ test_81() { # LU-4665
 
        # Check max_easize.
        local max_easize=$($LCTL get_param -n llite.*.max_easize)
-       [[ $max_easize -eq 128 ]] ||
-               error "max_easize is $max_easize, should be 128 bytes"
+       # 65452 is XATTR_SIZE_MAX less ldiskfs ea overhead
+       if large_xattr_enabled; then
+               [[ $max_easize -ge 65452 ]] ||
+                       error "max_easize is $max_easize, should be at least 65452 bytes"
+       else
+               # LU-11868
+               # 4012 is 4096 less ldiskfs ea overhead
+               [[ $max_easize -ge 4012 ]] ||
+                       error "max_easize is $max_easize, should be at least 4012 bytes"
+       fi
 
        restore_ostindex
 }
@@ -5871,9 +5959,9 @@ run_test 81 "sparse OST indexing"
 #
 # 5. Lastly ensure this functionality fails with directories.
 test_82a() { # LU-4665
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
-               { skip "Need MDS version at least 2.6.54" && return; }
-       [[ $OSTCOUNT -ge 3 ]] || { skip_env "needs >= 3 OSTs" && return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
+               skip "Need MDS version at least 2.6.54"
+       [[ $OSTCOUNT -ge 3 ]] || skip_env "needs >= 3 OSTs"
 
        stopall
 
@@ -5890,7 +5978,7 @@ test_82a() { # LU-4665
        done
        ost_indices=$(comma_list $ost_indices)
 
-       trap "restore_ostindex" EXIT
+       stack_trap "restore_ostindex" EXIT
        echo -e "\nFormat $OSTCOUNT OSTs with sparse indices $ost_indices"
        OST_INDEX_LIST=[$ost_indices] formatall
 
@@ -5901,16 +5989,23 @@ test_82a() { # LU-4665
                        error "start ost$i failed"
        done
 
+       # Collect debug information - start of test
+       do_nodes $(comma_list $(mdts_nodes)) \
+                  $LCTL get_param osp.*.prealloc_*_id
+
        mount_client $MOUNT || error "mount client $MOUNT failed"
        wait_osts_up
 
        $LFS df $MOUNT || error "$LFS df $MOUNT failed"
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
 
+       stack_trap "do_nodes $(comma_list $(mdts_nodes)) \
+                  $LCTL get_param osp.*.prealloc_*_id" EXIT
+
        # 1. If the file does not exist, new file will be created
        #    with specified OSTs.
        local file=$DIR/$tdir/$tfile-1
-       local cmd="$SETSTRIPE -o $ost_indices $file"
+       local cmd="$LFS setstripe -o $ost_indices $file"
        echo -e "\n$cmd"
        eval $cmd || error "$cmd failed"
        check_stripe_count $file $OSTCOUNT
@@ -5922,7 +6017,7 @@ test_82a() { # LU-4665
        #    will be attached with specified layout.
        file=$DIR/$tdir/$tfile-2
        mcreate $file || error "mcreate $file failed"
-       cmd="$SETSTRIPE -o $ost_indices $file"
+       cmd="$LFS setstripe -o $ost_indices $file"
        echo -e "\n$cmd"
        eval $cmd || error "$cmd failed"
        dd if=/dev/urandom of=$file count=1 bs=1M > /dev/null 2>&1 ||
@@ -5939,7 +6034,7 @@ test_82a() { # LU-4665
        #    be in the OST indices list.
        local start_ost_idx=${ost_indices##*,}
        file=$DIR/$tdir/$tfile-3
-       cmd="$SETSTRIPE -o $ost_indices -i $start_ost_idx $file"
+       cmd="$LFS setstripe -o $ost_indices -i $start_ost_idx $file"
        echo -e "\n$cmd"
        eval $cmd || error "$cmd failed"
        check_stripe_count $file $OSTCOUNT
@@ -5947,7 +6042,7 @@ test_82a() { # LU-4665
        check_start_ost_idx $file $start_ost_idx
 
        file=$DIR/$tdir/$tfile-4
-       cmd="$SETSTRIPE"
+       cmd="$LFS setstripe"
        cmd+=" -o $(exclude_items_from_list $ost_indices $start_ost_idx)"
        cmd+=" -i $start_ost_idx $file"
        echo -e "\n$cmd"
@@ -5956,9 +6051,9 @@ test_82a() { # LU-4665
        # 5. Specifying OST indices for directory should succeed.
        local dir=$DIR/$tdir/$tdir
        mkdir $dir || error "mkdir $dir failed"
-       cmd="$SETSTRIPE -o $ost_indices $dir"
-       if [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.11.53) &&
-          $(lustre_version_code client -gt $(version_code 2.11.53)) ]]; then
+       cmd="$LFS setstripe -o $ost_indices $dir"
+       if [ "$MDS1_VERSION" -gt $(version_code 2.11.53) ] &&
+               [ "$CLIENT_VERSION" -gt $(version_code 2.11.53) ]; then
                echo -e "\n$cmd"
                eval $cmd || error "unable to specify OST indices on directory"
        else
@@ -5975,9 +6070,6 @@ cleanup_82b() {
        # Remove OSTs from a pool and destroy the pool.
        destroy_pool $ost_pool || true
 
-       if ! combined_mgs_mds ; then
-               umount_mgs_client
-       fi
        restore_ostindex
 }
 
@@ -5986,9 +6078,9 @@ cleanup_82b() {
 # the supplied OST index list points to OSTs not contained in the user
 # supplied pool.
 test_82b() { # LU-4665
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.6.54) ]] ||
-               { skip "Need MDS version at least 2.6.54" && return; }
-       [[ $OSTCOUNT -ge 4 ]] || { skip_env "needs >= 4 OSTs" && return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.6.54) ]] ||
+               skip "Need MDS version at least 2.6.54"
+       [[ $OSTCOUNT -ge 4 ]] || skip_env "needs >= 4 OSTs"
 
        stopall
 
@@ -6017,9 +6109,6 @@ test_82b() { # LU-4665
        done
 
        mount_client $MOUNT || error "mount client $MOUNT failed"
-       if ! combined_mgs_mds ; then
-               mount_mgs_client
-       fi
 
        wait_osts_up
        $LFS df $MOUNT || error "$LFS df $MOUNT failed"
@@ -6057,17 +6146,17 @@ test_82b() { # LU-4665
        # If [--pool|-p <pool_name>] is set with [--ost-list|-o <ost_indices>],
        # then the OSTs must be the members of the pool.
        local file=$DIR/$tdir/$tfile
-       cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
+       cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
        echo -e "\n$cmd"
        eval $cmd && error "OST with index $ost_idx_in_list should be" \
                           "in OST pool $ost_pool"
 
        # Only select OST $ost_idx_in_list from $ost_pool for file.
        ost_idx_in_list=${ost_idx_in_pool#*,}
-       cmd="$SETSTRIPE -p $ost_pool -o $ost_idx_in_list $file"
+       cmd="$LFS setstripe -p $ost_pool -o $ost_idx_in_list $file"
        echo -e "\n$cmd"
        eval $cmd || error "$cmd failed"
-       cmd="$GETSTRIPE $file"
+       cmd="$LFS getstripe $file"
        echo -e "\n$cmd"
        eval $cmd || error "$cmd failed"
        check_stripe_count $file 2
@@ -6080,11 +6169,10 @@ test_82b() { # LU-4665
 run_test 82b "specify OSTs for file with --pool and --ost-list options"
 
 test_83() {
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.6.91) ]] ||
-               { skip "Need OST version at least 2.6.91" && return 0; }
-       if [ $(facet_fstype ost1) != ldiskfs ]; then
+       [[ "$OST1_VERSION" -ge $(version_code 2.6.91) ]] ||
+               skip "Need OST version at least 2.6.91"
+       if [ "$ost1_FSTYPE" != ldiskfs ]; then
                skip "ldiskfs only test"
-               return
        fi
 
        local dev
@@ -6094,25 +6182,24 @@ test_83() {
 
        dev=$(ostdevname 1)
        ostmnt=$(facet_mntpt ost1)
-       fstype=$(facet_fstype ost1)
 
        # Mount the OST as an ldiskfs filesystem.
-       log "mount the OST $dev as a $fstype filesystem"
+       log "mount the OST $dev as a $ost1_FSTYPE filesystem"
        add ost1 $(mkfs_opts ost1 $dev) $FSTYPE_OPT \
                --reformat $dev > /dev/null ||
                error "format ost1 error"
 
        if ! test -b $dev; then
-               mnt_opts=$(csa_add "$OST_MOUNT_OPTS" -o loop)
+               mnt_opts=$(csa_add "$OST_MOUNT_FS_OPTS" -o loop)
        fi
        echo "mnt_opts $mnt_opts"
-       do_facet ost1 mount -t $fstype $dev \
+       do_facet ost1 mount -t "$ost1_FSTYPE" $dev \
                $ostmnt $mnt_opts
        # Run llverfs on the mounted ldiskfs filesystem.
        # It is needed to get ENOSPACE.
-       log "run llverfs in partial mode on the OST $fstype $ostmnt"
+       log "run llverfs in partial mode on the OST $ost1_FSTYPE $ostmnt"
        do_rpc_nodes $(facet_host ost1) run_llverfs $ostmnt -vpl \
-               "no" || error "run_llverfs error on $fstype"
+               "no" || error "run_llverfs error on $ost1_FSTYPE"
 
        # Unmount the OST.
        log "unmount the OST $dev"
@@ -6128,7 +6215,7 @@ test_83() {
        err=$(do_facet ost1 dmesg | grep "VFS: Busy inodes after unmount of")
        echo "string err $err"
        [ -z "$err" ] || error $err
-       reformat
+       reformat_and_config
 }
 run_test 83 "ENOSPACE on OST doesn't cause message VFS: \
 Busy inodes after unmount ..."
@@ -6198,8 +6285,8 @@ test_84() {
 run_test 84 "check recovery_hard_time"
 
 test_85() {
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.7.55) ]] ||
-               { skip "Need OST version at least 2.7.55" && return 0; }
+       [[ "$OST1_VERSION" -ge $(version_code 2.7.55) ]] ||
+               skip "Need OST version at least 2.7.55"
 ##define OBD_FAIL_OSD_OST_EA_FID_SET 0x197
        do_facet ost1 "lctl set_param fail_loc=0x197"
        start_ost
@@ -6217,29 +6304,20 @@ cleanup_86() {
 }
 
 test_86() {
-       local server_version=$(lustre_version_code $SINGLEMDS)
-       [ "$(facet_fstype ost1)" = "zfs" ] &&
-               skip "LU-6442: no such mkfs params for ZFS OSTs" && return
-       [[ $server_version -ge $(version_code 2.7.56) ]] ||
-               { skip "Need server version newer than 2.7.55"; return 0; }
-
-       local OST_OPTS="$(mkfs_opts ost1 $(ostdevname 1)) \
-               --reformat $(ostdevname 1) $(ostvdevname 1)"
+       [ "$ost1_FSTYPE" = zfs ] &&
+               skip "LU-6442: no such mkfs params for ZFS OSTs"
+       [[ "$MDS1_VERSION" -ge $(version_code 2.7.56) ]] ||
+               skip "Need server version newer than 2.7.55"
 
        local NEWSIZE=1024
        local OLDSIZE=$(do_facet ost1 "$DEBUGFS -c -R stats $(ostdevname 1)" |
                awk '/Flex block group size: / { print $NF; exit; }')
 
-       local opts=OST_OPTS
-       if [[ ${!opts} != *mkfsoptions* ]]; then
-               eval opts=\"${!opts} \
-                       --mkfsoptions='\\\"-O flex_bg -G $NEWSIZE\\\"'\"
-       else
-               val=${!opts//--mkfsoptions=\\\"/ \
-                       --mkfsoptions=\\\"-O flex_bg -G $NEWSIZE }
-               eval opts='${val}'
-       fi
+       [ "$OLDSIZE" == "$NEWSIZE" ] && skip "$NEWSIZE groups already"
 
+       local opts=" -O flex_bg -G $NEWSIZE"
+       opts=$(OST_FS_MKFS_OPTS+="$opts" mkfs_opts ost1 $(ostdevname 1))
+       opts+=" --reformat $(ostdevname 1) $(ostvdevname 1)"
        echo "params: $opts"
 
        trap cleanup_86 EXIT ERR
@@ -6258,12 +6336,13 @@ test_86() {
 run_test 86 "Replacing mkfs.lustre -G option"
 
 test_87() { #LU-6544
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.51) ]] ||
-               { skip "Need MDS version at least 2.9.51" && return; }
-       [[ $(facet_fstype $SINGLEMDS) != ldiskfs ]] &&
-               { skip "ldiskfs only test" && return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.9.51) ]] ||
+               skip "Need MDS version at least 2.9.51"
+       [[ "$mds1_FSTYPE" != ldiskfs ]] &&
+               skip "ldiskfs only test"
        [[ $OSTCOUNT -gt 59 ]] &&
-               { skip "Ignore wide striping situation" && return; }
+               skip "Ignore wide striping situation"
+       [ -n "$FILESET" ] && skip "Not functional for FILESET set"
 
        local mdsdev=$(mdsdevname 1)
        local mdsvdev=$(mdsvdevname 1)
@@ -6299,6 +6378,10 @@ test_87() { #LU-6544
        unload_modules
        reformat
 
+       if ! combined_mgs_mds ; then
+               start_mgs
+       fi
+
        add mds1 $(mkfs_opts mds1 ${mdsdev}) --stripe-count-hint=$stripe_cnt \
                --reformat $mdsdev $mdsvdev || error "add mds1 failed"
        start_mdt 1 > /dev/null || error "start mdt1 failed"
@@ -6310,10 +6393,10 @@ test_87() { #LU-6544
        check_mount || error "check client $MOUNT failed"
 
        #set xattr
-       $SETSTRIPE -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
+       $LFS setstripe -E 1M -S 1M -c 1 -E 64M -c 1 -E -1 -c -1 $file ||
                error "Create file with 3 components failed"
        $TRUNCATE $file $((1024*1024*64+1)) || error "truncate file failed"
-       i=$($GETSTRIPE -I3 -c $file) || error "get 3rd stripe count failed"
+       i=$($LFS getstripe -I3 -c $file) || error "get 3rd stripe count failed"
        if [ $i -ne $OSTCOUNT ]; then
                left_size=$(expr $left_size + $(expr $OSTCOUNT - $i) \* 24)
                echo -n "Since only $i out $OSTCOUNT OSTs are used, "
@@ -6338,13 +6421,17 @@ test_87() { #LU-6544
                       more than $left_size-byte space left in inode."
        echo "Verified: at most $left_size-byte space left in inode."
 
-       stopall
+       unmount_ldiskfs $SINGLEMDS
+
+       for i in $(seq $OSTCOUNT); do
+               stop ost$i -f || error "stop ost$i failed"
+       done
 }
 run_test 87 "check if MDT inode can hold EAs with N stripes properly"
 
 test_88() {
-       [ "$(facet_fstype mds1)" == "zfs" ] &&
-               skip "LU-6662: no implementation for ZFS" && return
+       [ "$mds1_FSTYPE" == zfs ] &&
+               skip "LU-6662: no implementation for ZFS"
 
        load_modules
 
@@ -6366,8 +6453,8 @@ test_88() {
 run_test 88 "check the default mount options can be overridden"
 
 test_89() { # LU-7131
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.9.54) ]] ||
-               { skip "Need MDT version at least 2.9.54" && return 0; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.9.54) ]] ||
+               skip "Need MDT version at least 2.9.54"
 
        local key=failover.node
        local val1=192.0.2.254@tcp0 # Reserved IPs, see RFC 5735
@@ -6377,7 +6464,7 @@ test_89() { # LU-7131
 
        stopall
 
-       [ $(facet_fstype mds1) == zfs ] && import_zpool mds1
+       [ "$mds1_FSTYPE" == zfs ] && import_zpool mds1
        # Check that parameters are added correctly
        echo "tunefs --param $key=$val1"
        do_facet mds "$TUNEFS --param $key=$val1 $mdsdev >/dev/null" ||
@@ -6436,7 +6523,7 @@ test_89() { # LU-7131
        [ $(echo $params | tr ' ' '\n') == "$key=$val1" ] ||
                error "on-disk param not added correctly with --erase-params"
 
-       reformat
+       reformat_and_config
 }
 run_test 89 "check tunefs --param and --erase-param{s} options"
 
@@ -6525,15 +6612,11 @@ check_max_mod_rpcs_in_flight() {
 }
 
 test_90a() {
-       reformat
-       if ! combined_mgs_mds ; then
-               start_mgs
-       fi
        setup
 
        [[ $($LCTL get_param mdc.*.import |
             grep "connect_flags:.*multi_mod_rpc") ]] ||
-               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+               skip "Need MDC with 'multi_mod_rpcs' feature"
 
        # check default value
        $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
@@ -6553,7 +6636,7 @@ test_90b() {
 
        [[ $($LCTL get_param mdc.*.import |
             grep "connect_flags:.*multi_mod_rpc") ]] ||
-               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+               skip "Need MDC with 'multi_mod_rpcs' feature"
 
        ### test 1.
        # update max_mod_rpcs_in_flight
@@ -6565,9 +6648,8 @@ test_90b() {
        tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
                grep -c "multi_mod_rpcs")
        if [ "$tmp" -ne $MDSCOUNT ]; then
-               echo "Client not able to send multiple modify RPCs in parallel"
                cleanup
-               return
+               skip "Client not able to send multiple modify RPCs in parallel"
        fi
 
        # update max_mod_rpcs_in_flight
@@ -6600,62 +6682,114 @@ test_90b() {
 }
 run_test 90b "check max_mod_rpcs_in_flight is enforced after update"
 
-test_90c() {
-       local tmp
-       local mrif
-       local mmrpc
+save_params_90c() {
+       # get max_rpcs_in_flight value
+       mrif_90c=$($LCTL get_param -n \
+                  mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
+       echo "max_rpcs_in_flight is $mrif_90c"
 
-       setup
+       # get max_mod_rpcs_in_flight value
+       mmrif_90c=$($LCTL get_param -n \
+                   mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight)
+       echo "max_mod_rpcs_in_flight is $mmrif_90c"
 
-       [[ $($LCTL get_param mdc.*.import |
-            grep "connect_flags:.*multi_mod_rpc") ]] ||
-               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+       # get MDT max_mod_rpcs_per_client value
+       mmrpc_90c=$(do_facet mds1 \
+                   cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
+       echo "max_mod_rpcs_per_client is $mmrpc_90c"
+}
+
+restore_params_90c() {
+       trap 0
+
+       # restore max_rpcs_in_flight value
+       do_facet mgs $LCTL set_param -P \
+               mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
+
+       # restore max_mod_rpcs_in_flight value
+       do_facet mgs $LCTL set_param -P \
+               mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mmrif_90c
+
+       # restore MDT max_mod_rpcs_per_client value
+       do_facet mds1 "echo $mmrpc_90c > \
+                      /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+}
+
+test_90c() {
+       local tmp
+
+       setup
+
+       [[ $($LCTL get_param mdc.*.import |
+            grep "connect_flags:.*multi_mod_rpc") ]] ||
+               skip "Need MDC with 'multi_mod_rpcs' feature"
 
        # check client is able to send multiple modify RPCs in paralell
        tmp=$($LCTL get_param -n mdc.$FSNAME-MDT*-mdc-*.import |
                grep -c "multi_mod_rpcs")
        if [ "$tmp" -ne $MDSCOUNT ]; then
-               skip "Client not able to send multiple modify RPCs in parallel"
                cleanup
-               return
+               skip "Client not able to send multiple modify RPCs in parallel"
        fi
 
-       # get max_rpcs_in_flight value
-       mrif=$($LCTL get_param -n mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
-       echo "max_rpcs_in_flight is $mrif"
-
-       # get MDT max_mod_rpcs_per_client
-       mmrpc=$(do_facet mds1 \
-                   cat /sys/module/mdt/parameters/max_mod_rpcs_per_client)
-       echo "max_mod_rpcs_per_client is $mmrpc"
+       save_params_90c
+       stack_trap restore_params_90c
 
        # testcase 1
        # attempt to set max_mod_rpcs_in_flight to max_rpcs_in_flight value
        # prerequisite: set max_mod_rpcs_per_client to max_rpcs_in_flight value
-       umount_client $MOUNT
-       do_facet mds1 \
-               "echo $mrif > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
-       mount_client $MOUNT
+       do_facet mds1 "echo $mrif_90c > \
+                      /sys/module/mdt/parameters/max_mod_rpcs_per_client"
 
-       $LCTL set_param \
-           mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif &&
-           error "set max_mod_rpcs_in_flight to $mrif should fail"
+       # if max_mod_rpcs_in_flight is set to be equal to or larger than
+       # max_rpcs_in_flight, then max_rpcs_in_flight will be increased
+       if [[ "$CLIENT_VERSION" -ge $(version_code 2.13.53) ]]; then
+               $LCTL set_param \
+               mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c ||
+                       error "set max_mod_rpcs_in_flight to $mrif_90c failed"
+
+               local new_mrif=$($LCTL get_param -n \
+                                mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight)
+               ((new_mrif == mrif_90c + 1)) ||
+                       error "max_rpcs_in_flight was not increased"
+       fi
 
        umount_client $MOUNT
-       do_facet mds1 \
-               "echo $mmrpc > /sys/module/mdt/parameters/max_mod_rpcs_per_client"
+       do_facet mds1 "echo $mmrpc_90c > \
+                      /sys/module/mdt/parameters/max_mod_rpcs_per_client"
        mount_client $MOUNT
 
        # testcase 2
        # attempt to set max_mod_rpcs_in_flight to max_mod_rpcs_per_client+1
        # prerequisite: set max_rpcs_in_flight to max_mod_rpcs_per_client+2
        $LCTL set_param \
-           mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc + 2))
+               mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$((mmrpc_90c + 2))
 
        $LCTL set_param \
-           mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc + 1)) &&
-           error "set max_mod_rpcs_in_flight to $((mmrpc + 1)) should fail"
+       mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$((mmrpc_90c + 1)) &&
+       error "set max_mod_rpcs_in_flight to $((mmrpc_90c + 1)) should fail"
+
+       # testcase 3
+       # attempt to set max_mod_rpcs_in_flight permanently
+       do_facet mgs $LCTL set_param -P \
+               mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight=$mrif_90c
+
+       do_facet mgs $LCTL set_param -P \
+               mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight=$mrif_90c
 
+       remount_client $MOUNT
+
+       wait_update_facet --verbose client "$LCTL get_param -n \
+               mdc.$FSNAME-MDT0000-mdc-*.max_rpcs_in_flight" \
+               "$((mrif_90c + 1))" ||
+               error "expected '$((mrif_90c + 1))' for max_rpcs_in_flight"
+
+       wait_update_facet --verbose client "$LCTL get_param -n \
+               mdc.$FSNAME-MDT0000-mdc-*.max_mod_rpcs_in_flight" \
+               "$mrif_90c" ||
+               error "expected '$mrif_90c' for max_mod_rpcs_in_flight"
+
+       restore_params_90c
        cleanup
 }
 run_test 90c "check max_mod_rpcs_in_flight update limits"
@@ -6671,7 +6805,7 @@ test_90d() {
 
        [[ $($LCTL get_param mdc.*.import |
             grep "connect_flags:.*multi_mod_rpc") ]] ||
-               { skip "Need MDC with 'multi_mod_rpcs' feature"; return 0; }
+               skip "Need MDC with 'multi_mod_rpcs' feature"
 
        $LFS mkdir -c1 $DIR/$tdir || error "mkdir $DIR/$tdir failed"
        idx=$(printf "%04x" $($LFS getdirstripe -i $DIR/$tdir))
@@ -6681,9 +6815,8 @@ test_90d() {
        tmp=$($LCTL get_param -N \
                mdc.$FSNAME-MDT$idx-mdc-*.max_mod_rpcs_in_flight)
        if [ -z "$tmp" ]; then
-               skip "Client does not support multiple modify RPCs in flight"
                cleanup
-               return
+               skip "Client does not support multiple modify RPCs in flight"
        fi
 
        # get current value of max_mod_rcps_in_flight
@@ -6736,7 +6869,7 @@ check_uuid_on_ost() {
 
 check_uuid_on_mdt() {
        local nid=$1
-       do_facet $SINGLEMDS "$LCTL get_param mdt.${FSNAME}*.exports.'$nid'.uuid"
+       do_facet $SINGLEMDS "$LCTL get_param mdt.${mds1_svc}*.exports.'$nid'.uuid"
 }
 
 test_91() {
@@ -6744,10 +6877,10 @@ test_91() {
        local nid
        local found
 
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.7.63) ]] ||
-               { skip "Need OST version at least 2.7.63" && return 0; }
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.7.63) ]] ||
-               { skip "Need MDT version at least 2.7.63" && return 0; }
+       [[ "$OST1_VERSION" -ge $(version_code 2.7.63) ]] ||
+               skip "Need OST version at least 2.7.63"
+       [[ "$MDS1_VERSION" -ge $(version_code 2.7.63) ]] ||
+               skip "Need MDT version at least 2.7.63"
 
        start_mds || error "MDS start failed"
        start_ost || error "unable to start OST"
@@ -6780,6 +6913,7 @@ test_91() {
        echo "evict $nid"
        do_facet $SINGLEMDS \
                "$LCTL set_param -n mdt.${mds1_svc}.evict_client nid:$nid"
+       sleep 1 # eviction above is async, give it some time to proceed
 
        found=$(check_uuid_on_mdt $nid | grep $uuid)
        [ -n "$found" ] && error "found $uuid $nid on MDT"
@@ -6805,7 +6939,7 @@ generate_ldev_conf() {
        touch $ldevconfpath
 
        fstype=$(facet_fstype mgs)
-       if [ "$fstype" == "zfs" ]; then
+       if [ "$fstype" == zfs ]; then
                fsldevformat="$fstype:"
        else
                fsldevformat=""
@@ -6824,7 +6958,7 @@ generate_ldev_conf() {
 
        for num in $(seq $MDSCOUNT); do
                fstype=$(facet_fstype mds$num)
-               if [ "$fstype" == "zfs" ]; then
+               if [ "$fstype" == zfs ]; then
                        fsldevformat="$fstype:"
                else
                        fsldevformat=""
@@ -6846,7 +6980,7 @@ generate_ldev_conf() {
 
        for num in $(seq $OSTCOUNT); do
                fstype=$(facet_fstype ost$num)
-               if [ "$fstype" == "zfs" ]; then
+               if [ "$fstype" == zfs ]; then
                        fsldevformat="$fstype:"
                else
                        fsldevformat=""
@@ -6940,7 +7074,7 @@ test_92() {
 run_test 92 "ldev returns MGS NID correctly in command substitution"
 
 test_93() {
-       [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs" && return
+       [ $MDSCOUNT -lt 3 ] && skip "needs >= 3 MDTs"
 
        reformat
        #start mgs or mgs/mdt0
@@ -6954,14 +7088,14 @@ test_93() {
        start_ost || error "OST0 start fail"
 
        #define OBD_FAIL_MGS_WRITE_TARGET_DELAY  0x90e
-       do_facet mgs "$LCTL set_param fail_val = 10 fail_loc=0x8000090e"
+       do_facet mgs "$LCTL set_param fail_val=10 fail_loc=0x8000090e"
        for num in $(seq 2 $MDSCOUNT); do
                start_mdt $num &
        done
 
        mount_client $MOUNT || error "mount client fails"
        wait_osc_import_state mds ost FULL
-       wait_osc_import_state client ost FULL
+       wait_osc_import_ready client ost
        check_mount || error "check_mount failed"
 
        cleanup || error "cleanup failed with $?"
@@ -7236,7 +7370,7 @@ test_98()
        for ((x = 1; x <= 400; x++)); do
                mountopt="$mountopt,user_xattr"
        done
-       remount_client $mountopt $MOUNT  2>&1 | grep "too long" ||
+       mount_client $MOUNT remount,$mountopt 2>&1 | grep "too long" ||
                error "Buffer overflow check failed"
        cleanup || error "cleanup failed"
 }
@@ -7244,15 +7378,15 @@ run_test 98 "Buffer-overflow check while parsing mount_opts"
 
 test_99()
 {
-       [[ $(facet_fstype ost1) != ldiskfs ]] &&
-               { skip "ldiskfs only test" && return; }
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.8.57) ]] ||
-               { skip "Need OST version at least 2.8.57" && return 0; }
+       [[ "$ost1_FSTYPE" != ldiskfs ]] &&
+               skip "ldiskfs only test"
+       [[ "$OST1_VERSION" -ge $(version_code 2.8.57) ]] ||
+               skip "Need OST version at least 2.8.57"
 
        local ost_opts="$(mkfs_opts ost1 $(ostdevname 1)) \
                --reformat $(ostdevname 1) $(ostvdevname 1)"
        do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" &&
-               skip "meta_bg already set" && return
+               skip "meta_bg already set"
 
        local opts=ost_opts
        if [[ ${!opts} != *mkfsoptions* ]]; then
@@ -7266,18 +7400,18 @@ test_99()
 
        echo "params: $opts"
 
+       load_modules
        add ost1 $opts || error "add ost1 failed with new params"
 
        do_facet ost1 $DEBUGFS -c -R stats `ostdevname 1` | grep "meta_bg" ||
                error "meta_bg is not set"
-
-       reformat
 }
 run_test 99 "Adding meta_bg option"
 
 test_100() {
        reformat
-       start_mds || error "MDS start failed"
+
+       start_mgsmds || error "MDS start failed"
        start_ost || error "unable to start OST"
        mount_client $MOUNT || error "client start failed"
        check_mount || error "check_mount failed"
@@ -7285,9 +7419,9 @@ test_100() {
        # Desired output
        # MGS:
        #     0@lo
-       # lustre-MDT0000:
+       # $FSNAME-MDT0000:
        #     0@lo
-       # lustre-OST0000:
+       # $FSNAME-OST0000:
        #     0@lo
        do_facet mgs 'lshowmount -v' | awk 'BEGIN {NR == 0; rc=1} /MGS:/ {rc=0}
                END {exit rc}' || error "lshowmount have no output MGS"
@@ -7302,7 +7436,7 @@ test_100() {
 }
 run_test 100 "check lshowmount lists MGS, MDT, OST and 0@lo"
 
-test_101() {
+test_101a() {
        local createmany_pid
        local dev=$FSNAME-OST0000-osc-MDT0000
        setup
@@ -7329,23 +7463,48 @@ test_101() {
        unlinkmany $DIR1/$tdir/$tfile-%d 50000
        cleanup
 }
-run_test 101 "Race MDT->OST reconnection with create"
+run_test 101a "Race MDT->OST reconnection with create"
+
+test_101b () {
+       local dev=$FSNAME-OST0000-osc-MDT0000
+       local dir=$DIR1/$tdir
+       setup
+
+       mkdir $dir
+       $LFS setstripe -c 1 -i 0 $dir
+       do_facet $SINGLEMDS "$LCTL --device $dev deactivate;"
+#define OBD_FAIL_OSP_CON_EVENT_DELAY 0x2107
+       do_facet mds1 "$LCTL set_param fail_loc=0x80002107 fail_val=20"
+       do_facet $SINGLEMDS "$LCTL --device $dev activate;"
+       stop_ost
+       sleep 25
+       start_ost
+
+       wait_osc_import_state client ost1 FULL
+       touch $dir/$tfile || error "Can't create file"
+
+       cleanup
+}
+run_test 101b "Race events DISCONNECT and ACTIVE in osp"
 
 test_102() {
-       [[ $(lustre_version_code $SINGLEMDS) -gt $(version_code 2.9.53) ]] ||
+       [[ "$MDS1_VERSION" -gt $(version_code 2.9.53) ]] ||
                skip "Need server version greater than 2.9.53"
+       [[ “$(mdsdevname 1)” != “$(mgsdevname)” ]] &&
+               [[ “$(facet_host mds1)” = “$(facet_host mgs)” ]] &&
+               skip "MGS must be on different node or combined"
+
        cleanup || error "cleanup failed with $?"
 
        local mds1dev=$(mdsdevname 1)
        local mds1mnt=$(facet_mntpt mds1)
-       local mds1fstype=$(facet_fstype mds1)
        local mds1opts=$MDS_MOUNT_OPTS
 
-       if [ $mds1fstype == ldiskfs ] &&
+       if [ "$mds1_FSTYPE" == ldiskfs ] &&
           ! do_facet mds1 test -b $mds1dev; then
                mds1opts=$(csa_add "$mds1opts" -o loop)
        fi
-       if [[ $mds1fstype == zfs ]]; then
+       if [[ "$mds1_FSTYPE" == zfs ]]; then
                import_zpool mds1 || return ${PIPESTATUS[0]}
        fi
 
@@ -7376,34 +7535,34 @@ test_renamefs() {
        echo "rename $FSNAME to $newname"
 
        if ! combined_mgs_mds ; then
-               local facet=$(mgsdevname)
+               local dev=$(mgsdevname)
 
                do_facet mgs \
-                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
-                       error "(7) Fail to rename MGS"
-               if [ "$(facet_fstype $facet)" = "zfs" ]; then
+                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
+                               error "(7) Fail to rename MGS"
+               if [ "$(facet_fstype mgs)" = "zfs" ]; then
                        reimport_zpool mgs $newname-mgs
                fi
        fi
 
        for num in $(seq $MDSCOUNT); do
-               local facet=$(mdsdevname $num)
+               local dev=$(mdsdevname $num)
 
                do_facet mds${num} \
-                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
-                       error "(8) Fail to rename MDT $num"
-               if [ "$(facet_fstype $facet)" = "zfs" ]; then
+                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
+                               error "(8) Fail to rename MDT $num"
+               if [ "$(facet_fstype mds${num})" = "zfs" ]; then
                        reimport_zpool mds${num} $newname-mdt${num}
                fi
        done
 
        for num in $(seq $OSTCOUNT); do
-               local facet=$(ostdevname $num)
+               local dev=$(ostdevname $num)
 
                do_facet ost${num} \
-                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $facet"||
-                       error "(9) Fail to rename OST $num"
-               if [ "$(facet_fstype $facet)" = "zfs" ]; then
+                       "$TUNEFS --fsname=$newname --rename=$FSNAME -v $dev" ||
+                               error "(9) Fail to rename OST $num"
+               if [ "$(facet_fstype ost${num})" = "zfs" ]; then
                        reimport_zpool ost${num} $newname-ost${num}
                fi
        done
@@ -7447,9 +7606,6 @@ test_103() {
        cp $LUSTRE/tests/test-framework.sh $DIR/$tdir ||
                error "(2) Fail to copy test-framework.sh"
 
-       if ! combined_mgs_mds ; then
-               mount_mgs_client
-       fi
        do_facet mgs $LCTL pool_new $FSNAME.pool1 ||
                error "(3) Fail to create $FSNAME.pool1"
        # name the pool name as the fsname
@@ -7458,12 +7614,9 @@ test_103() {
 
        test_103_set_pool $FSNAME OST0000
 
-       $SETSTRIPE -p $FSNAME $DIR/$tdir/d0 ||
+       $LFS setstripe -p $FSNAME $DIR/$tdir/d0 ||
                error "(6) Fail to setstripe on $DIR/$tdir/d0"
 
-       if ! combined_mgs_mds ; then
-               umount_mgs_client
-       fi
        KEEP_ZPOOL=true
        stopall
 
@@ -7473,20 +7626,14 @@ test_103() {
        FSNAME="mylustre"
        setupall
 
-       if ! combined_mgs_mds ; then
-               mount_mgs_client
-       fi
        test_103_check_pool $save_fsname 7
 
        if [ $OSTCOUNT -ge 2 ]; then
                test_103_set_pool $save_fsname OST0001
        fi
 
-       $SETSTRIPE -p $save_fsname $DIR/$tdir/f0 ||
+       $LFS setstripe -p $save_fsname $DIR/$tdir/f0 ||
                error "(16) Fail to setstripe on $DIR/$tdir/f0"
-       if ! combined_mgs_mds ; then
-               umount_mgs_client
-       fi
 
        stopall
 
@@ -7495,14 +7642,8 @@ test_103() {
        FSNAME="tfs"
        setupall
 
-       if ! combined_mgs_mds ; then
-               mount_mgs_client
-       fi
        test_103_check_pool $save_fsname 17
 
-       if ! combined_mgs_mds ; then
-               umount_mgs_client
-       fi
        stopall
 
        test_renamefs $save_fsname
@@ -7513,7 +7654,7 @@ test_103() {
 }
 run_test 103 "rename filesystem name"
 
-test_104() { # LU-6952
+test_104a() { # LU-6952
        local mds_mountopts=$MDS_MOUNT_OPTS
        local ost_mountopts=$OST_MOUNT_OPTS
        local mds_mountfsopts=$MDS_MOUNT_FS_OPTS
@@ -7521,7 +7662,7 @@ test_104() { # LU-6952
                        awk '{ print $2 }')
 
        [[ $(version_code $lctl_ver) -lt $(version_code 2.9.55) ]] &&
-               { skip "this test needs utils above 2.9.55" && return 0; }
+               skip "this test needs utils above 2.9.55"
 
        # specify "acl" in mount options used by mkfs.lustre
        if [ -z "$MDS_MOUNT_FS_OPTS" ]; then
@@ -7535,6 +7676,10 @@ test_104() { # LU-6952
 
        #reformat/remount the MDT to apply the MDT_MOUNT_FS_OPT options
        formatall
+       if ! combined_mgs_mds ; then
+               start_mgs
+       fi
+
        if [ -z "$MDS_MOUNT_OPTS" ]; then
                MDS_MOUNT_OPTS="-o noacl"
        else
@@ -7558,11 +7703,23 @@ test_104() { # LU-6952
        MDS_MOUNT_OPTS=$mds_mountopts
        OST_MOUNT_OPTS=$ost_mountopts
        MDS_MOUNT_FS_OPTS=$mds_mountfsopts
+}
+run_test 104a "Make sure user defined options are reflected in mount"
 
-       formatall
-       setupall
+test_104b() { # LU-12859
+       mount_client $MOUNT3 flock,localflock
+       stack_trap "umount_client $MOUNT3" EXIT
+       mount | grep "$MOUNT3 .*,flock" && error "flock is still set"
+       mount | grep "$MOUNT3 .*,localflock" || error "localflock is not set"
+       umount_client $MOUNT3
+       mount_client $MOUNT3 localflock,flock
+       mount | grep "$MOUNT3 .*,localflock" && error "localflock is still set"
+       mount | grep "$MOUNT3 .*,flock" || error "flock is not set"
+       umount_client $MOUNT3
+       mount_client $MOUNT3 localflock,flock,noflock
+       flock_is_enabled $MOUNT3 && error "some flock is still enabled" || true
 }
-run_test 104 "Make sure user defined options are reflected in mount"
+run_test 104b "Mount uses last flock argument"
 
 error_and_umount() {
        umount $TMP/$tdir
@@ -7573,7 +7730,7 @@ error_and_umount() {
 test_105() {
        cleanup -f
        reformat
-       setup
+       setup_noconfig
        mkdir -p $TMP/$tdir
        mount --bind $DIR $TMP/$tdir || error "mount bind mnt pt failed"
        rm -f $TMP/$tdir/$tfile
@@ -7606,7 +7763,7 @@ test_106() {
        local repeat=5
 
        reformat
-       setupall
+       setup_noconfig
        mkdir -p $DIR/$tdir || error "create $tdir failed"
        lfs setstripe -c 1 -i 0 $DIR/$tdir
 #define OBD_FAIL_CAT_RECORDS                        0x1312
@@ -7624,20 +7781,20 @@ test_106() {
 #shows that osp code is buggy
        do_facet mds1 $LCTL set_param fail_loc=0 fail_val=0
 
-       stopall
+       cleanup
 }
 run_test 106 "check osp llog processing when catalog is wrapped"
 
 test_107() {
-       [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.10.50) ]] ||
-               { skip "Need MDS version > 2.10.50"; return; }
+       [[ "$MDS1_VERSION" -ge $(version_code 2.10.50) ]] ||
+               skip "Need MDS version > 2.10.50"
        local cmd
 
        start_mgsmds || error "start_mgsmds failed"
        start_ost || error "unable to start OST"
 
        # add unknown configuration parameter.
-       if [[ $PERM_CMD = *"set_param -P"* ]]; then
+       if [[ $PERM_CMD == *"set_param -P"* ]]; then
                cmd="$PERM_CMD ost.$FSNAME-OST0000*.unknown_param"
        else
                cmd="$PERM_CMD $FSNAME-OST0000*.ost.unknown_param"
@@ -7660,7 +7817,7 @@ t_108_prep() {
        $rcmd mkdir -p $tmp/{mnt,images} || error "failed to mkdir remotely"
 
        for facet in $facets; do
-               [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
+               [ "$mds1_FSTYPE" = zfs ] &&
                        $rcmd $ZPOOL -f export lustre-$facet > /dev/null 2>&1
                $rcmd mkdir $tmp/mnt/$facet ||
                        error "failed to mkdir $tmp/mnt/$facet"
@@ -7728,7 +7885,7 @@ t_108_cleanup() {
        for facet in $facets; do
                $rcmd umount -f $tmp/mnt/$facet ||
                        error "failed to umount $facet"
-               if [ $(facet_fstype $SINGLEMDS) = "zfs" ]; then
+               if [ "$mds1_FSTYPE" = zfs ]; then
                        $rcmd $ZPOOL export -f lustre-$facet ||
                                error "failed to export lustre-$facet"
                fi
@@ -7738,13 +7895,10 @@ t_108_cleanup() {
 }
 
 test_108a() {
-       [ "$CLIENTONLY" ] && skip "Client-only testing" && return
-
-       [ $(facet_fstype $SINGLEMDS) != "zfs" ] &&
-               skip "zfs only test" && return
-
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
-               skip "Need server version at least 2.10.58" && return
+       [ "$CLIENTONLY" ] && skip "Client-only testing"
+       [ "$mds1_FSTYPE" != zfs ] && skip "zfs only test"
+       [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
+               skip "Need server version at least 2.10.58"
 
        stopall
        load_modules
@@ -7783,10 +7937,10 @@ test_108a() {
 
        echo "changing server nid..."
        $rcmd mount -t lustre -o nosvc lustre-mdt1/mdt1 $tmp/mnt/mdt1
-       $rcmd lctl replace_nids lustre-MDT0000 $nid
-       $rcmd lctl replace_nids lustre-MDT0001 $nid
-       $rcmd lctl replace_nids lustre-OST0000 $nid
-       $rcmd lctl replace_nids lustre-OST0001 $nid
+       $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
+       $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
+       $rcmd lctl replace_nids $FSNAME-OST0000 $nid
+       $rcmd lctl replace_nids $FSNAME-OST0001 $nid
        $rcmd umount $tmp/mnt/mdt1
 
        for facet in $facets; do
@@ -7805,13 +7959,10 @@ test_108a() {
 run_test 108a "migrate from ldiskfs to ZFS"
 
 test_108b() {
-       [ "$CLIENTONLY" ] && skip "Client-only testing" && return
-
-       [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
-
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.58) ] &&
-               skip "Need server version at least 2.10.58" && return
+       [ "$CLIENTONLY" ] && skip "Client-only testing"
+       [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
+       [ "$MDS1_VERSION" -lt $(version_code 2.10.58) ] &&
+               skip "Need server version at least 2.10.58"
 
        stopall
        load_modules
@@ -7835,6 +7986,7 @@ test_108b() {
                $rcmd mount -t ldiskfs -o loop $tmp/images/$facet \
                        $tmp/mnt/$facet ||
                        error "failed to local mount $facet"
+
                $rcmd tar jxf $LUSTRE/tests/zfs_${facet}_2_11.tar.bz2 \
                        --xattrs --xattrs-include="*.*" \
                        -C $tmp/mnt/$facet/ > /dev/null 2>&1 ||
@@ -7847,10 +7999,10 @@ test_108b() {
 
        echo "changing server nid..."
        $rcmd mount -t lustre -o nosvc,loop $tmp/images/mdt1 $tmp/mnt/mdt1
-       $rcmd lctl replace_nids lustre-MDT0000 $nid
-       $rcmd lctl replace_nids lustre-MDT0001 $nid
-       $rcmd lctl replace_nids lustre-OST0000 $nid
-       $rcmd lctl replace_nids lustre-OST0001 $nid
+       $rcmd lctl replace_nids $FSNAME-MDT0000 $nid
+       $rcmd lctl replace_nids $FSNAME-MDT0001 $nid
+       $rcmd lctl replace_nids $FSNAME-OST0000 $nid
+       $rcmd lctl replace_nids $FSNAME-OST0001 $nid
        $rcmd umount $tmp/mnt/mdt1
 
        for facet in $facets; do
@@ -7860,7 +8012,7 @@ test_108b() {
        done
 
        for facet in $scrub_list; do
-               $rcmd $LCTL lfsck_start -M lustre-$facet -t scrub ||
+               $rcmd $LCTL lfsck_start -M $FSNAME-$facet -t scrub ||
                        error "failed to start OI scrub on $facet"
        done
 
@@ -7932,7 +8084,7 @@ test_109_clear_conf()
 
        local mgsdev
        if ! combined_mgs_mds ; then
-               mgsdev=$MGSDEV
+               mgsdev=$(mgsdevname)
                stop_mgs || error "stop_mgs failed"
                start_mgs "-o nosvc" || error "start_mgs nosvc failed"
        else
@@ -7971,8 +8123,11 @@ test_109_file_shortened() {
 
 test_109a()
 {
-       [ "$(facet_fstype mgs)" == "zfs" ] &&
-               skip "LU-8727: no implementation for ZFS" && return
+       [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
+               skip "Needs MDS version 2.10.59 or later."
+       [ "$(facet_fstype mgs)" == zfs ] &&
+               skip "LU-8727: no implementation for ZFS"
+
        stopall
        reformat
        setup_noconfig
@@ -8014,8 +8169,11 @@ run_test 109a "test lctl clear_conf fsname"
 
 test_109b()
 {
-       [ "$(facet_fstype mgs)" == "zfs" ] &&
-               skip "LU-8727: no implementation for ZFS" && return
+       [ $MDS1_VERSION -lt $(version_code 2.10.59) ] &&
+               skip "Needs MDS version 2.10.59 or later."
+       [ "$(facet_fstype mgs)" == zfs ] &&
+               skip "LU-8727: no implementation for ZFS"
+
        stopall
        reformat
        setup_noconfig
@@ -8040,7 +8198,6 @@ test_109b()
                error "failed to clear client config"
 
        setup_noconfig
-
        #
        # check that configurations are intact
        #
@@ -8055,23 +8212,296 @@ test_109b()
 }
 run_test 109b "test lctl clear_conf one config"
 
+test_110()
+{
+       [[ "$mds1_FSTYPE" != ldiskfs ]] &&
+               skip "Only applicable to ldiskfs-based MDTs"
+
+       do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
+               skip "large_dir option is not supported on MDS"
+       do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
+               skip "large_dir option is not supported on OSS"
+
+       stopall # stop all targets before modifying the target counts
+       local old_mdscount=$MDSCOUNT
+       local old_ostcount=$OSTCOUNT
+       local replace=""
+       stack_trap "MDSCOUNT=$old_mdscount OSTCOUNT=$old_ostcount" EXIT
+       MDSCOUNT=1
+       OSTCOUNT=1
+
+       # ext4_dir_entry_2 struct size:264
+       # dx_root struct size:8
+       # dx_node struct size:8
+       # dx_entry struct size:8
+       # For 1024 bytes block size.
+       # First level directory entries: 126
+       # Second level directory entries: 127
+       # Entries in leaf: 3
+       # For 2 levels limit: 48006
+       # For 3 levels limit : 6096762
+       # Create 80000 files to safely exceed 2-level htree limit.
+       CONF_SANITY_110_LINKS=${CONF_SANITY_110_LINKS:-80000}
+
+       # can fit at most 3 filenames per 1KB leaf block, but each
+       # leaf/index block will only be 3/4 full before split at each level
+       (( MDSSIZE < CONF_SANITY_110_LINKS / 3 * 4/3 * 4/3 )) &&
+               CONF_SANITY_110_LINKS=$((MDSSIZE * 3 * 3/4 * 3/4))
+
+       combined_mgs_mds || replace=" --replace "
+       local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
+                   $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
+       if [[ $opts != *large_dir* ]]; then
+               if [[ $opts != *mkfsoptions* ]]; then
+                       opts+=" --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536\\\""
+               else
+                       opts="${opts//--mkfsoptions=\\\"/ \
+                               --mkfsoptions=\\\"-O large_dir -b 1024 -i 65536 }"
+               fi
+       fi
+       echo "MDT params: $opts"
+       load_modules
+       combined_mgs_mds || start_mgs
+       add mds1 $opts || error "add mds1 failed with new params"
+       start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
+
+       opts="$(mkfs_opts ost1 $(ostdevname 1)) \
+               $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
+
+       if [[ $opts != *large_dir* ]]; then
+               if [[ $opts != *mkfsoptions* ]]; then
+                       opts+=" --mkfsoptions=\\\"-O large_dir\\\" "
+               else
+                       opts="${opts//--mkfsoptions=\\\"/ \
+                               --mkfsoptions=\\\"-O large_dir }"
+               fi
+       fi
+       echo "OST params: $opts"
+       add ost1 $opts || error "add ost1 failed with new params"
+       start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
+
+       MOUNT_2=yes mountcli || error "mount clients failed"
+
+       mkdir -v $DIR/$tdir || error "cannot create $DIR/$tdir"
+       local pids count=0 group=0
+
+       echo "creating $CONF_SANITY_110_LINKS in total"
+       while (( count < CONF_SANITY_110_LINKS )); do
+               local len=$((253 - $(wc -c <<<"$tfile-$group-40000-")))
+               local dir=DIR$((group % 2 + 1))
+               local target=${!dir}/$tdir/$tfile-$group
+               local long=$target-$(generate_name $len)-
+               local create=$((CONF_SANITY_110_LINKS - count))
+
+               (( create > 40000 )) && create=40000
+               touch $target || error "creating $target failed"
+               echo "creating $create hard links to $target"
+               createmany -l $target $long $create &
+               pids+=" $!"
+
+               count=$((count + create))
+               group=$((group + 1))
+       done
+       echo "waiting for PIDs$pids to complete"
+       wait $pids || error "createmany failed after $group groups"
+
+       umount_client $MOUNT2 -f
+       cleanup
+
+       run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
+       MDSCOUNT=$old_mdscount
+       OSTCOUNT=$old_ostcount
+}
+run_test 110 "Adding large_dir with 3-level htree"
+
+test_111() {
+       [[ "$mds1_FSTYPE" != ldiskfs ]] &&
+               skip "Only applicable to ldiskfs-based MDTs"
+
+       is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
+               skip "This test can not be executed on flakey dev"
+
+       do_facet $SINGLEMDS $DEBUGFS -w -R supported_features |grep large_dir ||
+               skip "large_dir option is not supported on MDS"
+
+       do_facet ost1 $DEBUGFS -w -R supported_features | grep large_dir ||
+               skip "large_dir option is not supported on OSS"
+
+       # cleanup before changing target counts
+       cleanup
+       local old_mdscount=$MDSCOUNT
+       local old_ostcount=$OSTCOUNT
+       local old_mdssize=$MDSSIZE
+       local replace=""
+       stack_trap "MDSSIZE=$MDSSIZE MDSCOUNT=$MDSCOUNT OSTCOUNT=$OSTCOUNT" EXIT
+       MDSCOUNT=1
+       OSTCOUNT=1
+       (( MDSSIZE < 2400000 )) && MDSSIZE=2400000 # need at least 2.4GB
+
+       local mdsdev=$(mdsdevname 1)
+       combined_mgs_mds || replace=" --replace "
+       local opts="$(mkfs_opts mds1 $(mdsdevname 1)) \
+                   $replace --reformat $(mdsdevname 1) $(mdsvdevname 1)"
+       if [[ $opts != *large_dir* ]]; then
+               if [[ $opts != *mkfsoptions* ]]; then
+                       opts+=" --mkfsoptions=\\\"-O large_dir -i 1048576 \\\" "
+               else
+                       opts="${opts//--mkfsoptions=\\\"/ \
+                               --mkfsoptions=\\\"-O large_dir -i 1048576 }"
+               fi
+       fi
+       echo "MDT params: $opts"
+       load_modules
+       combined_mgs_mds || start_mgs
+       __touch_device mds 1
+       add mds1 $opts || error "add mds1 failed with new params"
+       start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
+
+       opts="$(mkfs_opts ost1 $(ostdevname 1)) \
+               $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
+       if [[ $opts != *large_dir* ]]; then
+               if [[ $opts != *mkfsoptions* ]]; then
+                       opts+=" --mkfsoptions=\\\"-O large_dir \\\""
+               else
+                       opts="${opts//--mkfsoptions=\\\"/ --mkfsoptions=\\\"-O large_dir }"
+               fi
+       fi
+       echo "OST params: $opts"
+       __touch_device ost 1
+       add ost1 $opts || error "add ost1 failed with new params"
+       start ost1 $(ostdevname 1) $OST_MOUNT_OPTS
+
+       MOUNT_2=yes mountcli
+       mkdir $DIR/$tdir || error "cannot create $DIR/$tdir"
+       lfs df $DIR/$tdir
+       lfs df -i $DIR/$tdir
+
+       local group=0
+
+       local start=$SECONDS
+       local dirsize=0
+       local dirmax=$((2 << 30))
+       local needskip=0
+       local taken=0
+       local rate=0
+       local left=0
+       local num=0
+       while (( !needskip & dirsize < dirmax )); do
+               local pids=""
+
+               for cli in ${CLIENTS//,/ }; do
+                       local len=$((253 - $(wc -c <<<"$cli-$group-60000-")))
+                       local target=$cli-$group
+                       local long=$DIR/$tdir/$target-$(generate_name $len)-
+
+                       RPWD=$DIR/$tdir do_node $cli touch $target ||
+                               error "creating $target failed"
+                       echo "creating 60000 hardlinks to $target"
+                       RPWD=$DIR/$tdir do_node $cli createmany -l $target $long 60000 &
+                       pids+=" $!"
+
+                       group=$((group + 1))
+                       target=$cli-$group
+                       long=$DIR2/$tdir/$target-$(generate_name $len)-
+
+                       RPWD=$DIR2/$tdir do_node $cli touch $target ||
+                               error "creating $target failed"
+                       echo "creating 60000 hardlinks to $target"
+                       RPWD=$DIR2/$tdir do_node $cli createmany -l $target $long 60000 &
+                       pids+=" $!"
+
+                       group=$((group + 1))
+               done
+               echo "waiting for PIDs$pids to complete"
+               wait $pids || error "createmany failed after $group groups"
+               dirsize=$(stat -c %s $DIR/$tdir)
+               taken=$((SECONDS - start))
+               rate=$((dirsize / taken))
+               left=$(((dirmax - dirsize) / rate))
+               num=$((group * 60000))
+               echo "estimate ${left}s left after $num files / ${taken}s"
+               # if the estimated time remaining is too large (it may change
+               # over time as the create rate is not constant) then exit
+               # without declaring a failure.
+               (( left > 1200 )) && needskip=1
+       done
+
+       umount_client $MOUNT2 -f
+       cleanup
+
+       (( $needskip )) && skip "ETA ${left}s after $num files / ${taken}s is too long"
+
+       run_e2fsck $(facet_active_host mds1) $(mdsdevname 1) -n
+       MDSCOUNT=$old_mdscount
+       OSTCOUNT=$old_ostcount
+       MDSSIZE=$old_mdssize
+}
+run_test 111 "Adding large_dir with over 2GB directory"
+
+test_112() {
+       start_mds || error "MDS start failed"
+       start_ost || error "OSS start failed"
+       echo "start ost2 service on $(facet_active_host ost2)"
+       start ost2 $(ostdevname 2) $(csa_add "$OST_MOUNT_OPTS" -o no_precreate) ||
+               error "start ost2 facet failed"
+       local val=$(do_facet ost2 \
+                  "$LCTL get_param -n obdfilter.$FSNAME-OST0001*.no_precreate")
+       (( $val == 1 )) || error "obdfilter.$FSNAME-OST0001*.no_precreate=$val"
+
+       mount_client $MOUNT || error "mount client failed"
+       wait_osc_import_state mds1 ost1 FULL
+       wait_osc_import_state client ost1 FULL
+       wait_osc_import_state client ost2 FULL
+
+       $LFS setstripe -i 0 $DIR/$tfile.0 ||
+               error "problem creating $tfile.0 on OST0000"
+       $LFS setstripe -i 1 $DIR/$tfile.1 && $LFS getstripe $DIR/$tfile.1 &&
+               (( $($LFS getstripe -i $DIR/$tfile.1) == 1 )) &&
+               error "allowed to create $tfile.1 on OST0001"
+       do_facet ost2 $LCTL set_param obdfilter.*.no_precreate=0
+       sleep_maxage
+       $LFS setstripe -i 1 $DIR/$tfile.2 ||
+               error "failed to create $tfile.2 on ost1 facet"
+       # files not cleaned with ONLY_REPEAT because of client unmount below
+       rm -f $DIR/$tfile.[012]
+       stop_ost2 || error "stop ost2 facet failed"
+       cleanup
+}
+run_test 112 "mount OST with nocreate option"
+
 cleanup_115()
 {
        trap 0
        stopall
        rm -f $TMP/$tdir/lustre-mdt
-       formatall
 }
 
 test_115() {
-       IMAGESIZE=$((3072 << 30)) # 3072 GiB
-
-       if [ $(facet_fstype $SINGLEMDS) != ldiskfs ]; then
+       if [ "$mds1_FSTYPE" != ldiskfs ]; then
                skip "Only applicable to ldiskfs-based MDTs"
-               return
        fi
+       [ -n "$FILESET" ] && skip "Not functional for FILESET set"
+
+       local dbfs_ver=$(do_facet $SINGLEMDS $DEBUGFS -V 2>&1)
+
+       echo "debugfs version: $dbfs_ver"
+       echo "$dbfs_ver" | egrep -w "1.44.3.wc1|1.44.5.wc1|1.45.2.wc1" &&
+               skip_env "This version of debugfs doesn't show inode number"
+
+       is_dm_flakey_dev $SINGLEMDS $(mdsdevname 1) &&
+               skip "This test can not be executed on flakey dev"
+
+       IMAGESIZE=$((3072 << 30)) # 3072 GiB
 
        stopall
+
+       echo "client1: "
+       lctl dl
+       mount | grep lustre
+       echo "mds1: "
+       do_facet mds1 "hostname; ifconfig; lctl dl; mount"
+       echo "ost1: "
+       do_facet ost1 "hostname; ifconfig; lctl dl; mount"
        # We need MDT size 3072GB, because it is smallest
        # partition that can store 2B inodes
        do_facet $SINGLEMDS "mkdir -p $TMP/$tdir"
@@ -8080,59 +8510,53 @@ test_115() {
        do_facet $SINGLEMDS "touch $mdsimgname"
        trap cleanup_115 RETURN EXIT
        do_facet $SINGLEMDS "$TRUNCATE $mdsimgname $IMAGESIZE" ||
-               { skip "Backend FS doesn't support sparse files"; return 0; }
+               skip "Backend FS doesn't support sparse files"
        local mdsdev=$(do_facet $SINGLEMDS "losetup -f")
        do_facet $SINGLEMDS "losetup $mdsdev $mdsimgname"
 
-       local mds_opts="$(mkfs_opts mds1 ${mdsdev}) --device-size=$IMAGESIZE   \
-               --mkfsoptions='-O lazy_itable_init,ea_inode,^resize_inode,meta_bg \
-               -i 1024'"
+       local mds_opts="$(mkfs_opts mds1 $(mdsdevname 1))        \
+               --mkfsoptions='-O ea_inode,^resize_inode,meta_bg \
+               -N 2247484000 -E lazy_itable_init' --device-size=$IMAGESIZE"
        add mds1 $mds_opts --mgs --reformat $mdsdev ||
-               { skip_env "format large MDT failed"; return 0; }
-       add ost1 $(mkfs_opts ost1 $(ostdevname 1)) --index=$i \
-                       --reformat $(ostdevname 1) $(ostvdevname 1)
-
-       start $SINGLEMDS ${mdsdev} $MDS_MOUNT_OPTS || error "start MDS failed"
+               skip_env "format large MDT failed"
+       opts="$(mkfs_opts ost1 $(ostdevname 1)) \
+               $replace --reformat $(ostdevname 1) $(ostvdevname 1)"
+       add ost1 $opts || error "add ost1 failed with new params"
+       start $SINGLEMDS  $mdsdev $MDS_MOUNT_OPTS || error "start MDS failed"
        start_ost || error "start OSS failed"
        mount_client $MOUNT || error "mount client failed"
 
        mkdir -p $DIR/$tdir || error "mkdir $DIR/$tdir fail"
-       for goal in $(do_facet $SINGLEMDS "ls /sys/fs/ldiskfs/*/inode_goal"); do
-               do_facet $SINGLEMDS "echo 2147483947 >> $goal; grep . $goal"
-       done
-
+       goal="/sys/fs/ldiskfs/$(basename $mdsdev)/inode_goal"
+echo goal: $goal
+       # 2147483648 is 0x80000000
+       do_facet $SINGLEMDS "echo 2147483648 >> $goal; grep . $goal"
        touch $DIR/$tdir/$tfile
 
-       # Add > 5k bytes to xattr
-       for i in {1..30}; do
-               ln $DIR/$tdir/$tfile $DIR/$tdir/$(printf "link%0250d" $i) ||
-                       error "Can't make link"
+       # attrs from 1 to 15 go to block, 16th - to inode
+       for i in {1..16}; do
+               local nm="trusted.ea$i"
+               setfattr -n $nm -v $(printf "xattr%0250d" $i) $DIR/$tdir/$tfile
        done
 
-       sync; sleep 5; sync
-
+       # inode <2147483649> trusted.ea16 (255)
        local inode_num=$(do_facet $SINGLEMDS \
-                        "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsimgname" |
-                        awk '/link =/ { print $4 }' |
+                       "$DEBUGFS -c -R 'stat ROOT/$tdir/$tfile' $mdsdev" |
+                        awk '/ea16/ { print $2 }' |
                         sed -e 's/>//' -e 's/<//' -e 's/\"//')
        echo "inode num: $inode_num"
-       [ $inode_num -ge 2147483947 ] || error "inode $inode_num too small"
+       [ $inode_num -ge 2147483648 ] || error "inode $inode_num too small"
        do_facet $SINGLEMDS "losetup -d $mdsdev"
        cleanup_115
 }
 run_test 115 "Access large xattr with inodes number over 2TB"
 
 test_116() {
-       [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
-               skip "ldiskfs only test" && return
-
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.59) ] &&
-               skip "Need server version at least 2.10.59" && return
-
-       do_facet $SINGLEMDS which mkfs.xfs || {
+       [ "$mds1_FSTYPE" != ldiskfs ] && skip "ldiskfs only test"
+       [ "$MDS1_VERSION" -lt $(version_code 2.10.59) ] &&
+               skip "Need server version at least 2.10.59"
+       do_facet $SINGLEMDS which mkfs.xfs ||
                skip_env "No mkfs.xfs installed"
-               return
-       }
 
        stopall
        load_modules
@@ -8160,11 +8584,15 @@ test_116() {
 
        MDSSIZE=$old_mdssize
        MDSISIZE=$old_mdsisize
-       do_facet $SINGLEMDS $MKFS $opts17t $tmpmnt/$mdtimg ||
+
+       do_facet $SINGLEMDS $MKFS \
+               ${opts17t/-E /-E lazy_itable_init,lazy_journal_init,} \
+               $tmpmnt/$mdtimg ||
                error "failed to mkfs for $tmpmnt/$mdtimg"
 
        do_facet $SINGLEMDS $TUNE2FS -l $tmpmnt/$mdtimg |
                grep -qw 'features.*extent' || error "extent should be enabled"
+       reformat_and_config
 }
 run_test 116 "big size MDT support"
 
@@ -8179,9 +8607,9 @@ run_test 117 "lctl get_param return errors properly"
 
 test_120() { # LU-11130
        [ "$MDSCOUNT" -lt 2 ] && skip "mdt count < 2"
-       [ $(facet_fstype $SINGLEMDS) != "ldiskfs" ] &&
+       [ "$mds1_FSTYPE" != ldiskfs ] &&
                skip "ldiskfs only test"
-       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.11.56) ] &&
+       [ "$MDS1_VERSION" -lt $(version_code 2.11.56) ] &&
                skip "Need DNE2 capable MD target with LU-11130 fix"
 
        setup
@@ -8203,39 +8631,246 @@ test_120() { # LU-11130
 run_test 120 "cross-target rename should not create bad symlinks"
 
 test_122() {
-       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return
-       [[ $(lustre_version_code ost1) -ge $(version_code 2.11.53) ]] ||
-               { skip "Need OST version at least 2.11.53" && return 0; }
-
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       [[ "$OST1_VERSION" -ge $(version_code 2.11.53) ]] ||
+               skip "Need OST version at least 2.11.53"
 
        reformat
        LOAD_MODULES_REMOTE=true load_modules
 #define OBD_FAIL_OFD_SET_OID 0x1e0
        do_facet ost1 $LCTL set_param fail_loc=0x00001e0
 
-       setupall
+       setup_noconfig
        $LFS mkdir -i1 -c1 $DIR/$tdir
        $LFS setstripe -i0 -c1 $DIR/$tdir
        do_facet ost1 $LCTL set_param fail_loc=0
        createmany -o $DIR/$tdir/file_ 1000 ||
                error "Fail to create a new sequence"
 
-       reformat
+       cleanup
 }
 run_test 122 "Check OST sequence update"
 
-test_123() {
-       setupall
+test_123aa() {
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       [ -d $MOUNT/.lustre ] || setup
+
+       # test old logid format until removal from llog_ioctl.c::str2logid()
+       if [ $MGS_VERSION -lt $(version_code 3.1.53) ]; then
+               do_facet mgs $LCTL dl | grep MGS
+               do_facet mgs "$LCTL --device %MGS llog_print \
+                             \\\\\\\$$FSNAME-client 1 10" ||
+                       error "old llog_print failed"
+       fi
+
+       # test new logid format
+       if [ $MGS_VERSION -ge $(version_code 2.9.53) ]; then
+               do_facet mgs "$LCTL --device MGS llog_print $FSNAME-client" ||
+                       error "new llog_print failed"
+       fi
+}
+run_test 123aa "llog_print works with FIDs and simple names"
+
+test_123ab() {
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       [[ $MGS_VERSION -gt $(version_code 2.11.51) ]] ||
+               skip "Need server with working llog_print support"
+
+       [ -d $MOUNT/.lustre ] || setup
+
+       local yaml
+       local orig_val
+       local mgs_arg=""
+
+       [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+               mgs_arg="--device MGS"
+
+       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 $mgs_arg 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 123ab "llog_print params output values from set_param -P"
+
+test_123ac() { # LU-11566
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
+               skip "Need 'lctl llog_print --start' on MGS"
+
+       local start=10
+       local end=50
+       local mgs_arg=""
+
+       [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+               mgs_arg="--device MGS"
+
+       [ -d $MOUNT/.lustre ] || setup
+
+       # - { index: 10, event: add_uuid, nid: 192.168.20.1@tcp(0x20000c0a81401,
+       #     node: 192.168.20.1@tcp }
+       do_facet mgs $LCTL $mgs_arg \
+               llog_print --start $start --end $end $FSNAME-client | tr -d , |
+               while read DASH BRACE INDEX idx EVENT BLAH BLAH BLAH; do
+               (( idx >= start )) || error "llog_print index $idx < $start"
+               (( idx <= end )) || error "llog_print index $idx > $end"
+       done
+}
+run_test 123ac "llog_print with --start and --end"
+
+test_123ad() { # LU-11566
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       # older versions of lctl may not print all records properly
+       do_facet mgs "$LCTL help llog_print" 2>&1 | grep -q -- --start ||
+               skip "Need 'lctl llog_print --start' on MGS"
+
+       [ -d $MOUNT/.lustre ] || setup
+
+       # append a new record, to avoid issues if last record was cancelled
+       local old=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
+       do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$old
+
+       # logid:            [0x3:0xa:0x0]:0
+       # flags:            4 (plain)
+       # records_count:    72
+       # last_index:       72
+       local num=$(do_facet mgs $LCTL --device MGS llog_info $FSNAME-client |
+                   awk '/last_index:/ { print $2 - 1 }')
+
+       # - { index: 71, event: set_timeout, num: 0x14, param: sys.timeout=20 }
+       local last=$(do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
+                    tail -1 | awk '{ print $4 }' | tr -d , )
+       (( last == num )) || error "llog_print only showed $last/$num records"
+}
+run_test 123ad "llog_print shows all records"
+
+test_123ae() { # LU-11566
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+       [ -d $MOUNT/.lustre ] || setupall
+
+       local max=$($LCTL get_param -n osc.*-OST0000-*.max_dirty_mb | head -1)
+       local mgs_arg=""
+
+       [[ $MGS_VERSION -gt $(version_code 2.13.54) ]] ||
+               mgs_arg="--device MGS"
+
+       if do_facet mgs "$LCTL help llog_cancel" 2>&1| grep -q -- --log_id; then
+               # save one set_param -P record in case none exist
+               do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
+
+               local log=params
+               local orig=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
+                            tail -1 | awk '{ print $4 }' | tr -d , )
+               do_facet mgs $LCTL set_param -P osc.*.max_dirty_mb=$max
+               do_facet mgs $LCTL $mgs_arg llog_print $log | tail -1 |
+                       grep "parameter: osc.*.max_dirty_mb" ||
+                       error "new set_param -P wasn't stored in params log"
+
+               # - { index: 71, event: set_param, device: general,
+               #     param: osc.*.max_dirty_mb, value: 256 }
+               local id=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
+                          tail -1 | awk '{ print $4 }' | tr -d , )
+
+               do_facet mgs $LCTL $mgs_arg llog_cancel $log --log_idx=$id
+               local new=$(do_facet mgs $LCTL $mgs_arg llog_print $log |
+                           tail -1 | awk '{ print $4 }' | tr -d , )
+               (( new == orig )) ||
+                       error "new llog_cancel now $new, not at $orig records"
+       fi
+
+       # test old positional parameters for a while still
+       if [ "$MGS_VERSION" -le $(version_code 3.1.53) ]; then
+               log=$FSNAME-client
+               orig=$(do_facet mgs $LCTL --device MGS llog_print $log |
+                      tail -1 | awk '{ print $4 }' | tr -d , )
+               do_facet mgs $LCTL conf_param $FSNAME-OST0000.osc.max_dirty_mb=$max
+               do_facet mgs $LCTL --device MGS llog_print $log |
+                       tail -1 | grep "parameter: osc.max_dirty_mb" ||
+                       error "old conf_param wasn't stored in params log"
+
+               # - { index: 71, event: conf_param, device: testfs-OST0000-osc,
+               #     param: osc.max_dirty_mb=256 }
+               id=$(do_facet mgs $LCTL --device MGS llog_print $log |
+                    tail -1 | awk '{ print $4 }' | tr -d , )
+               do_facet mgs $LCTL --device MGS llog_cancel $log $id
+               new=$(do_facet mgs $LCTL --device MGS llog_print $log |
+                     tail -1 | awk '{ print $4 }' | tr -d , )
+               (( new == orig )) ||
+                       error "old llog_cancel now $new, not at $orig records"
+       fi
+}
+run_test 123ae "llog_cancel can cancel requested record"
+
+test_123af() { #LU-13609
+       [ "$MGS_VERSION" -ge $(version_code 2.13.54) -a \
+          "$MDS1_VERSION" -ge $(version_code 2.13.54) ] ||
+               skip "Need both MGS and MDS version at least 2.13.54"
+
+       [ -d $MOUNT/.lustre ] || setupall
+       stack_trap "do_facet mds1 $LCTL set_param fail_loc=0" EXIT
+
+       local device
+       local facet
+       local cmd
+       local orig_clist
+       local orig_count
+       local new_clist
+       local new_count
+
+       for device in "MGS" "$FSNAME-MDT0000"; do
+               cmd="--device $device llog_catlist"
+               echo "lctl $cmd ..."
+               if [ "$device" = "MGS" ]; then
+                       facet="mgs"
+               else
+                       facet="mds1"
+               fi
+               orig_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
+               orig_count=${#orig_clist[@]}
+               echo "orig_clist: ${orig_clist[@]}"
+
+               #define OBD_FAIL_CATLIST 0x131b
+               #fetch to llog records from the second one
+               do_facet $facet $LCTL set_param fail_loc=0x131b fail_val=2
+
+               new_clist=($(do_facet $facet $LCTL $cmd | awk '{ print $2 }'))
+               new_count=${#new_clist[@]}
+               echo "new_clist: ${new_clist[@]}"
+
+               [ $new_count -eq $((orig_count - 1)) ] ||
+                       error "$new_count != $orig_count - 1"
+               for i in $(seq 0 $new_count); do
+                       j=$((i + 1))
+                       [ "${orig_clist[$j]}" = "${new_clist[$i]}" ] ||
+                               error "${orig_clist[$j]} != ${new_clist[$i]}"
+               done
+               do_facet mds1 $LCTL set_param fail_loc=0
+               echo "done"
+       done
+}
+run_test 123af "llog_catlist can show all config files correctly"
+
+test_123F() {
+       remote_mgs_nodsh && skip "remote MGS with nodsh"
+
+       [ -d $MOUNT/.lustre ] || setup
        local yaml_file="$TMP/$tfile.yaml"
        do_facet mgs rm "$yaml_file"
-       local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist |"\
-                       " sed 's/config_log://'")
+       local cfgfiles=$(do_facet mgs "lctl --device MGS llog_catlist" |
+                        sed 's/config_log://')
 
        # set jobid_var to a different value for test
        local orig_val=$(do_facet mgs $LCTL get_param jobid_var)
-       do_facet mgs $LCTL set_param -P jobid_var="testname"
+       do_facet mgs $LCTL set_param -P jobid_var="TESTNAME"
 
-       for i in params $cfgfiles; do
+       for i in $cfgfiles params; do
                do_facet mgs "lctl --device MGS llog_print ${i} >> $yaml_file"
        done
 
@@ -8256,12 +8891,276 @@ test_123() {
        local set_val=$(do_facet mgs $LCTL get_param jobid_var)
        do_facet mgs $LCTL set_param -P $orig_val
 
-       [ $set_val == "jobid_var=testname" ] ||
-               error "$set_val is not testname"
+       [ $set_val == "jobid_var=TESTNAME" ] ||
+               error "$set_val is not TESTNAME"
 
        do_facet mgs rm "$yaml_file"
+       cleanup
+}
+run_test 123F "clear and reset all parameters using set_param -F"
+
+test_124()
+{
+       [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs"
+       [ -z $mds2failover_HOST ] && skip "needs MDT failover setup"
+
+       setup
+       do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
+               grep 1.2.3.4@tcp && error "Should not be fake nid"
+       do_facet mgs $LCTL conf_param $FSNAME-MDT0001.failover.node=1.2.3.4@tcp\
+               || error "Set params error"
+       do_facet mgs $LCTL --device MGS llog_print $FSNAME-client |
+               grep 1.2.3.4@tcp || error "Fake nid should be added"
+       cleanup
+
+       load_modules
+       if combined_mgs_mds; then
+               start_mdt 1 "-o nosvc" ||
+                       error "starting mds with nosvc option failed"
+       fi
+       local nid=$(do_facet mds2 $LCTL list_nids | head -1)
+       local failover_nid=$(do_node $mds2failover_HOST $LCTL list_nids | head -1)
+       do_facet mgs $LCTL replace_nids $FSNAME-MDT0001 $nid:$failover_nid ||
+               error "replace_nids execution error"
+
+       if combined_mgs_mds; then
+               stop_mdt 1
+       fi
+
+       setup
+       fail mds2
+       echo "lfs setdirstripe"
+       $LFS setdirstripe -i 1 $MOUNT/$tdir || error "setdirstirpe error"
+       echo ok
+}
+run_test 124 "check failover after replace_nids"
+
+get_max_sectors_kb() {
+       local facet="$1"
+       local device="$2"
+       local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
+       local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
+
+       do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
+                          cat ${max_sectors_path}"
+}
+
+get_max_hw_sectors_kb() {
+       local facet="$1"
+       local device="$2"
+       local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
+       local max_hw_path="/sys/block/${dev_base}/queue/max_hw_sectors_kb"
+
+       do_facet ${facet} "[[ -e ${max_hw_path} ]] && cat ${max_hw_path}"
+}
+
+set_max_sectors_kb() {
+       local facet="$1"
+       local device="$2"
+       local value="$3"
+       local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
+       local max_sectors_path="/sys/block/${dev_base}/queue/max_sectors_kb"
+
+       do_facet ${facet} "[[ -e ${max_sectors_path} ]] &&
+                          echo ${value} > ${max_sectors_path}"
+       rc=$?
+
+       [[ $rc -ne 0 ]] && echo "Failed to set ${max_sectors_path} to ${value}"
+
+       return $rc
+}
+
+# Return 0 if all slave devices have max_sectors_kb == max_hw_sectors_kb
+# Otherwise return > 0
+check_slaves_max_sectors_kb()
+{
+       local facet="$1"
+       local device="$2"
+       local dev_base=$(basename $(do_facet ${facet} "readlink -f ${device}"))
+       local slaves_dir=/sys/block/${dev_base}/slaves
+       local slave_devices=$(do_facet ${facet} "ls ${slaves_dir} 2>/dev/null")
+       [[ -z ${slave_devices} ]] && return 0
+
+       local slave max_sectors new_max_sectors max_hw_sectors path
+       local rc=0
+       for slave in ${slave_devices}; do
+               path="/dev/${slave}"
+               ! is_blkdev ${facet} ${path} && continue
+               max_sectors=$(get_max_sectors_kb ${facet} ${path})
+               max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${path})
+               new_max_sectors=${max_hw_sectors}
+               [[ ${new_max_sectors} -gt ${RQ_SIZE_LIMIT} ]] &&
+                       new_max_sectors=${RQ_SIZE_LIMIT}
+
+               if [[ ${max_sectors} -ne ${new_max_sectors} ]]; then
+                       echo "${path} ${max_sectors} ${new_max_sectors}"
+                       ((rc++))
+               fi
+               check_slaves_max_sectors_kb ${facet} ${path}
+               ((rc + $?))
+       done
+
+       return $rc
+}
+
+test_125()
+{
+       local facet_list="mgs mds1 ost1"
+       combined_mgs_mds && facet_list="mgs ost1"
+
+       local facet
+       for facet in ${facet_list}; do
+               [[ $(facet_fstype ${facet}) != ldiskfs ]] &&
+                       skip "ldiskfs only test" &&
+                       return 0
+               ! is_blkdev ${facet} $(facet_device ${facet}) &&
+                       skip "requires all real devices" &&
+                       return 0
+       done
+
+       local rc=0
+       # We don't increase IO request size limit past 16MB. See comments in
+       # lustre/utils/libmount_utils_ldiskfs.c:tune_max_sectors_kb()
+       RQ_SIZE_LIMIT=$((16 * 1024))
+       local device old_max_sectors new_max_sectors max_hw_sectors
+       for facet in ${facet_list}; do
+               device=$(facet_device ${facet})
+               old_max_sectors=$(get_max_sectors_kb ${facet} ${device})
+               max_hw_sectors=$(get_max_hw_sectors_kb ${facet} ${device})
+
+               # The expected value after l_tunedisk is executed
+               new_max_sectors=$old_max_sectors
+               [[ ${new_max_sectors_kb} -gt ${RQ_SIZE_LIMIT} ]] &&
+                       new_max_sectors_kb=${RQ_SIZE_LIMIT}
+
+               # Ensure the current value of max_sectors_kb does not equal
+               # max_hw_sectors_kb, so we can tell whether l_tunedisk did
+               # anything
+               set_max_sectors_kb ${facet} ${device} $((new_max_sectors - 1))
+
+               # Value before l_tunedisk
+               local pre_max_sectors=$(get_max_sectors_kb ${facet} ${device})
+               if [[ ${pre_max_sectors} -ne $((new_max_sectors - 1)) ]]; then
+                       echo "unable to satsify test pre-condition:"
+                       echo "${pre_max_sectors} != $((new_max_sectors - 1))"
+                       ((rc++))
+                       continue
+               fi
+
+               echo "Before: ${facet} ${device} ${pre_max_sectors} ${max_hw_sectors}"
+
+               do_facet ${facet} "l_tunedisk ${device}"
+
+               # Value after l_tunedisk
+               local post_max_sectors=$(get_max_sectors_kb ${facet} ${device})
+
+               echo "After: ${facet} ${device} ${post_max_sectors} ${max_hw_sectors}"
+
+               if [[ ${facet} != ost1 ]]; then
+                       if [[ ${post_max_sectors} -ne ${pre_max_sectors} ]]; then
+                               echo "l_tunedisk modified max_sectors_kb of ${facet}"
+                               ((rc++))
+                       fi
+
+                       set_max_sectors_kb ${facet} ${device} ${old_max_sectors}
+               else
+                       if [[ ${post_max_sectors} -eq ${pre_max_sectors} ]]; then
+                               echo "l_tunedisk failed to modify max_sectors_kb of ${facet}"
+                               ((rc++))
+                       fi
+
+                       check_slaves_max_sectors_kb ${facet} ${device} ||
+                               ((rc++))
+               fi
+       done
+
+       return $rc
+}
+run_test 125 "check l_tunedisk only tunes OSTs and their slave devices"
+
+test_126() {
+       [[ "$MDS1_VERSION" -ge $(version_code 2.13.52) ]] ||
+               skip "Need MDS version at least 2.13.52"
+
+       cleanup
+       do_rpc_nodes $(facet_active_host $SINGLEMDS) load_module ../libcfs/libcfs/libcfs
+       #define OBD_FAIL_OBD_SETUP 0x60d
+       do_facet mds1 $LCTL set_param fail_loc=0x60d
+       do_rpc_nodes $(facet_active_host $SINGLEMDS) load_modules &
+       for i in {1..40}; do
+               do_facet mds1 lsmod | grep -q osd_$mds1_FSTYPE && break
+               sleep 1
+       done
+       clear_failloc $SINGLEMDS 20 &
+       start mds1 $(mdsdevname 1) $MDS_MOUNT_OPTS
+}
+run_test 126 "mount in parallel shouldn't cause a crash"
+
+test_127() {
+       [[ "$ost1_FSTYPE" == ldiskfs ]] || skip "ldiskfs only test"
+
+       cleanup
+       setup
+       zconf_umount_clients $RCLIENTS $MOUNT
+
+       wait_osp_active ost ${FSNAME}-OST0000 0 1
+       local osc_tgt="$FSNAME-OST0000-osc-$($LFS getname -i $DIR)"
+       local avail1=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
+
+       $LFS setstripe -i 0 $DIR/$tfile || error "failed creating $DIR/$tfile"
+       dd if=/dev/zero of=$DIR/$tfile bs=1M oflag=direct || true
+
+       local avail2=($($LCTL get_param -n osc.${osc_tgt}.kbytesavail))
+
+       if ((avail2 * 100 / avail1 > 1)); then
+               lfs df $DIR
+               ls -l $DIR/$tfile
+               error "more than 1% space left: before=$avail1 after=$avail2"
+       fi
+
+       local mbs=$(($(stat -c %s $DIR/$tfile) / (1024 * 1024)))
+
+       dd if=/dev/zero of=$DIR/$tfile bs=1M count=$mbs conv=notrunc \
+               oflag=direct || error "overwrite failed"
+}
+run_test 127 "direct io overwrite on full ost"
+
+test_128()
+{
+       combined_mgs_mds && skip "need separate mgs device"
+       [ "$ost2_FSTYPE" == zfs ] && import_zpool ost2
+
+       format_ost 2
+       # Try to apply nolocallogs to the virgin OST. Should fail.
+       do_facet ost2 "$TUNEFS --nolocallogs $(ostdevname 2)" &&
+               error "nolocallogs should not be allowed on the virgin target"
+
+       setupall
+       stopall
+
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
+       # Start OST without MGS (local configs)
+       do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)"
+       start_ost || error "unable to start OST1"
+       stop_ost || error "Unable to stop OST1"
+
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
+       # Do not allow reading local configs, should fail
+       do_facet ost1 "$TUNEFS --nolocallogs $(ostdevname 1)" ||
+               error "Can not set nolocallogs"
+       start_ost && error "OST1 started, but should fail"
+
+       # Connect to MGS successfully, reset nolocallogs flag
+       [ "$ost1_FSTYPE" == zfs ] && import_zpool ost1
+       start_mgs || error "unable to start MGS"
+       start_ost || error "unable to start OST1"
+
+       do_facet ost1 "$TUNEFS --dryrun $(ostdevname 1)" | grep "nolocallogs" &&
+               error "nolocallogs expected to be reset"
+
+       stop_ost || error "Unable to stop OST1"
 }
-run_test 123 "clear and reset all parameters using set_param -F"
+run_test 128 "Force using remote logs with --nolocallogs"
 
 if ! combined_mgs_mds ; then
        stop mgs