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 local dev=$(get_mds_mdt_device_proc_path)
879 for i in `seq 1 10`; do
880 echo "$i of 10 ($(date +%s))"
881 do_facet mds "lctl get_param -n mdt.*.$dev.timeouts | grep service"
882 #define OBD_FAIL_TGT_CONN_RACE 0x701
883 do_facet mds "lctl set_param fail_loc=0x80000701"
884 # lctl below may fail, it is valid case
885 $LCTL --device $mdcdev recover
889 do_facet mds "lctl set_param fail_loc=0"
890 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
893 run_test 44a "race in target handle connect"
896 local mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
897 [ "$mdcdev" ] || return 2
898 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
900 local dev=$(get_mds_mdt_device_proc_path)
901 for i in `seq 1 10`; do
902 echo "$i of 10 ($(date +%s))"
903 do_facet mds "lctl get_param -n mdt.*.$dev.timeouts | grep service"
904 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
905 do_facet mds "lctl set_param fail_loc=0x80000704"
906 # lctl below may fail, it is valid case
907 $LCTL --device $mdcdev recover
910 do_facet mds "lctl set_param fail_loc=0"
913 run_test 44b "race in target handle connect"
915 # Handle failed close
917 local mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
918 [ "$mdcdev" ] || return 2
919 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
921 $LCTL --device $mdcdev recover || return 6
923 multiop_bg_pause $DIR/$tfile O_c || return 1
926 # This will cause the CLOSE to fail before even
927 # allocating a reply buffer
928 $LCTL --device $mdcdev deactivate || return 4
932 wait $pid || return 1
934 $LCTL --device $mdcdev activate || return 5
937 $CHECKSTAT -t file $DIR/$tfile || return 2
940 run_test 45 "Handle failed close"
944 drop_reply "touch $DIR/$tfile"
946 # ironically, the previous test, 45, will cause a real forced close,
947 # so just look for one for this test
948 dmesg | grep -i "force closing client file handle for $tfile" && return 1
951 run_test 46 "Don't leak file handle after open resend (3325)"
953 test_47() { # bug 2824
954 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
956 # create some files to make sure precreate has been done on all
957 # OSTs. (just in case this test is run independently)
958 createmany -o $DIR/$tfile 20 || return 1
960 # OBD_FAIL_OST_CREATE_NET 0x204
962 do_facet ost1 "lctl set_param fail_loc=0x80000204"
963 client_up || return 2
965 # let the MDS discover the OST failure, attempt to recover, fail
967 sleep $((3 * TIMEOUT))
969 # Without 2824, this createmany would hang
970 createmany -o $DIR/$tfile 20 || return 3
971 unlinkmany $DIR/$tfile 20 || return 4
973 do_facet ost1 "lctl set_param fail_loc=0"
976 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
979 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
980 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
983 createmany -o $DIR/$tfile 20 || return 1
985 #define OBD_FAIL_OST_EROFS 0x216
986 do_facet ost1 "lctl set_param fail_loc=0x80000216"
987 client_up || return 2
989 createmany -o $DIR/$tfile 20 20 || return 2
990 unlinkmany $DIR/$tfile 40 || return 3
993 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
996 multiop $DIR/$tfile O_c &
1001 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
1002 do_facet mds "lctl set_param fail_loc=0x80000122"
1004 do_facet mds "lctl set_param fail_loc=0"
1006 replay_barrier_nodf mds
1009 wait $pid || return 1
1010 $CHECKSTAT -t file $DIR/$tfile && return 2
1013 run_test 49a "mds fail after close reply is dropped: open|create "
1017 multiop $DIR/$tfile o_c &
1022 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
1023 do_facet mds "lctl set_param fail_loc=0x80000122"
1025 do_facet mds "lctl set_param fail_loc=0"
1027 replay_barrier_nodf mds
1030 wait $pid || return 1
1031 $CHECKSTAT -t file $DIR/$tfile && return 2
1034 run_test 49c "mds fail after close reply is dropped: open"
1037 local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1`
1038 [ "$oscdev" ] || return 1
1039 do_facet mds $LCTL --device $oscdev recover || return 2
1040 do_facet mds $LCTL --device $oscdev recover || return 3
1041 # give the mds_lov_sync threads a chance to run
1044 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1046 # b3764 timed out lock replay
1049 cancel_lru_locks mdc
1051 multiop $DIR/$tfile s || return 1
1053 #define OBD_FAIL_LDLM_REPLY 0x30c
1054 do_facet mds "lctl set_param fail_loc=0x8000030c"
1055 fail mds || return 2
1056 do_facet mds "lctl set_param fail_loc=0x0"
1058 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1060 run_test 52 "time out lock replay (3764)"
1062 # bug 3462 - simultaneous MDC requests
1064 mkdir -p $DIR/${tdir}-1
1065 mkdir -p $DIR/${tdir}-2
1066 multiop $DIR/${tdir}-1/f O_c &
1068 # give multiop a chance to open
1071 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1072 do_facet mds "lctl set_param fail_loc=0x80000115"
1073 kill -USR1 $close_pid
1074 cancel_lru_locks mdc # force the close
1075 do_facet mds "lctl set_param fail_loc=0"
1076 mcreate $DIR/${tdir}-2/f || return 1
1078 # close should still be here
1079 [ -d /proc/$close_pid ] || return 2
1080 replay_barrier_nodf mds
1082 wait $close_pid || return 3
1084 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1085 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1086 rm -rf $DIR/${tdir}-*
1088 run_test 53a "|X| close request while two MDC requests in flight"
1091 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1093 mkdir -p $DIR/$tdir-1
1094 mkdir -p $DIR/$tdir-2
1096 multiop_bg_pause $DIR/$tdir-1/f O_c || return 6
1099 #define OBD_FAIL_MDS_REINT_NET 0x107
1100 do_facet mds "lctl set_param fail_loc=0x80000107"
1101 mcreate $DIR/${tdir}-2/f &
1105 do_facet mds "lctl set_param fail_loc=0"
1106 kill -USR1 $close_pid
1107 cancel_lru_locks mdc # force the close
1108 wait $close_pid || return 1
1109 # open should still be here
1110 [ -d /proc/$open_pid ] || return 2
1112 replay_barrier_nodf mds
1114 wait $open_pid || return 3
1116 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1117 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1118 rm -rf $DIR/${tdir}-*
1120 run_test 53b "|X| open request while two MDC requests in flight"
1123 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1125 mkdir -p $DIR/${tdir}-1
1126 mkdir -p $DIR/${tdir}-2
1127 multiop $DIR/${tdir}-1/f O_c &
1130 #define OBD_FAIL_MDS_REINT_NET 0x107
1131 do_facet mds "lctl set_param fail_loc=0x80000107"
1132 mcreate $DIR/${tdir}-2/f &
1136 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1137 do_facet mds "lctl set_param fail_loc=0x80000115"
1138 kill -USR1 $close_pid
1139 cancel_lru_locks mdc # force the close
1141 replay_barrier_nodf mds
1143 wait $open_pid || return 1
1145 # close should be gone
1146 [ -d /proc/$close_pid ] && return 2
1147 do_facet mds "lctl set_param fail_loc=0"
1149 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1150 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1151 rm -rf $DIR/${tdir}-*
1153 run_test 53c "|X| open request and close request while two MDC requests in flight"
1156 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1158 mkdir -p $DIR/${tdir}-1
1159 mkdir -p $DIR/${tdir}-2
1160 multiop $DIR/${tdir}-1/f O_c &
1162 # give multiop a chance to open
1165 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1166 do_facet mds "lctl set_param fail_loc=0x8000013b"
1167 kill -USR1 $close_pid
1168 cancel_lru_locks mdc # force the close
1169 do_facet mds "lctl set_param fail_loc=0"
1170 mcreate $DIR/${tdir}-2/f || return 1
1172 # close should still be here
1173 [ -d /proc/$close_pid ] || return 2
1174 replay_barrier_nodf mds
1176 wait $close_pid || return 3
1178 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1179 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1180 rm -rf $DIR/${tdir}-*
1182 run_test 53d "|X| close reply while two MDC requests in flight"
1185 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1187 mkdir -p $DIR/$tdir-1
1188 mkdir -p $DIR/$tdir-2
1189 multiop $DIR/$tdir-1/f O_c &
1192 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1193 do_facet mds "lctl set_param fail_loc=0x80000119"
1194 mcreate $DIR/${tdir}-2/f &
1198 do_facet mds "lctl set_param fail_loc=0"
1199 kill -USR1 $close_pid
1200 cancel_lru_locks mdc # force the close
1201 wait $close_pid || return 1
1202 # open should still be here
1203 [ -d /proc/$open_pid ] || return 2
1205 replay_barrier_nodf mds
1207 wait $open_pid || return 3
1209 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1210 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1211 rm -rf $DIR/${tdir}-*
1213 run_test 53e "|X| open reply while two MDC requests in flight"
1216 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1218 mkdir -p $DIR/${tdir}-1
1219 mkdir -p $DIR/${tdir}-2
1220 multiop $DIR/${tdir}-1/f O_c &
1223 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1224 do_facet mds "lctl set_param fail_loc=0x80000119"
1225 mcreate $DIR/${tdir}-2/f &
1229 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1230 do_facet mds "lctl set_param fail_loc=0x8000013b"
1231 kill -USR1 $close_pid
1232 cancel_lru_locks mdc
1234 replay_barrier_nodf mds
1236 wait $open_pid || return 1
1238 #close should be gone
1239 [ -d /proc/$close_pid ] && return 2
1240 do_facet mds "lctl set_param fail_loc=0"
1242 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1243 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1244 rm -rf $DIR/${tdir}-*
1246 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1249 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1251 mkdir -p $DIR/${tdir}-1
1252 mkdir -p $DIR/${tdir}-2
1253 multiop $DIR/${tdir}-1/f O_c &
1256 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1257 do_facet mds "lctl set_param fail_loc=0x80000119"
1258 mcreate $DIR/${tdir}-2/f &
1262 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1263 do_facet mds "lctl set_param fail_loc=0x80000115"
1264 kill -USR1 $close_pid
1265 cancel_lru_locks mdc # force the close
1267 do_facet mds "lctl set_param fail_loc=0"
1268 replay_barrier_nodf mds
1270 wait $open_pid || return 1
1272 # close should be gone
1273 [ -d /proc/$close_pid ] && return 2
1275 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1276 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1277 rm -rf $DIR/${tdir}-*
1279 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1282 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1284 mkdir -p $DIR/${tdir}-1
1285 mkdir -p $DIR/${tdir}-2
1286 multiop $DIR/${tdir}-1/f O_c &
1289 #define OBD_FAIL_MDS_REINT_NET 0x107
1290 do_facet mds "lctl set_param fail_loc=0x80000107"
1291 mcreate $DIR/${tdir}-2/f &
1295 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1296 do_facet mds "lctl set_param fail_loc=0x8000013b"
1297 kill -USR1 $close_pid
1298 cancel_lru_locks mdc # force the close
1301 replay_barrier_nodf mds
1303 wait $open_pid || return 1
1305 # close should be gone
1306 [ -d /proc/$close_pid ] && return 2
1307 do_facet mds "lctl set_param fail_loc=0"
1309 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1310 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1311 rm -rf $DIR/${tdir}-*
1313 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1315 #b3761 ASSERTION(hash != 0) failed
1317 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1318 do_facet mds "lctl set_param fail_loc=0x8000012b"
1320 # give touch a chance to run
1322 do_facet mds "lctl set_param fail_loc=0x0"
1326 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1328 #b3440 ASSERTION(rec->ur_fid2->id) failed
1330 ln -s foo $DIR/$tfile
1332 #drop_reply "cat $DIR/$tfile"
1336 run_test 56 "don't replay a symlink open request (3440)"
1338 #recovery one mds-ost setattr from llog
1340 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1341 do_facet mds "lctl set_param fail_loc=0x8000012c"
1346 $CHECKSTAT -t file $DIR/$tfile || return 1
1347 do_facet mds "lctl set_param fail_loc=0x0"
1350 run_test 57 "test recovery from llog for setattr op"
1352 #recovery many mds-ost setattr from llog
1355 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1356 do_facet mds "lctl set_param fail_loc=0x8000012c"
1357 createmany -o $DIR/$tdir/$tfile-%d 2500
1361 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1362 do_facet mds "lctl set_param fail_loc=0x0"
1363 unlinkmany $DIR/$tdir/$tfile-%d 2500
1366 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1369 mount_client $MOUNT2
1371 touch $DIR/$tdir/$tfile
1373 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1375 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1376 [ x$VAL = x"bar" ] || return 1
1377 rm -f $DIR/$tdir/$tfile
1379 zconf_umount `hostname` $MOUNT2
1381 run_test 58b "test replay of setxattr op"
1383 test_58c() { # bug 16570
1384 mount_client $MOUNT2
1386 touch $DIR/$tdir/$tfile
1387 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1389 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1390 [ x$VAL = x"bar" ] || return 2
1391 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1393 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1394 [ x$VAL = x"bar1" ] || return 4
1395 rm -f $DIR/$tdir/$tfile
1397 zconf_umount `hostname` $MOUNT2
1399 run_test 58c "resend/reconstruct setxattr op"
1401 # log_commit_thread vs filter_destroy race used to lead to import use after free
1404 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1407 createmany -o $DIR/$tdir/$tfile-%d 200
1409 unlinkmany $DIR/$tdir/$tfile-%d 200
1410 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1411 do_facet ost1 "lctl set_param fail_loc=0x507"
1414 do_facet ost1 "lctl set_param fail_loc=0x0"
1418 run_test 59 "test log_commit_thread vs filter_destroy race"
1420 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1421 # bug 12086: should no oops and No ctxt error for this test
1424 createmany -o $DIR/$tdir/$tfile-%d 200
1426 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1428 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1429 local no_ctxt=`dmesg | grep "No ctxt"`
1430 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1432 run_test 60 "test llog post recovery init vs llog unlink"
1434 #test race llog recovery thread vs llog cleanup
1436 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1439 createmany -o $DIR/$tdir/$tfile-%d 800
1441 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1442 unlinkmany $DIR/$tdir/$tfile-%d 800
1443 do_facet ost "lctl set_param fail_loc=0x80000221"
1448 do_facet ost "lctl set_param fail_loc=0x0"
1449 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1452 run_test 61a "test race llog recovery vs llog cleanup"
1454 #test race mds llog sync vs llog cleanup
1456 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1457 do_facet mds "lctl set_param fail_loc=0x8000013a"
1461 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1463 run_test 61b "test race mds llog sync vs llog cleanup"
1465 #test race cancel cookie cb vs llog cleanup
1467 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1469 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1471 do_facet ost "lctl set_param fail_loc=0x80000222"
1476 run_test 61c "test race mds llog sync vs llog cleanup"
1478 test_61d() { # bug 16002
1479 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1481 do_facet mds "lctl set_param fail_loc=0x80000605"
1482 start mds $MDSDEV $MDS_MOUNT_OPTS && error "mds start should have failed"
1483 do_facet mds "lctl set_param fail_loc=0"
1484 start mds $MDSDEV $MDS_MOUNT_OPTS || error "cannot restart mds"
1486 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1488 test_62() { # Bug 15756 - don't mis-drop resent replay
1491 createmany -o $DIR/$tdir/$tfile- 25
1492 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1493 do_facet mds "lctl set_param fail_loc=0x80000707"
1495 do_facet mds "lctl set_param fail_loc=0"
1496 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1499 run_test 62 "don't mis-drop resent replay"
1501 #Adaptive Timeouts (bug 3055)
1509 echo "Cleaning up AT ..."
1510 if [ -n "$ATOLDBASE" ]; then
1511 local at_history=$($LCTL get_param -n at_history)
1512 do_facet mds "lctl set_param at_history=$at_history" || true
1513 do_facet ost1 "lctl set_param at_history=$at_history" || true
1516 if [ $AT_MAX_SET -ne 0 ]; then
1517 for facet in mds client ost; do
1518 var=AT_MAX_SAVE_${facet}
1519 echo restore AT on $facet to saved value ${!var}
1520 at_max_set ${!var} $facet
1521 at_new=$(at_max_get $facet)
1522 echo Restored AT value on $facet $at_new
1523 [ $at_new -eq ${!var} ] || \
1524 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1531 local at_max_new=600
1533 # Save at_max original values
1535 if [ $AT_MAX_SET -eq 0 ]; then
1536 # Suppose that all osts have the same at_max
1537 for facet in mds client ost; do
1538 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1542 for facet in mds client ost; do
1543 at_max=$(at_max_get $facet)
1544 if [ $at_max -ne $at_max_new ]; then
1545 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1546 at_max_set $at_max_new $facet
1551 if [ -z "$ATOLDBASE" ]; then
1552 ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
1553 # speed up the timebase so we can check decreasing AT
1554 do_facet mds "lctl set_param at_history=8" || true
1555 do_facet ost1 "lctl set_param at_history=8" || true
1557 # sleep for a while to cool down, should be > 8s and also allow
1558 # at least one ping to be sent. simply use TIMEOUT to be safe.
1563 test_65a() #bug 3055
1565 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1567 at_start || return 0
1568 $LCTL dk > /dev/null
1570 lctl set_param debug="+other"
1571 # Slow down a request to the current service time, this is critical
1572 # because previous tests may have caused this value to increase.
1573 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1574 awk '/portal 12/ {print $5}'`
1575 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1577 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1578 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1579 do_facet mds lctl set_param fail_loc=0x8000050a
1580 createmany -o $DIR/$tfile 10 > /dev/null
1581 unlinkmany $DIR/$tfile 10 > /dev/null
1582 # check for log message
1583 $LCTL dk | grep "Early reply #" || error "No early reply"
1584 # client should show REQ_DELAY estimates
1585 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1587 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1589 run_test 65a "AT: verify early replies"
1591 test_65b() #bug 3055
1593 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1595 at_start || return 0
1598 lctl set_param debug="+other"
1599 $LCTL dk > /dev/null
1600 # Slow down a request to the current service time, this is critical
1601 # because previous tests may have caused this value to increase.
1602 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1603 awk '/portal 6/ {print $5}'`
1604 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1606 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1607 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1608 do_facet ost1 lctl set_param fail_loc=0x224
1611 lfs setstripe $DIR/$tfile --index=0 --count=1
1612 # force some real bulk transfer
1613 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1615 do_facet ost1 lctl set_param fail_loc=0
1616 # check for log message
1617 $LCTL dk | grep "Early reply #" || error "No early reply"
1619 # client should show REQ_DELAY estimates
1620 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1622 run_test 65b "AT: verify early replies on packed reply / bulk"
1624 test_66a() #bug 3055
1626 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1628 at_start || return 0
1629 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1630 # adjust 5s at a time so no early reply is sent (within deadline)
1631 do_facet mds "lctl set_param fail_val=5000"
1632 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1633 do_facet mds "lctl set_param fail_loc=0x8000050a"
1634 createmany -o $DIR/$tfile 20 > /dev/null
1635 unlinkmany $DIR/$tfile 20 > /dev/null
1636 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1637 do_facet mds "lctl set_param fail_val=10000"
1638 do_facet mds "lctl set_param fail_loc=0x8000050a"
1639 createmany -o $DIR/$tfile 20 > /dev/null
1640 unlinkmany $DIR/$tfile 20 > /dev/null
1641 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1642 do_facet mds "lctl set_param fail_loc=0"
1644 createmany -o $DIR/$tfile 20 > /dev/null
1645 unlinkmany $DIR/$tfile 20 > /dev/null
1646 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal | grep "portal 12"
1647 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1648 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1649 echo "Current MDT timeout $CUR, worst $WORST"
1650 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1652 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1654 test_66b() #bug 3055
1656 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1658 at_start || return 0
1659 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1660 lctl set_param fail_val=$(($ORIG + 5))
1661 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1662 lctl set_param fail_loc=0x50c
1663 ls $DIR/$tfile > /dev/null 2>&1
1664 lctl set_param fail_loc=0
1665 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1666 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1667 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1668 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1670 run_test 66b "AT: verify net latency adjusts"
1672 test_67a() #bug 3055
1674 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1676 at_start || return 0
1677 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1678 # sleeping threads may drive values above this
1679 do_facet ost1 "lctl set_param fail_val=400"
1680 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1681 do_facet ost1 "lctl set_param fail_loc=0x50a"
1682 createmany -o $DIR/$tfile 20 > /dev/null
1683 unlinkmany $DIR/$tfile 20 > /dev/null
1684 do_facet ost1 "lctl set_param fail_loc=0"
1685 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1686 ATTEMPTS=$(($CONN2 - $CONN1))
1687 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1688 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1691 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1693 test_67b() #bug 3055
1695 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1697 at_start || return 0
1698 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1700 # exhaust precreations on ost1
1701 local OST=$(lfs osts | grep 0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1702 local mdtosc=$(get_mdtosc_proc_path $OST)
1703 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
1704 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
1706 mkdir -p $DIR/$tdir/${OST}
1707 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1708 echo "Creating to objid $last_id on ost $OST..."
1709 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1710 do_facet ost1 "lctl set_param fail_val=20000"
1711 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1712 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1715 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1717 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1718 ATTEMPTS=$(($CONN2 - $CONN1))
1719 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1720 # do it again; should not timeout
1721 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1722 cp /etc/profile $DIR/$tfile || error "cp failed"
1723 do_facet ost1 "lctl set_param fail_loc=0"
1725 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1726 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1727 ATTEMPTS=$(($CONN3 - $CONN2))
1728 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1729 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1732 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1734 test_68 () #bug 13813
1736 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1738 at_start || return 0
1739 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1740 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1741 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1742 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1743 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1744 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1745 echo $TIMEOUT >> $ldlm_enqueue_min
1746 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1750 lfs setstripe $DIR/$tdir --index=0 --count=1
1751 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1752 lctl set_param fail_val=$(($TIMEOUT - 1))
1753 lctl set_param fail_loc=0x80000312
1754 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1755 lctl set_param fail_val=$((TIMEOUT * 5 / 4))
1756 lctl set_param fail_loc=0x80000312
1757 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1758 lctl set_param fail_loc=0
1760 echo $ENQ_MIN >> $ldlm_enqueue_min
1761 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1765 run_test 68 "AT: verify slowing locks"
1768 # end of AT tests includes above lines
1770 # start multi-client tests
1772 [ -z "$CLIENTS" ] && \
1773 { skip "Need two or more clients." && return; }
1774 [ $CLIENTCOUNT -lt 2 ] && \
1775 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1777 echo "mount clients $CLIENTS ..."
1778 zconf_mount_clients $CLIENTS $DIR
1780 local clients=${CLIENTS//,/ }
1781 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1782 for CLIENT in $clients; do
1783 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1784 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1785 error "dd failed on $CLIENT"
1788 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1789 for C in ${CLIENTS//,/ }; do
1790 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1791 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1797 run_test 70a "check multi client t-f"
1800 local clients=${CLIENTS:-$HOSTNAME}
1802 zconf_mount_clients $clients $DIR
1805 [ "$SLOW" = "no" ] && duration=60
1806 local cmd="rundbench 1 -t $duration"
1808 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1809 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1810 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1813 log "Started rundbench load PID=$PID ..."
1817 START_TS=$(date +%s)
1818 CURRENT_TS=$START_TS
1819 while [ $ELAPSED -lt $duration ]; do
1822 sleep 1 # give clients a time to do operations
1823 # Increment the number of failovers
1824 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1825 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1827 CURRENT_TS=$(date +%s)
1828 ELAPSED=$((CURRENT_TS - START_TS))
1831 wait $PID || error "rundbench load on $CLIENTS failed!"
1833 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1834 # end multi-client tests
1836 # vbr export handling
1838 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1840 UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
1841 echo "Client UUID is $UUID"
1845 zconf_mount `hostname` $DIR || error "mount fails"
1846 client_up || error "post-failover df failed"
1847 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
1848 error "no delayed exports"
1849 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1851 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1852 sleep $((NEW_AGE + 2))
1853 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
1854 error "exports didn't expire"
1855 do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
1856 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
1857 error "Export wasn't removed manually"
1858 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1861 run_test 71a "lost client export is kept"
1864 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1867 create_fake_exports mds $FAKE_NUM
1868 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1869 [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
1870 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1872 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1873 sleep $((NEW_AGE + 2))
1874 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1875 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1876 do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
1877 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
1878 error "Exports weren't flushed"
1879 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1882 run_test 71b "stale exports are expired, lctl flushes them"
1885 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1888 create_fake_exports mds $FAKE_NUM
1889 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1890 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1891 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1893 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1894 sleep $((NEW_AGE + 2))
1895 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1896 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1899 zconf_mount `hostname` $DIR || error "mount fails"
1901 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1902 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1903 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1906 run_test 71c "stale exports are expired, new client connection flush them"
1909 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1912 create_fake_exports mds $FAKE_NUM
1913 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1914 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1915 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1917 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
1918 sleep $((NEW_AGE + 2))
1919 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1920 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1924 FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1925 [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
1926 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1927 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1928 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
1931 run_test 71d "expired exports, server init removes them, conf_param works"
1933 # end vbr exports tests
1935 test_72() { #bug 16711
1937 multiop_bg_pause $DIR/$tfile O_c || return 4
1939 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709
1940 do_facet mds "lctl set_param fail_loc=0x80000709"
1942 kill -USR1 $pid || return 1
1943 wait $pid || return 2
1944 $CHECKSTAT -t file $DIR/$tfile || return 3
1946 run_test 72 "target_finish_recovery vs process_recovery_queue race"
1949 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1954 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1955 do_facet mds "lctl set_param fail_loc=0x80000302"
1958 wait $pid || return 1
1959 [ -e $DIR/$tfile ] && return 2
1962 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1965 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1970 #define OBD_FAIL_LDLM_REPLY 0x30c
1971 do_facet mds "lctl set_param fail_loc=0x8000030c"
1974 wait $pid || return 1
1975 [ -e $DIR/$tfile ] && return 2
1978 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1981 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1986 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1987 do_facet mds "lctl set_param fail_loc=0x80000710"
1990 wait $pid || return 1
1991 [ -e $DIR/$tfile ] && return 2
1994 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1997 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2000 lfs setstripe -i 0 -c 1 $DIR/$tfile
2001 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2002 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2003 cancel_lru_locks osc
2005 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2006 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2007 if [ $cksum != $cksum2 ] ; then
2008 error "New checksum $cksum2 does not match original $cksum"
2011 run_test 80a "write replay"
2014 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2017 lfs setstripe -i 0 -c 1 $DIR/$tfile
2018 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2019 sleep 1 # Give it a chance to flush dirty data
2020 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2021 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2022 cancel_lru_locks osc
2024 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2025 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2026 if [ $cksum != $cksum2 ] ; then
2027 error "New checksum $cksum2 does not match original $cksum"
2030 run_test 80b "write replay with changed data (checksum resend)"
2034 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2035 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2036 do_facet mds "lctl set_param fail_loc=0x80000140"
2037 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2039 run_test 81a "fail log_add during unlink recovery"
2043 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2045 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2046 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2047 do_facet mds "lctl set_param fail_loc=0x80000140"
2050 run_test 81b "fail log_add during unlink recovery"
2052 test_82() { #bug 18927
2053 multiop_bg_pause $DIR/$tfile O_c || return 1
2055 multiop_bg_pause $DIR/$tfile o:O_CREAT:O_RDONLY:_c || return 2
2061 wait $pid1 || return 3
2063 wait $pid2 || return 4
2064 [ -e $DIR/$tfile ] && return 5
2067 run_test 82 "second open|creat in replay with open orphan"
2069 test_83() { #bug 19224
2070 #define OBD_FAIL_MDS_SPLIT_OPEN 0x142
2071 do_facet mds "lctl set_param fail_loc=0x80000142"
2072 # open will sleep after first transaction
2076 # set barrier between open transactions
2077 replay_barrier_nodf mds
2078 createmany -o $DIR/$tfile- 10
2079 # open should finish now
2080 wait $PID || return 1
2082 rm $DIR/$tfile || return 2
2083 unlinkmany $DIR/$tfile- 10 || return 3
2086 run_test 83 "open replay with barrier between transactions"
2089 #define OBD_FAIL_OBD_FAIL_MDS_SPLIT_OPEN 0x142
2090 do_facet mds "lctl set_param fail_loc=0x80000142"
2091 createmany -o $DIR/$tfile- 1 &
2095 client_up || client_up || true # reconnect
2097 run_test 84 "stale open during export disconnect"
2099 test_85a() { #bug 16774
2100 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2102 for i in `seq 100`; do
2103 echo "tag-$i" > $DIR/$tfile-$i
2104 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2107 lov_id=`lctl dl | grep "clilov"`
2108 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2109 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2110 echo "before recovery: unused locks count = $count"
2114 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2115 echo "after recovery: unused locks count = $count2"
2117 if [ $count2 -ge $count ]; then
2118 error "unused locks are not canceled"
2121 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2123 test_85b() { #bug 16774
2124 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2126 lfs setstripe -o 0 -c 1 $DIR
2128 for i in `seq 100`; do
2129 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2132 cancel_lru_locks osc
2134 for i in `seq 100`; do
2135 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2138 lov_id=`lctl dl | grep "clilov"`
2139 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2140 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2141 echo "before recovery: unused locks count = $count"
2145 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2146 echo "after recovery: unused locks count = $count2"
2148 if [ $count2 -ge $count ]; then
2149 error "unused locks are not canceled"
2152 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2154 equals_msg `basename $0`: test complete, cleaning up
2155 check_and_cleanup_lustre
2156 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true