Whamcloud - gitweb
LU-6655 ptlrpc: skip delayed replay requests
[fs/lustre-release.git] / lustre / tests / replay-single.sh
index f0824b5..ada7584 100755 (executable)
@@ -22,22 +22,15 @@ require_dsh_mds || exit 0
 
 # Skip these tests
 # bug number for skipped tests:
-#                                    LU-472 LU-4039
-ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT 61d    90"
+ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT "
 # UPDATE THE COMMENT ABOVE WITH BUG NUMBERS WHEN CHANGING ALWAYS_EXCEPT!
 
-case "$(lsb_release -sr)" in   # only disable tests for el7
-7*)    # bug number:  LU-6455-----
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 28"
-       ;;
-esac
-
 #                                  7.5  (min)"
 [ "$SLOW" = "no" ] && EXCEPT_SLOW="44b"
 
 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
-# bug number for skipped test:        LU-1867  LU-3127
-       ALWAYS_EXCEPT="$ALWAYS_EXCEPT 89        73b"
+# bug number for skipped test:
+       ALWAYS_EXCEPT="$ALWAYS_EXCEPT "
 
 build_test_filter
 
@@ -126,6 +119,24 @@ test_2b() {
 }
 run_test 2b "touch"
 
+test_2c() {
+       replay_barrier $SINGLEMDS
+       $LFS setstripe -c $OSTCOUNT $DIR/$tfile
+       fail $SINGLEMDS
+       $CHECKSTAT -t file $DIR/$tfile ||
+               error "$CHECKSTAT $DIR/$tfile check failed"
+}
+run_test 2c "setstripe replay"
+
+test_2d() {
+       replay_barrier $SINGLEMDS
+       $LFS setdirstripe -i 0 -c $MDSCOUNT $DIR/$tdir
+       fail $SINGLEMDS
+       $CHECKSTAT -t dir $DIR/$tdir ||
+               error "$CHECKSTAT $DIR/$tdir check failed"
+}
+run_test 2d "setdirstripe replay"
+
 test_3a() {
        local file=$DIR/$tfile
        replay_barrier $SINGLEMDS
@@ -455,35 +466,47 @@ run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans
 
 test_20b() { # bug 10480
        local wait_timeout=$((TIMEOUT * 4))
-       local BEFOREUSED
-       local AFTERUSED
+       local extra=$(fs_log_size)
+       local n_attempts=1
+
+       sync_all_data
+       $LFS setstripe -i 0 -c 1 $DIR
+
+       local beforeused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
 
-       BEFOREUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
        dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
        while [ ! -e $DIR/$tfile ] ; do
-               usleep 60                      # give dd a chance to start
+               usleep 60                       # give dd a chance to start
        done
 
-       $GETSTRIPE $DIR/$tfile || error "$GETSTRIPE $DIR/$tfile failed"
+       $LFS getstripe $DIR/$tfile || error "$LFS getstripe $DIR/$tfile failed"
        # make it an orphan
        rm -f $DIR/$tfile || error "rm -f $DIR/$tfile failed"
        mds_evict_client
-       client_up || client_up || true    # reconnect
+       client_up || client_up || true          # reconnect
 
-       do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync 1"
+       do_facet $SINGLEMDS "lctl set_param -n osd*.*MDT*.force_sync=1"
 
-       fail $SINGLEMDS                            # start orphan recovery
+       fail $SINGLEMDS                         # start orphan recovery
        wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
-       wait_delete_completed_mds $wait_timeout ||
-               error "delete did not complete"
+       wait_delete_completed $wait_timeout || error "delete did not finish"
+       sync_all_data
 
-       AFTERUSED=$(df -P $DIR | tail -1 | awk '{ print $3 }')
-       log "before $BEFOREUSED, after $AFTERUSED"
-       (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
-               error "after $AFTERUSED > before $BEFOREUSED"
-       return 0
+       while true; do
+               local afterused=$(df -P $DIR | tail -1 | awk '{ print $3 }')
+               log "before $beforeused, after $afterused"
+
+               (( $beforeused + $extra >= $afterused )) && break
+               n_attempts=$((n_attempts + 1))
+               [ $n_attempts -gt 3 ] &&
+                       error "after $afterused > before $beforeused + $extra"
+
+               wait_zfs_commit $SINGLEMDS 5
+               sync_all_data
+       done
 }
-run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
+
+run_test 20b "write, unlink, eviction, replay (test mds_cleanup_orphans)"
 
 test_20c() { # bug 10480
        multiop_bg_pause $DIR/$tfile Ow_c ||
@@ -916,9 +939,7 @@ run_test 40 "cause recovery in ptlrpc, ensure IO continues"
 # the page, guarnateeing that the unlock from the RPC completion would
 # assert on trying to unlock the unlocked page.
 test_41() {
-    [ $OSTCOUNT -lt 2 ] &&
-        skip_env "skipping test 41: we don't have a second OST to test with" &&
-        return
+       [ $OSTCOUNT -lt 2 ] && skip_env "needs >= 2 OSTs" && return
 
        local f=$MOUNT/$tfile
        # make sure the start of the file is ost1
@@ -1124,8 +1145,7 @@ run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
 
 test_48() {
        remote_ost_nodsh && skip "remote OST with nodsh" && return 0
-       [ "$OSTCOUNT" -lt "2" ] &&
-               skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
+       [ "$OSTCOUNT" -lt "2" ] && skip_env "needs >= 2 OSTs" && return
 
        replay_barrier $SINGLEMDS
        createmany -o $DIR/$tfile 20  ||
@@ -1135,6 +1155,10 @@ test_48() {
        do_facet ost1 "lctl set_param fail_loc=0x80000216"
        client_up || error "client_up failed"
 
+       # let the MDS discover the OST failure, attempt to recover, fail
+       # and recover again.
+       sleep $((3 * TIMEOUT))
+
        createmany -o $DIR/$tfile 20 20 ||
                error "createmany recraete $DIR/$tfile failed"
        unlinkmany $DIR/$tfile 40 || error "unlinkmany $DIR/$tfile failed"
@@ -1504,7 +1528,8 @@ test_57() {
        touch $DIR/$tfile || error "touch $DIR/$tfile failed"
        replay_barrier $SINGLEMDS
        fail $SINGLEMDS
-       sleep 1
+       wait_recovery_complete $SINGLEMDS || error "MDS recovery is not done"
+       wait_mds_ost_sync || error "wait_mds_ost_sync failed"
        $CHECKSTAT -t file $DIR/$tfile ||
                error "$CHECKSTAT $DIR/$tfile attribute check failed"
        do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
@@ -1811,36 +1836,39 @@ run_test 65a "AT: verify early replies"
 
 test_65b() #bug 3055
 {
-    remote_ost_nodsh && skip "remote OST with nodsh" && return 0
-
-    at_start || return 0
-    # turn on D_ADAPTTO
-    debugsave
-    $LCTL set_param debug="other trace"
-    $LCTL dk > /dev/null
-    # Slow down a request to the current service time, this is critical
-    # because previous tests may have caused this value to increase.
-    $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
-    multiop $DIR/$tfile Ow1yc
-    REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
-               awk '/portal 6/ {print $5}'`
-    REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
-
-    do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
-#define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
-    do_facet ost1 $LCTL set_param fail_loc=0x224
+       remote_ost_nodsh && skip "remote OST with nodsh" && return 0
 
-    rm -f $DIR/$tfile
-    $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
-    # force some real bulk transfer
-    multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+       at_start || return 0
+       # turn on D_ADAPTTO
+       debugsave
+       $LCTL set_param debug="other trace"
+       $LCTL dk > /dev/null
+       # Slow down a request to the current service time, this is critical
+       # because previous tests may have caused this value to increase.
+       $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
+               error "$SETSTRIPE failed for $DIR/$tfile"
+
+       multiop $DIR/$tfile Ow1yc
+       REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
+                  awk '/portal 6/ {print $5}'`
+       REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
+
+       do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
+       #define OBD_FAIL_OST_BRW_PAUSE_PACK      0x224
+       do_facet ost1 $LCTL set_param fail_loc=0x224
 
-    do_facet ost1 $LCTL set_param fail_loc=0
-    # check for log message
-    $LCTL dk | grep "Early reply #" || error "No early reply"
-    debugrestore
-    # client should show REQ_DELAY estimates
-    lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
+       rm -f $DIR/$tfile
+       $SETSTRIPE --stripe-index=0 --stripe-count=1 $DIR/$tfile ||
+               error "$SETSTRIPE failed"
+       # force some real bulk transfer
+       multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
+
+       do_facet ost1 $LCTL set_param fail_loc=0
+       # check for log message
+       $LCTL dk | grep "Early reply #" || error "No early reply"
+       debugrestore
+       # client should show REQ_DELAY estimates
+       lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
 }
 run_test 65b "AT: verify early replies on packed reply / bulk"
 
@@ -1884,7 +1912,7 @@ test_66b() #bug 3055
        $LCTL set_param fail_val=$(($ORIG + 5))
        #define OBD_FAIL_PTLRPC_PAUSE_REP      0x50c
        $LCTL set_param fail_loc=0x50c
-       ls $DIR/$tfile > /dev/null 2>&1
+       touch $DIR/$tfile > /dev/null 2>&1
        $LCTL set_param fail_loc=0
        CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
                awk '/network/ {print $4}')
@@ -1976,20 +2004,21 @@ test_68 () #bug 13813
        do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
 
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
-       $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
-#define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
-    $LCTL set_param fail_val=$(($TIMEOUT - 1))
-    $LCTL set_param fail_loc=0x80000312
-    cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
-    $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
-    $LCTL set_param fail_loc=0x80000312
-    cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
-    $LCTL set_param fail_loc=0
-
-    echo $ENQ_MIN >> $ldlm_enqueue_min
-    do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
-    rm -rf $DIR/$tdir
-    return 0
+       $SETSTRIPE --stripe-index=0 -c 1 $DIR/$tdir ||
+               error "$SETSTRIPE failed for $DIR/$tdir"
+       #define OBD_FAIL_LDLM_PAUSE_CANCEL       0x312
+       $LCTL set_param fail_val=$(($TIMEOUT - 1))
+       $LCTL set_param fail_loc=0x80000312
+       cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
+       $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
+       $LCTL set_param fail_loc=0x80000312
+       cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
+       $LCTL set_param fail_loc=0
+
+       echo $ENQ_MIN >> $ldlm_enqueue_min
+       do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
+       rm -rf $DIR/$tdir
+       return 0
 }
 run_test 68 "AT: verify slowing locks"
 
@@ -2036,10 +2065,6 @@ check_for_process () {
 
 test_70b () {
        local clients=${CLIENTS:-$HOSTNAME}
-       local mdscount=$MDSCOUNT
-
-       # until LU-6844 is fixed, run on one MDT instead of disabling test
-       mdscount=1
 
        zconf_mount_clients $clients $MOUNT
 
@@ -2052,9 +2077,9 @@ test_70b () {
        local start_ts=$(date +%s)
        local cmd="rundbench 1 -t $duration"
        local pid=""
-       if [ $mdscount -ge 2 ]; then
-               test_mkdir -p -c$mdscount $DIR/$tdir
-               $LFS setdirstripe -D -c$mdscount $DIR/$tdir
+       if [ $MDSCOUNT -ge 2 ]; then
+               test_mkdir -p -c$MDSCOUNT $DIR/$tdir
+               $LFS setdirstripe -D -c$MDSCOUNT $DIR/$tdir
        fi
        do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
                PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
@@ -2091,7 +2116,7 @@ test_70b () {
                log "$TESTNAME fail mds$fail_index $num_failovers times"
                fail mds$fail_index
                elapsed=$(($(date +%s) - start_ts))
-               if [ $fail_index -ge $mdscount ]; then
+               if [ $fail_index -ge $MDSCOUNT ]; then
                        fail_index=1
                else
                        fail_index=$((fail_index+1))
@@ -2275,7 +2300,7 @@ test_70e () {
                while true; do
                        mrename $DIR/$tdir/test_0/a $DIR/$tdir/test_1/b > \
                                                /dev/null || {
-                               echo "a->b fails" 
+                               echo "a->b fails"
                                break;
                        }
 
@@ -2312,6 +2337,121 @@ test_70e () {
 }
 run_test 70e "rename cross-MDT with random fails"
 
+test_70f_write_and_read(){
+       local srcfile=$1
+       local stopflag=$2
+       local client
+
+       echo "Write/read files in: '$DIR/$tdir', clients: '$CLIENTS' ..."
+       for client in ${CLIENTS//,/ }; do
+               [ -f $stopflag ] || return
+
+               local tgtfile=$DIR/$tdir/$tfile.$client
+               do_node $client dd $DD_OPTS bs=1M count=10 if=$srcfile \
+                       of=$tgtfile 2>/dev/null ||
+                       error "dd $DD_OPTS bs=1M count=10 if=$srcfile " \
+                             "of=$tgtfile failed on $client, rc=$?"
+       done
+
+       local prev_client=$(echo ${CLIENTS//,/ } | awk '{ print $NF }')
+       local index=0
+
+       for client in ${CLIENTS//,/ }; do
+               [ -f $stopflag ] || return
+
+               # flush client cache in case test is running on only one client
+               # do_node $client cancel_lru_locks osc
+               do_node $client $LCTL set_param ldlm.namespaces.*.lru_size=clear
+
+               tgtfile=$DIR/$tdir/$tfile.$client
+               local md5=$(do_node $prev_client "md5sum $tgtfile")
+               [ ${checksum[$index]// */} = ${md5// */} ] ||
+                       error "$tgtfile: checksum doesn't match on $prev_client"
+               index=$((index + 1))
+               prev_client=$client
+       done
+}
+
+test_70f_loop(){
+       local srcfile=$1
+       local stopflag=$2
+       DD_OPTS=
+
+       mkdir -p $DIR/$tdir || error "cannot create $DIR/$tdir directory"
+       $SETSTRIPE -c -1 $DIR/$tdir || error "cannot $SETSTRIPE $DIR/$tdir"
+
+       touch $stopflag
+       while [ -f $stopflag ]; do
+               test_70f_write_and_read $srcfile $stopflag
+               # use direct IO and buffer cache in turns if loop
+               [ -n "$DD_OPTS" ] && DD_OPTS="" || DD_OPTS="oflag=direct"
+       done
+}
+
+test_70f_cleanup() {
+       trap 0
+       rm -f $TMP/$tfile.stop
+       do_nodes $CLIENTS rm -f $TMP/$tfile
+       rm -f $DIR/$tdir/$tfile.*
+}
+
+test_70f() {
+#      [ x$ost1failover_HOST = x$ost_HOST ] &&
+#              { skip "Failover host not defined" && return; }
+#      [ -z "$CLIENTS" ] &&
+#              { skip "CLIENTS are not specified." && return; }
+#      [ $CLIENTCOUNT -lt 2 ] &&
+#              { skip "Need 2 or more clients, have $CLIENTCOUNT" && return; }
+
+       [[ $(lustre_version_code ost1) -lt $(version_code 2.9.53) ]] &&
+               skip "Need server version at least 2.9.53" && return
+
+       echo "mount clients $CLIENTS ..."
+       zconf_mount_clients $CLIENTS $MOUNT
+
+       local srcfile=$TMP/$tfile
+       local client
+       local index=0
+
+       trap test_70f_cleanup EXIT
+       # create a different source file local to each client node so we can
+       # detect if the file wasn't written out properly after failover
+       do_nodes $CLIENTS dd bs=1M count=10 if=/dev/urandom of=$srcfile \
+               2>/dev/null || error "can't create $srcfile on $CLIENTS"
+       for client in ${CLIENTS//,/ }; do
+               checksum[$index]=$(do_node $client "md5sum $srcfile")
+               index=$((index + 1))
+       done
+
+       local duration=120
+       [ "$SLOW" = "no" ] && duration=60
+       # set duration to 900 because it takes some time to boot node
+       [ "$FAILURE_MODE" = HARD ] && duration=900
+
+       local stopflag=$TMP/$tfile.stop
+       test_70f_loop $srcfile $stopflag &
+       local pid=$!
+
+       local elapsed=0
+       local num_failovers=0
+       local start_ts=$SECONDS
+       while [ $elapsed -lt $duration ]; do
+               sleep 3
+               replay_barrier ost1
+               sleep 1
+               num_failovers=$((num_failovers + 1))
+               log "$TESTNAME failing OST $num_failovers times"
+               fail ost1
+               sleep 2
+               elapsed=$((SECONDS - start_ts))
+       done
+
+       rm -f $stopflag
+       wait $pid
+       test_70f_cleanup
+}
+run_test 70f "OSS O_DIRECT recovery with $CLIENTCOUNT clients"
+
 cleanup_71a() {
        trap 0
        kill -9 $mkdir_71a_pid
@@ -2711,7 +2851,7 @@ test_81a() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2741,7 +2881,7 @@ test_81b() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2774,7 +2914,7 @@ test_81c() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2801,7 +2941,7 @@ test_81d() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2833,7 +2973,7 @@ test_81e() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2864,7 +3004,7 @@ test_81f() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2897,7 +3037,7 @@ test_81g() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2924,7 +3064,7 @@ test_81h() {
 
        wait $CLIENT_PID || error "rm remote dir failed"
 
-       stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
+       stat $remote_dir &>/dev/null && error "$remote_dir still exist!"
 
        rm -rf $DIR/$tdir || error "rmdir failed"
 
@@ -2972,7 +3112,11 @@ run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
 test_85b() { #bug 16774
        lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
 
-       do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME ||
+       if ! combined_mgs_mds ; then
+               mount_mgs_client
+       fi
+
+       create_pool $FSNAME.$TESTNAME ||
                error "unable to create pool $TESTNAME"
        do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 ||
                error "unable to add pool $TESTNAME"
@@ -3009,6 +3153,10 @@ test_85b() { #bug 16774
        do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME ||
                error "unable to destroy the pool $TESTNAME"
 
+       if ! combined_mgs_mds ; then
+               umount_mgs_client
+       fi
+
        if [ $count2 -ge $count ]; then
                error "unused locks are not canceled"
        fi
@@ -3025,7 +3173,7 @@ test_86() {
 }
 run_test 86 "umount server after clear nid_stats should not hit LBUG"
 
-test_87() {
+test_87a() {
        do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
 
        replay_barrier ost1
@@ -3041,7 +3189,7 @@ test_87() {
                error "New checksum $cksum2 does not match original $cksum"
        fi
 }
-run_test 87 "write replay"
+run_test 87a "write replay"
 
 test_87b() {
        do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
@@ -3149,11 +3297,14 @@ test_89() {
        cancel_lru_locks osc
        mkdir $DIR/$tdir || error "mkdir $DIR/$tdir failed"
        rm -f $DIR/$tdir/$tfile
-       wait_mds_ost_sync
-       wait_delete_completed
-       BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
+       wait_mds_ost_sync || error "initial MDS-OST sync timed out"
+       wait_delete_completed || error "initial wait delete timed out"
+       local blocks1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
+       local write_size=$(fs_log_size)
+
        $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
-       dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
+       [ $write_size -lt 1024 ] && write_size=1024
+       dd if=/dev/zero bs=${write_size}k count=10 of=$DIR/$tdir/$tfile
        sync
        stop ost1
        facet_failover $SINGLEMDS
@@ -3162,23 +3313,24 @@ test_89() {
        mount_facet ost1
        zconf_mount $(hostname) $MOUNT || error "mount fails"
        client_up || error "client_up failed"
-       wait_mds_ost_sync
-       wait_delete_completed
-       BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
-       [ $((BLOCKS2 - BLOCKS1)) -le 4  ] ||
-               error $((BLOCKS2 - BLOCKS1)) blocks leaked
-}
+       wait_mds_ost_sync || error "MDS-OST sync timed out"
+       wait_delete_completed || error "wait delete timed out"
+       local blocks2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
 
+       [ $((blocks2 - blocks1)) -le $(fs_log_size)  ] ||
+               error $((blocks2 - blocks1)) blocks leaked
+}
 run_test 89 "no disk space leak on late ost connection"
 
 cleanup_90 () {
-    local facet=$1
-    trap 0
-    reboot_facet $facet
-    change_active $facet
-    wait_for_facet $facet
-    mount_facet $facet || error "Restart of $facet failed"
-    clients_up
+       local facet=$1
+
+       trap 0
+       reboot_facet $facet
+       change_active $facet
+       wait_for_facet $facet
+       mount_facet $facet || error "Restart of $facet failed"
+       clients_up
 }
 
 test_90() { # bug 19494
@@ -3192,8 +3344,8 @@ test_90() { # bug 19494
             return 0
         fi
     fi
-       # maybe effected by previous test
-        wait_osc_import_state mds ost FULL
+       # ensure all OSTs are active to allow allocations
+       wait_osts_up
 
        mkdir $dir || error "mkdir $dir failed"
 
@@ -3623,6 +3775,10 @@ run_test 102d "check replay & reconstruction with multiple mod RPCs in flight"
 
 test_103() {
        remote_mds_nodsh && skip "remote MDS with nodsh" && return
+       local mds_version=$(lustre_version_code $SINGLEMDS)
+       [[ $mds_version -gt $(version_code 2.8.54) ]] ||
+               { skip "Need MDS version 2.8.54+"; return; }
+
 #define OBD_FAIL_MDS_TRACK_OVERFLOW 0x162
        do_facet mds1 $LCTL set_param fail_loc=0x80000162
 
@@ -3767,7 +3923,7 @@ test_110f() {
        replay_barrier mds1
        replay_barrier mds2
        $LFS mkdir -i1 -c$MDSCOUNT $DIR/$tdir/striped_dir
-       fail mds1,mds2
+       fail mds2,mds1
 
        check_striped_dir_110 || error "check striped_dir failed"
 
@@ -4308,7 +4464,7 @@ test_116a() {
 
        # OBD_FAIL_SPLIT_UPDATE_REC       0x1702
        do_facet mds1 "lctl set_param fail_loc=0x80001702"
-       $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
 
        fail mds1
        $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
@@ -4333,7 +4489,7 @@ test_116b() {
 
        # OBD_FAIL_SPLIT_UPDATE_REC       0x1702
        do_facet mds2 "lctl set_param fail_loc=0x80001702"
-       $LFS setdirstripe -c$MDSCOUNT $DIR/$tdir/striped_dir
+       $LFS setdirstripe -i0 -c$MDSCOUNT $DIR/$tdir/striped_dir
 
        fail mds2
        $CHECKSTAT -t dir $DIR/$tdir/striped_dir ||
@@ -4425,7 +4581,7 @@ test_119() {
        replay_barrier mds1
        mkdir $DIR/$tdir/dir_1
        for ((i = 0; i < 20; i++)); do
-               $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i
+               $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i
        done
 
        stop mds1
@@ -4471,7 +4627,7 @@ test_120() {
                        error "create dir-$i fails"
                        break
                }
-               $LFS setdirstripe -c2 $DIR/$tdir/stripe_dir-$i || {
+               $LFS setdirstripe -i0 -c2 $DIR/$tdir/stripe_dir-$i || {
                        error "create stripe_dir-$i fails"
                        break
                }
@@ -4492,6 +4648,43 @@ test_120() {
 }
 run_test 120 "DNE fail abort should stop both normal and DNE replay"
 
+test_121() {
+       [ $(lustre_version_code $SINGLEMDS) -lt $(version_code 2.10.90) ] &&
+               skip "Don't support it before 2.11" &&
+               return 0
+
+       local at_max_saved=$(at_max_get mds)
+
+       touch $DIR/$tfile || error "touch $DIR/$tfile failed"
+       cancel_lru_locks mdc
+
+       multiop_bg_pause $DIR/$tfile s_s || error "multiop $DIR/$tfile failed"
+       mpid=$!
+
+       lctl set_param -n ldlm.cancel_unused_locks_before_replay "0"
+
+       stop mds1
+       change_active mds1
+       wait_for_facet mds1
+
+       #define OBD_FAIL_TGT_RECOVERY_REQ_RACE  0x721
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x721 fail_val=0"
+       at_max_set 0 mds
+
+       mount_facet mds1
+       wait_clients_import_state "$clients" mds1 FULL
+       clients_up || clients_up || error "failover df: $?"
+
+       kill -USR1 $mpid
+       wait $mpid || error "multiop_bg_pause pid failed"
+
+       do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
+       lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
+       at_max_set $at_max_saved mds
+       rm -f $DIR/$tfile
+}
+run_test 121 "lock replay timed out and race"
+
 complete $SECONDS
 check_and_cleanup_lustre
 exit_status