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 "f1c-$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
295 run_test 13 "open chmod 0 |x| write close"
298 multiop_bg_pause $DIR/$tfile O_tSc || return 4
302 kill -USR1 $pid || return 1
303 wait $pid || return 2
306 [ -e $DIR/$tfile ] && return 3
309 run_test 14 "open(O_CREAT), unlink |X| close"
312 multiop_bg_pause $DIR/$tfile O_tSc || return 5
316 touch $DIR/g11 || return 1
318 wait $pid || return 2
321 [ -e $DIR/$tfile ] && return 3
322 touch $DIR/h11 || return 4
325 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
331 mcreate $DIR/$tfile-2
333 [ -e $DIR/$tfile ] && return 1
334 [ -e $DIR/$tfile-2 ] || return 2
335 munlink $DIR/$tfile-2 || return 3
337 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
341 multiop_bg_pause $DIR/$tfile O_c || return 4
344 kill -USR1 $pid || return 1
345 wait $pid || return 2
346 $CHECKSTAT -t file $DIR/$tfile || return 3
349 run_test 17 "|X| open(O_CREAT), |replay| close"
353 multiop_bg_pause $DIR/$tfile O_tSc || return 8
356 touch $DIR/$tfile-2 || return 1
357 echo "pid: $pid will close"
359 wait $pid || return 2
362 [ -e $DIR/$tfile ] && return 3
363 [ -e $DIR/$tfile-2 ] || return 4
364 # this touch frequently fails
365 touch $DIR/$tfile-3 || return 5
366 munlink $DIR/$tfile-2 || return 6
367 munlink $DIR/$tfile-3 || return 7
370 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
372 # bug 1855 (a simpler form of test_11 above)
376 echo "old" > $DIR/$tfile
377 mv $DIR/$tfile $DIR/$tfile-2
378 grep old $DIR/$tfile-2
380 grep old $DIR/$tfile-2 || return 2
382 run_test 19 "|X| mcreate, open, write, rename "
384 test_20a() { # was test_20
386 multiop_bg_pause $DIR/$tfile O_tSc || return 3
392 wait $pid || return 1
393 [ -e $DIR/$tfile ] && return 2
396 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
398 test_20b() { # bug 10480
399 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
401 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
403 while [ ! -e $DIR/$tfile ] ; do
404 sleep 0.060s # give dd a chance to start
407 lfs getstripe $DIR/$tfile || return 1
408 rm -f $DIR/$tfile || return 2 # make it an orphan
410 df -P $DIR || df -P $DIR || true # reconnect
412 fail mds # start orphan recovery
413 df -P $DIR || df -P $DIR || true # reconnect
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
439 df -P $DIR || df -P $DIR || true # reconnect
442 test -s $DIR/$tfile || error "File was truncated"
444 wait $pid || return 1
447 run_test 20c "check that client eviction does not affect file content"
451 multiop_bg_pause $DIR/$tfile O_tSc || return 5
454 touch $DIR/g11 || return 1
458 wait $pid || return 2
459 [ -e $DIR/$tfile ] && return 3
460 touch $DIR/h11 || return 4
463 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
466 multiop_bg_pause $DIR/$tfile O_tSc || return 3
474 wait $pid || return 1
475 [ -e $DIR/$tfile ] && return 2
478 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
481 multiop_bg_pause $DIR/$tfile O_tSc || return 5
486 touch $DIR/g11 || return 1
490 wait $pid || return 2
491 [ -e $DIR/$tfile ] && return 3
492 touch $DIR/h11 || return 4
495 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
498 multiop_bg_pause $DIR/$tfile O_tSc || return 3
505 wait $pid || return 1
506 [ -e $DIR/$tfile ] && return 2
509 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
512 multiop_bg_pause $DIR/$tfile O_tSc || return 3
519 wait $pid || return 1
520 [ -e $DIR/$tfile ] && return 2
523 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
527 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
529 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
534 wait $pid2 || return 1
538 wait $pid1 || return 2
539 [ -e $DIR/$tfile-1 ] && return 3
540 [ -e $DIR/$tfile-2 ] && return 4
543 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
547 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
549 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
556 wait $pid1 || return 1
558 wait $pid2 || return 2
559 [ -e $DIR/$tfile-1 ] && return 3
560 [ -e $DIR/$tfile-2 ] && return 4
563 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
566 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
568 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
574 wait $pid2 || return 1
578 wait $pid1 || return 2
579 [ -e $DIR/$tfile-1 ] && return 3
580 [ -e $DIR/$tfile-2 ] && return 4
583 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
586 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
588 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
596 wait $pid1 || return 1
598 wait $pid2 || return 2
599 [ -e $DIR/$tfile-1 ] && return 3
600 [ -e $DIR/$tfile-2 ] && return 4
603 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
606 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
608 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
616 wait $pid1 || return 1
618 wait $pid2 || return 2
619 [ -e $DIR/$tfile-1 ] && return 3
620 [ -e $DIR/$tfile-2 ] && return 4
623 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
626 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
628 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
636 wait $pid1 || return 1
638 wait $pid2 || return 2
639 [ -e $DIR/$tfile-1 ] && return 3
640 [ -e $DIR/$tfile-2 ] && return 4
643 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
645 # tests for bug 2104; completion without crashing is success. The close is
646 # stale, but we always return 0 for close, so the app never sees it.
648 multiop_bg_pause $DIR/$tfile O_c || return 2
650 multiop_bg_pause $DIR/$tfile O_c || return 3
653 df $MOUNT || sleep 1 && df $MOUNT || return 1
656 wait $pid1 || return 4
657 wait $pid2 || return 5
660 run_test 32 "close() notices client eviction; close() after client eviction"
662 # Abort recovery before client complete
663 test_33a() { # was test_33
665 createmany -o $DIR/$tfile-%d 100
667 # this file should be gone, because the replay was aborted
668 $CHECKSTAT -t file $DIR/$tfile-* && return 3
669 unlinkmany $DIR/$tfile-%d 0 100
672 run_test 33a "abort recovery before client does replay"
675 multiop_bg_pause $DIR/$tfile O_c || return 2
682 wait $pid || return 3
683 [ -e $DIR/$tfile ] && return 1
687 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
689 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
693 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
694 do_facet mds "lctl set_param fail_loc=0x80000119"
699 # give a chance to remove from MDS
701 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
703 run_test 35 "test recovery from llog for unlink op"
705 # b=2432 resent cancel after replay uses wrong cookie,
706 # so don't resend cancels
710 checkstat $DIR/$tfile
713 if dmesg | grep "unknown lock cookie"; then
714 echo "cancel after replay failed"
718 run_test 36 "don't resend cancel"
721 # directory orphans can't be unlinked from PENDING directory
723 rmdir $DIR/$tfile 2>/dev/null
724 multiop_bg_pause $DIR/$tfile dD_c || return 2
729 # clear the dmesg buffer so we only see errors from this recovery
733 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
734 wait $pid || return 3
738 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
741 createmany -o $DIR/$tfile-%d 800
742 unlinkmany $DIR/$tfile-%d 0 400
745 unlinkmany $DIR/$tfile-%d 400 400
747 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
749 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
751 test_39() { # bug 4176
752 createmany -o $DIR/$tfile-%d 800
754 unlinkmany $DIR/$tfile-%d 0 400
756 unlinkmany $DIR/$tfile-%d 400 400
759 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
761 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
764 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
769 $LCTL mark multiop $MOUNT/$tfile OS_c
770 multiop $MOUNT/$tfile OS_c &
772 writeme -s $MOUNT/${tfile}-2 &
776 #define OBD_FAIL_MDS_CONNECT_NET 0x117
777 do_facet mds "lctl set_param fail_loc=0x80000117"
779 stat1=`count_ost_writes`
781 stat2=`count_ost_writes`
782 echo "$stat1, $stat2"
783 if [ $stat1 -lt $stat2 ]; then
784 echo "writes continuing during recovery"
787 echo "writes not continuing during recovery, bug 2477"
790 echo "waiting for writeme $WRITE_PID"
794 echo "waiting for multiop $PID"
795 wait $PID || return 2
796 do_facet client munlink $MOUNT/$tfile || return 3
797 do_facet client munlink $MOUNT/${tfile}-2 || return 3
800 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_valid && 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
977 # 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=$(do_facet mds "find /sys/ -name at_history")
1505 do_facet mds "echo $ATOLDBASE >> $at_history" || true
1506 do_facet ost1 "echo $ATOLDBASE >> $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
1525 if ! at_is_valid; then
1526 skip "AT env is invalid"
1530 # Save at_max original values
1532 if [ $AT_MAX_SET -eq 0 ]; then
1533 # Suppose that all osts have the same at_max
1534 for facet in mds client ost; do
1535 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1539 for facet in mds client ost; do
1540 at_max=$(at_max_get $facet)
1541 if [ $at_max -ne $at_max_new ]; then
1542 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1543 at_max_set $at_max_new $facet
1548 if [ -z "$ATOLDBASE" ]; then
1549 local at_history=$(do_facet mds "find /sys/ -name at_history")
1550 [ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
1551 ATOLDBASE=$(do_facet mds "cat $at_history")
1552 # speed up the timebase so we can check decreasing AT
1553 do_facet mds "echo 8 >> $at_history"
1554 do_facet ost1 "echo 8 >> $at_history"
1556 # sleep for a while to cool down, should be > 8s and also allow
1557 # at least one ping to be sent. simply use TIMEOUT to be safe.
1562 test_65a() #bug 3055
1564 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1566 at_start || return 0
1567 $LCTL dk > /dev/null
1569 lctl set_param debug="+other"
1570 # Slow down a request to the current service time, this is critical
1571 # because previous tests may have caused this value to increase.
1572 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1573 awk '/portal 12/ {print $5}'`
1574 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1576 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1577 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1578 do_facet mds lctl set_param fail_loc=0x8000050a
1579 createmany -o $DIR/$tfile 10 > /dev/null
1580 unlinkmany $DIR/$tfile 10 > /dev/null
1581 # check for log message
1582 $LCTL dk | grep "Early reply #" || error "No early reply"
1583 # client should show REQ_DELAY estimates
1584 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1586 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1588 run_test 65a "AT: verify early replies"
1590 test_65b() #bug 3055
1592 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1594 at_start || return 0
1597 lctl set_param debug="+other"
1598 $LCTL dk > /dev/null
1599 # Slow down a request to the current service time, this is critical
1600 # because previous tests may have caused this value to increase.
1601 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1602 awk '/portal 6/ {print $5}'`
1603 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1605 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1606 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1607 do_facet ost1 lctl set_param fail_loc=0x224
1610 lfs setstripe $DIR/$tfile --index=0 --count=1
1611 # force some real bulk transfer
1612 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1614 do_facet ost1 lctl set_param fail_loc=0
1615 # check for log message
1616 $LCTL dk | grep "Early reply #" || error "No early reply"
1618 # client should show REQ_DELAY estimates
1619 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1621 run_test 65b "AT: verify early replies on packed reply / bulk"
1623 test_66a() #bug 3055
1625 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1627 at_start || return 0
1628 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1629 # adjust 5s at a time so no early reply is sent (within deadline)
1630 do_facet mds "lctl set_param fail_val=5000"
1631 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1632 do_facet mds "lctl set_param fail_loc=0x8000050a"
1633 createmany -o $DIR/$tfile 20 > /dev/null
1634 unlinkmany $DIR/$tfile 20 > /dev/null
1635 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1636 do_facet mds "lctl set_param fail_val=10000"
1637 do_facet mds "lctl set_param fail_loc=0x8000050a"
1638 createmany -o $DIR/$tfile 20 > /dev/null
1639 unlinkmany $DIR/$tfile 20 > /dev/null
1640 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1641 do_facet mds "lctl set_param fail_loc=0"
1643 createmany -o $DIR/$tfile 20 > /dev/null
1644 unlinkmany $DIR/$tfile 20 > /dev/null
1645 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal | grep "portal 12"
1646 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1647 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1648 echo "Current MDT timeout $CUR, worst $WORST"
1649 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1651 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1653 test_66b() #bug 3055
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1657 at_start || return 0
1658 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1659 lctl set_param fail_val=$(($ORIG + 5))
1660 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1661 lctl set_param fail_loc=0x50c
1662 ls $DIR/$tfile > /dev/null 2>&1
1663 lctl set_param fail_loc=0
1664 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1665 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1666 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1667 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1669 run_test 66b "AT: verify net latency adjusts"
1671 test_67a() #bug 3055
1673 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1675 at_start || return 0
1676 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1677 # sleeping threads may drive values above this
1678 do_facet ost1 "lctl set_param fail_val=400"
1679 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1680 do_facet ost1 "lctl set_param fail_loc=0x50a"
1681 createmany -o $DIR/$tfile 20 > /dev/null
1682 unlinkmany $DIR/$tfile 20 > /dev/null
1683 do_facet ost1 "lctl set_param fail_loc=0"
1684 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1685 ATTEMPTS=$(($CONN2 - $CONN1))
1686 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1687 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1690 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1692 test_67b() #bug 3055
1694 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1696 at_start || return 0
1697 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1698 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1699 do_facet ost1 "lctl set_param fail_val=20000"
1700 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1701 cp /etc/profile $DIR/$tfile || error "cp failed"
1703 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1705 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1706 ATTEMPTS=$(($CONN2 - $CONN1))
1707 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1708 # do it again; should not timeout
1709 do_facet ost1 "lctl set_param fail_loc=0x80000223"
1710 cp /etc/profile $DIR/$tfile || error "cp failed"
1711 do_facet ost1 "lctl set_param fail_loc=0"
1713 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1714 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1715 ATTEMPTS=$(($CONN3 - $CONN2))
1716 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1717 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1720 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1722 test_68 () #bug 13813
1724 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1726 at_start || return 0
1727 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1728 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1729 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1730 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1731 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1732 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1733 echo $TIMEOUT >> $ldlm_enqueue_min
1734 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1736 rm -f $DIR/${tfile}_[1-2]
1737 lfs setstripe $DIR/$tfile --index=0 --count=1
1738 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1739 lctl set_param fail_val=$(($TIMEOUT - 1))
1740 lctl set_param fail_loc=0x80000312
1741 cp /etc/profile $DIR/${tfile}_1 || error "1st cp failed $?"
1742 lctl set_param fail_val=$((TIMEOUT * 3 / 2))
1743 lctl set_param fail_loc=0x80000312
1744 cp /etc/profile $DIR/${tfile}_2 || error "2nd cp failed $?"
1745 lctl set_param fail_loc=0
1747 echo $ENQ_MIN >> $ldlm_enqueue_min
1748 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1751 run_test 68 "AT: verify slowing locks"
1754 # end of AT tests includes above lines
1756 # start multi-client tests
1758 [ -z "$CLIENTS" ] && \
1759 { skip "Need two or more clients." && return; }
1760 [ $CLIENTCOUNT -lt 2 ] && \
1761 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1763 echo "mount clients $CLIENTS ..."
1764 zconf_mount_clients $CLIENTS $DIR
1766 local clients=${CLIENTS//,/ }
1767 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1768 for CLIENT in $clients; do
1769 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1770 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1771 error "dd failed on $CLIENT"
1774 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1775 for C in ${CLIENTS//,/ }; do
1776 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1777 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1783 run_test 70a "check multi client t-f"
1786 local clients=${CLIENTS:-$HOSTNAME}
1788 zconf_mount_clients $clients $DIR
1791 [ "$SLOW" = "no" ] && duration=60
1792 local cmd="rundbench 1 -t $duration"
1794 do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1795 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1796 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1799 log "Started rundbench load PID=$PID ..."
1801 sleep $((duration / 4))
1803 sleep 3 # give clients a time to do operations
1805 log "$TESTNAME fail mds 1"
1808 wait $PID || error "rundbench load on $CLIENTS failed!"
1811 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1812 # end multi-client tests
1814 # vbr export handling
1816 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1818 UUID=$(lctl dl | awk '/mdc.*-mdc-/ { print $5 }')
1819 echo "Client UUID is $UUID"
1823 zconf_mount `hostname` $DIR || error "mount fails"
1824 df $DIR || error "post-failover df failed"
1825 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" || \
1826 error "no delayed exports"
1827 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1829 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1830 sleep $((NEW_AGE + 2))
1831 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep \"$UUID.*EXPIRED\"" || \
1832 error "exports didn't expire"
1833 do_facet mds "lctl set_param mds.${mds_svc}.evict_client=$UUID"
1834 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep $UUID" && \
1835 error "Export wasn't removed manually"
1836 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1839 run_test 71a "lost client export is kept"
1842 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1845 create_fake_exports mds $FAKE_NUM
1846 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1847 [ $NUM -eq 0 ] && error "no fake exports $NUM - $FAKE_NUM"
1848 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1850 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1851 sleep $((NEW_AGE + 2))
1852 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1853 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1854 do_facet mds "lctl set_param mds.${mds_svc}.flush_stale_exports=1"
1855 do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep EXPIRED" && \
1856 error "Exports weren't flushed"
1857 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1860 run_test 71b "stale exports are expired, lctl flushes them"
1863 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1866 create_fake_exports mds $FAKE_NUM
1867 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1868 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1869 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1871 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$NEW_AGE"
1872 sleep $((NEW_AGE + 2))
1873 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1874 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1877 zconf_mount `hostname` $DIR || error "mount fails"
1879 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1880 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1881 do_facet mds "lctl set_param mds.${mds_svc}.stale_export_age=$OLD_AGE"
1884 run_test 71c "stale exports are expired, new client connection flush them"
1887 delayed_recovery_enabled || { skip "No delayed recovery support"; return 0; }
1890 create_fake_exports mds $FAKE_NUM
1891 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1892 [ "$NUM" -eq "$FAKE_NUM" ] || error "no fake exports $NUM - $FAKE_NUM"
1893 OLD_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1895 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$NEW_AGE"
1896 sleep $((NEW_AGE + 2))
1897 EX_NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|grep -c EXPIRED")
1898 [ "$EX_NUM" -eq "$NUM" ] || error "not all exports are expired $EX_NUM != $NUM"
1902 FAIL_AGE=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_export_age")
1903 [ $FAIL_AGE -eq $NEW_AGE ] || error "new age wasn't set after recovery"
1904 NUM=$(do_facet mds "lctl get_param -n mds.${mds_svc}.stale_exports|wc -l")
1905 [ $NUM -eq 0 ] || error "$NUM fake exports are still exists"
1906 do_facet mds "lctl conf_param ${mds_svc}.mdt.stale_export_age=$OLD_AGE"
1909 run_test 71d "expired exports, server init removes them, conf_param works"
1911 # end vbr exports tests
1913 test_72() { #bug 16711
1915 multiop_bg_pause $DIR/$tfile O_c || return 4
1917 #define OBD_FAIL_TGT_REPLAY_DELAY 0x709
1918 do_facet mds "lctl set_param fail_loc=0x80000709"
1920 kill -USR1 $pid || return 1
1921 wait $pid || return 2
1922 $CHECKSTAT -t file $DIR/$tfile || return 3
1924 run_test 72 "target_finish_recovery vs process_recovery_queue race"
1927 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1932 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1933 do_facet mds "lctl set_param fail_loc=0x80000302"
1936 wait $pid || return 1
1937 [ -e $DIR/$tfile ] && return 2
1940 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1943 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1948 #define OBD_FAIL_LDLM_REPLY 0x30c
1949 do_facet mds "lctl set_param fail_loc=0x8000030c"
1952 wait $pid || return 1
1953 [ -e $DIR/$tfile ] && return 2
1956 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1959 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1964 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1965 do_facet mds "lctl set_param fail_loc=0x80000710"
1968 wait $pid || return 1
1969 [ -e $DIR/$tfile ] && return 2
1972 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1975 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1978 lfs setstripe -i 0 -c 1 $DIR/$tfile
1979 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1980 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
1981 cancel_lru_locks osc
1983 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
1984 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
1985 if [ $cksum != $cksum2 ] ; then
1986 error "New checksum $cksum2 does not match original $cksum"
1989 run_test 80a "write replay"
1992 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
1995 lfs setstripe -i 0 -c 1 $DIR/$tfile
1996 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
1997 sleep 1 # Give it a chance to flush dirty data
1998 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
1999 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2000 cancel_lru_locks osc
2002 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2003 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2004 if [ $cksum != $cksum2 ] ; then
2005 error "New checksum $cksum2 does not match original $cksum"
2008 run_test 80b "write replay with changed data (checksum resend)"
2012 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2013 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2014 do_facet mds "lctl set_param fail_loc=0x80000140"
2015 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2017 run_test 81a "fail log_add during unlink recovery"
2021 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2023 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2024 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2025 do_facet mds "lctl set_param fail_loc=0x80000140"
2028 run_test 81b "fail log_add during unlink recovery"
2031 equals_msg `basename $0`: test complete, cleaning up
2032 check_and_cleanup_lustre
2033 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true