Whamcloud - gitweb
LU-9669 tests: check required nrs availability on a facet
[fs/lustre-release.git] / lustre / tests / sanityn.sh
index 29ba159..0b6517f 100755 (executable)
@@ -3,8 +3,8 @@
 set -e
 
 ONLY=${ONLY:-"$*"}
-# bug number for skipped test: 9977/LU-7105 LU-9452
-ALWAYS_EXCEPT="                28           29      $SANITYN_EXCEPT"
+# bug number for skipped test: 9977/LU-7105
+ALWAYS_EXCEPT="                28           $SANITYN_EXCEPT"
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
 SRCDIR=$(dirname $0)
@@ -48,6 +48,8 @@ TRACE=${TRACE:-""}
 
 check_and_setup_lustre
 
+OSC=${OSC:-"osc"}
+
 assert_DIR
 rm -rf $DIR1/[df][0-9]* $DIR1/lnk $DIR/[df].${TESTSUITE}*
 
@@ -82,7 +84,8 @@ test_2a() {
        touch $DIR1/f2a
        ls -l $DIR2/f2a
        chmod 777 $DIR2/f2a
-       $CHECKSTAT -t file -p 0777 $DIR1/f2a || error
+       $CHECKSTAT -t file -p 0777 $DIR1/f2a ||
+               error "Either not file type or perms not 0777"
 }
 run_test 2a "check cached attribute updates on 2 mtpt's ========"
 
@@ -90,20 +93,23 @@ test_2b() {
        touch $DIR1/f2b
        ls -l $DIR2/f2b
        chmod 777 $DIR1/f2b
-       $CHECKSTAT -t file -p 0777 $DIR2/f2b || error
+       $CHECKSTAT -t file -p 0777 $DIR2/f2b ||
+               error "Either not file type or perms not 0777"
 }
 run_test 2b "check cached attribute updates on 2 mtpt's ========"
 
 # NEED TO SAVE ROOT DIR MODE
 test_2c() {
        chmod 777 $DIR1
-       $CHECKSTAT -t dir -p 0777 $DIR2 || error
+       $CHECKSTAT -t dir -p 0777 $DIR2 ||
+               error "Either not dir type or perms not 0777"
 }
 run_test 2c "check cached attribute updates on 2 mtpt's root ==="
 
 test_2d() {
        chmod 755 $DIR1
-       $CHECKSTAT -t dir -p 0755 $DIR2 || error
+       $CHECKSTAT -t dir -p 0755 $DIR2 ||
+               error "Either not file type or perms not 0775"
 }
 run_test 2d "check cached attribute updates on 2 mtpt's root ==="
 
@@ -112,7 +118,8 @@ test_2e() {
         ls -l $DIR1
         ls -l $DIR2
         chmod 777 $DIR1
-        $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 || error
+               $RUNAS dd if=/dev/zero of=$DIR2/$tfile count=1 ||
+                       error "dd failed"
 }
 run_test 2e "check chmod on root is propagated to others"
 
@@ -159,7 +166,7 @@ test_2g() {
        local block2=$(stat $DIR2/$tfile | awk '/Blocks/ {print $4} ')
        echo "$DIR1/$tfile has $block1 blocks"
        echo "$DIR2/$tfile has $block2 blocks"
-       [ $block1 -eq $block2 ] || error
+       [ $block1 -eq $block2 ] || error "$block1 not equal to $block2"
 }
 run_test 2g "check blocks update on sync write"
 
@@ -179,7 +186,8 @@ run_test 4 "fstat validation on multiple mount points =========="
 test_5() {
        mcreate $DIR1/f5
        $TRUNCATE $DIR2/f5 100
-       $CHECKSTAT -t file -s 100 $DIR1/f5 || error
+       $CHECKSTAT -t file -s 100 $DIR1/f5 ||
+               error "Either not file type or size not equal to 100 bytes"
        rm $DIR1/f5
 }
 run_test 5 "create a file on one mount, truncate it on the other"
@@ -258,7 +266,7 @@ test_11() {
        $DIR2/d11/f
        RC=$?
        kill -USR1 $MULTIPID
-       wait $MULTIPID || error
+       wait $MULTIPID || error "wait for PID $MULTIPID failed"
        [ $RC -eq 0 ] && error || true
 }
 run_test 11 "execution of file opened for write should return error ===="
@@ -270,16 +278,16 @@ run_test 12 "test lock ordering (link, stat, unlink)"
 
 test_13() {    # bug 2451 - directory coherency
        test_mkdir $DIR1/d13
-       cd $DIR1/d13 || error
+       cd $DIR1/d13 || error "cd to $DIR1/d13 failed"
        ls
        ( touch $DIR1/d13/f13 ) # needs to be a separate shell
        ls
-       rm -f $DIR2/d13/f13 || error
+       rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
        ls 2>&1 | grep f13 && error "f13 shouldn't return an error (1)" || true
        # need to run it twice
        ( touch $DIR1/d13/f13 ) # needs to be a separate shell
        ls
-       rm -f $DIR2/d13/f13 || error
+       rm -f $DIR2/d13/f13 || error "Cannot remove $DIR2/d13/f13"
        ls 2>&1 | grep f13 && error "f13 shouldn't return an error (2)" || true
 }
 run_test 13 "test directory page revocation"
@@ -377,7 +385,7 @@ else
        FSXP=100
 fi
 
-test_16() {
+test_16a() {
        local file1=$DIR1/$tfile
        local file2=$DIR2/$tfile
 
@@ -396,7 +404,26 @@ test_16() {
        fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -S 0 -Z -r 4096 \
                -w 4096 $file1 $file2 || error "fsx with O_DIRECT failed."
 }
-run_test 16 "$FSXNUM iterations of dual-mount fsx"
+run_test 16a "$FSXNUM iterations of dual-mount fsx"
+
+# Consistency check for tiny writes, LU-9409
+test_16b() {
+       local file1=$DIR1/$tfile
+       local file2=$DIR2/$tfile
+
+       # to allocate grant because it may run out due to test_15.
+       lfs setstripe -c -1 $file1
+       dd if=/dev/zero of=$file1 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
+       dd if=/dev/zero of=$file2 bs=$STRIPE_BYTES count=$OSTCOUNT oflag=sync
+       rm -f $file1
+
+       lfs setstripe -c -1 $file1 # b=10919
+       # -o is set to 8192 because writes < 1 page and between 1 and 2 pages
+       # create a mix of tiny writes & normal writes
+       fsx -c 50 -p $FSXP -N $FSXNUM -l $((SIZE * 256)) -o 8192 -S 0 $file1 \
+       $file2
+}
+run_test 16b "$FSXNUM iterations of dual-mount fsx at small size"
 
 test_17() { # bug 3513, 3667
        remote_ost_nodsh && skip "remote OST with nodsh" && return
@@ -432,6 +459,8 @@ run_test 18 "mmap sanity check ================================="
 test_19() { # bug3811
        local node=$(facet_active_host ost1)
 
+       [ "x$DOM" = "xyes" ] && node=$(facet_active_host $SINGLEMDS)
+
        # check whether obdfilter is cache capable at all
        if ! get_osd_param $node '' read_cache_enable >/dev/null; then
                echo "not cache-capable obdfilter"
@@ -446,7 +475,7 @@ test_19() { # bug3811
        cp $TMP/$tfile $DIR1/$tfile
        for i in `seq 1 20`; do
                [ $((i % 5)) -eq 0 ] && log "$testname loop $i"
-               cancel_lru_locks osc > /dev/null
+               cancel_lru_locks $OSC > /dev/null
                cksum $DIR1/$tfile | cut -d" " -f 1,2 > $TMP/sum1 & \
                cksum $DIR2/$tfile | cut -d" " -f 1,2 > $TMP/sum2
                wait
@@ -462,12 +491,12 @@ run_test 19 "test concurrent uncached read races ==============="
 
 test_20() {
        test_mkdir $DIR1/d20
-       cancel_lru_locks osc
+       cancel_lru_locks $OSC
        CNT=$((`lctl get_param -n llite.*.dump_page_cache | wc -l`))
        $MULTIOP $DIR1/f20 Ow8190c
        $MULTIOP $DIR2/f20 Oz8194w8190c
        $MULTIOP $DIR1/f20 Oz0r8190c
-       cancel_lru_locks osc
+       cancel_lru_locks $OSC
        CNTD=$((`lctl get_param -n llite.*.dump_page_cache | wc -l` - $CNT))
        [ $CNTD -gt 0 ] && \
            error $CNTD" page left in cache after lock cancel" || true
@@ -498,7 +527,7 @@ test_23() { # Bug 5972
        echo "atime should be updated while another read" > $DIR1/$tfile
 
        # clear the lock(mode: LCK_PW) gotten from creating operation
-       cancel_lru_locks osc
+       cancel_lru_locks $OSC
        time1=$(date +%s)
        echo "now is $time1"
        sleep $((at_diff + 1))
@@ -530,9 +559,9 @@ test_24a() {
 
        OSC=`lctl dl | awk '/-osc-|OSC.*MNT/ {print $4}' | head -n 1`
 #      OSC=`lctl dl | awk '/-osc-/ {print $4}' | head -n 1`
-       lctl --device %$OSC deactivate
+       lctl --device %osc deactivate
        lfs df -i || error "lfs df -i with deactivated OSC failed"
-       lctl --device %$OSC activate
+       lctl --device %osc activate
        lfs df || error "lfs df with reactivated OSC failed"
 }
 run_test 24a "lfs df [-ih] [path] test ========================="
@@ -602,7 +631,7 @@ test_25b() {
 run_test 25b "change ACL under remote dir on one mountpoint be seen on another"
 
 test_26a() {
-        utime $DIR1/f26a -s $DIR2/f26a || error
+       utime $DIR1/f26a -s $DIR2/f26a || error "utime failed for $DIR1/f26a"
 }
 run_test 26a "allow mtime to get older"
 
@@ -622,7 +651,7 @@ test_26b() {
 run_test 26b "sync mtime between ost and mds"
 
 test_27() {
-       cancel_lru_locks osc
+       cancel_lru_locks $OSC
        lctl clear
        dd if=/dev/zero of=$DIR2/$tfile bs=$((4096+4))k conv=notrunc count=4 seek=3 &
        DD2_PID=$!
@@ -666,16 +695,17 @@ test_28() { # bug 9977
        EOF
 
        # reading of 1st stripe should pass
-       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
+       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
        # reading of 2nd stripe should fail (this stripe was destroyed)
        dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 && error
 
        # now, recreating test file
-       dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error
+       dd if=/dev/zero of=$DIR1/$tfile bs=1024k count=2 || error "dd failed"
        # reading of 1st stripe should pass
-       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error
+       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 || error "dd failed"
        # reading of 2nd stripe should pass
-       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 || error
+       dd if=$DIR2/$tfile of=/dev/null bs=1024k count=1 skip=1 ||
+               error "dd failed"
 }
 run_test 28 "read/write/truncate file with lost stripes"
 
@@ -728,38 +758,39 @@ run_test 31b "voluntary OST cancel / blocking ast race=============="
 
 # enable/disable lockless truncate feature, depending on the arg 0/1
 enable_lockless_truncate() {
-        lctl set_param -n osc.*.lockless_truncate $1
+       lctl set_param -n $OSC.*.lockless_truncate $1
 }
 
 test_32a() { # bug 11270
        local p="$TMP/$TESTSUITE-$TESTNAME.parameters"
-       save_lustre_params client "osc.*.lockless_truncate" > $p
-       cancel_lru_locks osc
+
+       save_lustre_params client "$OSC.*.lockless_truncate" > $p
+       cancel_lru_locks $OSC
        enable_lockless_truncate 1
        rm -f $DIR1/$tfile
        lfs setstripe -c -1 $DIR1/$tfile
        dd if=/dev/zero of=$DIR1/$tfile count=$OSTCOUNT bs=$STRIPE_BYTES > \
                /dev/null 2>&1
-       clear_stats osc.*.osc_stats
+       clear_stats $OSC.*.${OSC}_stats
 
        log "checking cached lockless truncate"
        $TRUNCATE $DIR1/$tfile 8000000
        $CHECKSTAT -s 8000000 $DIR2/$tfile || error "wrong file size"
-       [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
+       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
                error "cached truncate isn't lockless"
 
        log "checking not cached lockless truncate"
        $TRUNCATE $DIR2/$tfile 5000000
        $CHECKSTAT -s 5000000 $DIR1/$tfile || error "wrong file size"
-       [ $(calc_stats osc.*.osc_stats lockless_truncate) -ne 0 ] ||
+       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -ne 0 ] ||
                error "not cached truncate isn't lockless"
 
        log "disabled lockless truncate"
        enable_lockless_truncate 0
-       clear_stats osc.*.osc_stats
+       clear_stats $OSC.*.${OSC}_stats
        $TRUNCATE $DIR2/$tfile 3000000
        $CHECKSTAT -s 3000000 $DIR1/$tfile || error "wrong file size"
-       [ $(calc_stats osc.*.osc_stats lockless_truncate) -eq 0 ] ||
+       [ $(calc_stats $OSC.*.${OSC}_stats lockless_truncate) -eq 0 ] ||
                error "lockless truncate disabling failed"
        rm $DIR1/$tfile
        # restore lockless_truncate default values
@@ -782,21 +813,21 @@ test_32b() { # bug 11270
                "ldlm.namespaces.filter-*.contended_locks" >> $p
        save_lustre_params $facets \
                "ldlm.namespaces.filter-*.contention_seconds" >> $p
-       clear_stats osc.*.osc_stats
+       clear_stats $OSC.*.${OSC}_stats
 
        # agressive lockless i/o settings
        do_nodes $(comma_list $(osts_nodes)) \
                "lctl set_param -n ldlm.namespaces.*.max_nolock_bytes=2000000 \
                        ldlm.namespaces.filter-*.contended_locks=0 \
                        ldlm.namespaces.filter-*.contention_seconds=60"
-       lctl set_param -n osc.*.contention_seconds=60
+       lctl set_param -n $OSC.*.contention_seconds=60
        for i in {1..5}; do
                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
                        /dev/null 2>&1
                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
                        /dev/null 2>&1
        done
-       [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -ne 0 ] ||
+       [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -ne 0 ] ||
                error "lockless i/o was not triggered"
        # disable lockless i/o (it is disabled by default)
        do_nodes $(comma_list $(osts_nodes)) \
@@ -805,15 +836,15 @@ test_32b() { # bug 11270
                        ldlm.namespaces.filter-*.contention_seconds=0"
        # set contention_seconds to 0 at client too, otherwise Lustre still
        # remembers lock contention
-       lctl set_param -n osc.*.contention_seconds=0
-       clear_stats osc.*.osc_stats
+       lctl set_param -n $OSC.*.contention_seconds=0
+       clear_stats $OSC.*.${OSC}_stats
        for i in {1..1}; do
                dd if=/dev/zero of=$DIR1/$tfile bs=4k count=1 conv=notrunc > \
                        /dev/null 2>&1
                dd if=/dev/zero of=$DIR2/$tfile bs=4k count=1 conv=notrunc > \
                        /dev/null 2>&1
        done
-       [ $(calc_stats osc.*.osc_stats lockless_write_bytes) -eq 0 ] ||
+       [ $(calc_stats $OSC.*.${OSC}_stats lockless_write_bytes) -eq 0 ] ||
                error "lockless i/o works when disabled"
        rm -f $DIR1/$tfile
        restore_lustre_params <$p
@@ -1367,7 +1398,7 @@ test_39d() { # LU-7310
 
        $LCTL set_param fail_loc=0
 
-       cancel_lru_locks osc
+       cancel_lru_locks $OSC
 
        local mtime2=$(stat -c %Y $DIR2/$tfile)
        [ "$mtime2" -ge "$d1" ] && [ "$mtime2" -le "$d2" ] ||
@@ -2514,14 +2545,14 @@ test_51d() {
        local br=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
        echo "Before revoking layout lock: $br KB mapped"
 
-       # delete the file will revoke layout lock
-       rm -f $DIR2/$tfile
+       # cancel layout lock manually
+       cancel_lru_locks mdc
 
        # rss after revoking
        local ar=$(grep -A 10 $tfile /proc/$PID/smaps | awk '/^Rss/{print $2}')
 
        kill -USR1 $PID
-       wait $PID || error
+       wait $PID || error "wait PID $PID failed"
 
        [ $ar -eq 0 ] || error "rss before: $br, after $ar, some pages remained"
 }
@@ -3052,8 +3083,13 @@ nrs_write_read() {
 }
 
 test_77a() { #LU-3266
+       local rc
+
        oss=$(comma_list $(osts_nodes))
-       do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo"
+       do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="fifo" ||
+               rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS exists" && return
+       [[ $rc -ne 0 ]] && error "failed to set fifo policy"
        nrs_write_read
 
        return 0
@@ -3061,21 +3097,29 @@ test_77a() { #LU-3266
 run_test 77a "check FIFO NRS policy"
 
 test_77b() { #LU-3266
+       local rc
+
        oss=$(comma_list $(osts_nodes))
 
        do_nodes $oss lctl set_param ost.OSS.*.nrs_policies="crrn" \
-                          ost.OSS.*.nrs_crrn_quantum=1
+               ost.OSS.*.nrs_crrn_quantum=1 || rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS exists" && return
+       [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 1"
 
        echo "policy: crr-n, crrn_quantum 1"
        nrs_write_read
 
-       do_nodes $oss lctl set_param ost.OSS.*.nrs_crrn_quantum=64
+       do_nodes $oss lctl set_param \
+               ost.OSS.*.nrs_crrn_quantum=64 || rc=$?
+       [[ $rc -ne 0 ]] && error "failed to set crrn_quantum to 64"
 
        echo "policy: crr-n, crrn_quantum 64"
        nrs_write_read
 
        # cleanup
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
+       do_nodes $oss lctl set_param \
+               ost.OSS.ost_io.nrs_policies="fifo" || rc=$?
+       [[ $rc -ne 0 ]] && error "failed to set fifo policy"
        return 0
 }
 run_test 77b "check CRR-N NRS policy"
@@ -3086,37 +3130,49 @@ orr_trr() {
        oss=$(comma_list $(osts_nodes))
 
        do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies=$policy \
-                                    ost.OSS.*.nrs_"$policy"_quantum=1 \
-                                    ost.OSS.*.nrs_"$policy"_offset_type="physical" \
-                                    ost.OSS.*.nrs_"$policy"_supported="reads"
+               ost.OSS.*.nrs_"$policy"_quantum=1 \
+               ost.OSS.*.nrs_"$policy"_offset_type="physical" \
+               ost.OSS.*.nrs_"$policy"_supported="reads" || return $?
 
-       echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type physical, ${policy}_supported reads"
+       echo "policy: $policy, ${policy}_quantum 1, ${policy}_offset_type " \
+               "physical, ${policy}_supported reads"
        nrs_write_read
 
-       do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="writes" \
-                                    ost.OSS.*.nrs_${policy}_quantum=64
+       do_nodes $oss lctl set_param \
+               ost.OSS.*.nrs_${policy}_supported="writes" \
+               ost.OSS.*.nrs_${policy}_quantum=64 || return $?
 
-       echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type physical, ${policy}_supported writes"
+       echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
+               "physical, ${policy}_supported writes"
        nrs_write_read
 
-       do_nodes $oss lctl set_param ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
-                                    ost.OSS.*.nrs_${policy}_offset_type="logical"
-       echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type logical, ${policy}_supported reads_and_writes"
+       do_nodes $oss lctl set_param \
+               ost.OSS.*.nrs_${policy}_supported="reads_and_writes" \
+               ost.OSS.*.nrs_${policy}_offset_type="logical" || return $?
+       echo "policy: $policy, ${policy}_quantum 64, ${policy}_offset_type " \
+               "logical, ${policy}_supported reads_and_writes"
        nrs_write_read
 
        # cleanup
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
+       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="fifo" ||
+               return $?
        return 0
 }
 
 test_77c() { #LU-3266
-       orr_trr "orr"
+       local rc
+       orr_trr "orr" || rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS exists" && return
+       [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
        return 0
 }
 run_test 77c "check ORR NRS policy"
 
 test_77d() { #LU-3266
-       orr_trr "trr"
+       local rc
+       orr_trr "trr" || rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS exists" && return
+       [[ $rc -ne 0 ]] && error "orr_trr failed rc:$rc"
        return 0
 }
 run_test 77d "check TRR nrs policy"
@@ -3189,14 +3245,14 @@ tbf_verify() {
 }
 
 test_77e() {
-       local server_version=$(lustre_version_code ost1)
-       [[ $server_version -ge $(version_code 2.7.58) ]] ||
-               { skip "Need server version newer than 2.7.57"; return 0; }
+       local rc
 
        oss=$(comma_list $(osts_nodes))
 
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
-       [ $? -ne 0 ] && error "failed to set TBF policy"
+       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
+               rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
+       [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
 
        local idis
        local rateis
@@ -3235,23 +3291,26 @@ test_77e() {
 run_test 77e "check TBF NID nrs policy"
 
 test_77f() {
-       local server_version=$(lustre_version_code ost1)
-       [[ $server_version -ge $(version_code 2.7.58) ]] ||
-               { skip "Need server version newer than 2.7.57"; return 0; }
+       local rc
 
        oss=$(comma_list $(osts_nodes))
 
+       do_nodes $oss $LCTL set_param \
+               ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
+       [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
+
        # Configure jobid_var
        local saved_jobid_var=$($LCTL get_param -n jobid_var)
+       rc=$?
+       [[ $rc -eq 3 ]] && skip "jobid_var not found" && return
+       [[ $rc -ne 0 ]] && error "failed to get param jobid_var"
        if [ $saved_jobid_var != procname_uid ]; then
                set_conf_param_and_check client                 \
                        "$LCTL get_param -n jobid_var"          \
                        "$FSNAME.sys.jobid_var" procname_uid
        fi
 
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
-       [ $? -ne 0 ] && error "failed to set TBF policy"
-
        local idis
        local rateis
        if [ $(lustre_version_code ost1) -ge $(version_code 2.8.54) ]; then
@@ -3284,6 +3343,7 @@ test_77f() {
        nrs_write_read "$RUNAS"
 
        local current_jobid_var=$($LCTL get_param -n jobid_var)
+       [[ $? -ne 0 ]] && error "failed to get param jobid_var"
        if [ $saved_jobid_var != $current_jobid_var ]; then
                set_conf_param_and_check client                 \
                        "$LCTL get_param -n jobid_var"          \
@@ -3294,17 +3354,18 @@ test_77f() {
 run_test 77f "check TBF JobID nrs policy"
 
 test_77g() {
-       local server_version=$(lustre_version_code ost1)
-       [[ $server_version -ge $(version_code 2.7.58) ]] ||
-               { skip "Need server version newer than 2.7.57"; return 0; }
+       local rc=0
 
        oss=$(comma_list $(osts_nodes))
 
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
-       [ $? -ne 0 ] && error "failed to set TBF policy"
+       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid" ||
+               rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS TBF exists" && return
+       [[ $rc -ne 0 ]] && error "failed to set TBF NID policy"
 
-       do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ jobid"
-       [ $? -ne 0 ] && error "failed to set TBF policy"
+       do_nodes $oss lctl set_param \
+               ost.OSS.ost_io.nrs_policies="tbf\ jobid" || rc=$?
+       [[ $rc -ne 0 ]] && error "failed to set TBF JOBID policy"
 
        local idis
        local rateis
@@ -3380,7 +3441,7 @@ tbf_rule_check()
 }
 
 test_77i() {
-    [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
+       [ $(lustre_version_code ost1) -ge $(version_code 2.8.55) ] ||
                { skip "Need OST version at least 2.8.55"; return 0; }
 
        for i in $(seq 1 $OSTCOUNT)
@@ -3435,7 +3496,11 @@ run_test 77i "Change rank of TBF rule"
 test_77j() {
        local idis
        local rateis
-       if [ $(lustre_version_code ost1) -ge $(version_code 2.8.60) ]; then
+       local ost_version=$(lustre_version_code ost1)
+
+       [ $ost_version -ge $(version_code 2.9.53) ] ||
+               { skip "Need OST version at least 2.9.53"; return 0; }
+       if [ $ost_version -ge $(version_code 2.8.60) ]; then
                idis="opcode="
                rateis="rate="
        fi
@@ -3514,6 +3579,26 @@ test_77k() {
 run_test 77k "check the extended TBF policy with NID/JobID/OPCode expression"
 
 test_77l() {
+       [[ $(lustre_version_code ost1) -ge $(version_code 2.10.56) ]] ||
+               { skip "Need OST version at least 2.10.56"; return 0; }
+
+       do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf\ nid"
+       do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="tbf"
+
+       local output=$(do_facet ost1 lctl get_param \
+                       ost.OSS.ost_io.nrs_policies | \
+                       awk '/name: tbf/ {print;exit}' | \
+                       awk -F ': ' '{print $2}')
+
+       if [ "$output" != "tbf" ]; then
+               error "The generic TBF output is '$output', not 'tbf'"
+       fi
+
+       do_facet ost1 lctl set_param ost.OSS.ost_io.nrs_policies="fifo"
+}
+run_test 77l "check the output of NRS policies for generic TBF"
+
+test_77m() {
        if [ $(lustre_version_code ost1) -lt $(version_code 2.9.54) ]; then
                skip "Need OST version at least 2.9.54"
                return 0
@@ -3563,19 +3648,16 @@ test_77l() {
 
        return 0
 }
-run_test 77l "check NRS Delay slows write RPC processing"
+run_test 77m "check NRS Delay slows write RPC processing"
 
 test_78() { #LU-6673
-       local server_version=$(lustre_version_code ost1)
-       [[ $server_version -ge $(version_code 2.7.58) ]] ||
-               { skip "Need server version newer than 2.7.57"; return 0; }
-
        local rc
 
        oss=$(comma_list $(osts_nodes))
        do_nodes $oss lctl set_param ost.OSS.ost_io.nrs_policies="orr" &
        do_nodes $oss lctl set_param ost.OSS.*.nrs_orr_quantum=1
        rc=$?
+       [[ $rc -eq 3 ]] && skip "no NRS exists" && return
        # Valid return codes are:
        # 0: Tuning succeeded
        # ENODEV: Policy is still stopped
@@ -4002,6 +4084,183 @@ test_93() {
 }
 run_test 93 "alloc_rr should not allocate on same ost"
 
+# Data-on-MDT tests
+test_100a() {
+       skip "Reserved for glimpse-ahead" && return
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+
+       lctl set_param -n mdc.*.stats=clear
+       dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
+
+       $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
+       # first stat from server should return size data and save glimpse
+       local gls=$(lctl get_param -n mdc.*.stats | \
+               awk '/ldlm_glimpse/ {print $2}')
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       # second stat to check size is NOT cached on client without IO lock
+       $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
+
+       local gls=$(lctl get_param -n mdc.*.stats | grep ldlm_glimpse | wc -l)
+       [ "1" == "$gls" ] || error "Expect 1 glimpse RPCs but got $gls"
+       rm -f $dom
+}
+run_test 100a "DoM: glimpse RPCs for stat without IO lock (DoM only file)"
+
+test_100b() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+
+       lctl set_param -n mdc.*.stats=clear
+       dd if=/dev/zero of=$DIR2/$tdir/dom bs=4096 count=1 || return 1
+       cancel_lru_locks mdc
+       # first stat data from server should have size
+       $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #1"
+       # second stat to check size is cached on client
+       $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom || error "stat #2"
+
+       local gls=$(lctl get_param -n mdc.*.stats |
+                       awk '/ldlm_glimpse/ {print $2}')
+       # both stats should cause no glimpse requests
+       [ -z $gls ] || error "Unexpected $gls glimpse RPCs"
+       rm -f $dom
+}
+run_test 100b "DoM: no glimpse RPC for stat with IO lock (DoM only file)"
+
+test_100c() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+
+       lctl set_param -n mdc.*.stats=clear
+       lctl set_param -n osc.*.stats=clear
+       dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
+
+       # check that size is merged from MDT and OST correctly
+       $CHECKSTAT -t file -s 2097152 $DIR/$tdir/dom ||
+               error "Wrong size from stat #1"
+
+       local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
+       [ $gls -eq 0 ] && error "Expect OST glimpse RPCs but got none"
+
+       rm -f $dom
+}
+run_test 100c "DoM: write vs stat without IO lock (combined file)"
+
+test_100d() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       mkdir -p $DIR/$tdir
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR/$tdir/dom
+
+
+       dd if=/dev/zero of=$DIR2/$tdir/dom bs=2048K count=1 || return 1
+       lctl set_param -n mdc.*.stats=clear
+       $TRUNCATE $DIR2/$tdir/dom 4096
+
+       # check that reported size is valid after file grows to OST and
+       # is truncated back to MDT stripe size
+       $CHECKSTAT -t file -s 4096 $DIR/$tdir/dom ||
+               error "Wrong size from stat #1"
+
+       local gls=$(lctl get_param -n osc.*.stats | grep ldlm_glimpse | wc -l)
+       [ $gls -eq 0 ] && error "Expect OST glimpse but got none"
+
+       rm -f $dom
+}
+run_test 100d "DoM: write+truncate vs stat without IO lock (combined file)"
+
+test_101a() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
+       # to get layout
+       $CHECKSTAT -t file $DIR1/$tfile
+
+       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
+       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
+       echo $OLD_VAL
+
+       # open + IO lock
+       dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
+               error_noexit "Write fails"
+       # must discard pages
+       lctl set_param -n mdc.*.stats=clear
+       rm $DIR2/$tfile || error_noexit "Unlink fails"
+       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
+       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+
+       [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
+}
+run_test 101a "Discard DoM data on unlink"
+
+test_101b() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
+       touch $DIR1/${tfile}_2
+       # to get layout
+       $CHECKSTAT -t file $DIR1/$tfile
+
+       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
+       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
+       echo $OLD_VAL
+
+       # open + IO lock
+       dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
+               error_noexit "Write fails"
+       # must discard pages
+       lctl set_param -n mdc.*.stats=clear
+       mv $DIR2/${tfile}_2 $DIR2/$tfile || error_noexit "Rename fails"
+       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
+       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+       [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
+}
+run_test 101b "Discard DoM data on rename"
+
+test_101c() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.55) ] &&
+               skip "Need MDS version at least 2.10.55" && return
+
+       $LFS setstripe -E 1024K -L mdt -E EOF $DIR1/$tfile
+       # to get layout
+       $CHECKSTAT -t file $DIR1/$tfile
+
+       OLD_VAL=$(cat /proc/sys/vm/dirty_writeback_centisecs)
+       echo 0 > /proc/sys/vm/dirty_writeback_centisecs
+       echo $OLD_VAL
+
+       # open + IO lock
+       dd if=/dev/zero of=$DIR1/$tfile bs=4096 count=1 ||
+               error_noexit "Write fails"
+       $MULTIOP $DIR1/$tfile O_c &
+       MULTIOP_PID=$!
+       sleep 1
+       lctl set_param -n mdc.*.stats=clear
+       rm $DIR2/$tfile > /dev/null || error_noexit "Unlink fails"
+       kill -USR1 $MULTIOP_PID && wait $MULTIOP_PID ||
+               error_noexit "multiop failure"
+       local writes=$(lctl get_param -n mdc.*.stats | grep ost_write | wc -l)
+       echo $OLD_VAL > /proc/sys/vm/dirty_writeback_centisecs
+       [ $writes -eq 0 ] || error "Found WRITE RPC but expect none"
+}
+run_test 101c "Discard DoM data on close-unlink"
+
 log "cleanup: ======================================================"
 
 # kill and wait in each test only guarentee script finish, but command in script