+test_8a() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ verify=$ROOT/tmp/verify-$$
+ dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
+ error "Create verify file failed"
+ #define OBD_FAIL_OST_DQACQ_NET 0x230
+ do_facet ost1 "lctl set_param fail_loc=0x230"
+ dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
+ ddpid=$!
+ sleep $TIMEOUT # wait for the io to become redo io
+ if ! ps -p $ddpid > /dev/null 2>&1; then
+ error "redo io finished incorrectly"
+ fi
+ do_facet ost1 "lctl set_param fail_loc=0"
+ wait $ddpid || true
+ cancel_lru_locks osc
+ cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
+ rm -f $verify $TDIR/$tfile
+ message=$(dmesg | grep "redo for recoverable error -115")
+ [ -z "$message" ] || error "redo error messages found in dmesg"
+}
+run_test 8a "Verify redo io: redo io when get -EINPROGRESS error"
+
+test_8b() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ verify=$ROOT/tmp/verify-$$
+ dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
+ error "Create verify file failed"
+ #define OBD_FAIL_OST_DQACQ_NET 0x230
+ do_facet ost1 "lctl set_param fail_loc=0x230"
+ dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
+ ddpid=$!
+ sleep $TIMEOUT # wait for the io to become redo io
+ fail ost1
+ do_facet ost1 "lctl set_param fail_loc=0"
+ wait $ddpid || error "dd did not complete"
+ cancel_lru_locks osc
+ cmp $verify $TDIR/$tfile || error "compare $verify $TDIR/$tfile failed"
+ rm -f $verify $TDIR/$tfile
+}
+run_test 8b "Verify redo io: redo io should success after recovery"
+
+test_8c() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ verify=$ROOT/tmp/verify-$$
+ dd if=/dev/urandom of=$verify bs=4096 count=1280 ||
+ error "Create verify file failed"
+ #define OBD_FAIL_OST_DQACQ_NET 0x230
+ do_facet ost1 "lctl set_param fail_loc=0x230"
+ dd if=$verify of=$TDIR/$tfile bs=4096 count=1280 oflag=sync &
+ ddpid=$!
+ sleep $TIMEOUT # wait for the io to become redo io
+ ost_evict_client
+ # allow recovery to complete
+ sleep $((TIMEOUT + 2))
+ do_facet ost1 "lctl set_param fail_loc=0"
+ wait $ddpid
+ cancel_lru_locks osc
+ cmp $verify $TDIR/$tfile && error "compare files should fail"
+ rm -f $verify $TDIR/$tfile
+}
+run_test 8c "Verify redo io: redo io should fail after eviction"
+
+test_8d() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ #define OBD_FAIL_MDS_DQACQ_NET 0x187
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
+ # test the non-intent create path
+ mcreate $TDIR/$tfile &
+ cpid=$!
+ sleep $TIMEOUT
+ if ! ps -p $cpid > /dev/null 2>&1; then
+ error "mknod finished incorrectly"
+ fi
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+ wait $cpid || error "mcreate did not complete"
+ stat $TDIR/$tfile || error "mknod failed"
+
+ rm $TDIR/$tfile
+
+ #define OBD_FAIL_MDS_DQACQ_NET 0x187
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0x187"
+ # test the intent create path
+ openfile -f O_RDWR:O_CREAT $TDIR/$tfile &
+ cpid=$!
+ sleep $TIMEOUT
+ if ! ps -p $cpid > /dev/null 2>&1; then
+ error "open finished incorrectly"
+ fi
+ do_facet $SINGLEMDS "lctl set_param fail_loc=0"
+ wait $cpid || error "openfile failed"
+ stat $TDIR/$tfile || error "open failed"
+}
+run_test 8d "Verify redo creation on -EINPROGRESS"
+
+test_8e() {
+ [[ $(lustre_version_code $SINGLEMDS) -ge $(version_code 2.3.0) ]] ||
+ { skip "Need MDS version at least 2.3.0"; return; }
+ sleep 1 # ensure we have a fresh statfs
+ #define OBD_FAIL_OST_STATFS_EINPROGRESS 0x231
+ do_facet ost1 "lctl set_param fail_loc=0x231"
+ $LFS df $MOUNT &
+ dfpid=$!
+ sleep $TIMEOUT
+ if ! ps -p $dfpid > /dev/null 2>&1; then
+ do_facet ost1 "lctl set_param fail_loc=0"
+ error "df shouldn't have completed!"
+ fi
+}
+run_test 8e "Verify that ptlrpc resends request on -EINPROGRESS"
+
+test_9() {
+ [ $(lustre_version_code ost1) -ge $(version_code 2.6.54) ] ||
+ { skip "Need OST version at least 2.6.54"; return; }
+ $LFS setstripe -i 0 -c 1 $DIR/$tfile || error "setstripe failed"
+
+ # LU-1573 - Add duplicate write to generate grants
+ dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
+ error "First write failed"
+ replay_barrier ost1
+ # do IO
+ dd if=/dev/zero of=$DIR/$tfile count=1 bs=1M > /dev/null ||
+ error "failed to write"
+ # failover, replay and resend replayed waiting request
+ #define OBD_FAIL_TGT_REPLAY_DELAY2 0x714
+ do_facet ost1 $LCTL set_param fail_loc=0x00000714
+ do_facet ost1 $LCTL set_param fail_val=$TIMEOUT
+ fail ost1
+ do_facet ost1 $LCTL set_param fail_loc=0
+ do_facet ost1 "dmesg | tail -n 100" |
+ sed -n '/no req deadline/,$ p' | grep -q 'Already past' &&
+ return 1
+ return 0
+}
+run_test 9 "Verify that no req deadline happened during recovery"
+
+test_10() {
+ rm -f $TDIR/$tfile
+
+ dd if=/dev/zero of=$TDIR/$tfile count=10 || error "dd failed"
+
+ #define OBD_FAIL_OSC_DELAY_IO 0x414
+ $LCTL set_param fail_val=60 fail_loc=0x414
+ cancel_lru_locks OST0000-osc &
+ sleep 2
+ facet_failover ost1 || error "failover: $?"
+
+ #define OBD_FAIL_LDLM_GRANT_CHECK 0x32a
+ $LCTL set_param fail_loc=0x32a
+ stat $TDIR/$tfile
+
+ wait
+}
+run_test 10 "conflicting PW & PR locks on a client"
+
+test_12() {
+ [ $FAILURE_MODE != "HARD" ] &&
+ skip "Test needs FAILURE_MODE HARD" && return 0
+ remote_ost || { skip "need remote OST" && return 0; }
+
+ local tmp=$TMP/$tdir
+ local dir=$DIR/$tdir
+ declare -a pids
+
+
+ mkdir -p $tmp || error "can't create $tmp"
+ mkdir -p $dir || error "can't create $dir"
+
+ $LFS setstripe -c 1 -i 0 $dir
+
+ for i in `seq 1 10`; do mkdir $dir/d$i; done
+
+ #define OBD_FAIL_OST_DELAY_TRANS 0x245
+ do_facet ost1 "$LCTL set_param fail_loc=0x245" ||
+ error "can't set fail_loc"
+
+ for i in `seq 1 10`;
+ do
+ createmany -o $dir/d$i/$(openssl rand -base64 12) 500 &
+ pids+=($!)
+ done
+ echo "Waiting createmany pids"
+ wait ${pids[@]}
+
+ ls -lR $dir > $tmp/ls_r_out 2>&1&
+ local ls_pid=$!
+
+ facet_failover ost1
+
+ echo "starting wait for ls -l"
+ wait $ls_pid
+ grep "?\|No such file or directory" $tmp/ls_r_out &&
+ error "Found file without object on OST"
+ rm -rf $tmp
+ rm -rf $dir
+}
+run_test 12 "check stat after OST failover"
+
+complete $SECONDS