7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
19 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
23 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
25 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
26 CONFIG_EXCEPTIONS="0b 42 47 61a 61c"
27 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
28 echo "Except the tests: $CONFIG_EXCEPTIONS"
29 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
32 # 63 min 7 min AT AT AT AT"
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
37 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]*
44 test_0a() { # was test_0
48 run_test 0a "empty replay"
51 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
53 # this test attempts to trigger a race in the precreation code,
54 # and must run before any other objects are created on the filesystem
56 createmany -o $DIR/$tfile 20 || return 1
57 unlinkmany $DIR/$tfile 20 || return 2
59 run_test 0b "ensure object created after recover exists. (3284)"
65 zconf_mount `hostname` $DIR || error "mount fails"
66 df $DIR || error "post-failover df failed"
68 run_test 0c "expired recovery with no clients"
74 $CHECKSTAT -t file $DIR/$tfile || return 1
77 run_test 1 "simple create"
83 $CHECKSTAT -t file $DIR/$tfile || return 1
93 $CHECKSTAT -t file $DIR/$tfile || return 1
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 df -P $DIR || df -P $DIR || true # reconnect
413 fail mds # start orphan recovery
414 df -P $DIR || df -P $DIR || true # reconnect
415 wait_recovery_complete mds || error "MDS recovery not done"
417 # For interop with 2.0 only:
418 # FIXME just because recovery is done doesn't mean we've finished
419 # orphan cleanup. Fake it with a sleep for now...
422 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
423 log "before $BEFOREUSED, after $AFTERUSED"
424 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
425 error "after $AFTERUSED > before $BEFOREUSED" && return 5
428 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
430 test_20c() { # bug 10480
431 multiop $DIR/$tfile Ow_c &
433 # give multiop a chance to open
440 df -P $DIR || df -P $DIR || true # reconnect
443 test -s $DIR/$tfile || error "File was truncated"
445 wait $pid || return 1
448 run_test 20c "check that client eviction does not affect file content"
452 multiop_bg_pause $DIR/$tfile O_tSc || return 5
455 touch $DIR/g11 || return 1
459 wait $pid || return 2
460 [ -e $DIR/$tfile ] && return 3
461 touch $DIR/h11 || return 4
464 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
467 multiop_bg_pause $DIR/$tfile O_tSc || return 3
475 wait $pid || return 1
476 [ -e $DIR/$tfile ] && return 2
479 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
482 multiop_bg_pause $DIR/$tfile O_tSc || return 5
487 touch $DIR/g11 || return 1
491 wait $pid || return 2
492 [ -e $DIR/$tfile ] && return 3
493 touch $DIR/h11 || return 4
496 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
499 multiop_bg_pause $DIR/$tfile O_tSc || return 3
506 wait $pid || return 1
507 [ -e $DIR/$tfile ] && return 2
510 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
513 multiop_bg_pause $DIR/$tfile O_tSc || return 3
520 wait $pid || return 1
521 [ -e $DIR/$tfile ] && return 2
524 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
528 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
530 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
535 wait $pid2 || return 1
539 wait $pid1 || return 2
540 [ -e $DIR/$tfile-1 ] && return 3
541 [ -e $DIR/$tfile-2 ] && return 4
544 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
548 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
550 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
557 wait $pid1 || return 1
559 wait $pid2 || return 2
560 [ -e $DIR/$tfile-1 ] && return 3
561 [ -e $DIR/$tfile-2 ] && return 4
564 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
567 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
569 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
575 wait $pid2 || return 1
579 wait $pid1 || return 2
580 [ -e $DIR/$tfile-1 ] && return 3
581 [ -e $DIR/$tfile-2 ] && return 4
584 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
587 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
589 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
597 wait $pid1 || return 1
599 wait $pid2 || return 2
600 [ -e $DIR/$tfile-1 ] && return 3
601 [ -e $DIR/$tfile-2 ] && return 4
604 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
607 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
609 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
617 wait $pid1 || return 1
619 wait $pid2 || return 2
620 [ -e $DIR/$tfile-1 ] && return 3
621 [ -e $DIR/$tfile-2 ] && return 4
624 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
627 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
629 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
637 wait $pid1 || return 1
639 wait $pid2 || return 2
640 [ -e $DIR/$tfile-1 ] && return 3
641 [ -e $DIR/$tfile-2 ] && return 4
644 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
646 # tests for bug 2104; completion without crashing is success. The close is
647 # stale, but we always return 0 for close, so the app never sees it.
649 multiop_bg_pause $DIR/$tfile O_c || return 2
651 multiop_bg_pause $DIR/$tfile O_c || return 3
654 df $MOUNT || sleep 1 && df $MOUNT || return 1
657 wait $pid1 || return 4
658 wait $pid2 || return 5
661 run_test 32 "close() notices client eviction; close() after client eviction"
663 # Abort recovery before client complete
664 test_33a() { # was test_33
666 createmany -o $DIR/$tfile-%d 100
668 # this file should be gone, because the replay was aborted
669 $CHECKSTAT -t file $DIR/$tfile-* && return 3
670 unlinkmany $DIR/$tfile-%d 0 100
673 run_test 33a "abort recovery before client does replay"
676 multiop_bg_pause $DIR/$tfile O_c || return 2
683 wait $pid || return 3
684 [ -e $DIR/$tfile ] && return 1
688 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
690 # bug 2278 - generate one orphan on OST, then destroy it during llog recovery
694 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
695 do_facet mds "lctl set_param fail_loc=0x80000119"
700 # give a chance to remove from MDS
702 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
704 run_test 35 "test recovery from llog for unlink op"
706 # b=2432 resent cancel after replay uses wrong cookie,
707 # so don't resend cancels
711 checkstat $DIR/$tfile
714 if dmesg | grep "unknown lock cookie"; then
715 echo "cancel after replay failed"
719 run_test 36 "don't resend cancel"
722 # directory orphans can't be unlinked from PENDING directory
724 rmdir $DIR/$tfile 2>/dev/null
725 multiop_bg_pause $DIR/$tfile dD_c || return 2
730 # clear the dmesg buffer so we only see errors from this recovery
734 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
735 wait $pid || return 3
739 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
742 createmany -o $DIR/$tfile-%d 800
743 unlinkmany $DIR/$tfile-%d 0 400
746 unlinkmany $DIR/$tfile-%d 400 400
748 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
750 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
752 test_39() { # bug 4176
753 createmany -o $DIR/$tfile-%d 800
755 unlinkmany $DIR/$tfile-%d 0 400
757 unlinkmany $DIR/$tfile-%d 400 400
760 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
762 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
765 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
770 $LCTL mark multiop $MOUNT/$tfile OS_c
771 multiop $MOUNT/$tfile OS_c &
773 writeme -s $MOUNT/${tfile}-2 &
777 #define OBD_FAIL_MDS_CONNECT_NET 0x117
778 do_facet mds "lctl set_param fail_loc=0x80000117"
780 stat1=`count_ost_writes`
782 stat2=`count_ost_writes`
783 echo "$stat1, $stat2"
784 if [ $stat1 -lt $stat2 ]; then
785 echo "writes continuing during recovery"
788 echo "writes not continuing during recovery, bug 2477"
791 echo "waiting for writeme $WRITE_PID"
795 echo "waiting for multiop $PID"
796 wait $PID || return 2
797 do_facet client munlink $MOUNT/$tfile || return 3
798 do_facet client munlink $MOUNT/${tfile}-2 || return 3
801 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
804 # make sure that a read to one osc doesn't try to double-unlock its page just
805 # because another osc is invalid. trigger_group_io used to mistakenly return
806 # an error if any oscs were invalid even after having successfully put rpcs
807 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
808 # the page, guarnateeing that the unlock from the RPC completion would
809 # assert on trying to unlock the unlocked page.
811 [ $OSTCOUNT -lt 2 ] && \
812 skip "skipping test 41: we don't have a second OST to test with" && \
815 local f=$MOUNT/$tfile
816 # make sure the start of the file is ost1
817 lfs setstripe $f -s $((128 * 1024)) -i 0
818 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
820 # fail ost2 and read from ost1
821 local osc2dev=`lctl get_param -n devices | grep ${ost2_svc}-osc- | awk '{print $1}'`
822 [ "$osc2dev" ] || return 4
823 $LCTL --device $osc2dev deactivate || return 1
824 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
825 $LCTL --device $osc2dev activate || return 2
828 run_test 41 "read from a valid osc while other oscs are invalid"
830 # test MDS recovery after ost failure
832 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
833 createmany -o $DIR/$tfile-%d 800
835 unlinkmany $DIR/$tfile-%d 0 400
837 lctl set_param debug=-1
840 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
841 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
842 #[ $blocks_after -lt $blocks ] || return 1
843 echo wait for MDS to timeout and recover
844 sleep $((TIMEOUT * 2))
846 unlinkmany $DIR/$tfile-%d 400 400
847 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
849 run_test 42 "recovery after ost failure"
851 # timeout in MDS/OST recovery RPC will LBUG MDS
852 test_43() { # bug 2530
853 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
857 # OBD_FAIL_OST_CREATE_NET 0x204
858 do_facet ost1 "lctl set_param fail_loc=0x80000204"
861 do_facet ost1 "lctl set_param fail_loc=0"
865 run_test 43 "mds osc import failure during recovery; don't LBUG"
867 test_44a() { # was test_44
870 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
871 [ "$mdcdev" ] || exit 2
873 # adaptive timeouts slow this way down
874 if at_is_enabled; then
875 at_max_saved=$(at_max_get mds)
879 for i in `seq 1 10`; do
880 echo "$i of 10 ($(date +%s))"
881 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
882 #define OBD_FAIL_TGT_CONN_RACE 0x701
883 do_facet mds "lctl set_param fail_loc=0x80000701"
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 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
896 [ "$mdcdev" ] || exit 2
897 for i in `seq 1 10`; do
898 echo "$i of 10 ($(date +%s))"
899 do_facet mds "lctl get_param -n mdt.MDS.mds.timeouts | grep service"
900 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
901 do_facet mds "lctl set_param fail_loc=0x80000704"
902 $LCTL --device $mdcdev recover
905 do_facet mds "lctl set_param fail_loc=0"
908 run_test 44b "race in target handle connect"
910 # Handle failed close
912 mdcdev=`lctl get_param -n devices | awk '/-mdc-/ {print $1}'`
913 [ "$mdcdev" ] || exit 2
914 $LCTL --device $mdcdev recover
916 multiop_bg_pause $DIR/$tfile O_c || return 1
919 # This will cause the CLOSE to fail before even
920 # allocating a reply buffer
921 $LCTL --device $mdcdev deactivate || return 4
925 wait $pid || return 1
927 $LCTL --device $mdcdev activate || return 5
930 $CHECKSTAT -t file $DIR/$tfile || return 2
933 run_test 45 "Handle failed close"
937 drop_reply "touch $DIR/$tfile"
939 # ironically, the previous test, 45, will cause a real forced close,
940 # so just look for one for this test
941 dmesg | grep -i "force closing client file handle for $tfile" && return 1
944 run_test 46 "Don't leak file handle after open resend (3325)"
946 test_47() { # bug 2824
947 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
949 # create some files to make sure precreate has been done on all
950 # OSTs. (just in case this test is run independently)
951 createmany -o $DIR/$tfile 20 || return 1
953 # OBD_FAIL_OST_CREATE_NET 0x204
955 do_facet ost1 "lctl set_param fail_loc=0x80000204"
956 df $MOUNT || return 2
958 # let the MDS discover the OST failure, attempt to recover, fail
960 sleep $((3 * TIMEOUT))
962 # Without 2824, this createmany would hang
963 createmany -o $DIR/$tfile 20 || return 3
964 unlinkmany $DIR/$tfile 20 || return 4
966 do_facet ost1 "lctl set_param fail_loc=0"
969 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
972 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
973 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
976 createmany -o $DIR/$tfile 20 || return 1
978 #define OBD_FAIL_OST_EROFS 0x216
979 do_facet ost1 "lctl set_param fail_loc=0x80000216"
980 df $MOUNT || return 2
982 createmany -o $DIR/$tfile 20 20 || return 2
983 unlinkmany $DIR/$tfile 40 || return 3
986 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
989 multiop $DIR/$tfile O_c &
994 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
995 do_facet mds "lctl set_param fail_loc=0x80000122"
997 do_facet mds "lctl set_param fail_loc=0"
999 replay_barrier_nodf mds
1002 wait $pid || return 1
1003 $CHECKSTAT -t file $DIR/$tfile && return 2
1006 run_test 49a "mds fail after close reply is dropped: open|create "
1010 multiop $DIR/$tfile o_c &
1015 #define OBD_FAIL_MDS_ALL_REPLY_NET 0x122
1016 do_facet mds "lctl set_param fail_loc=0x80000122"
1018 do_facet mds "lctl set_param fail_loc=0"
1020 replay_barrier_nodf mds
1023 wait $pid || return 1
1024 $CHECKSTAT -t file $DIR/$tfile && return 2
1027 run_test 49c "mds fail after close reply is dropped: open"
1030 local oscdev=`do_facet mds lctl get_param -n devices | grep ${ost1_svc}-osc | awk '{print $1}' | head -1`
1031 [ "$oscdev" ] || return 1
1032 do_facet mds $LCTL --device $oscdev recover || return 2
1033 do_facet mds $LCTL --device $oscdev recover || return 3
1034 # give the mds_lov_sync threads a chance to run
1037 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1039 # b3764 timed out lock replay
1042 cancel_lru_locks mdc
1044 multiop $DIR/$tfile s || return 1
1046 #define OBD_FAIL_LDLM_REPLY 0x30c
1047 do_facet mds "lctl set_param fail_loc=0x8000030c"
1048 fail mds || return 2
1049 do_facet mds "lctl set_param fail_loc=0x0"
1051 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1053 run_test 52 "time out lock replay (3764)"
1055 # bug 3462 - simultaneous MDC requests
1057 mkdir -p $DIR/${tdir}-1
1058 mkdir -p $DIR/${tdir}-2
1059 multiop $DIR/${tdir}-1/f O_c &
1061 # give multiop a chance to open
1064 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1065 do_facet mds "lctl set_param fail_loc=0x80000115"
1066 kill -USR1 $close_pid
1067 cancel_lru_locks mdc # force the close
1068 do_facet mds "lctl set_param fail_loc=0"
1069 mcreate $DIR/${tdir}-2/f || return 1
1071 # close should still be here
1072 [ -d /proc/$close_pid ] || return 2
1073 replay_barrier_nodf mds
1075 wait $close_pid || return 3
1077 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1078 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1079 rm -rf $DIR/${tdir}-*
1081 run_test 53a "|X| close request while two MDC requests in flight"
1084 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1086 mkdir -p $DIR/$tdir-1
1087 mkdir -p $DIR/$tdir-2
1088 multiop $DIR/$tdir-1/f O_c &
1091 #define OBD_FAIL_MDS_REINT_NET 0x107
1092 do_facet mds "lctl set_param fail_loc=0x80000107"
1093 mcreate $DIR/${tdir}-2/f &
1097 do_facet mds "lctl set_param fail_loc=0"
1098 kill -USR1 $close_pid
1099 cancel_lru_locks mdc # force the close
1100 wait $close_pid || return 1
1101 # open should still be here
1102 [ -d /proc/$open_pid ] || return 2
1104 replay_barrier_nodf mds
1106 wait $open_pid || return 3
1108 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1109 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1110 rm -rf $DIR/${tdir}-*
1112 run_test 53b "|X| open request while two MDC requests in flight"
1115 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1117 mkdir -p $DIR/${tdir}-1
1118 mkdir -p $DIR/${tdir}-2
1119 multiop $DIR/${tdir}-1/f O_c &
1122 #define OBD_FAIL_MDS_REINT_NET 0x107
1123 do_facet mds "lctl set_param fail_loc=0x80000107"
1124 mcreate $DIR/${tdir}-2/f &
1128 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1129 do_facet mds "lctl set_param fail_loc=0x80000115"
1130 kill -USR1 $close_pid
1131 cancel_lru_locks mdc # force the close
1133 replay_barrier_nodf mds
1135 wait $open_pid || return 1
1137 # close should be gone
1138 [ -d /proc/$close_pid ] && return 2
1139 do_facet mds "lctl set_param fail_loc=0"
1141 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1142 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1143 rm -rf $DIR/${tdir}-*
1145 run_test 53c "|X| open request and close request while two MDC requests in flight"
1148 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1150 mkdir -p $DIR/${tdir}-1
1151 mkdir -p $DIR/${tdir}-2
1152 multiop $DIR/${tdir}-1/f O_c &
1154 # give multiop a chance to open
1157 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1158 do_facet mds "lctl set_param fail_loc=0x8000013b"
1159 kill -USR1 $close_pid
1160 cancel_lru_locks mdc # force the close
1161 do_facet mds "lctl set_param fail_loc=0"
1162 mcreate $DIR/${tdir}-2/f || return 1
1164 # close should still be here
1165 [ -d /proc/$close_pid ] || return 2
1166 replay_barrier_nodf mds
1168 wait $close_pid || return 3
1170 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1171 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1172 rm -rf $DIR/${tdir}-*
1174 run_test 53d "|X| close reply while two MDC requests in flight"
1177 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1179 mkdir -p $DIR/$tdir-1
1180 mkdir -p $DIR/$tdir-2
1181 multiop $DIR/$tdir-1/f O_c &
1184 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1185 do_facet mds "lctl set_param fail_loc=0x80000119"
1186 mcreate $DIR/${tdir}-2/f &
1190 do_facet mds "lctl set_param fail_loc=0"
1191 kill -USR1 $close_pid
1192 cancel_lru_locks mdc # force the close
1193 wait $close_pid || return 1
1194 # open should still be here
1195 [ -d /proc/$open_pid ] || return 2
1197 replay_barrier_nodf mds
1199 wait $open_pid || return 3
1201 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1202 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1203 rm -rf $DIR/${tdir}-*
1205 run_test 53e "|X| open reply while two MDC requests in flight"
1208 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1210 mkdir -p $DIR/${tdir}-1
1211 mkdir -p $DIR/${tdir}-2
1212 multiop $DIR/${tdir}-1/f O_c &
1215 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1216 do_facet mds "lctl set_param fail_loc=0x80000119"
1217 mcreate $DIR/${tdir}-2/f &
1221 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1222 do_facet mds "lctl set_param fail_loc=0x8000013b"
1223 kill -USR1 $close_pid
1224 cancel_lru_locks mdc
1226 replay_barrier_nodf mds
1228 wait $open_pid || return 1
1230 #close should be gone
1231 [ -d /proc/$close_pid ] && return 2
1232 do_facet mds "lctl set_param fail_loc=0"
1234 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1235 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1236 rm -rf $DIR/${tdir}-*
1238 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1241 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1243 mkdir -p $DIR/${tdir}-1
1244 mkdir -p $DIR/${tdir}-2
1245 multiop $DIR/${tdir}-1/f O_c &
1248 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1249 do_facet mds "lctl set_param fail_loc=0x80000119"
1250 mcreate $DIR/${tdir}-2/f &
1254 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1255 do_facet mds "lctl set_param fail_loc=0x80000115"
1256 kill -USR1 $close_pid
1257 cancel_lru_locks mdc # force the close
1259 do_facet mds "lctl set_param fail_loc=0"
1260 replay_barrier_nodf mds
1262 wait $open_pid || return 1
1264 # close should be gone
1265 [ -d /proc/$close_pid ] && return 2
1267 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1268 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1269 rm -rf $DIR/${tdir}-*
1271 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1274 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1276 mkdir -p $DIR/${tdir}-1
1277 mkdir -p $DIR/${tdir}-2
1278 multiop $DIR/${tdir}-1/f O_c &
1281 #define OBD_FAIL_MDS_REINT_NET 0x107
1282 do_facet mds "lctl set_param fail_loc=0x80000107"
1283 mcreate $DIR/${tdir}-2/f &
1287 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1288 do_facet mds "lctl set_param fail_loc=0x8000013b"
1289 kill -USR1 $close_pid
1290 cancel_lru_locks mdc # force the close
1293 replay_barrier_nodf mds
1295 wait $open_pid || return 1
1297 # close should be gone
1298 [ -d /proc/$close_pid ] && return 2
1299 do_facet mds "lctl set_param fail_loc=0"
1301 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1302 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1303 rm -rf $DIR/${tdir}-*
1305 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1307 #b3761 ASSERTION(hash != 0) failed
1309 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1310 do_facet mds "lctl set_param fail_loc=0x8000012b"
1312 # give touch a chance to run
1314 do_facet mds "lctl set_param fail_loc=0x0"
1318 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1320 #b3440 ASSERTION(rec->ur_fid2->id) failed
1322 ln -s foo $DIR/$tfile
1324 #drop_reply "cat $DIR/$tfile"
1328 run_test 56 "don't replay a symlink open request (3440)"
1330 #recovery one mds-ost setattr from llog
1332 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1333 do_facet mds "lctl set_param fail_loc=0x8000012c"
1338 $CHECKSTAT -t file $DIR/$tfile || return 1
1339 do_facet mds "lctl set_param fail_loc=0x0"
1342 run_test 57 "test recovery from llog for setattr op"
1344 #recovery many mds-ost setattr from llog
1347 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1348 do_facet mds "lctl set_param fail_loc=0x8000012c"
1349 createmany -o $DIR/$tdir/$tfile-%d 2500
1353 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1354 do_facet mds "lctl set_param fail_loc=0x0"
1355 unlinkmany $DIR/$tdir/$tfile-%d 2500
1358 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1361 mount_client $MOUNT2
1363 touch $DIR/$tdir/$tfile
1365 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1367 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1368 [ x$VAL = x"bar" ] || return 1
1369 rm -f $DIR/$tdir/$tfile
1371 zconf_umount `hostname` $MOUNT2
1373 run_test 58b "test replay of setxattr op"
1375 test_58c() { # bug 16570
1376 mount_client $MOUNT2
1378 touch $DIR/$tdir/$tfile
1379 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1381 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1382 [ x$VAL = x"bar" ] || return 2
1383 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1385 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1386 [ x$VAL = x"bar1" ] || return 4
1387 rm -f $DIR/$tdir/$tfile
1389 zconf_umount `hostname` $MOUNT2
1391 run_test 58c "resend/reconstruct setxattr op"
1393 # log_commit_thread vs filter_destroy race used to lead to import use after free
1396 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1399 createmany -o $DIR/$tdir/$tfile-%d 200
1401 unlinkmany $DIR/$tdir/$tfile-%d 200
1402 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1403 do_facet ost1 "lctl set_param fail_loc=0x507"
1406 do_facet ost1 "lctl set_param fail_loc=0x0"
1410 run_test 59 "test log_commit_thread vs filter_destroy race"
1412 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1413 # bug 12086: should no oops and No ctxt error for this test
1416 createmany -o $DIR/$tdir/$tfile-%d 200
1418 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1420 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1421 local no_ctxt=`dmesg | grep "No ctxt"`
1422 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1424 run_test 60 "test llog post recovery init vs llog unlink"
1426 #test race llog recovery thread vs llog cleanup
1428 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1431 createmany -o $DIR/$tdir/$tfile-%d 800
1433 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1434 unlinkmany $DIR/$tdir/$tfile-%d 800
1435 do_facet ost "lctl set_param fail_loc=0x80000221"
1440 do_facet ost "lctl set_param fail_loc=0x0"
1441 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1444 run_test 61a "test race llog recovery vs llog cleanup"
1446 #test race mds llog sync vs llog cleanup
1448 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1449 do_facet mds "lctl set_param fail_loc=0x8000013a"
1453 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1455 run_test 61b "test race mds llog sync vs llog cleanup"
1457 #test race cancel cookie cb vs llog cleanup
1459 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1461 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1463 do_facet ost "lctl set_param fail_loc=0x80000222"
1468 run_test 61c "test race mds llog sync vs llog cleanup"
1470 test_61d() { # bug 16002
1471 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1473 do_facet mds "lctl set_param fail_loc=0x80000605"
1474 start mds $MDSDEV $MDS_MOUNT_OPTS && error "mds start should have failed"
1475 do_facet mds "lctl set_param fail_loc=0"
1476 start mds $MDSDEV $MDS_MOUNT_OPTS || error "cannot restart mds"
1478 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1480 test_62() { # Bug 15756 - don't mis-drop resent replay
1483 createmany -o $DIR/$tdir/$tfile- 25
1484 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1485 do_facet mds "lctl set_param fail_loc=0x80000707"
1487 df $MOUNT || return 1
1488 do_facet mds "lctl set_param fail_loc=0"
1489 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1492 run_test 62 "don't mis-drop resent replay"
1494 #Adaptive Timeouts (bug 3055)
1502 echo "Cleaning up AT ..."
1503 if [ -n "$ATOLDBASE" ]; then
1504 local at_history=$($LCTL get_param -n at_history)
1505 do_facet mds "lctl set_param at_history=$at_history" || true
1506 do_facet ost1 "lctl set_param at_history=$at_history" || true
1509 if [ $AT_MAX_SET -ne 0 ]; then
1510 for facet in mds client ost; do
1511 var=AT_MAX_SAVE_${facet}
1512 echo restore AT on $facet to saved value ${!var}
1513 at_max_set ${!var} $facet
1514 at_new=$(at_max_get $facet)
1515 echo Restored AT value on $facet $at_new
1516 [ $at_new -eq ${!var} ] || \
1517 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1524 local at_max_new=600
1526 # Save at_max original values
1528 if [ $AT_MAX_SET -eq 0 ]; then
1529 # Suppose that all osts have the same at_max
1530 for facet in mds client ost; do
1531 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1535 for facet in mds client ost; do
1536 at_max=$(at_max_get $facet)
1537 if [ $at_max -ne $at_max_new ]; then
1538 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1539 at_max_set $at_max_new $facet
1544 if [ -z "$ATOLDBASE" ]; then
1545 ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
1546 # speed up the timebase so we can check decreasing AT
1547 do_facet mds "lctl set_param at_history=8" || true
1548 do_facet ost1 "lctl set_param at_history=8" || true
1550 # sleep for a while to cool down, should be > 8s and also allow
1551 # at least one ping to be sent. simply use TIMEOUT to be safe.
1556 test_65a() #bug 3055
1558 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1560 at_start || return 0
1561 $LCTL dk > /dev/null
1563 lctl set_param debug="+other"
1564 # Slow down a request to the current service time, this is critical
1565 # because previous tests may have caused this value to increase.
1566 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1567 awk '/portal 12/ {print $5}'`
1568 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1570 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1571 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1572 do_facet mds lctl set_param fail_loc=0x8000050a
1573 createmany -o $DIR/$tfile 10 > /dev/null
1574 unlinkmany $DIR/$tfile 10 > /dev/null
1575 # check for log message
1576 $LCTL dk | grep "Early reply #" || error "No early reply"
1577 # client should show REQ_DELAY estimates
1578 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1580 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1582 run_test 65a "AT: verify early replies"
1584 test_65b() #bug 3055
1586 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1588 at_start || return 0
1591 lctl set_param debug="+other"
1592 $LCTL dk > /dev/null
1593 # Slow down a request to the current service time, this is critical
1594 # because previous tests may have caused this value to increase.
1595 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1596 awk '/portal 6/ {print $5}'`
1597 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1599 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1600 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1601 do_facet ost1 lctl set_param fail_loc=0x224
1604 lfs setstripe $DIR/$tfile --index=0 --count=1
1605 # force some real bulk transfer
1606 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1608 do_facet ost1 lctl set_param fail_loc=0
1609 # check for log message
1610 $LCTL dk | grep "Early reply #" || error "No early reply"
1612 # client should show REQ_DELAY estimates
1613 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1615 run_test 65b "AT: verify early replies on packed reply / bulk"
1617 test_66a() #bug 3055
1619 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1621 at_start || return 0
1622 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1623 # adjust 5s at a time so no early reply is sent (within deadline)
1624 do_facet mds "lctl set_param fail_val=5000"
1625 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1626 do_facet mds "lctl set_param fail_loc=0x8000050a"
1627 createmany -o $DIR/$tfile 20 > /dev/null
1628 unlinkmany $DIR/$tfile 20 > /dev/null
1629 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1630 do_facet mds "lctl set_param fail_val=10000"
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_loc=0"
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 | grep "portal 12"
1640 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1641 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1642 echo "Current MDT timeout $CUR, worst $WORST"
1643 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1645 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1647 test_66b() #bug 3055
1649 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1651 at_start || return 0
1652 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1653 lctl set_param fail_val=$(($ORIG + 5))
1654 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1655 lctl set_param fail_loc=0x50c
1656 ls $DIR/$tfile > /dev/null 2>&1
1657 lctl set_param fail_loc=0
1658 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1659 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1660 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1661 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1663 run_test 66b "AT: verify net latency adjusts"
1665 test_67a() #bug 3055
1667 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1669 at_start || return 0
1670 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1671 # sleeping threads may drive values above this
1672 do_facet ost1 "lctl set_param fail_val=400"
1673 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1674 do_facet ost1 "lctl set_param fail_loc=0x50a"
1675 createmany -o $DIR/$tfile 20 > /dev/null
1676 unlinkmany $DIR/$tfile 20 > /dev/null
1677 do_facet ost1 "lctl set_param fail_loc=0"
1678 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1679 ATTEMPTS=$(($CONN2 - $CONN1))
1680 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1681 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1684 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1686 test_67b() #bug 3055
1688 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1690 at_start || return 0
1691 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1692 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1693 do_facet ost1 "lctl set_param fail_val=20000"
1694 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1695 cp /etc/profile $DIR/$tfile || error "cp failed"
1697 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1699 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1700 ATTEMPTS=$(($CONN2 - $CONN1))
1701 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1702 # do it again; should not timeout
1703 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1704 cp /etc/profile $DIR/$tfile || error "cp failed"
1705 do_facet ost1 "lctl set_param fail_loc=0"
1707 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1708 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1709 ATTEMPTS=$(($CONN3 - $CONN2))
1710 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1711 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1714 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1716 test_68 () #bug 13813
1718 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1720 at_start || return 0
1721 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1722 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1723 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1724 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1725 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1726 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1727 echo $TIMEOUT >> $ldlm_enqueue_min
1728 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1732 lfs setstripe $DIR/$tdir --index=0 --count=1
1733 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1734 lctl set_param fail_val=$(($TIMEOUT - 1))
1735 lctl set_param fail_loc=0x80000312
1736 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1737 lctl set_param fail_val=$((TIMEOUT * 5 / 4))
1738 lctl set_param fail_loc=0x80000312
1739 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1740 lctl set_param fail_loc=0
1742 echo $ENQ_MIN >> $ldlm_enqueue_min
1743 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1747 run_test 68 "AT: verify slowing locks"
1750 # end of AT tests includes above lines
1752 # start multi-client tests
1754 [ -z "$CLIENTS" ] && \
1755 { skip "Need two or more clients." && return; }
1756 [ $CLIENTCOUNT -lt 2 ] && \
1757 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1759 echo "mount clients $CLIENTS ..."
1760 zconf_mount_clients $CLIENTS $DIR
1762 local clients=${CLIENTS//,/ }
1763 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1764 for CLIENT in $clients; do
1765 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1766 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1767 error "dd failed on $CLIENT"
1770 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1771 for C in ${CLIENTS//,/ }; do
1772 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1773 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1779 run_test 70a "check multi client t-f"
1782 local clients=${CLIENTS:-$HOSTNAME}
1784 zconf_mount_clients $clients $DIR
1787 [ "$SLOW" = "no" ] && duration=60
1788 local cmd="rundbench 1 -t $duration"
1790 do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1791 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1792 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1795 log "Started rundbench load PID=$PID ..."
1799 START_TS=$(date +%s)
1800 CURRENT_TS=$START_TS
1801 while [ $ELAPSED -lt $duration ]; do
1804 sleep 1 # give clients a time to do operations
1805 # Increment the number of failovers
1806 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1807 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1809 CURRENT_TS=$(date +%s)
1810 ELAPSED=$((CURRENT_TS - START_TS))
1813 wait $PID || error "rundbench load on $CLIENTS failed!"
1815 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1816 # end multi-client tests
1818 # vbr export handling
1820 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1822 UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
1823 echo "Client UUID is $UUID"
1827 zconf_mount `hostname` $DIR || error "mount fails"
1828 df $DIR || error "post-failover df failed"
1829 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
1830 error "no delayed exports"
1831 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1833 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1834 sleep $((NEW_AGE + 2))
1835 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
1836 error "exports didn't expire"
1837 do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
1838 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
1839 error "Export wasn't removed manually"
1840 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1843 run_test 71a "lost client export is kept"
1846 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1849 create_fake_exports mds $FAKE_NUM
1850 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1851 [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
1852 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1854 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1855 sleep $((NEW_AGE + 2))
1856 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1857 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1858 do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
1859 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
1860 error "Exports weren't flushed"
1861 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1864 run_test 71b "stale exports are expired, lctl flushes them"
1867 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1870 create_fake_exports mds $FAKE_NUM
1871 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1872 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1873 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1875 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1876 sleep $((NEW_AGE + 2))
1877 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1878 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1881 zconf_mount `hostname` $DIR || error "mount fails"
1883 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1884 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1885 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1888 run_test 71c "stale exports are expired, new client connection flush them"
1891 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1894 create_fake_exports mds $FAKE_NUM
1895 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1896 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1897 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1899 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
1900 sleep $((NEW_AGE + 2))
1901 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1902 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1906 FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1907 [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
1908 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1909 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1910 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
1913 run_test 71d "expired exports, server init removes them, conf_param works"
1915 # end vbr exports tests
1917 test_72() { #bug 16711
1919 multiop_bg_pause $DIR/$tfile O_c || return 4
1921 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709
1922 do_facet mds "lctl set_param fail_loc=0x80000709"
1924 kill -USR1 $pid || return 1
1925 wait $pid || return 2
1926 $CHECKSTAT -t file $DIR/$tfile || return 3
1928 run_test 72 "target_finish_recovery vs process_recovery_queue race"
1931 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1936 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1937 do_facet mds "lctl set_param fail_loc=0x80000302"
1940 wait $pid || return 1
1941 [ -e $DIR/$tfile ] && return 2
1944 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1947 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1952 #define OBD_FAIL_LDLM_REPLY 0x30c
1953 do_facet mds "lctl set_param fail_loc=0x8000030c"
1956 wait $pid || return 1
1957 [ -e $DIR/$tfile ] && return 2
1960 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1963 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1968 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1969 do_facet mds "lctl set_param fail_loc=0x80000710"
1972 wait $pid || return 1
1973 [ -e $DIR/$tfile ] && return 2
1976 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1979 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1982 lfs setstripe -i 0 -c 1 $DIR/$tfile
1983 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1984 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
1985 cancel_lru_locks osc
1987 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
1988 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
1989 if [ $cksum != $cksum2 ] ; then
1990 error "New checksum $cksum2 does not match original $cksum"
1993 run_test 80a "write replay"
1996 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1999 lfs setstripe -i 0 -c 1 $DIR/$tfile
2000 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2001 sleep 1 # Give it a chance to flush dirty data
2002 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2003 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2004 cancel_lru_locks osc
2006 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2007 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2008 if [ $cksum != $cksum2 ] ; then
2009 error "New checksum $cksum2 does not match original $cksum"
2012 run_test 80b "write replay with changed data (checksum resend)"
2016 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2017 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2018 do_facet mds "lctl set_param fail_loc=0x80000140"
2019 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2021 run_test 81a "fail log_add during unlink recovery"
2025 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2027 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2028 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2029 do_facet mds "lctl set_param fail_loc=0x80000140"
2032 run_test 81b "fail log_add during unlink recovery"
2034 test_82() { #bug 18927
2035 multiop_bg_pause $DIR/$tfile O_c || return 1
2037 multiop_bg_pause $DIR/$tfile o:O_CREAT:O_RDONLY:_c || return 2
2043 wait $pid1 || return 3
2045 wait $pid2 || return 4
2046 [ -e $DIR/$tfile ] && return 5
2049 run_test 82 "second open|creat in replay with open orphan"
2051 test_83() { #bug 19224
2052 #define OBD_FAIL_MDS_SPLIT_OPEN 0x142
2053 do_facet mds "lctl set_param fail_loc=0x80000142"
2054 # open will sleep after first transaction
2058 # set barrier between open transactions
2059 replay_barrier_nodf mds
2060 createmany -o $DIR/$tfile- 10
2061 # open should finish now
2062 wait $PID || return 1
2064 rm $DIR/$tfile || return 2
2065 unlinkmany $DIR/$tfile- 10 || return 3
2068 run_test 83 "open replay with barrier between transactions"
2071 #define OBD_FAIL_OBD_FAIL_MDS_SPLIT_OPEN 0x142
2072 do_facet mds "lctl set_param fail_loc=0x80000142"
2073 createmany -o $DIR/$tfile- 1 &
2078 run_test 84 "stale open during export disconnect"
2080 equals_msg `basename $0`: test complete, cleaning up
2081 check_and_cleanup_lustre
2082 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true