+test_46() {
+ dmesg -c >/dev/null
+ drop_reply "touch $DIR/$tfile"
+ fail $SINGLEMDS
+ # ironically, the previous test, 45, will cause a real forced close,
+ # so just look for one for this test
+ dmesg | grep -i "force closing client file handle for $tfile" && return 1
+ return 0
+}
+run_test 46 "Don't leak file handle after open resend (3325)"
+
+# b=2824
+test_47() {
+
+ # create some files to make sure precreate has been done on all
+ # OSTs. (just in case this test is run independently)
+ createmany -o $DIR/$tfile 20 || return 1
+
+ # OBD_FAIL_OST_CREATE_NET 0x204
+ fail ost
+ do_facet ost "sysctl -w lustre.fail_loc=0x80000204"
+ df $MOUNT || return 2
+
+ # let the MDS discover the OST failure, attempt to recover, fail
+ # and recover again.
+ sleep $((3 * TIMEOUT))
+
+ # Without 2824, this createmany would hang
+ createmany -o $DIR/$tfile 20 || return 3
+ unlinkmany $DIR/$tfile 20 || return 4
+
+ do_facet ost "sysctl -w lustre.fail_loc=0"
+ return 0
+}
+run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
+
+
+test_48() {
+ createmany -o $DIR/${tfile}- 100
+ $CHECKSTAT $DIR/${tfile}-99 || return 1
+ mds_evict_client
+ df $MOUNT || echo "first df failed"
+ sleep 1
+ df $MOUNT || return 2
+ sleep 1
+ $CHECKSTAT $DIR/${tfile}-99 || return 3
+
+ dmesg -c >/dev/null
+ replay_barrier $SINGLEMDS
+ fail $SINGLEMDS
+ unlinkmany $DIR/${tfile}- 100 || return 4
+ if dmesg | grep "back in time"; then
+ echo "server went back in time!"
+ return 5
+ fi
+ return 0
+}
+run_test 48 "Don't lose transno when client is evicted (2525)"
+
+# b=3550 - replay of unlink
+test_49() {
+ replay_barrier $SINGLEMDS
+ createmany -o $DIR/$tfile-%d 400 || return 1
+ unlinkmany $DIR/$tfile-%d 0 400 || return 2
+ fail $SINGLEMDS
+ $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
+}
+run_test 49 "re-write records to llog as written during fail"
+
+test_50() {
+ local osc_dev=`$LCTL device_list | \
+ awk '(/ost_svc_$SINGLEMDS_svc/){print $4}' `
+ $LCTL --device %$osc_dev recover && $LCTL --device %$osc_dev recover
+ # give the mds_lov_sync threads a chance to run
+ sleep 5
+}
+run_test 50 "Double OSC recovery, don't LASSERT (3812)"
+
+# bug 3462 - simultaneous MDC requests
+test_51a() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ touch $DIR/${tdir}-2/f
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 1
+
+ fail $SINGLEMDS
+
+ wait $pid || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51a "|X| close request while two MDC requests in flight"
+
+test_51b() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/$tdir-1
+ mkdir -p $DIR/$tdir-2
+ multiop $DIR/$tdir-1/f O_c &
+ pid=$!
+
+ # give multiop a chance to open
+ # 1 second seems to be not enough, we met already such a cases
+ # --umka
+ sleep 5
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
+ touch $DIR/${tdir}-2/f &
+ usleep 500
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ kill -USR1 $pid
+ wait $pid || return 1
+
+ fail $SINGLEMDS
+
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51b "|X| open request while two MDC requests in flight"
+
+test_51c() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
+ touch $DIR/${tdir}-2/f &
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ fail $SINGLEMDS
+
+ wait $pid || return 1
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51c "|X| open request and close request while two MDC requests in flight"
+
+test_51d() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ touch $DIR/${tdir}-2/f
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+ #$CHECKSTAT -t file $DIR/${tdir}-2/f || return 1
+
+ fail $SINGLEMDS
+
+ wait $pid || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51d "|X| close reply while two MDC requests in flight"
+
+test_51e() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/$tdir-1
+ mkdir -p $DIR/$tdir-2
+ multiop $DIR/$tdir-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
+ touch $DIR/${tdir}-2/f &
+ usleep 500
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ kill -USR1 $pid
+ wait $pid || return 1
+
+ fail $SINGLEMDS
+
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51e "|X| open reply while two MDC requests in flight"
+
+test_51f() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
+ touch $DIR/${tdir}-2/f &
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ fail $SINGLEMDS
+
+ wait $pid || return 1
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51f "|X| open reply and close reply while two MDC requests in flight"
+
+test_51g() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multiop a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
+ touch $DIR/${tdir}-2/f &
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ fail $SINGLEMDS
+
+ wait $pid || return 1
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51g "|X| open reply and close request while two MDC requests in flight"
+
+test_51h() {
+ replay_barrier_nodf $SINGLEMDS
+ mkdir -p $DIR/${tdir}-1
+ mkdir -p $DIR/${tdir}-2
+ multiop $DIR/${tdir}-1/f O_c &
+ pid=$!
+ # give multio:wp a chance to open
+ sleep 1
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
+ touch $DIR/${tdir}-2/f &
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000122"
+ kill -USR1 $pid
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ fail $SINGLEMDS
+
+ wait $pid || return 1
+ $CHECKSTAT -t file $DIR/${tdir}-1/f || return 2
+ $CHECKSTAT -t file $DIR/${tdir}-2/f || return 3
+ rm -rf $DIR/${tdir}-*
+}
+run_test 51h "|X| open request and close reply while two MDC requests in flight"
+
+# b3764 timed out lock replay
+test_52() {
+ touch $DIR/$tfile
+ cancel_lru_locks MDC
+
+ multiop $DIR/$tfile s
+ replay_barrier $SINGLEMDS
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000030c"
+ fail $SINGLEMDS
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
+
+ $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
+}
+run_test 52 "time out lock replay (3764)"
+
+test_53() {
+ replay_barrier_nodf $SINGLEMDS
+ f1=$DIR/${tfile}-1
+ cat <<EOF > $f1
+#!/bin/sh
+true
+EOF
+ chmod +x $f1
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
+ $f1 || return 1
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
+
+ fail $SINGLEMDS
+ rm -f $f1
+}
+run_test 53 "|X| open request and close reply while two MDC requests in flight"
+
+test_54() {
+ replay_barrier $SINGLEMDS
+ createmany -o $DIR/$tfile 20
+ unlinkmany $DIR/$tfile 20
+ fail $SINGLEMDS
+}
+run_test 54 "|X| open request and close reply while two MDC requests in flight"
+
+#b3440 ASSERTION(rec->ur_fid2->id) failed
+test_55() {
+ sysctl -w portals.debug=-1 portals.debug_mb=25
+ ln -s foo $DIR/$tfile
+ replay_barrier $SINGLEMDS
+ #drop_reply "cat $DIR/$tfile"
+ fail $SINGLEMDS
+ sleep 10
+}
+run_test 55 "don't replay a symlink open request (3440)"
+
+#b3761 ASSERTION(hash != 0) failed
+test_56() {
+# OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012b"
+ touch $DIR/$tfile
+ pid=$!
+ # give a chance for touch to run
+ sleep 5
+ do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
+ wait $pid || return 1
+ rm $DIR/$tfile
+ return 0
+}
+run_test 56 "let MDS_CHECK_RESENT return the original return code instead of 0"
+
+#b7312 LASSERT(!IS_ERR(parent)) in reconstruct_open()
+test_57() {
+ mkdir $DIR/$tdir || return 1
+ touch $DIR/$tdir/$tfile || return 2
+ multiop $DIR/$tdir/$tfile o_ &
+ MULTIPID=$!
+ sleep 1
+ rm -f $DIR/$tdir/$tfile || return 3
+ rm -rf $DIR/$tdir || return 4
+ # drop first reint reply
+ sysctl -w lustre.fail_loc=0x0000030c
+ facet_failover $SINGLEMDS
+ df $MOUNT || return 1
+ kill -USR1 $MULTIPID || return 5
+ wait $MULTIPID || return 6
+ sysctl -w lustre.fail_loc=0
+}
+run_test 57 "open orphan in reconstruct_open()"
+
+test_58() {
+ capa=`cat /proc/fs/lustre/mds/mds*/capa`
+ if [ "$capa" == "0" ]; then
+ echo "skip testing - no capa enabled"
+ return 0
+ fi
+ sysctl -w lustre.fail_loc=0x0000030c
+ rc=multiop $DIR/$tfile Ow
+ sysctl -w lustre.fail_loc=0
+ return rc
+}
+run_test 58 "open+create resent should return capa"
+