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 clients_up || 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
99 local file=$DIR/$tfile
102 openfile -f O_DIRECTORY $file
104 $CHECKSTAT -t file $file || return 2
107 run_test 3a "replay failed open(O_DIRECTORY)"
111 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
112 do_facet mds "lctl set_param fail_loc=0x80000114"
114 do_facet mds "lctl set_param fail_loc=0"
116 $CHECKSTAT -t file $DIR/$tfile && return 2
119 run_test 3b "replay failed open -ENOMEM"
123 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
124 do_facet mds "lctl set_param fail_loc=0x80000128"
126 do_facet mds "lctl set_param fail_loc=0"
129 $CHECKSTAT -t file $DIR/$tfile && return 2
132 run_test 3c "replay failed open -ENOMEM"
134 test_4a() { # was test_4
136 for i in `seq 10`; do
137 echo "tag-$i" > $DIR/$tfile-$i
140 for i in `seq 10`; do
141 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
144 run_test 4a "|x| 10 open(O_CREAT)s"
150 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
152 run_test 4b "|x| rm 10 files"
154 # The idea is to get past the first block of precreated files on both
155 # osts, and then replay.
158 for i in `seq 220`; do
159 echo "tag-$i" > $DIR/$tfile-$i
162 for i in `seq 220`; do
163 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
167 # waiting for commitment of removal
169 run_test 5 "|x| 220 open(O_CREAT)"
172 test_6a() { # was test_6
175 mcreate $DIR/$tdir/$tfile
177 $CHECKSTAT -t dir $DIR/$tdir || return 1
178 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
180 # waiting for log process thread
182 run_test 6a "mkdir + contained create"
189 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
191 run_test 6b "|X| rmdir"
196 mcreate $DIR/$tdir/$tfile
198 $CHECKSTAT -t dir $DIR/$tdir || return 1
199 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
202 run_test 7 "mkdir |X| contained create"
206 multiop_bg_pause $DIR/$tfile mo_c || return 4
210 $CHECKSTAT -t file $DIR/$tfile || return 1
211 kill -USR1 $MULTIPID || return 2
212 wait $MULTIPID || return 3
215 run_test 8 "creat open |X| close"
220 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
222 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
224 echo " old_inum == $old_inum, new_inum == $new_inum"
225 if [ $old_inum -eq $new_inum ] ;
227 echo " old_inum and new_inum match"
229 echo "!!!! old_inum and new_inum NOT match"
234 run_test 9 "|X| create (same inum/gen)"
239 mv $DIR/$tfile $DIR/$tfile-2
242 $CHECKSTAT $DIR/$tfile && return 1
243 $CHECKSTAT $DIR/$tfile-2 ||return 2
247 run_test 10 "create |X| rename unlink"
251 echo "old" > $DIR/$tfile
252 mv $DIR/$tfile $DIR/$tfile-2
254 echo "new" > $DIR/$tfile
256 grep old $DIR/$tfile-2
258 grep new $DIR/$tfile || return 1
259 grep old $DIR/$tfile-2 || return 2
261 run_test 11 "create open write rename |X| create-old-name read"
265 multiop_bg_pause $DIR/$tfile o_tSc || return 3
270 wait $pid || return 1
273 [ -e $DIR/$tfile ] && return 2
276 run_test 12 "open, unlink |X| close"
279 # 1777 - replay open after committed chmod that would make
280 # a regular open a failure
283 multiop_bg_pause $DIR/$tfile O_wc || return 3
286 $CHECKSTAT -p 0 $DIR/$tfile
290 wait $pid || return 1
292 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
293 rm $DIR/$tfile || return 4
296 run_test 13 "open chmod 0 |x| write close"
299 multiop_bg_pause $DIR/$tfile O_tSc || return 4
303 kill -USR1 $pid || return 1
304 wait $pid || return 2
307 [ -e $DIR/$tfile ] && return 3
310 run_test 14 "open(O_CREAT), unlink |X| close"
313 multiop_bg_pause $DIR/$tfile O_tSc || return 5
317 touch $DIR/g11 || return 1
319 wait $pid || return 2
322 [ -e $DIR/$tfile ] && return 3
323 touch $DIR/h11 || return 4
326 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
332 mcreate $DIR/$tfile-2
334 [ -e $DIR/$tfile ] && return 1
335 [ -e $DIR/$tfile-2 ] || return 2
336 munlink $DIR/$tfile-2 || return 3
338 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
342 multiop_bg_pause $DIR/$tfile O_c || return 4
345 kill -USR1 $pid || return 1
346 wait $pid || return 2
347 $CHECKSTAT -t file $DIR/$tfile || return 3
350 run_test 17 "|X| open(O_CREAT), |replay| close"
354 multiop_bg_pause $DIR/$tfile O_tSc || return 8
357 touch $DIR/$tfile-2 || return 1
358 echo "pid: $pid will close"
360 wait $pid || return 2
363 [ -e $DIR/$tfile ] && return 3
364 [ -e $DIR/$tfile-2 ] || return 4
365 # this touch frequently fails
366 touch $DIR/$tfile-3 || return 5
367 munlink $DIR/$tfile-2 || return 6
368 munlink $DIR/$tfile-3 || return 7
371 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
373 # bug 1855 (a simpler form of test_11 above)
377 echo "old" > $DIR/$tfile
378 mv $DIR/$tfile $DIR/$tfile-2
379 grep old $DIR/$tfile-2
381 grep old $DIR/$tfile-2 || return 2
383 run_test 19 "|X| mcreate, open, write, rename "
385 test_20a() { # was test_20
387 multiop_bg_pause $DIR/$tfile O_tSc || return 3
393 wait $pid || return 1
394 [ -e $DIR/$tfile ] && return 2
397 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
399 test_20b() { # bug 10480
400 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
402 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
404 while [ ! -e $DIR/$tfile ] ; do
405 sleep 0.060s # give dd a chance to start
408 lfs getstripe $DIR/$tfile || return 1
409 rm -f $DIR/$tfile || return 2 # make it an orphan
411 client_up || client_up || true # reconnect
413 fail mds # start orphan recovery
414 wait_recovery_complete mds || error "MDS recovery not done"
416 # For interop with 2.0 only:
417 # FIXME just because recovery is done doesn't mean we've finished
418 # orphan cleanup. Fake it with a sleep for now...
421 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
422 log "before $BEFOREUSED, after $AFTERUSED"
423 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
424 error "after $AFTERUSED > before $BEFOREUSED" && return 5
427 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
429 test_20c() { # bug 10480
430 multiop $DIR/$tfile Ow_c &
432 # give multiop a chance to open
438 client_up || client_up || true # reconnect
441 wait $pid || return 1
442 [ -s $DIR/$tfile ] || error "File was truncated"
446 run_test 20c "check that client eviction does not affect file content"
450 multiop_bg_pause $DIR/$tfile O_tSc || return 5
453 touch $DIR/g11 || return 1
457 wait $pid || return 2
458 [ -e $DIR/$tfile ] && return 3
459 touch $DIR/h11 || return 4
462 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
465 multiop_bg_pause $DIR/$tfile O_tSc || return 3
473 wait $pid || return 1
474 [ -e $DIR/$tfile ] && return 2
477 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
480 multiop_bg_pause $DIR/$tfile O_tSc || return 5
485 touch $DIR/g11 || return 1
489 wait $pid || return 2
490 [ -e $DIR/$tfile ] && return 3
491 touch $DIR/h11 || return 4
494 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
497 multiop_bg_pause $DIR/$tfile O_tSc || return 3
504 wait $pid || return 1
505 [ -e $DIR/$tfile ] && return 2
508 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
511 multiop_bg_pause $DIR/$tfile O_tSc || return 3
518 wait $pid || return 1
519 [ -e $DIR/$tfile ] && return 2
522 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
526 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
528 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
533 wait $pid2 || return 1
537 wait $pid1 || return 2
538 [ -e $DIR/$tfile-1 ] && return 3
539 [ -e $DIR/$tfile-2 ] && return 4
542 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
546 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
548 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
555 wait $pid1 || return 1
557 wait $pid2 || return 2
558 [ -e $DIR/$tfile-1 ] && return 3
559 [ -e $DIR/$tfile-2 ] && return 4
562 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
565 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
567 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
573 wait $pid2 || return 1
577 wait $pid1 || return 2
578 [ -e $DIR/$tfile-1 ] && return 3
579 [ -e $DIR/$tfile-2 ] && return 4
582 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
585 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
587 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
595 wait $pid1 || return 1
597 wait $pid2 || return 2
598 [ -e $DIR/$tfile-1 ] && return 3
599 [ -e $DIR/$tfile-2 ] && return 4
602 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
605 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
607 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
615 wait $pid1 || return 1
617 wait $pid2 || return 2
618 [ -e $DIR/$tfile-1 ] && return 3
619 [ -e $DIR/$tfile-2 ] && return 4
622 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
625 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
627 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
635 wait $pid1 || return 1
637 wait $pid2 || return 2
638 [ -e $DIR/$tfile-1 ] && return 3
639 [ -e $DIR/$tfile-2 ] && return 4
642 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
644 # tests for bug 2104; completion without crashing is success. The close is
645 # stale, but we always return 0 for close, so the app never sees it.
647 multiop_bg_pause $DIR/$tfile O_c || return 2
649 multiop_bg_pause $DIR/$tfile O_c || return 3
652 client_up || client_up || return 1
655 wait $pid1 || return 4
656 wait $pid2 || return 5
659 run_test 32 "close() notices client eviction; close() after client eviction"
661 # Abort recovery before client complete
662 test_33a() { # was test_33
664 createmany -o $DIR/$tfile-%d 100
666 # this file should be gone, because the replay was aborted
667 $CHECKSTAT -t file $DIR/$tfile-* && return 3
668 unlinkmany $DIR/$tfile-%d 0 100
671 run_test 33a "abort recovery before client does replay"
674 multiop_bg_pause $DIR/$tfile O_c || return 2
681 wait $pid || return 3
682 [ -e $DIR/$tfile ] && return 1
686 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
688 # bug 2278 - generate one orphan on OST, then destroy it during llog recovery
692 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
693 do_facet mds "lctl set_param fail_loc=0x80000119"
698 # give a chance to remove from MDS
700 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
702 run_test 35 "test recovery from llog for unlink op"
704 # b=2432 resent cancel after replay uses wrong cookie,
705 # so don't resend cancels
709 checkstat $DIR/$tfile
712 if dmesg | grep "unknown lock cookie"; then
713 echo "cancel after replay failed"
717 run_test 36 "don't resend cancel"
720 # directory orphans can't be unlinked from PENDING directory
722 rmdir $DIR/$tfile 2>/dev/null
723 multiop_bg_pause $DIR/$tfile dD_c || return 2
728 # clear the dmesg buffer so we only see errors from this recovery
732 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
733 wait $pid || return 3
737 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
740 createmany -o $DIR/$tfile-%d 800
741 unlinkmany $DIR/$tfile-%d 0 400
744 unlinkmany $DIR/$tfile-%d 400 400
746 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
748 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
750 test_39() { # bug 4176
751 createmany -o $DIR/$tfile-%d 800
753 unlinkmany $DIR/$tfile-%d 0 400
755 unlinkmany $DIR/$tfile-%d 400 400
758 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
760 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
763 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
768 $LCTL mark multiop $MOUNT/$tfile OS_c
769 multiop $MOUNT/$tfile OS_c &
771 writeme -s $MOUNT/${tfile}-2 &
775 #define OBD_FAIL_MDS_CONNECT_NET 0x117
776 do_facet mds "lctl set_param fail_loc=0x80000117"
778 stat1=`count_ost_writes`
780 stat2=`count_ost_writes`
781 echo "$stat1, $stat2"
782 if [ $stat1 -lt $stat2 ]; then
783 echo "writes continuing during recovery"
786 echo "writes not continuing during recovery, bug 2477"
789 echo "waiting for writeme $WRITE_PID"
793 echo "waiting for multiop $PID"
794 wait $PID || return 2
795 do_facet client munlink $MOUNT/$tfile || return 3
796 do_facet client munlink $MOUNT/${tfile}-2 || return 3
799 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
802 # make sure that a read to one osc doesn't try to double-unlock its page just
803 # because another osc is invalid. trigger_group_io used to mistakenly return
804 # an error if any oscs were invalid even after having successfully put rpcs
805 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
806 # the page, guarnateeing that the unlock from the RPC completion would
807 # assert on trying to unlock the unlocked page.
809 [ $OSTCOUNT -lt 2 ] && \
810 skip_env "skipping test 41: we don't have a second OST to test with" && \
813 local f=$MOUNT/$tfile
814 # make sure the start of the file is ost1
815 lfs setstripe $f -s $((128 * 1024)) -i 0
816 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
818 # fail ost2 and read from ost1
819 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | awk '{print $1}'`
820 [ "$osc2dev" ] || return 4
821 $LCTL --device $osc2dev deactivate || return 1
822 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
823 $LCTL --device $osc2dev activate || return 2
826 run_test 41 "read from a valid osc while other oscs are invalid"
828 # test MDS recovery after ost failure
830 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
831 createmany -o $DIR/$tfile-%d 800
833 unlinkmany $DIR/$tfile-%d 0 400
835 lctl set_param debug=-1
838 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
839 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
840 #[ $blocks_after -lt $blocks ] || return 1
841 echo wait for MDS to timeout and recover
842 sleep $((TIMEOUT * 2))
844 unlinkmany $DIR/$tfile-%d 400 400
845 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
847 run_test 42 "recovery after ost failure"
849 # timeout in MDS/OST recovery RPC will LBUG MDS
850 test_43() { # bug 2530
851 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
855 # OBD_FAIL_OST_CREATE_NET 0x204
856 do_facet ost1 "lctl set_param fail_loc=0x80000204"
859 do_facet ost1 "lctl set_param fail_loc=0"
863 run_test 43 "mds osc import failure during recovery; don't LBUG"
865 test_44a() { # was test_44
868 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
869 [ "$mdcdev" ] || return 2
870 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
872 # adaptive timeouts slow this way down
873 if at_is_enabled; then
874 at_max_saved=$(at_max_get mds)
878 for i in `seq 1 10`; do
879 echo "$i of 10 ($(date +%s))"
880 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
881 #define OBD_FAIL_TGT_CONN_RACE 0x701
882 do_facet mds "lctl set_param fail_loc=0x80000701"
883 # lctl below may fail, it is valid case
884 $LCTL --device $mdcdev recover
888 do_facet mds "lctl set_param fail_loc=0"
889 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
892 run_test 44a "race in target handle connect"
895 local mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
896 [ "$mdcdev" ] || return 2
897 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
899 for i in `seq 1 10`; do
900 echo "$i of 10 ($(date +%s))"
901 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
902 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
903 do_facet mds "lctl set_param fail_loc=0x80000704"
904 # lctl below may fail, it is valid case
905 $LCTL --device $mdcdev recover
908 do_facet mds "lctl set_param fail_loc=0"
911 run_test 44b "race in target handle connect"
913 # Handle failed close
915 local mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
916 [ "$mdcdev" ] || return 2
917 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
919 $LCTL --device $mdcdev recover || return 6
921 multiop_bg_pause $DIR/$tfile O_c || return 1
924 # This will cause the CLOSE to fail before even
925 # allocating a reply buffer
926 $LCTL --device $mdcdev deactivate || return 4
930 wait $pid || return 1
932 $LCTL --device $mdcdev activate || return 5
935 $CHECKSTAT -t file $DIR/$tfile || return 2
938 run_test 45 "Handle failed close"
942 drop_reply "touch $DIR/$tfile"
944 # ironically, the previous test, 45, will cause a real forced close,
945 # so just look for one for this test
946 dmesg | grep -i "force closing client file handle for $tfile" && return 1
949 run_test 46 "Don't leak file handle after open resend (3325)"
951 test_47() { # bug 2824
952 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
954 # create some files to make sure precreate has been done on all
955 # OSTs. (just in case this test is run independently)
956 createmany -o $DIR/$tfile 20 || return 1
958 # OBD_FAIL_OST_CREATE_NET 0x204
960 do_facet ost1 "lctl set_param fail_loc=0x80000204"
961 client_up || return 2
963 # let the MDS discover the OST failure, attempt to recover, fail
965 sleep $((3 * TIMEOUT))
967 # Without 2824, this createmany would hang
968 createmany -o $DIR/$tfile 20 || return 3
969 unlinkmany $DIR/$tfile 20 || return 4
971 do_facet ost1 "lctl set_param fail_loc=0"
974 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
977 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
978 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
981 createmany -o $DIR/$tfile 20 || return 1
983 #define OBD_FAIL_OST_EROFS 0x216
984 do_facet ost1 "lctl set_param fail_loc=0x80000216"
985 client_up || return 2
987 createmany -o $DIR/$tfile 20 20 || return 2
988 unlinkmany $DIR/$tfile 40 || return 3
991 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
994 multiop $DIR/$tfile O_c &
999 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
1000 do_facet mds "lctl set_param fail_loc=0x80000122"
1002 do_facet mds "lctl set_param fail_loc=0"
1004 replay_barrier_nodf mds
1007 wait $pid || return 1
1008 $CHECKSTAT -t file $DIR/$tfile && return 2
1011 run_test 49a "mds fail after close reply is dropped: open|create "
1015 multiop $DIR/$tfile o_c &
1020 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
1021 do_facet mds "lctl set_param fail_loc=0x80000122"
1023 do_facet mds "lctl set_param fail_loc=0"
1025 replay_barrier_nodf mds
1028 wait $pid || return 1
1029 $CHECKSTAT -t file $DIR/$tfile && return 2
1032 run_test 49c "mds fail after close reply is dropped: open"
1035 local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1`
1036 [ "$oscdev" ] || return 1
1037 do_facet mds $LCTL --device $oscdev recover || return 2
1038 do_facet mds $LCTL --device $oscdev recover || return 3
1039 # give the mds_lov_sync threads a chance to run
1042 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1044 # b3764 timed out lock replay
1047 cancel_lru_locks mdc
1049 multiop $DIR/$tfile s || return 1
1051 #define OBD_FAIL_LDLM_REPLY 0x30c
1052 do_facet mds "lctl set_param fail_loc=0x8000030c"
1053 fail mds || return 2
1054 do_facet mds "lctl set_param fail_loc=0x0"
1056 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1058 run_test 52 "time out lock replay (3764)"
1060 # bug 3462 - simultaneous MDC requests
1062 mkdir -p $DIR/${tdir}-1
1063 mkdir -p $DIR/${tdir}-2
1064 multiop $DIR/${tdir}-1/f O_c &
1066 # give multiop a chance to open
1069 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1070 do_facet mds "lctl set_param fail_loc=0x80000115"
1071 kill -USR1 $close_pid
1072 cancel_lru_locks mdc # force the close
1073 do_facet mds "lctl set_param fail_loc=0"
1074 mcreate $DIR/${tdir}-2/f || return 1
1076 # close should still be here
1077 [ -d /proc/$close_pid ] || return 2
1078 replay_barrier_nodf mds
1080 wait $close_pid || return 3
1082 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1083 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1084 rm -rf $DIR/${tdir}-*
1086 run_test 53a "|X| close request while two MDC requests in flight"
1089 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1091 mkdir -p $DIR/$tdir-1
1092 mkdir -p $DIR/$tdir-2
1094 multiop_bg_pause $DIR/$tdir-1/f O_c || return 6
1097 #define OBD_FAIL_MDS_REINT_NET 0x107
1098 do_facet mds "lctl set_param fail_loc=0x80000107"
1099 mcreate $DIR/${tdir}-2/f &
1103 do_facet mds "lctl set_param fail_loc=0"
1104 kill -USR1 $close_pid
1105 cancel_lru_locks mdc # force the close
1106 wait $close_pid || return 1
1107 # open should still be here
1108 [ -d /proc/$open_pid ] || return 2
1110 replay_barrier_nodf mds
1112 wait $open_pid || return 3
1114 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1115 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1116 rm -rf $DIR/${tdir}-*
1118 run_test 53b "|X| open request while two MDC requests in flight"
1121 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1123 mkdir -p $DIR/${tdir}-1
1124 mkdir -p $DIR/${tdir}-2
1125 multiop $DIR/${tdir}-1/f O_c &
1128 #define OBD_FAIL_MDS_REINT_NET 0x107
1129 do_facet mds "lctl set_param fail_loc=0x80000107"
1130 mcreate $DIR/${tdir}-2/f &
1134 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1135 do_facet mds "lctl set_param fail_loc=0x80000115"
1136 kill -USR1 $close_pid
1137 cancel_lru_locks mdc # force the close
1139 replay_barrier_nodf mds
1141 wait $open_pid || return 1
1143 # close should be gone
1144 [ -d /proc/$close_pid ] && return 2
1145 do_facet mds "lctl set_param fail_loc=0"
1147 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1148 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1149 rm -rf $DIR/${tdir}-*
1151 run_test 53c "|X| open request and close request while two MDC requests in flight"
1154 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1156 mkdir -p $DIR/${tdir}-1
1157 mkdir -p $DIR/${tdir}-2
1158 multiop $DIR/${tdir}-1/f O_c &
1160 # give multiop a chance to open
1163 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1164 do_facet mds "lctl set_param fail_loc=0x8000013b"
1165 kill -USR1 $close_pid
1166 cancel_lru_locks mdc # force the close
1167 do_facet mds "lctl set_param fail_loc=0"
1168 mcreate $DIR/${tdir}-2/f || return 1
1170 # close should still be here
1171 [ -d /proc/$close_pid ] || return 2
1172 replay_barrier_nodf mds
1174 wait $close_pid || return 3
1176 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1177 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1178 rm -rf $DIR/${tdir}-*
1180 run_test 53d "|X| close reply while two MDC requests in flight"
1183 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1185 mkdir -p $DIR/$tdir-1
1186 mkdir -p $DIR/$tdir-2
1187 multiop $DIR/$tdir-1/f O_c &
1190 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1191 do_facet mds "lctl set_param fail_loc=0x80000119"
1192 mcreate $DIR/${tdir}-2/f &
1196 do_facet mds "lctl set_param fail_loc=0"
1197 kill -USR1 $close_pid
1198 cancel_lru_locks mdc # force the close
1199 wait $close_pid || return 1
1200 # open should still be here
1201 [ -d /proc/$open_pid ] || return 2
1203 replay_barrier_nodf mds
1205 wait $open_pid || return 3
1207 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1208 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1209 rm -rf $DIR/${tdir}-*
1211 run_test 53e "|X| open reply while two MDC requests in flight"
1214 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1216 mkdir -p $DIR/${tdir}-1
1217 mkdir -p $DIR/${tdir}-2
1218 multiop $DIR/${tdir}-1/f O_c &
1221 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1222 do_facet mds "lctl set_param fail_loc=0x80000119"
1223 mcreate $DIR/${tdir}-2/f &
1227 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1228 do_facet mds "lctl set_param fail_loc=0x8000013b"
1229 kill -USR1 $close_pid
1230 cancel_lru_locks mdc
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 53f "|X| open reply and close reply while two MDC requests in flight"
1247 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1249 mkdir -p $DIR/${tdir}-1
1250 mkdir -p $DIR/${tdir}-2
1251 multiop $DIR/${tdir}-1/f O_c &
1254 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1255 do_facet mds "lctl set_param fail_loc=0x80000119"
1256 mcreate $DIR/${tdir}-2/f &
1260 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1261 do_facet mds "lctl set_param fail_loc=0x80000115"
1262 kill -USR1 $close_pid
1263 cancel_lru_locks mdc # force the close
1265 do_facet mds "lctl set_param fail_loc=0"
1266 replay_barrier_nodf mds
1268 wait $open_pid || return 1
1270 # close should be gone
1271 [ -d /proc/$close_pid ] && return 2
1273 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1274 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1275 rm -rf $DIR/${tdir}-*
1277 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1280 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1282 mkdir -p $DIR/${tdir}-1
1283 mkdir -p $DIR/${tdir}-2
1284 multiop $DIR/${tdir}-1/f O_c &
1287 #define OBD_FAIL_MDS_REINT_NET 0x107
1288 do_facet mds "lctl set_param fail_loc=0x80000107"
1289 mcreate $DIR/${tdir}-2/f &
1293 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1294 do_facet mds "lctl set_param fail_loc=0x8000013b"
1295 kill -USR1 $close_pid
1296 cancel_lru_locks mdc # force the close
1299 replay_barrier_nodf mds
1301 wait $open_pid || return 1
1303 # close should be gone
1304 [ -d /proc/$close_pid ] && return 2
1305 do_facet mds "lctl set_param fail_loc=0"
1307 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1308 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1309 rm -rf $DIR/${tdir}-*
1311 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1313 #b3761 ASSERTION(hash != 0) failed
1315 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1316 do_facet mds "lctl set_param fail_loc=0x8000012b"
1318 # give touch a chance to run
1320 do_facet mds "lctl set_param fail_loc=0x0"
1324 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1326 #b3440 ASSERTION(rec->ur_fid2->id) failed
1328 ln -s foo $DIR/$tfile
1330 #drop_reply "cat $DIR/$tfile"
1334 run_test 56 "don't replay a symlink open request (3440)"
1336 #recovery one mds-ost setattr from llog
1338 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1339 do_facet mds "lctl set_param fail_loc=0x8000012c"
1344 $CHECKSTAT -t file $DIR/$tfile || return 1
1345 do_facet mds "lctl set_param fail_loc=0x0"
1348 run_test 57 "test recovery from llog for setattr op"
1350 #recovery many mds-ost setattr from llog
1353 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1354 do_facet mds "lctl set_param fail_loc=0x8000012c"
1355 createmany -o $DIR/$tdir/$tfile-%d 2500
1359 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1360 do_facet mds "lctl set_param fail_loc=0x0"
1361 unlinkmany $DIR/$tdir/$tfile-%d 2500
1364 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1367 mount_client $MOUNT2
1369 touch $DIR/$tdir/$tfile
1371 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1373 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1374 [ x$VAL = x"bar" ] || return 1
1375 rm -f $DIR/$tdir/$tfile
1377 zconf_umount `hostname` $MOUNT2
1379 run_test 58b "test replay of setxattr op"
1381 test_58c() { # bug 16570
1382 mount_client $MOUNT2
1384 touch $DIR/$tdir/$tfile
1385 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1387 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1388 [ x$VAL = x"bar" ] || return 2
1389 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1391 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1392 [ x$VAL = x"bar1" ] || return 4
1393 rm -f $DIR/$tdir/$tfile
1395 zconf_umount `hostname` $MOUNT2
1397 run_test 58c "resend/reconstruct setxattr op"
1399 # log_commit_thread vs filter_destroy race used to lead to import use after free
1402 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1405 createmany -o $DIR/$tdir/$tfile-%d 200
1407 unlinkmany $DIR/$tdir/$tfile-%d 200
1408 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1409 do_facet ost1 "lctl set_param fail_loc=0x507"
1412 do_facet ost1 "lctl set_param fail_loc=0x0"
1416 run_test 59 "test log_commit_thread vs filter_destroy race"
1418 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1419 # bug 12086: should no oops and No ctxt error for this test
1422 createmany -o $DIR/$tdir/$tfile-%d 200
1424 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1426 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1427 local no_ctxt=`dmesg | grep "No ctxt"`
1428 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1430 run_test 60 "test llog post recovery init vs llog unlink"
1432 #test race llog recovery thread vs llog cleanup
1434 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1437 createmany -o $DIR/$tdir/$tfile-%d 800
1439 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1440 unlinkmany $DIR/$tdir/$tfile-%d 800
1441 do_facet ost "lctl set_param fail_loc=0x80000221"
1446 do_facet ost "lctl set_param fail_loc=0x0"
1447 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1450 run_test 61a "test race llog recovery vs llog cleanup"
1452 #test race mds llog sync vs llog cleanup
1454 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1455 do_facet mds "lctl set_param fail_loc=0x8000013a"
1459 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1461 run_test 61b "test race mds llog sync vs llog cleanup"
1463 #test race cancel cookie cb vs llog cleanup
1465 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1467 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1469 do_facet ost "lctl set_param fail_loc=0x80000222"
1474 run_test 61c "test race mds llog sync vs llog cleanup"
1476 test_61d() { # bug 16002
1477 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1479 do_facet mds "lctl set_param fail_loc=0x80000605"
1480 start mds $MDSDEV $MDS_MOUNT_OPTS && error "mds start should have failed"
1481 do_facet mds "lctl set_param fail_loc=0"
1482 start mds $MDSDEV $MDS_MOUNT_OPTS || error "cannot restart mds"
1484 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1486 test_62() { # Bug 15756 - don't mis-drop resent replay
1489 createmany -o $DIR/$tdir/$tfile- 25
1490 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1491 do_facet mds "lctl set_param fail_loc=0x80000707"
1493 do_facet mds "lctl set_param fail_loc=0"
1494 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1497 run_test 62 "don't mis-drop resent replay"
1499 #Adaptive Timeouts (bug 3055)
1507 echo "Cleaning up AT ..."
1508 if [ -n "$ATOLDBASE" ]; then
1509 local at_history=$($LCTL get_param -n at_history)
1510 do_facet mds "lctl set_param at_history=$at_history" || true
1511 do_facet ost1 "lctl set_param at_history=$at_history" || true
1514 if [ $AT_MAX_SET -ne 0 ]; then
1515 for facet in mds client ost; do
1516 var=AT_MAX_SAVE_${facet}
1517 echo restore AT on $facet to saved value ${!var}
1518 at_max_set ${!var} $facet
1519 at_new=$(at_max_get $facet)
1520 echo Restored AT value on $facet $at_new
1521 [ $at_new -eq ${!var} ] || \
1522 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1529 local at_max_new=600
1531 # Save at_max original values
1533 if [ $AT_MAX_SET -eq 0 ]; then
1534 # Suppose that all osts have the same at_max
1535 for facet in mds client ost; do
1536 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1540 for facet in mds client ost; do
1541 at_max=$(at_max_get $facet)
1542 if [ $at_max -ne $at_max_new ]; then
1543 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1544 at_max_set $at_max_new $facet
1549 if [ -z "$ATOLDBASE" ]; then
1550 ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
1551 # speed up the timebase so we can check decreasing AT
1552 do_facet mds "lctl set_param at_history=8" || true
1553 do_facet ost1 "lctl set_param at_history=8" || true
1555 # sleep for a while to cool down, should be > 8s and also allow
1556 # at least one ping to be sent. simply use TIMEOUT to be safe.
1561 test_65a() #bug 3055
1563 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1565 at_start || return 0
1566 $LCTL dk > /dev/null
1568 lctl set_param debug="+other"
1569 # Slow down a request to the current service time, this is critical
1570 # because previous tests may have caused this value to increase.
1571 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1572 awk '/portal 12/ {print $5}'`
1573 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1575 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1576 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1577 do_facet mds lctl set_param fail_loc=0x8000050a
1578 createmany -o $DIR/$tfile 10 > /dev/null
1579 unlinkmany $DIR/$tfile 10 > /dev/null
1580 # check for log message
1581 $LCTL dk | grep "Early reply #" || error "No early reply"
1582 # client should show REQ_DELAY estimates
1583 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1585 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1587 run_test 65a "AT: verify early replies"
1589 test_65b() #bug 3055
1591 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1593 at_start || return 0
1596 lctl set_param debug="+other"
1597 $LCTL dk > /dev/null
1598 # Slow down a request to the current service time, this is critical
1599 # because previous tests may have caused this value to increase.
1600 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1601 awk '/portal 6/ {print $5}'`
1602 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1604 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1605 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1606 do_facet ost1 lctl set_param fail_loc=0x224
1609 lfs setstripe $DIR/$tfile --index=0 --count=1
1610 # force some real bulk transfer
1611 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1613 do_facet ost1 lctl set_param fail_loc=0
1614 # check for log message
1615 $LCTL dk | grep "Early reply #" || error "No early reply"
1617 # client should show REQ_DELAY estimates
1618 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1620 run_test 65b "AT: verify early replies on packed reply / bulk"
1622 test_66a() #bug 3055
1624 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1626 at_start || return 0
1627 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1628 # adjust 5s at a time so no early reply is sent (within deadline)
1629 do_facet mds "lctl set_param fail_val=5000"
1630 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1631 do_facet mds "lctl set_param fail_loc=0x8000050a"
1632 createmany -o $DIR/$tfile 20 > /dev/null
1633 unlinkmany $DIR/$tfile 20 > /dev/null
1634 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1635 do_facet mds "lctl set_param fail_val=10000"
1636 do_facet mds "lctl set_param fail_loc=0x8000050a"
1637 createmany -o $DIR/$tfile 20 > /dev/null
1638 unlinkmany $DIR/$tfile 20 > /dev/null
1639 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1640 do_facet mds "lctl set_param fail_loc=0"
1642 createmany -o $DIR/$tfile 20 > /dev/null
1643 unlinkmany $DIR/$tfile 20 > /dev/null
1644 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal | grep "portal 12"
1645 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1646 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1647 echo "Current MDT timeout $CUR, worst $WORST"
1648 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1650 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1652 test_66b() #bug 3055
1654 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1656 at_start || return 0
1657 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1658 lctl set_param fail_val=$(($ORIG + 5))
1659 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1660 lctl set_param fail_loc=0x50c
1661 ls $DIR/$tfile > /dev/null 2>&1
1662 lctl set_param fail_loc=0
1663 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1664 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1665 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1666 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1668 run_test 66b "AT: verify net latency adjusts"
1670 test_67a() #bug 3055
1672 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1674 at_start || return 0
1675 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1676 # sleeping threads may drive values above this
1677 do_facet ost1 "lctl set_param fail_val=400"
1678 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1679 do_facet ost1 "lctl set_param fail_loc=0x50a"
1680 createmany -o $DIR/$tfile 20 > /dev/null
1681 unlinkmany $DIR/$tfile 20 > /dev/null
1682 do_facet ost1 "lctl set_param fail_loc=0"
1683 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1684 ATTEMPTS=$(($CONN2 - $CONN1))
1685 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1686 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1689 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1691 test_67b() #bug 3055
1693 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1695 at_start || return 0
1696 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1697 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1698 do_facet ost1 "lctl set_param fail_val=20000"
1699 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1700 cp /etc/profile $DIR/$tfile || error "cp failed"
1702 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1704 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1705 ATTEMPTS=$(($CONN2 - $CONN1))
1706 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1707 # do it again; should not timeout
1708 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1709 cp /etc/profile $DIR/$tfile || error "cp failed"
1710 do_facet ost1 "lctl set_param fail_loc=0"
1712 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1713 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1714 ATTEMPTS=$(($CONN3 - $CONN2))
1715 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1716 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1719 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1721 test_68 () #bug 13813
1723 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1725 at_start || return 0
1726 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1727 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1728 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1729 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1730 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1731 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1732 echo $TIMEOUT >> $ldlm_enqueue_min
1733 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1737 lfs setstripe $DIR/$tdir --index=0 --count=1
1738 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1739 lctl set_param fail_val=$(($TIMEOUT - 1))
1740 lctl set_param fail_loc=0x80000312
1741 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1742 lctl set_param fail_val=$((TIMEOUT * 5 / 4))
1743 lctl set_param fail_loc=0x80000312
1744 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1745 lctl set_param fail_loc=0
1747 echo $ENQ_MIN >> $ldlm_enqueue_min
1748 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1752 run_test 68 "AT: verify slowing locks"
1755 # end of AT tests includes above lines
1757 # start multi-client tests
1759 [ -z "$CLIENTS" ] && \
1760 { skip "Need two or more clients." && return; }
1761 [ $CLIENTCOUNT -lt 2 ] && \
1762 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1764 echo "mount clients $CLIENTS ..."
1765 zconf_mount_clients $CLIENTS $DIR
1767 local clients=${CLIENTS//,/ }
1768 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1769 for CLIENT in $clients; do
1770 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1771 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1772 error "dd failed on $CLIENT"
1775 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1776 for C in ${CLIENTS//,/ }; do
1777 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1778 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1784 run_test 70a "check multi client t-f"
1787 local clients=${CLIENTS:-$HOSTNAME}
1789 zconf_mount_clients $clients $DIR
1792 [ "$SLOW" = "no" ] && duration=60
1793 local cmd="rundbench 1 -t $duration"
1795 do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1796 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1797 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1800 log "Started rundbench load PID=$PID ..."
1804 START_TS=$(date +%s)
1805 CURRENT_TS=$START_TS
1806 while [ $ELAPSED -lt $duration ]; do
1809 sleep 1 # give clients a time to do operations
1810 # Increment the number of failovers
1811 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1812 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1814 CURRENT_TS=$(date +%s)
1815 ELAPSED=$((CURRENT_TS - START_TS))
1818 wait $PID || error "rundbench load on $CLIENTS failed!"
1820 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1821 # end multi-client tests
1823 # vbr export handling
1825 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1827 UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
1828 echo "Client UUID is $UUID"
1832 zconf_mount `hostname` $DIR || error "mount fails"
1833 client_up || error "post-failover df failed"
1834 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
1835 error "no delayed exports"
1836 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1838 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1839 sleep $((NEW_AGE + 2))
1840 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
1841 error "exports didn't expire"
1842 do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
1843 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
1844 error "Export wasn't removed manually"
1845 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1848 run_test 71a "lost client export is kept"
1851 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1854 create_fake_exports mds $FAKE_NUM
1855 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1856 [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
1857 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1859 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1860 sleep $((NEW_AGE + 2))
1861 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1862 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1863 do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
1864 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
1865 error "Exports weren't flushed"
1866 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1869 run_test 71b "stale exports are expired, lctl flushes them"
1872 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1875 create_fake_exports mds $FAKE_NUM
1876 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1877 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1878 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1880 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1881 sleep $((NEW_AGE + 2))
1882 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1883 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1886 zconf_mount `hostname` $DIR || error "mount fails"
1888 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1889 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1890 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1893 run_test 71c "stale exports are expired, new client connection flush them"
1896 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1899 create_fake_exports mds $FAKE_NUM
1900 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1901 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1902 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1904 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
1905 sleep $((NEW_AGE + 2))
1906 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1907 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1911 FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1912 [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
1913 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1914 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1915 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
1918 run_test 71d "expired exports, server init removes them, conf_param works"
1920 # end vbr exports tests
1922 test_72() { #bug 16711
1924 multiop_bg_pause $DIR/$tfile O_c || return 4
1926 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709
1927 do_facet mds "lctl set_param fail_loc=0x80000709"
1929 kill -USR1 $pid || return 1
1930 wait $pid || return 2
1931 $CHECKSTAT -t file $DIR/$tfile || return 3
1933 run_test 72 "target_finish_recovery vs process_recovery_queue race"
1936 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1941 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1942 do_facet mds "lctl set_param fail_loc=0x80000302"
1945 wait $pid || return 1
1946 [ -e $DIR/$tfile ] && return 2
1949 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1952 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1957 #define OBD_FAIL_LDLM_REPLY 0x30c
1958 do_facet mds "lctl set_param fail_loc=0x8000030c"
1961 wait $pid || return 1
1962 [ -e $DIR/$tfile ] && return 2
1965 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1968 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1973 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1974 do_facet mds "lctl set_param fail_loc=0x80000710"
1977 wait $pid || return 1
1978 [ -e $DIR/$tfile ] && return 2
1981 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1984 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1987 lfs setstripe -i 0 -c 1 $DIR/$tfile
1988 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1989 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
1990 cancel_lru_locks osc
1992 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
1993 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
1994 if [ $cksum != $cksum2 ] ; then
1995 error "New checksum $cksum2 does not match original $cksum"
1998 run_test 80a "write replay"
2001 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2004 lfs setstripe -i 0 -c 1 $DIR/$tfile
2005 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2006 sleep 1 # Give it a chance to flush dirty data
2007 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2008 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2009 cancel_lru_locks osc
2011 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2012 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2013 if [ $cksum != $cksum2 ] ; then
2014 error "New checksum $cksum2 does not match original $cksum"
2017 run_test 80b "write replay with changed data (checksum resend)"
2021 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2022 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2023 do_facet mds "lctl set_param fail_loc=0x80000140"
2024 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2026 run_test 81a "fail log_add during unlink recovery"
2030 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2032 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2033 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2034 do_facet mds "lctl set_param fail_loc=0x80000140"
2037 run_test 81b "fail log_add during unlink recovery"
2039 test_82() { #bug 18927
2040 multiop_bg_pause $DIR/$tfile O_c || return 1
2042 multiop_bg_pause $DIR/$tfile o:O_CREAT:O_RDONLY:_c || return 2
2048 wait $pid1 || return 3
2050 wait $pid2 || return 4
2051 [ -e $DIR/$tfile ] && return 5
2054 run_test 82 "second open|creat in replay with open orphan"
2056 test_83() { #bug 19224
2057 #define OBD_FAIL_MDS_SPLIT_OPEN 0x142
2058 do_facet mds "lctl set_param fail_loc=0x80000142"
2059 # open will sleep after first transaction
2063 # set barrier between open transactions
2064 replay_barrier_nodf mds
2065 createmany -o $DIR/$tfile- 10
2066 # open should finish now
2067 wait $PID || return 1
2069 rm $DIR/$tfile || return 2
2070 unlinkmany $DIR/$tfile- 10 || return 3
2073 run_test 83 "open replay with barrier between transactions"
2076 #define OBD_FAIL_OBD_FAIL_MDS_SPLIT_OPEN 0x142
2077 do_facet mds "lctl set_param fail_loc=0x80000142"
2078 createmany -o $DIR/$tfile- 1 &
2082 client_up || client_up || true # reconnect
2084 run_test 84 "stale open during export disconnect"
2086 equals_msg `basename $0`: test complete, cleaning up
2087 check_and_cleanup_lustre
2088 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true