7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
19 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
23 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
25 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
26 CONFIG_EXCEPTIONS="0b 42 47 61a 61c"
27 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
28 echo "Except the tests: $CONFIG_EXCEPTIONS"
29 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
32 # 63 min 7 min AT AT AT AT"
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
37 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]*
44 test_0a() { # was test_0
48 run_test 0a "empty replay"
51 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
53 # this test attempts to trigger a race in the precreation code,
54 # and must run before any other objects are created on the filesystem
56 createmany -o $DIR/$tfile 20 || return 1
57 unlinkmany $DIR/$tfile 20 || return 2
59 run_test 0b "ensure object created after recover exists. (3284)"
65 zconf_mount `hostname` $DIR || error "mount fails"
66 df $DIR || error "post-failover df failed"
68 run_test 0c "expired recovery with no clients"
74 $CHECKSTAT -t file $DIR/$tfile || return 1
77 run_test 1 "simple create"
83 $CHECKSTAT -t file $DIR/$tfile || return 1
93 $CHECKSTAT -t file $DIR/$tfile || return 1
101 o_directory $DIR/$tfile
103 $CHECKSTAT -t file $DIR/$tfile || return 2
106 run_test 3a "replay failed open(O_DIRECTORY)"
110 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
111 do_facet mds "lctl set_param fail_loc=0x80000114"
113 do_facet mds "lctl set_param fail_loc=0"
115 $CHECKSTAT -t file $DIR/$tfile && return 2
118 run_test 3b "replay failed open -ENOMEM"
122 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
123 do_facet mds "lctl set_param fail_loc=0x80000128"
125 do_facet mds "lctl set_param fail_loc=0"
128 $CHECKSTAT -t file $DIR/$tfile && return 2
131 run_test 3c "replay failed open -ENOMEM"
133 test_4a() { # was test_4
135 for i in `seq 10`; do
136 echo "tag-$i" > $DIR/$tfile-$i
139 for i in `seq 10`; do
140 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
143 run_test 4a "|x| 10 open(O_CREAT)s"
149 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
151 run_test 4b "|x| rm 10 files"
153 # The idea is to get past the first block of precreated files on both
154 # osts, and then replay.
157 for i in `seq 220`; do
158 echo "tag-$i" > $DIR/$tfile-$i
161 for i in `seq 220`; do
162 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
166 # waiting for commitment of removal
168 run_test 5 "|x| 220 open(O_CREAT)"
171 test_6a() { # was test_6
174 mcreate $DIR/$tdir/$tfile
176 $CHECKSTAT -t dir $DIR/$tdir || return 1
177 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
179 # waiting for log process thread
181 run_test 6a "mkdir + contained create"
188 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
190 run_test 6b "|X| rmdir"
195 mcreate $DIR/$tdir/$tfile
197 $CHECKSTAT -t dir $DIR/$tdir || return 1
198 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
201 run_test 7 "mkdir |X| contained create"
205 multiop_bg_pause $DIR/$tfile mo_c || return 4
209 $CHECKSTAT -t file $DIR/$tfile || return 1
210 kill -USR1 $MULTIPID || return 2
211 wait $MULTIPID || return 3
214 run_test 8 "creat open |X| close"
219 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
221 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
223 echo " old_inum == $old_inum, new_inum == $new_inum"
224 if [ $old_inum -eq $new_inum ] ;
226 echo " old_inum and new_inum match"
228 echo "!!!! old_inum and new_inum NOT match"
233 run_test 9 "|X| create (same inum/gen)"
238 mv $DIR/$tfile $DIR/$tfile-2
241 $CHECKSTAT $DIR/$tfile && return 1
242 $CHECKSTAT $DIR/$tfile-2 ||return 2
246 run_test 10 "create |X| rename unlink"
250 echo "old" > $DIR/$tfile
251 mv $DIR/$tfile $DIR/$tfile-2
253 echo "new" > $DIR/$tfile
255 grep old $DIR/$tfile-2
257 grep new $DIR/$tfile || return 1
258 grep old $DIR/$tfile-2 || return 2
260 run_test 11 "create open write rename |X| create-old-name read"
264 multiop_bg_pause $DIR/$tfile o_tSc || return 3
269 wait $pid || return 1
272 [ -e $DIR/$tfile ] && return 2
275 run_test 12 "open, unlink |X| close"
278 # 1777 - replay open after committed chmod that would make
279 # a regular open a failure
282 multiop_bg_pause $DIR/$tfile O_wc || return 3
285 $CHECKSTAT -p 0 $DIR/$tfile
289 wait $pid || return 1
291 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
294 run_test 13 "open chmod 0 |x| write close"
297 multiop_bg_pause $DIR/$tfile O_tSc || return 4
301 kill -USR1 $pid || return 1
302 wait $pid || return 2
305 [ -e $DIR/$tfile ] && return 3
308 run_test 14 "open(O_CREAT), unlink |X| close"
311 multiop_bg_pause $DIR/$tfile O_tSc || return 5
315 touch $DIR/g11 || return 1
317 wait $pid || return 2
320 [ -e $DIR/$tfile ] && return 3
321 touch $DIR/h11 || return 4
324 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
330 mcreate $DIR/$tfile-2
332 [ -e $DIR/$tfile ] && return 1
333 [ -e $DIR/$tfile-2 ] || return 2
334 munlink $DIR/$tfile-2 || return 3
336 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
340 multiop_bg_pause $DIR/$tfile O_c || return 4
343 kill -USR1 $pid || return 1
344 wait $pid || return 2
345 $CHECKSTAT -t file $DIR/$tfile || return 3
348 run_test 17 "|X| open(O_CREAT), |replay| close"
352 multiop_bg_pause $DIR/$tfile O_tSc || return 8
355 touch $DIR/$tfile-2 || return 1
356 echo "pid: $pid will close"
358 wait $pid || return 2
361 [ -e $DIR/$tfile ] && return 3
362 [ -e $DIR/$tfile-2 ] || return 4
363 # this touch frequently fails
364 touch $DIR/$tfile-3 || return 5
365 munlink $DIR/$tfile-2 || return 6
366 munlink $DIR/$tfile-3 || return 7
369 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
371 # bug 1855 (a simpler form of test_11 above)
375 echo "old" > $DIR/$tfile
376 mv $DIR/$tfile $DIR/$tfile-2
377 grep old $DIR/$tfile-2
379 grep old $DIR/$tfile-2 || return 2
381 run_test 19 "|X| mcreate, open, write, rename "
383 test_20a() { # was test_20
385 multiop_bg_pause $DIR/$tfile O_tSc || return 3
391 wait $pid || return 1
392 [ -e $DIR/$tfile ] && return 2
395 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
397 test_20b() { # bug 10480
398 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
400 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
402 while [ ! -e $DIR/$tfile ] ; do
403 sleep 0.060s # give dd a chance to start
406 lfs getstripe $DIR/$tfile || return 1
407 rm -f $DIR/$tfile || return 2 # make it an orphan
409 df -P $DIR || df -P $DIR || true # reconnect
411 fail mds # start orphan recovery
412 df -P $DIR || df -P $DIR || true # reconnect
413 wait_mds_recovery_done || error "MDS recovery not done"
415 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
416 log "before $BEFOREUSED, after $AFTERUSED"
417 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
418 error "after $AFTERUSED > before $BEFOREUSED" && return 5
421 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
423 test_20c() { # bug 10480
424 multiop $DIR/$tfile Ow_c &
426 # give multiop a chance to open
433 df -P $DIR || df -P $DIR || true # reconnect
436 test -s $DIR/$tfile || error "File was truncated"
438 wait $pid || return 1
441 run_test 20c "check that client eviction does not affect file content"
445 multiop_bg_pause $DIR/$tfile O_tSc || return 5
448 touch $DIR/g11 || return 1
452 wait $pid || return 2
453 [ -e $DIR/$tfile ] && return 3
454 touch $DIR/h11 || return 4
457 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
460 multiop_bg_pause $DIR/$tfile O_tSc || return 3
468 wait $pid || return 1
469 [ -e $DIR/$tfile ] && return 2
472 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
475 multiop_bg_pause $DIR/$tfile O_tSc || return 5
480 touch $DIR/g11 || return 1
484 wait $pid || return 2
485 [ -e $DIR/$tfile ] && return 3
486 touch $DIR/h11 || return 4
489 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
492 multiop_bg_pause $DIR/$tfile O_tSc || return 3
499 wait $pid || return 1
500 [ -e $DIR/$tfile ] && return 2
503 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
506 multiop_bg_pause $DIR/$tfile O_tSc || return 3
513 wait $pid || return 1
514 [ -e $DIR/$tfile ] && return 2
517 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
521 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
523 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
528 wait $pid2 || return 1
532 wait $pid1 || return 2
533 [ -e $DIR/$tfile-1 ] && return 3
534 [ -e $DIR/$tfile-2 ] && return 4
537 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
541 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
543 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
550 wait $pid1 || return 1
552 wait $pid2 || return 2
553 [ -e $DIR/$tfile-1 ] && return 3
554 [ -e $DIR/$tfile-2 ] && return 4
557 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
560 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
562 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
568 wait $pid2 || return 1
572 wait $pid1 || return 2
573 [ -e $DIR/$tfile-1 ] && return 3
574 [ -e $DIR/$tfile-2 ] && return 4
577 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
580 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
582 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
590 wait $pid1 || return 1
592 wait $pid2 || return 2
593 [ -e $DIR/$tfile-1 ] && return 3
594 [ -e $DIR/$tfile-2 ] && return 4
597 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
600 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
602 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
610 wait $pid1 || return 1
612 wait $pid2 || return 2
613 [ -e $DIR/$tfile-1 ] && return 3
614 [ -e $DIR/$tfile-2 ] && return 4
617 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
620 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
622 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
630 wait $pid1 || return 1
632 wait $pid2 || return 2
633 [ -e $DIR/$tfile-1 ] && return 3
634 [ -e $DIR/$tfile-2 ] && return 4
637 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
639 # tests for bug 2104; completion without crashing is success. The close is
640 # stale, but we always return 0 for close, so the app never sees it.
642 multiop_bg_pause $DIR/$tfile O_c || return 2
644 multiop_bg_pause $DIR/$tfile O_c || return 3
647 df $MOUNT || sleep 1 && df $MOUNT || return 1
650 wait $pid1 || return 4
651 wait $pid2 || return 5
654 run_test 32 "close() notices client eviction; close() after client eviction"
656 # Abort recovery before client complete
657 test_33a() { # was test_33
659 createmany -o $DIR/$tfile-%d 100
661 # this file should be gone, because the replay was aborted
662 $CHECKSTAT -t file $DIR/$tfile-* && return 3
663 unlinkmany $DIR/$tfile-%d 0 100
666 run_test 33a "abort recovery before client does replay"
669 multiop_bg_pause $DIR/$tfile O_c || return 2
676 wait $pid || return 3
677 [ -e $DIR/$tfile ] && return 1
681 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
683 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
687 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
688 do_facet mds "lctl set_param fail_loc=0x80000119"
693 # give a chance to remove from MDS
695 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
697 run_test 35 "test recovery from llog for unlink op"
699 # b=2432 resent cancel after replay uses wrong cookie,
700 # so don't resend cancels
704 checkstat $DIR/$tfile
707 if dmesg | grep "unknown lock cookie"; then
708 echo "cancel after replay failed"
712 run_test 36 "don't resend cancel"
715 # directory orphans can't be unlinked from PENDING directory
717 rmdir $DIR/$tfile 2>/dev/null
718 multiop_bg_pause $DIR/$tfile dD_c || return 2
723 # clear the dmesg buffer so we only see errors from this recovery
727 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
728 wait $pid || return 3
732 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
735 createmany -o $DIR/$tfile-%d 800
736 unlinkmany $DIR/$tfile-%d 0 400
739 unlinkmany $DIR/$tfile-%d 400 400
741 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
743 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
745 test_39() { # bug 4176
746 createmany -o $DIR/$tfile-%d 800
748 unlinkmany $DIR/$tfile-%d 0 400
750 unlinkmany $DIR/$tfile-%d 400 400
753 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
755 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
758 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
763 $LCTL mark multiop $MOUNT/$tfile OS_c
764 multiop $MOUNT/$tfile OS_c &
766 writeme -s $MOUNT/${tfile}-2 &
770 #define OBD_FAIL_MDS_CONNECT_NET 0x117
771 do_facet mds "lctl set_param fail_loc=0x80000117"
773 stat1=`count_ost_writes`
775 stat2=`count_ost_writes`
776 echo "$stat1, $stat2"
777 if [ $stat1 -lt $stat2 ]; then
778 echo "writes continuing during recovery"
781 echo "writes not continuing during recovery, bug 2477"
784 echo "waiting for writeme $WRITE_PID"
788 echo "waiting for multiop $PID"
789 wait $PID || return 2
790 do_facet client munlink $MOUNT/$tfile || return 3
791 do_facet client munlink $MOUNT/${tfile}-2 || return 3
794 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
798 # make sure that a read to one osc doesn't try to double-unlock its page just
799 # because another osc is invalid. trigger_group_io used to mistakenly return
800 # an error if any oscs were invalid even after having successfully put rpcs
801 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
802 # the page, guarnateeing that the unlock from the RPC completion would
803 # assert on trying to unlock the unlocked page.
805 [ $OSTCOUNT -lt 2 ] && \
806 skip "skipping test 41: we don't have a second OST to test with" && \
809 local f=$MOUNT/$tfile
810 # make sure the start of the file is ost1
811 lfs setstripe $f -s $((128 * 1024)) -i 0
812 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
814 # fail ost2 and read from ost1
815 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | awk '{print $1}'`
816 [ "$osc2dev" ] || return 4
817 $LCTL --device $osc2dev deactivate || return 1
818 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
819 $LCTL --device $osc2dev activate || return 2
822 run_test 41 "read from a valid osc while other oscs are invalid"
824 # test MDS recovery after ost failure
826 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
827 createmany -o $DIR/$tfile-%d 800
829 unlinkmany $DIR/$tfile-%d 0 400
831 lctl set_param debug=-1
834 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
835 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
836 #[ $blocks_after -lt $blocks ] || return 1
837 echo wait for MDS to timeout and recover
838 sleep $((TIMEOUT * 2))
840 unlinkmany $DIR/$tfile-%d 400 400
841 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
843 run_test 42 "recovery after ost failure"
845 # timeout in MDS/OST recovery RPC will LBUG MDS
846 test_43() { # bug 2530
847 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
851 # OBD_FAIL_OST_CREATE_NET 0x204
852 do_facet ost1 "lctl set_param fail_loc=0x80000204"
855 do_facet ost1 "lctl set_param fail_loc=0"
859 run_test 43 "mds osc import failure during recovery; don't LBUG"
861 test_44a() { # was test_44
864 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
865 [ "$mdcdev" ] || exit 2
867 # adaptive timeouts slow this way down
868 if at_is_valid && at_is_enabled; then
869 at_max_saved=$(at_max_get mds)
873 for i in `seq 1 10`; do
874 echo "$i of 10 ($(date +%s))"
875 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
876 #define OBD_FAIL_TGT_CONN_RACE 0x701
877 do_facet mds "lctl set_param fail_loc=0x80000701"
878 $LCTL --device $mdcdev recover
882 do_facet mds "lctl set_param fail_loc=0"
883 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
886 run_test 44a "race in target handle connect"
889 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
890 [ "$mdcdev" ] || exit 2
891 for i in `seq 1 10`; do
892 echo "$i of 10 ($(date +%s))"
893 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
894 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
895 do_facet mds "lctl set_param fail_loc=0x80000704"
896 $LCTL --device $mdcdev recover
899 do_facet mds "lctl set_param fail_loc=0"
902 run_test 44b "race in target handle connect"
904 # Handle failed close
906 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
907 [ "$mdcdev" ] || exit 2
908 $LCTL --device $mdcdev recover
910 multiop_bg_pause $DIR/$tfile O_c || return 1
913 # This will cause the CLOSE to fail before even
914 # allocating a reply buffer
915 $LCTL --device $mdcdev deactivate || return 4
919 wait $pid || return 1
921 $LCTL --device $mdcdev activate || return 5
924 $CHECKSTAT -t file $DIR/$tfile || return 2
927 run_test 45 "Handle failed close"
931 drop_reply "touch $DIR/$tfile"
933 # ironically, the previous test, 45, will cause a real forced close,
934 # so just look for one for this test
935 dmesg | grep -i "force closing client file handle for $tfile" && return 1
938 run_test 46 "Don't leak file handle after open resend (3325)"
940 test_47() { # bug 2824
941 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
943 # create some files to make sure precreate has been done on all
944 # OSTs. (just in case this test is run independently)
945 createmany -o $DIR/$tfile 20 || return 1
947 # OBD_FAIL_OST_CREATE_NET 0x204
949 do_facet ost1 "lctl set_param fail_loc=0x80000204"
950 df $MOUNT || return 2
952 # let the MDS discover the OST failure, attempt to recover, fail
954 sleep $((3 * TIMEOUT))
956 # Without 2824, this createmany would hang
957 createmany -o $DIR/$tfile 20 || return 3
958 unlinkmany $DIR/$tfile 20 || return 4
960 do_facet ost1 "lctl set_param fail_loc=0"
963 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
966 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
967 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
970 createmany -o $DIR/$tfile 20 || return 1
971 # OBD_FAIL_OST_EROFS 0x216
973 do_facet ost1 "lctl set_param fail_loc=0x80000216"
974 df $MOUNT || return 2
976 createmany -o $DIR/$tfile 20 20 || return 2
977 unlinkmany $DIR/$tfile 40 || return 3
980 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
983 local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1`
984 [ "$oscdev" ] || return 1
985 do_facet mds $LCTL --device $oscdev recover || return 2
986 do_facet mds $LCTL --device $oscdev recover || return 3
987 # give the mds_lov_sync threads a chance to run
990 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
992 # b3764 timed out lock replay
997 multiop $DIR/$tfile s || return 1
999 #define OBD_FAIL_LDLM_REPLY 0x30c
1000 do_facet mds "lctl set_param fail_loc=0x8000030c"
1001 fail mds || return 2
1002 do_facet mds "lctl set_param fail_loc=0x0"
1004 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1006 run_test 52 "time out lock replay (3764)"
1008 # bug 3462 - simultaneous MDC requests
1010 mkdir -p $DIR/${tdir}-1
1011 mkdir -p $DIR/${tdir}-2
1012 multiop $DIR/${tdir}-1/f O_c &
1014 # give multiop a chance to open
1017 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1018 do_facet mds "lctl set_param fail_loc=0x80000115"
1019 kill -USR1 $close_pid
1020 cancel_lru_locks mdc # force the close
1021 do_facet mds "lctl set_param fail_loc=0"
1022 mcreate $DIR/${tdir}-2/f || return 1
1024 # close should still be here
1025 [ -d /proc/$close_pid ] || return 2
1026 replay_barrier_nodf mds
1028 wait $close_pid || return 3
1030 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1031 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1032 rm -rf $DIR/${tdir}-*
1034 run_test 53a "|X| close request while two MDC requests in flight"
1037 mkdir -p $DIR/$tdir-1
1038 mkdir -p $DIR/$tdir-2
1039 multiop $DIR/$tdir-1/f O_c &
1042 #define OBD_FAIL_MDS_REINT_NET 0x107
1043 do_facet mds "lctl set_param fail_loc=0x80000107"
1044 mcreate $DIR/${tdir}-2/f &
1048 do_facet mds "lctl set_param fail_loc=0"
1049 kill -USR1 $close_pid
1050 cancel_lru_locks mdc # force the close
1051 wait $close_pid || return 1
1052 # open should still be here
1053 [ -d /proc/$open_pid ] || return 2
1055 replay_barrier_nodf mds
1057 wait $open_pid || return 3
1059 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1060 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1061 rm -rf $DIR/${tdir}-*
1063 run_test 53b "|X| open request while two MDC requests in flight"
1066 mkdir -p $DIR/${tdir}-1
1067 mkdir -p $DIR/${tdir}-2
1068 multiop $DIR/${tdir}-1/f O_c &
1071 #define OBD_FAIL_MDS_REINT_NET 0x107
1072 do_facet mds "lctl set_param fail_loc=0x80000107"
1073 mcreate $DIR/${tdir}-2/f &
1077 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1078 do_facet mds "lctl set_param fail_loc=0x80000115"
1079 kill -USR1 $close_pid
1080 cancel_lru_locks mdc # force the close
1082 replay_barrier_nodf mds
1084 wait $open_pid || return 1
1086 # close should be gone
1087 [ -d /proc/$close_pid ] && return 2
1088 do_facet mds "lctl set_param fail_loc=0"
1090 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1091 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1092 rm -rf $DIR/${tdir}-*
1094 run_test 53c "|X| open request and close request while two MDC requests in flight"
1097 mkdir -p $DIR/${tdir}-1
1098 mkdir -p $DIR/${tdir}-2
1099 multiop $DIR/${tdir}-1/f O_c &
1101 # give multiop a chance to open
1104 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1105 do_facet mds "lctl set_param fail_loc=0x8000013b"
1106 kill -USR1 $close_pid
1107 cancel_lru_locks mdc # force the close
1108 do_facet mds "lctl set_param fail_loc=0"
1109 mcreate $DIR/${tdir}-2/f || return 1
1111 # close should still be here
1112 [ -d /proc/$close_pid ] || return 2
1113 replay_barrier_nodf mds
1115 wait $close_pid || return 3
1117 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1118 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1119 rm -rf $DIR/${tdir}-*
1121 run_test 53d "|X| close reply while two MDC requests in flight"
1124 mkdir -p $DIR/$tdir-1
1125 mkdir -p $DIR/$tdir-2
1126 multiop $DIR/$tdir-1/f O_c &
1129 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1130 do_facet mds "lctl set_param fail_loc=0x80000119"
1131 mcreate $DIR/${tdir}-2/f &
1135 do_facet mds "lctl set_param fail_loc=0"
1136 kill -USR1 $close_pid
1137 cancel_lru_locks mdc # force the close
1138 wait $close_pid || return 1
1139 # open should still be here
1140 [ -d /proc/$open_pid ] || return 2
1142 replay_barrier_nodf mds
1144 wait $open_pid || return 3
1146 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1147 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1148 rm -rf $DIR/${tdir}-*
1150 run_test 53e "|X| open reply while two MDC requests in flight"
1153 mkdir -p $DIR/${tdir}-1
1154 mkdir -p $DIR/${tdir}-2
1155 multiop $DIR/${tdir}-1/f O_c &
1158 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1159 do_facet mds "lctl set_param fail_loc=0x80000119"
1160 mcreate $DIR/${tdir}-2/f &
1164 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1165 do_facet mds "lctl set_param fail_loc=0x8000013b"
1166 kill -USR1 $close_pid
1167 cancel_lru_locks mdc
1169 replay_barrier_nodf mds
1171 wait $open_pid || return 1
1173 #close should be gone
1174 [ -d /proc/$close_pid ] && return 2
1175 do_facet mds "lctl set_param fail_loc=0"
1177 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1178 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1179 rm -rf $DIR/${tdir}-*
1181 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1184 mkdir -p $DIR/${tdir}-1
1185 mkdir -p $DIR/${tdir}-2
1186 multiop $DIR/${tdir}-1/f O_c &
1189 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1190 do_facet mds "lctl set_param fail_loc=0x80000119"
1191 mcreate $DIR/${tdir}-2/f &
1195 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1196 do_facet mds "lctl set_param fail_loc=0x80000115"
1197 kill -USR1 $close_pid
1198 cancel_lru_locks mdc # force the close
1200 do_facet mds "lctl set_param fail_loc=0"
1201 replay_barrier_nodf mds
1203 wait $open_pid || return 1
1205 # close should be gone
1206 [ -d /proc/$close_pid ] && return 2
1208 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1209 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1210 rm -rf $DIR/${tdir}-*
1212 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1215 mkdir -p $DIR/${tdir}-1
1216 mkdir -p $DIR/${tdir}-2
1217 multiop $DIR/${tdir}-1/f O_c &
1220 #define OBD_FAIL_MDS_REINT_NET 0x107
1221 do_facet mds "lctl set_param fail_loc=0x80000107"
1222 mcreate $DIR/${tdir}-2/f &
1226 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1227 do_facet mds "lctl set_param fail_loc=0x8000013b"
1228 kill -USR1 $close_pid
1229 cancel_lru_locks mdc # force the close
1232 replay_barrier_nodf mds
1234 wait $open_pid || return 1
1236 # close should be gone
1237 [ -d /proc/$close_pid ] && return 2
1238 do_facet mds "lctl set_param fail_loc=0"
1240 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1241 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1242 rm -rf $DIR/${tdir}-*
1244 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1246 #b3761 ASSERTION(hash != 0) failed
1248 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1249 do_facet mds "lctl set_param fail_loc=0x8000012b"
1251 # give touch a chance to run
1253 do_facet mds "lctl set_param fail_loc=0x0"
1257 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1259 #b3440 ASSERTION(rec->ur_fid2->id) failed
1261 ln -s foo $DIR/$tfile
1263 #drop_reply "cat $DIR/$tfile"
1267 run_test 56 "don't replay a symlink open request (3440)"
1269 #recovery one mds-ost setattr from llog
1271 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1272 do_facet mds "lctl set_param fail_loc=0x8000012c"
1277 $CHECKSTAT -t file $DIR/$tfile || return 1
1278 do_facet mds "lctl set_param fail_loc=0x0"
1281 run_test 57 "test recovery from llog for setattr op"
1283 #recovery many mds-ost setattr from llog
1286 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1287 do_facet mds "lctl set_param fail_loc=0x8000012c"
1288 createmany -o $DIR/$tdir/$tfile-%d 2500
1292 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1293 do_facet mds "lctl set_param fail_loc=0x0"
1294 unlinkmany $DIR/$tdir/$tfile-%d 2500
1297 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1300 mount_client $MOUNT2
1302 touch $DIR/$tdir/$tfile
1304 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1306 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1307 [ x$VAL = x"bar" ] || return 1
1308 rm -f $DIR/$tdir/$tfile
1310 zconf_umount `hostname` $MOUNT2
1312 run_test 58b "test replay of setxattr op"
1314 test_58c() { # bug 16570
1315 mount_client $MOUNT2
1317 touch $DIR/$tdir/$tfile
1318 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1320 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1321 [ x$VAL = x"bar" ] || return 2
1322 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1324 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1325 [ x$VAL = x"bar1" ] || return 4
1326 rm -f $DIR/$tdir/$tfile
1328 zconf_umount `hostname` $MOUNT2
1330 run_test 58c "resend/reconstruct setxattr op"
1332 # log_commit_thread vs filter_destroy race used to lead to import use after free
1335 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1338 createmany -o $DIR/$tdir/$tfile-%d 200
1340 unlinkmany $DIR/$tdir/$tfile-%d 200
1341 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1342 do_facet ost1 "lctl set_param fail_loc=0x507"
1345 do_facet ost1 "lctl set_param fail_loc=0x0"
1349 run_test 59 "test log_commit_thread vs filter_destroy race"
1351 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1352 # bug 12086: should no oops and No ctxt error for this test
1355 createmany -o $DIR/$tdir/$tfile-%d 200
1357 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1359 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1360 local no_ctxt=`dmesg | grep "No ctxt"`
1361 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1363 run_test 60 "test llog post recovery init vs llog unlink"
1365 #test race llog recovery thread vs llog cleanup
1367 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1370 createmany -o $DIR/$tdir/$tfile-%d 800
1372 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1373 unlinkmany $DIR/$tdir/$tfile-%d 800
1374 do_facet ost "lctl set_param fail_loc=0x80000221"
1379 do_facet ost "lctl set_param fail_loc=0x0"
1380 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1383 run_test 61a "test race llog recovery vs llog cleanup"
1385 #test race mds llog sync vs llog cleanup
1387 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1388 do_facet mds "lctl set_param fail_loc=0x8000013a"
1392 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1394 run_test 61b "test race mds llog sync vs llog cleanup"
1396 #test race cancel cookie cb vs llog cleanup
1398 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1400 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1402 do_facet ost "lctl set_param fail_loc=0x80000222"
1407 run_test 61c "test race mds llog sync vs llog cleanup"
1409 test_61d() { # bug 16002
1410 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1412 do_facet mds "lctl set_param fail_loc=0x80000605"
1413 start mds $MDSDEV $MDS_MOUNT_OPTS && error "mds start should have failed"
1414 do_facet mds "lctl set_param fail_loc=0"
1415 start mds $MDSDEV $MDS_MOUNT_OPTS || error "cannot restart mds"
1417 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1419 test_62() { # Bug 15756 - don't mis-drop resent replay
1422 createmany -o $DIR/$tdir/$tfile- 25
1423 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1424 do_facet mds "lctl set_param fail_loc=0x80000707"
1426 df $MOUNT || return 1
1427 do_facet mds "lctl set_param fail_loc=0"
1428 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1431 run_test 62 "don't mis-drop resent replay"
1433 #Adaptive Timeouts (bug 3055)
1435 # Suppose that all osts have the same at_max
1436 for facet in mds client ost; do
1437 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1442 local at_max_new=600
1443 if ! at_is_valid; then
1444 skip "AT env is invalid"
1450 for facet in mds client ost; do
1451 at_max=$(at_max_get $facet)
1452 if [ $at_max -ne $at_max_new ]; then
1453 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1454 at_max_set $at_max_new $facet
1459 if [ -z "$ATOLDBASE" ]; then
1460 local at_history=$(do_facet mds "find /sys/ -name at_history")
1461 [ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
1462 ATOLDBASE=$(do_facet mds "cat $at_history")
1463 # speed up the timebase so we can check decreasing AT
1464 do_facet mds "echo 8 >> $at_history"
1465 do_facet ost1 "echo 8 >> $at_history"
1467 # sleep for a while to cool down, should be > 8s and also allow
1468 # at least one ping to be sent. simply use TIMEOUT to be safe.
1473 test_65a() #bug 3055
1475 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1477 at_start || return 0
1478 $LCTL dk > /dev/null
1480 lctl set_param debug="+other"
1481 # Slow down a request to the current service time, this is critical
1482 # because previous tests may have caused this value to increase.
1483 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1484 awk '/portal 12/ {print $5}'`
1485 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1487 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1488 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1489 do_facet mds lctl set_param fail_loc=0x8000050a
1490 createmany -o $DIR/$tfile 10 > /dev/null
1491 unlinkmany $DIR/$tfile 10 > /dev/null
1492 # check for log message
1493 $LCTL dk | grep "Early reply #" || error "No early reply"
1494 # client should show REQ_DELAY estimates
1495 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1497 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1499 run_test 65a "AT: verify early replies"
1501 test_65b() #bug 3055
1503 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1505 at_start || return 0
1508 lctl set_param debug="+other"
1509 $LCTL dk > /dev/null
1510 # Slow down a request to the current service time, this is critical
1511 # because previous tests may have caused this value to increase.
1512 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1513 awk '/portal 6/ {print $5}'`
1514 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1516 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1517 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1518 do_facet ost1 lctl set_param fail_loc=0x224
1521 lfs setstripe $DIR/$tfile --index=0 --count=1
1522 # force some real bulk transfer
1523 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1525 do_facet ost1 lctl set_param fail_loc=0
1526 # check for log message
1527 $LCTL dk | grep "Early reply #" || error "No early reply"
1529 # client should show REQ_DELAY estimates
1530 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1532 run_test 65b "AT: verify early replies on packed reply / bulk"
1534 test_66a() #bug 3055
1536 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1538 at_start || return 0
1539 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1540 # adjust 5s at a time so no early reply is sent (within deadline)
1541 do_facet mds "lctl set_param fail_val=5000"
1542 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1543 do_facet mds "lctl set_param fail_loc=0x8000050a"
1544 createmany -o $DIR/$tfile 20 > /dev/null
1545 unlinkmany $DIR/$tfile 20 > /dev/null
1546 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1547 do_facet mds "lctl set_param fail_val=10000"
1548 do_facet mds "lctl set_param fail_loc=0x8000050a"
1549 createmany -o $DIR/$tfile 20 > /dev/null
1550 unlinkmany $DIR/$tfile 20 > /dev/null
1551 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1552 do_facet mds "lctl set_param fail_loc=0"
1554 createmany -o $DIR/$tfile 20 > /dev/null
1555 unlinkmany $DIR/$tfile 20 > /dev/null
1556 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal | grep "portal 12"
1557 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1558 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1559 echo "Current MDT timeout $CUR, worst $WORST"
1560 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1562 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1564 test_66b() #bug 3055
1566 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1568 at_start || return 0
1569 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1570 lctl set_param fail_val=$(($ORIG + 5))
1571 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1572 lctl set_param fail_loc=0x50c
1573 ls $DIR/$tfile > /dev/null 2>&1
1574 lctl set_param fail_loc=0
1575 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1576 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1577 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1578 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1580 run_test 66b "AT: verify net latency adjusts"
1582 test_67a() #bug 3055
1584 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1586 at_start || return 0
1587 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1588 # sleeping threads may drive values above this
1589 do_facet ost1 "lctl set_param fail_val=400"
1590 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1591 do_facet ost1 "lctl set_param fail_loc=0x50a"
1592 createmany -o $DIR/$tfile 20 > /dev/null
1593 unlinkmany $DIR/$tfile 20 > /dev/null
1594 do_facet ost1 "lctl set_param fail_loc=0"
1595 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1596 ATTEMPTS=$(($CONN2 - $CONN1))
1597 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1598 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1601 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1603 test_67b() #bug 3055
1605 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1607 at_start || return 0
1608 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1609 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1610 do_facet ost1 "lctl set_param fail_val=20000"
1611 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1612 cp /etc/profile $DIR/$tfile || error "cp failed"
1614 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1616 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1617 ATTEMPTS=$(($CONN2 - $CONN1))
1618 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1619 # do it again; should not timeout
1620 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1621 cp /etc/profile $DIR/$tfile || error "cp failed"
1622 do_facet ost1 "lctl set_param fail_loc=0"
1624 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1625 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1626 ATTEMPTS=$(($CONN3 - $CONN2))
1627 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1628 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1631 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1633 test_68 () #bug 13813
1635 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1637 at_start || return 0
1638 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1639 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1640 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1641 echo $TIMEOUT >> $ldlm_enqueue_min
1642 rm -f $DIR/${tfile}_[1-2]
1643 lfs setstripe $DIR/$tfile --index=0 --count=1
1644 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1645 lctl set_param fail_val=$(($TIMEOUT - 1))
1646 lctl set_param fail_loc=0x80000312
1647 cp /etc/profile $DIR/${tfile}_1 || error "1st cp failed $?"
1648 lctl set_param fail_val=$((TIMEOUT * 3 / 2))
1649 lctl set_param fail_loc=0x80000312
1650 cp /etc/profile $DIR/${tfile}_2 || error "2nd cp failed $?"
1651 lctl set_param fail_loc=0
1652 echo $ENQ_MIN >> $ldlm_enqueue_min
1655 run_test 68 "AT: verify slowing locks"
1657 if [ -n "$ATOLDBASE" ]; then
1658 at_history=$(do_facet mds "find /sys/ -name at_history")
1659 do_facet mds "echo $ATOLDBASE >> $at_history" || true
1660 do_facet ost1 "echo $ATOLDBASE >> $at_history" || true
1663 if [ $AT_MAX_SET -ne 0 ]; then
1664 for facet in mds client ost; do
1665 var=AT_MAX_SAVE_${facet}
1666 echo restore AT on $facet to saved value ${!var}
1667 at_max_set ${!var} $facet
1668 AT_NEW=$(at_max_get $facet)
1669 echo Restored AT value on $facet $AT_NEW
1670 [ $AT_NEW -ne ${!var} ] && \
1671 error "$facet : AT value was not restored SAVED ${!var} NEW $AT_NEW"
1675 # end of AT tests includes above lines
1677 # start multi-client tests
1679 [ -z "$CLIENTS" ] && \
1680 { skip "Need two or more clients." && return; }
1681 [ $CLIENTCOUNT -lt 2 ] && \
1682 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1684 echo "mount clients $CLIENTS ..."
1685 zconf_mount_clients $CLIENTS $DIR
1687 local clients=${CLIENTS//,/ }
1688 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1689 for CLIENT in $clients; do
1690 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1691 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1692 error "dd failed on $CLIENT"
1695 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1696 for C in ${CLIENTS//,/ }; do
1697 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1698 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1704 run_test 70a "check multi client t-f"
1707 [ -z "$CLIENTS" ] && \
1708 { skip "Need two or more clients." && return; }
1709 [ $CLIENTCOUNT -lt 2 ] && \
1710 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1712 zconf_mount_clients $CLIENTS $DIR
1715 [ "$SLOW" = "no" ] && duration=60
1716 local cmd="rundbench 1 -t $duration"
1718 do_nodes $CLIENTS "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1719 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1720 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1723 log "Started rundbench load PID=$PID ..."
1725 sleep $((duration / 4))
1727 sleep 3 # give clients a time to do operations
1729 log "$TESTNAME fail mds 1"
1732 wait $PID || error "rundbench load on $CLIENTS failed!"
1735 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1736 # end multi-client tests
1738 # vbr export handling
1740 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1742 UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
1743 echo "Client UUID is $UUID"
1747 zconf_mount `hostname` $DIR || error "mount fails"
1748 df $DIR || error "post-failover df failed"
1749 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
1750 error "no delayed exports"
1751 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1753 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1754 sleep $((NEW_AGE + 2))
1755 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
1756 error "exports didn't expire"
1757 do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
1758 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
1759 error "Export wasn't removed manually"
1760 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1763 run_test 71a "lost client export is kept"
1766 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1769 create_fake_exports mds $FAKE_NUM
1770 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1771 [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
1772 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1774 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1775 sleep $((NEW_AGE + 2))
1776 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1777 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1778 do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
1779 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
1780 error "Exports weren't flushed"
1781 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1784 run_test 71b "stale exports are expired, lctl flushes them"
1787 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1790 create_fake_exports mds $FAKE_NUM
1791 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1792 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1793 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1795 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1796 sleep $((NEW_AGE + 2))
1797 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1798 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1801 zconf_mount `hostname` $DIR || error "mount fails"
1803 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1804 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1805 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1808 run_test 71c "stale exports are expired, new client connection flush them"
1811 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1814 create_fake_exports mds $FAKE_NUM
1815 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1816 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1817 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1819 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
1820 sleep $((NEW_AGE + 2))
1821 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1822 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1826 FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1827 [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
1828 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1829 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1830 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
1833 run_test 71d "expired exports, server init removes them, conf_param works"
1835 # end vbr exports tests
1837 test_72() { #bug 16711
1839 multiop_bg_pause $DIR/$tfile O_c || return 4
1841 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709
1842 do_facet mds "lctl set_param fail_loc=0x80000709"
1844 kill -USR1 $pid || return 1
1845 wait $pid || return 2
1846 $CHECKSTAT -t file $DIR/$tfile || return 3
1848 run_test 72 "target_finish_recovery vs process_recovery_queue race"
1851 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1856 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1857 do_facet mds "lctl set_param fail_loc=0x80000302"
1860 wait $pid || return 1
1861 [ -e $DIR/$tfile ] && return 2
1864 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1867 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1872 #define OBD_FAIL_LDLM_REPLY 0x30c
1873 do_facet mds "lctl set_param fail_loc=0x8000030c"
1876 wait $pid || return 1
1877 [ -e $DIR/$tfile ] && return 2
1880 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1883 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1888 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1889 do_facet mds "lctl set_param fail_loc=0x80000710"
1892 wait $pid || return 1
1893 [ -e $DIR/$tfile ] && return 2
1896 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1899 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1902 lfs setstripe -i 0 -c 1 $DIR/$tfile
1903 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1904 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
1905 cancel_lru_locks osc
1907 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
1908 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
1909 if [ $cksum != $cksum2 ] ; then
1910 error "New checksum $cksum2 does not match original $cksum"
1913 run_test 80a "write replay"
1916 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1919 lfs setstripe -i 0 -c 1 $DIR/$tfile
1920 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1921 sleep 1 # Give it a chance to flush dirty data
1922 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
1923 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
1924 cancel_lru_locks osc
1926 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
1927 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
1928 if [ $cksum != $cksum2 ] ; then
1929 error "New checksum $cksum2 does not match original $cksum"
1932 run_test 80b "write replay with changed data (checksum resend)"
1934 equals_msg `basename $0`: test complete, cleaning up
1935 check_and_cleanup_lustre
1936 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true