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
22 # bug number: 17466 18857,15962
23 ALWAYS_EXCEPT="61d 33a 33b $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
47 replay_barrier $SINGLEMDS
51 run_test 0a "empty replay"
54 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
56 # this test attempts to trigger a race in the precreation code,
57 # and must run before any other objects are created on the filesystem
59 createmany -o $DIR/$tfile 20 || return 1
60 unlinkmany $DIR/$tfile 20 || return 2
62 run_test 0b "ensure object created after recover exists. (3284)"
68 lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
74 lctl get_param -n seq.cli-srv-$mds-mdc-*.width
77 # This test should pass for single-mds and multi-mds configs.
78 # But for different configurations it tests different things.
82 # (1) fld_create replay should happen;
84 # (2) fld_create replay should not return -EEXISTS, if it does
85 # this means sequence manager recovery code is buggy and allocated
86 # same sequence two times after recovery.
90 # (1) fld_create replay may not happen, because its home MDS is
91 # MDS2 which is not involved to revovery;
93 # (2) as fld_create does not happen on MDS1, it does not make any
96 local label=`mdsdevlabel 1`
97 [ -z "$label" ] && echo "No label for mds1" && return 1
99 replay_barrier $SINGLEMDS
100 local sw=`seq_get_width $label`
102 # make seq manager switch to next sequence each
103 # time as new fid is needed.
104 seq_set_width $label 1
106 # make sure that fld has created at least one new
108 touch $DIR/$tfile || return 2
109 seq_set_width $label $sw
111 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
114 # wait for recovery finish
118 # flush fld cache and dentry cache to make it lookup
119 # created entry instead of revalidating existent one
121 zconf_mount `hostname` $MOUNT
123 # issue lookup which should call fld lookup which
124 # should fail if client did not replay fld create
125 # correctly and server has no fld entry
126 touch $DIR/$tfile || return 3
127 rm $DIR/$tfile || return 4
129 start_full_debug_logging
130 run_test 0c "fld create"
131 stop_full_debug_logging
134 replay_barrier $SINGLEMDS
137 $CHECKSTAT -t file $DIR/$tfile || return 1
140 run_test 1 "simple create"
143 replay_barrier $SINGLEMDS
146 $CHECKSTAT -t file $DIR/$tfile || return 1
153 replay_barrier $SINGLEMDS
156 $CHECKSTAT -t file $DIR/$tfile || return 1
162 local file=$DIR/$tfile
163 replay_barrier $SINGLEMDS
165 openfile -f O_DIRECTORY $file
167 $CHECKSTAT -t file $file || return 2
170 run_test 3a "replay failed open(O_DIRECTORY)"
173 replay_barrier $SINGLEMDS
174 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
175 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
177 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
179 $CHECKSTAT -t file $DIR/$tfile && return 2
182 run_test 3b "replay failed open -ENOMEM"
185 replay_barrier $SINGLEMDS
186 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
187 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
189 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
192 $CHECKSTAT -t file $DIR/$tfile && return 2
195 run_test 3c "replay failed open -ENOMEM"
197 test_4a() { # was test_4
198 replay_barrier $SINGLEMDS
199 for i in `seq 10`; do
200 echo "tag-$i" > $DIR/$tfile-$i
203 for i in `seq 10`; do
204 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
207 run_test 4a "|x| 10 open(O_CREAT)s"
210 replay_barrier $SINGLEMDS
213 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
215 run_test 4b "|x| rm 10 files"
217 # The idea is to get past the first block of precreated files on both
218 # osts, and then replay.
220 replay_barrier $SINGLEMDS
221 for i in `seq 220`; do
222 echo "tag-$i" > $DIR/$tfile-$i
225 for i in `seq 220`; do
226 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
230 # waiting for commitment of removal
232 run_test 5 "|x| 220 open(O_CREAT)"
235 test_6a() { # was test_6
237 replay_barrier $SINGLEMDS
238 mcreate $DIR/$tdir/$tfile
240 $CHECKSTAT -t dir $DIR/$tdir || return 1
241 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
243 # waiting for log process thread
245 run_test 6a "mkdir + contained create"
249 replay_barrier $SINGLEMDS
252 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
254 run_test 6b "|X| rmdir"
258 replay_barrier $SINGLEMDS
259 mcreate $DIR/$tdir/$tfile
261 $CHECKSTAT -t dir $DIR/$tdir || return 1
262 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
265 run_test 7 "mkdir |X| contained create"
268 # make sure no side-effect from previous test.
270 replay_barrier $SINGLEMDS
271 multiop_bg_pause $DIR/$tfile mo_c || return 4
275 $CHECKSTAT -t file $DIR/$tfile || return 1
276 kill -USR1 $MULTIPID || return 2
277 wait $MULTIPID || return 3
280 run_test 8 "creat open |X| close"
283 replay_barrier $SINGLEMDS
285 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
287 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
289 echo " old_inum == $old_inum, new_inum == $new_inum"
290 if [ $old_inum -eq $new_inum ] ;
292 echo " old_inum and new_inum match"
294 echo "!!!! old_inum and new_inum NOT match"
299 run_test 9 "|X| create (same inum/gen)"
303 replay_barrier $SINGLEMDS
304 mv $DIR/$tfile $DIR/$tfile-2
307 $CHECKSTAT $DIR/$tfile && return 1
308 $CHECKSTAT $DIR/$tfile-2 ||return 2
312 run_test 10 "create |X| rename unlink"
316 echo "old" > $DIR/$tfile
317 mv $DIR/$tfile $DIR/$tfile-2
318 replay_barrier $SINGLEMDS
319 echo "new" > $DIR/$tfile
321 grep old $DIR/$tfile-2
323 grep new $DIR/$tfile || return 1
324 grep old $DIR/$tfile-2 || return 2
326 run_test 11 "create open write rename |X| create-old-name read"
330 multiop_bg_pause $DIR/$tfile o_tSc || return 3
333 replay_barrier $SINGLEMDS
335 wait $pid || return 1
338 [ -e $DIR/$tfile ] && return 2
341 run_test 12 "open, unlink |X| close"
344 # 1777 - replay open after committed chmod that would make
345 # a regular open a failure
348 multiop_bg_pause $DIR/$tfile O_wc || return 3
351 $CHECKSTAT -p 0 $DIR/$tfile
352 replay_barrier $SINGLEMDS
355 wait $pid || return 1
357 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
358 rm $DIR/$tfile || return 4
361 run_test 13 "open chmod 0 |x| write close"
364 multiop_bg_pause $DIR/$tfile O_tSc || return 4
367 replay_barrier $SINGLEMDS
368 kill -USR1 $pid || return 1
369 wait $pid || return 2
372 [ -e $DIR/$tfile ] && return 3
375 run_test 14 "open(O_CREAT), unlink |X| close"
378 multiop_bg_pause $DIR/$tfile O_tSc || return 5
381 replay_barrier $SINGLEMDS
382 touch $DIR/g11 || return 1
384 wait $pid || return 2
387 [ -e $DIR/$tfile ] && return 3
388 touch $DIR/h11 || return 4
391 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
395 replay_barrier $SINGLEMDS
398 mcreate $DIR/$tfile-2
400 [ -e $DIR/$tfile ] && return 1
401 [ -e $DIR/$tfile-2 ] || return 2
402 munlink $DIR/$tfile-2 || return 3
404 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
407 replay_barrier $SINGLEMDS
408 multiop_bg_pause $DIR/$tfile O_c || return 4
411 kill -USR1 $pid || return 1
412 wait $pid || return 2
413 $CHECKSTAT -t file $DIR/$tfile || return 3
416 run_test 17 "|X| open(O_CREAT), |replay| close"
419 replay_barrier $SINGLEMDS
420 multiop_bg_pause $DIR/$tfile O_tSc || return 8
423 touch $DIR/$tfile-2 || return 1
424 echo "pid: $pid will close"
426 wait $pid || return 2
429 [ -e $DIR/$tfile ] && return 3
430 [ -e $DIR/$tfile-2 ] || return 4
431 # this touch frequently fails
432 touch $DIR/$tfile-3 || return 5
433 munlink $DIR/$tfile-2 || return 6
434 munlink $DIR/$tfile-3 || return 7
437 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
439 # bug 1855 (a simpler form of test_11 above)
441 replay_barrier $SINGLEMDS
443 echo "old" > $DIR/$tfile
444 mv $DIR/$tfile $DIR/$tfile-2
445 grep old $DIR/$tfile-2
447 grep old $DIR/$tfile-2 || return 2
449 run_test 19 "|X| mcreate, open, write, rename "
451 test_20a() { # was test_20
452 replay_barrier $SINGLEMDS
453 multiop_bg_pause $DIR/$tfile O_tSc || return 3
459 wait $pid || return 1
460 [ -e $DIR/$tfile ] && return 2
463 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
465 test_20b() { # bug 10480
466 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
468 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
470 while [ ! -e $DIR/$tfile ] ; do
471 usleep 60 # give dd a chance to start
474 lfs getstripe $DIR/$tfile || return 1
475 rm -f $DIR/$tfile || return 2 # make it an orphan
477 client_up || client_up || true # reconnect
479 fail $SINGLEMDS # start orphan recovery
480 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
481 wait_mds_ost_sync || return 3
482 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
483 log "before $BEFOREUSED, after $AFTERUSED"
484 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
485 error "after $AFTERUSED > before $BEFOREUSED"
488 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
490 test_20c() { # bug 10480
491 multiop_bg_pause $DIR/$tfile Ow_c || return 1
497 client_up || client_up || true # reconnect
500 wait $pid || return 1
501 [ -s $DIR/$tfile ] || error "File was truncated"
505 run_test 20c "check that client eviction does not affect file content"
508 replay_barrier $SINGLEMDS
509 multiop_bg_pause $DIR/$tfile O_tSc || return 5
512 touch $DIR/g11 || return 1
516 wait $pid || return 2
517 [ -e $DIR/$tfile ] && return 3
518 touch $DIR/h11 || return 4
521 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
524 multiop_bg_pause $DIR/$tfile O_tSc || return 3
527 replay_barrier $SINGLEMDS
532 wait $pid || return 1
533 [ -e $DIR/$tfile ] && return 2
536 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
539 multiop_bg_pause $DIR/$tfile O_tSc || return 5
542 replay_barrier $SINGLEMDS
544 touch $DIR/g11 || return 1
548 wait $pid || return 2
549 [ -e $DIR/$tfile ] && return 3
550 touch $DIR/h11 || return 4
553 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
556 multiop_bg_pause $DIR/$tfile O_tSc || return 3
559 replay_barrier $SINGLEMDS
563 wait $pid || return 1
564 [ -e $DIR/$tfile ] && return 2
567 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
570 multiop_bg_pause $DIR/$tfile O_tSc || return 3
574 replay_barrier $SINGLEMDS
577 wait $pid || return 1
578 [ -e $DIR/$tfile ] && return 2
581 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
584 replay_barrier $SINGLEMDS
585 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
587 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
592 wait $pid2 || return 1
596 wait $pid1 || return 2
597 [ -e $DIR/$tfile-1 ] && return 3
598 [ -e $DIR/$tfile-2 ] && return 4
601 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
604 replay_barrier $SINGLEMDS
605 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
607 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
614 wait $pid1 || return 1
616 wait $pid2 || return 2
617 [ -e $DIR/$tfile-1 ] && return 3
618 [ -e $DIR/$tfile-2 ] && return 4
621 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
624 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
626 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
628 replay_barrier $SINGLEMDS
632 wait $pid2 || return 1
636 wait $pid1 || return 2
637 [ -e $DIR/$tfile-1 ] && return 3
638 [ -e $DIR/$tfile-2 ] && return 4
641 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
644 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
646 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
648 replay_barrier $SINGLEMDS
654 wait $pid1 || return 1
656 wait $pid2 || return 2
657 [ -e $DIR/$tfile-1 ] && return 3
658 [ -e $DIR/$tfile-2 ] && return 4
661 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
664 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
666 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
671 replay_barrier $SINGLEMDS
674 wait $pid1 || return 1
676 wait $pid2 || return 2
677 [ -e $DIR/$tfile-1 ] && return 3
678 [ -e $DIR/$tfile-2 ] && return 4
681 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
684 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
686 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
690 replay_barrier $SINGLEMDS
694 wait $pid1 || return 1
696 wait $pid2 || return 2
697 [ -e $DIR/$tfile-1 ] && return 3
698 [ -e $DIR/$tfile-2 ] && return 4
701 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
703 # tests for bug 2104; completion without crashing is success. The close is
704 # stale, but we always return 0 for close, so the app never sees it.
706 multiop_bg_pause $DIR/$tfile O_c || return 2
708 multiop_bg_pause $DIR/$tfile O_c || return 3
711 client_up || client_up || return 1
714 wait $pid1 || return 4
715 wait $pid2 || return 5
718 run_test 32 "close() notices client eviction; close() after client eviction"
720 # Abort recovery before client complete
721 test_33a() { # was test_33
722 replay_barrier $SINGLEMDS
723 createmany -o $DIR/$tfile-%d 100
724 fail_abort $SINGLEMDS
725 # this file should be gone, because the replay was aborted
726 $CHECKSTAT -t file $DIR/$tfile-* && return 3
727 unlinkmany $DIR/$tfile-%d 0 100
730 run_test 33a "abort recovery before client does replay"
732 # Stale FID sequence bug 15962
733 test_33b() { # was test_33a
734 replay_barrier $SINGLEMDS
735 createmany -o $DIR/$tfile-%d 10
736 fail_abort $SINGLEMDS
737 unlinkmany $DIR/$tfile-%d 0 10
738 # recreate shouldn't fail
739 createmany -o $DIR/$tfile-%d 10 || return 3
740 unlinkmany $DIR/$tfile-%d 0 10
743 run_test 33b "fid shouldn't be reused after abort recovery"
746 multiop_bg_pause $DIR/$tfile O_c || return 2
750 replay_barrier $SINGLEMDS
751 fail_abort $SINGLEMDS
753 wait $pid || return 3
754 [ -e $DIR/$tfile ] && return 1
758 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
760 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
764 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
765 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
770 # give a chance to remove from MDS
771 fail_abort $SINGLEMDS
772 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
774 run_test 35 "test recovery from llog for unlink op"
776 # b=2432 resent cancel after replay uses wrong cookie,
777 # so don't resend cancels
779 replay_barrier $SINGLEMDS
781 checkstat $DIR/$tfile
782 facet_failover $SINGLEMDS
784 if dmesg | grep "unknown lock cookie"; then
785 echo "cancel after replay failed"
789 run_test 36 "don't resend cancel"
792 # directory orphans can't be unlinked from PENDING directory
794 rmdir $DIR/$tfile 2>/dev/null
795 multiop_bg_pause $DIR/$tfile dD_c || return 2
799 replay_barrier $SINGLEMDS
800 # clear the dmesg buffer so we only see errors from this recovery
802 fail_abort $SINGLEMDS
804 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
805 wait $pid || return 3
809 start_full_debug_logging
810 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
811 stop_full_debug_logging
814 createmany -o $DIR/$tfile-%d 800
815 unlinkmany $DIR/$tfile-%d 0 400
816 replay_barrier $SINGLEMDS
818 unlinkmany $DIR/$tfile-%d 400 400
820 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
822 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
824 test_39() { # bug 4176
825 createmany -o $DIR/$tfile-%d 800
826 replay_barrier $SINGLEMDS
827 unlinkmany $DIR/$tfile-%d 0 400
829 unlinkmany $DIR/$tfile-%d 400 400
831 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
833 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
836 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
841 $LCTL mark multiop $MOUNT/$tfile OS_c
842 multiop $MOUNT/$tfile OS_c &
844 writeme -s $MOUNT/${tfile}-2 &
847 facet_failover $SINGLEMDS
848 #define OBD_FAIL_MDS_CONNECT_NET 0x117
849 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
851 stat1=`count_ost_writes`
853 stat2=`count_ost_writes`
854 echo "$stat1, $stat2"
855 if [ $stat1 -lt $stat2 ]; then
856 echo "writes continuing during recovery"
859 echo "writes not continuing during recovery, bug 2477"
862 echo "waiting for writeme $WRITE_PID"
866 echo "waiting for multiop $PID"
867 wait $PID || return 2
868 do_facet client munlink $MOUNT/$tfile || return 3
869 do_facet client munlink $MOUNT/${tfile}-2 || return 3
872 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
876 # make sure that a read to one osc doesn't try to double-unlock its page just
877 # because another osc is invalid. trigger_group_io used to mistakenly return
878 # an error if any oscs were invalid even after having successfully put rpcs
879 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
880 # the page, guarnateeing that the unlock from the RPC completion would
881 # assert on trying to unlock the unlocked page.
883 [ $OSTCOUNT -lt 2 ] && \
884 skip_env "skipping test 41: we don't have a second OST to test with" && \
887 local f=$MOUNT/$tfile
888 # make sure the start of the file is ost1
889 lfs setstripe $f -s $((128 * 1024)) -i 0
890 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
892 # fail ost2 and read from ost1
893 local osc2dev=`do_facet $SINGLEMDS "lctl get_param -n devices | grep ${ost2_svc}-osc-MDT0000" | awk '{print $1}'`
894 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
895 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
896 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
897 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
900 run_test 41 "read from a valid osc while other oscs are invalid"
902 # test MDS recovery after ost failure
904 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
905 createmany -o $DIR/$tfile-%d 800
907 unlinkmany $DIR/$tfile-%d 0 400
909 lctl set_param debug=-1
912 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
913 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
914 #[ $blocks_after -lt $blocks ] || return 1
915 echo wait for MDS to timeout and recover
916 sleep $((TIMEOUT * 2))
918 unlinkmany $DIR/$tfile-%d 400 400
919 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
921 run_test 42 "recovery after ost failure"
923 # timeout in MDS/OST recovery RPC will LBUG MDS
924 test_43() { # bug 2530
925 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
927 replay_barrier $SINGLEMDS
929 # OBD_FAIL_OST_CREATE_NET 0x204
930 do_facet ost1 "lctl set_param fail_loc=0x80000204"
933 do_facet ost1 "lctl set_param fail_loc=0"
937 run_test 43 "mds osc import failure during recovery; don't LBUG"
939 test_44a() { # was test_44
942 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
943 [ "$mdcdev" ] || return 2
944 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
946 # adaptive timeouts slow this way down
947 if at_is_enabled; then
948 at_max_saved=$(at_max_get mds)
952 for i in `seq 1 10`; do
953 echo "$i of 10 ($(date +%s))"
954 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
955 #define OBD_FAIL_TGT_CONN_RACE 0x701
956 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
957 # lctl below may fail, it is valid case
958 $LCTL --device $mdcdev recover
961 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
962 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
965 run_test 44a "race in target handle connect"
968 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
969 [ "$mdcdev" ] || return 2
970 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
972 for i in `seq 1 10`; do
973 echo "$i of 10 ($(date +%s))"
974 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
975 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
976 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
977 # lctl below may fail, it is valid case
978 $LCTL --device $mdcdev recover
981 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
984 run_test 44b "race in target handle connect"
986 # Handle failed close
988 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
989 [ "$mdcdev" ] || return 2
990 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
992 $LCTL --device $mdcdev recover || return 6
994 multiop_bg_pause $DIR/$tfile O_c || return 1
997 # This will cause the CLOSE to fail before even
998 # allocating a reply buffer
999 $LCTL --device $mdcdev deactivate || return 4
1003 wait $pid || return 1
1005 $LCTL --device $mdcdev activate || return 5
1008 $CHECKSTAT -t file $DIR/$tfile || return 2
1011 run_test 45 "Handle failed close"
1015 drop_reply "touch $DIR/$tfile"
1017 # ironically, the previous test, 45, will cause a real forced close,
1018 # so just look for one for this test
1019 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1022 run_test 46 "Don't leak file handle after open resend (3325)"
1024 test_47() { # bug 2824
1025 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1027 # create some files to make sure precreate has been done on all
1028 # OSTs. (just in case this test is run independently)
1029 createmany -o $DIR/$tfile 20 || return 1
1031 # OBD_FAIL_OST_CREATE_NET 0x204
1033 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1034 client_up || return 2
1036 # let the MDS discover the OST failure, attempt to recover, fail
1037 # and recover again.
1038 sleep $((3 * TIMEOUT))
1040 # Without 2824, this createmany would hang
1041 createmany -o $DIR/$tfile 20 || return 3
1042 unlinkmany $DIR/$tfile 20 || return 4
1044 do_facet ost1 "lctl set_param fail_loc=0"
1047 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1050 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1051 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1053 replay_barrier $SINGLEMDS
1054 createmany -o $DIR/$tfile 20 || return 1
1055 # OBD_FAIL_OST_EROFS 0x216
1056 facet_failover $SINGLEMDS
1057 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1058 client_up || return 2
1060 createmany -o $DIR/$tfile 20 20 || return 2
1061 unlinkmany $DIR/$tfile 40 || return 3
1064 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1067 local oscdev=`do_facet $SINGLEMDS lctl get_param -n devices | grep ${ost1_svc}-osc-MDT0000 | awk '{print $1}'`
1068 [ "$oscdev" ] || return 1
1069 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1070 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1071 # give the mds_lov_sync threads a chance to run
1074 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1076 # b3764 timed out lock replay
1079 cancel_lru_locks mdc
1081 multiop $DIR/$tfile s || return 1
1082 replay_barrier $SINGLEMDS
1083 #define OBD_FAIL_LDLM_REPLY 0x30c
1084 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1085 fail $SINGLEMDS || return 2
1086 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1088 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1090 run_test 52 "time out lock replay (3764)"
1092 # bug 3462 - simultaneous MDC requests
1094 mkdir -p $DIR/${tdir}-1
1095 mkdir -p $DIR/${tdir}-2
1096 multiop $DIR/${tdir}-1/f O_c &
1098 # give multiop a change to open
1101 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1102 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1103 kill -USR1 $close_pid
1104 cancel_lru_locks mdc # force the close
1105 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1107 mcreate $DIR/${tdir}-2/f || return 1
1109 # close should still be here
1110 [ -d /proc/$close_pid ] || return 2
1112 replay_barrier_nodf $SINGLEMDS
1114 wait $close_pid || return 3
1116 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1117 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1118 rm -rf $DIR/${tdir}-*
1120 run_test 53a "|X| close request while two MDC requests in flight"
1123 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1125 mkdir -p $DIR/${tdir}-1
1126 mkdir -p $DIR/${tdir}-2
1127 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1130 #define OBD_FAIL_MDS_REINT_NET 0x107
1131 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1132 mcreate $DIR/${tdir}-2/f &
1136 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1137 kill -USR1 $close_pid
1138 cancel_lru_locks mdc # force the close
1139 wait $close_pid || return 1
1140 # open should still be here
1141 [ -d /proc/$open_pid ] || return 2
1143 replay_barrier_nodf $SINGLEMDS
1145 wait $open_pid || return 3
1147 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1148 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1149 rm -rf $DIR/${tdir}-*
1151 run_test 53b "|X| open request while two MDC requests in flight"
1154 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1156 mkdir -p $DIR/${tdir}-1
1157 mkdir -p $DIR/${tdir}-2
1158 multiop $DIR/${tdir}-1/f O_c &
1161 #define OBD_FAIL_MDS_REINT_NET 0x107
1162 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1163 mcreate $DIR/${tdir}-2/f &
1167 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1168 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1169 kill -USR1 $close_pid
1170 cancel_lru_locks mdc # force the close
1172 replay_barrier_nodf $SINGLEMDS
1173 fail_nodf $SINGLEMDS
1174 wait $open_pid || return 1
1176 # close should be gone
1177 [ -d /proc/$close_pid ] && return 2
1178 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1180 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1181 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1182 rm -rf $DIR/${tdir}-*
1184 run_test 53c "|X| open request and close request while two MDC requests in flight"
1187 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1189 mkdir -p $DIR/${tdir}-1
1190 mkdir -p $DIR/${tdir}-2
1191 multiop $DIR/${tdir}-1/f O_c &
1193 # give multiop a chance to open
1196 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1197 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1198 kill -USR1 $close_pid
1199 cancel_lru_locks mdc # force the close
1200 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1201 mcreate $DIR/${tdir}-2/f || return 1
1203 # close should still be here
1204 [ -d /proc/$close_pid ] || return 2
1206 wait $close_pid || return 3
1208 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1209 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1210 rm -rf $DIR/${tdir}-*
1212 run_test 53d "|X| close reply while two MDC requests in flight"
1215 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1217 mkdir -p $DIR/${tdir}-1
1218 mkdir -p $DIR/${tdir}-2
1219 multiop $DIR/${tdir}-1/f O_c &
1222 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1223 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1224 mcreate $DIR/${tdir}-2/f &
1228 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1229 kill -USR1 $close_pid
1230 cancel_lru_locks mdc # force the close
1231 wait $close_pid || return 1
1232 # open should still be here
1233 [ -d /proc/$open_pid ] || return 2
1235 replay_barrier_nodf $SINGLEMDS
1237 wait $open_pid || return 3
1239 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1240 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1241 rm -rf $DIR/${tdir}-*
1243 run_test 53e "|X| open reply while two MDC requests in flight"
1246 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1248 mkdir -p $DIR/${tdir}-1
1249 mkdir -p $DIR/${tdir}-2
1250 multiop $DIR/${tdir}-1/f O_c &
1253 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1254 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1255 mcreate $DIR/${tdir}-2/f &
1259 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1261 kill -USR1 $close_pid
1262 cancel_lru_locks mdc # force the close
1264 replay_barrier_nodf $SINGLEMDS
1265 fail_nodf $SINGLEMDS
1266 wait $open_pid || return 1
1268 # close should be gone
1269 [ -d /proc/$close_pid ] && return 2
1270 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1272 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1273 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1274 rm -rf $DIR/${tdir}-*
1276 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1279 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1281 mkdir -p $DIR/${tdir}-1
1282 mkdir -p $DIR/${tdir}-2
1283 multiop $DIR/${tdir}-1/f O_c &
1286 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1287 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1288 mcreate $DIR/${tdir}-2/f &
1292 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1293 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1294 kill -USR1 $close_pid
1295 cancel_lru_locks mdc # force the close
1297 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1298 replay_barrier_nodf $SINGLEMDS
1299 fail_nodf $SINGLEMDS
1300 wait $open_pid || return 1
1302 # close should be gone
1303 [ -d /proc/$close_pid ] && return 2
1305 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1306 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1307 rm -rf $DIR/${tdir}-*
1309 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1312 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1314 mkdir -p $DIR/${tdir}-1
1315 mkdir -p $DIR/${tdir}-2
1316 multiop $DIR/${tdir}-1/f O_c &
1319 #define OBD_FAIL_MDS_REINT_NET 0x107
1320 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1321 mcreate $DIR/${tdir}-2/f &
1325 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1326 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1327 kill -USR1 $close_pid
1328 cancel_lru_locks mdc # force the close
1331 replay_barrier_nodf $SINGLEMDS
1332 fail_nodf $SINGLEMDS
1333 wait $open_pid || return 1
1335 # close should be gone
1336 [ -d /proc/$close_pid ] && return 2
1337 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1339 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1340 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1341 rm -rf $DIR/${tdir}-*
1343 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1345 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1347 #b3761 ASSERTION(hash != 0) failed
1349 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1350 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1352 # give touch a chance to run
1354 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1358 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1360 #b3440 ASSERTION(rec->ur_fid2->id) failed
1362 ln -s foo $DIR/$tfile
1363 replay_barrier $SINGLEMDS
1364 #drop_reply "cat $DIR/$tfile"
1368 run_test 56 "don't replay a symlink open request (3440)"
1370 #recovery one mds-ost setattr from llog
1372 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1373 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1375 replay_barrier $SINGLEMDS
1378 $CHECKSTAT -t file $DIR/$tfile || return 1
1379 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1382 run_test 57 "test recovery from llog for setattr op"
1384 #recovery many mds-ost setattr from llog
1387 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1388 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1389 createmany -o $DIR/$tdir/$tfile-%d 2500
1390 replay_barrier $SINGLEMDS
1393 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1394 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1395 unlinkmany $DIR/$tdir/$tfile-%d 2500
1398 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1401 mount_client $MOUNT2
1403 touch $DIR/$tdir/$tfile
1404 replay_barrier $SINGLEMDS
1405 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1407 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1408 [ x$VAL = x"bar" ] || return 1
1409 rm -f $DIR/$tdir/$tfile
1411 zconf_umount `hostname` $MOUNT2
1413 run_test 58b "test replay of setxattr op"
1415 test_58c() { # bug 16570
1416 mount_client $MOUNT2
1418 touch $DIR/$tdir/$tfile
1419 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1421 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1422 [ x$VAL = x"bar" ] || return 2
1423 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1425 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1426 [ x$VAL = x"bar1" ] || return 4
1427 rm -f $DIR/$tdir/$tfile
1429 zconf_umount `hostname` $MOUNT2
1431 run_test 58c "resend/reconstruct setxattr op"
1433 # log_commit_thread vs filter_destroy race used to lead to import use after free
1436 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1439 createmany -o $DIR/$tdir/$tfile-%d 200
1441 unlinkmany $DIR/$tdir/$tfile-%d 200
1442 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1443 do_facet ost1 "lctl set_param fail_loc=0x507"
1446 do_facet ost1 "lctl set_param fail_loc=0x0"
1450 run_test 59 "test log_commit_thread vs filter_destroy race"
1452 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1453 # bug 12086: should no oops and No ctxt error for this test
1456 createmany -o $DIR/$tdir/$tfile-%d 200
1457 replay_barrier $SINGLEMDS
1458 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1460 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1461 local no_ctxt=`dmesg | grep "No ctxt"`
1462 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1464 run_test 60 "test llog post recovery init vs llog unlink"
1466 #test race llog recovery thread vs llog cleanup
1467 test_61a() { # was test_61
1468 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1471 createmany -o $DIR/$tdir/$tfile-%d 800
1473 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1474 unlinkmany $DIR/$tdir/$tfile-%d 800
1475 set_nodes_failloc "$(osts_nodes)" 0x80000221
1480 set_nodes_failloc "$(osts_nodes)" 0x0
1482 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1485 run_test 61a "test race llog recovery vs llog cleanup"
1487 #test race mds llog sync vs llog cleanup
1489 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1490 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1491 facet_failover $SINGLEMDS
1494 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1496 run_test 61b "test race mds llog sync vs llog cleanup"
1498 #test race cancel cookie cb vs llog cleanup
1500 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1502 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1504 set_nodes_failloc "$(osts_nodes)" 0x80000222
1508 set_nodes_failloc "$(osts_nodes)" 0x0
1510 run_test 61c "test race mds llog sync vs llog cleanup"
1512 test_61d() { # bug 16002 # bug 17466
1513 shutdown_facet $SINGLEMDS
1514 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x605"
1516 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS && error "mds start should have failed"
1517 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1518 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || error "cannot restart mds"
1520 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1522 test_62() { # Bug 15756 - don't mis-drop resent replay
1524 replay_barrier $SINGLEMDS
1525 createmany -o $DIR/$tdir/$tfile- 25
1526 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1527 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1529 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1530 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1533 run_test 62 "don't mis-drop resent replay"
1535 #Adaptive Timeouts (bug 3055)
1543 echo "Cleaning up AT ..."
1544 if [ -n "$ATOLDBASE" ]; then
1545 local at_history=$($LCTL get_param -n at_history)
1546 do_facet mds "lctl set_param at_history=$at_history" || true
1547 do_facet ost1 "lctl set_param at_history=$at_history" || true
1550 if [ $AT_MAX_SET -ne 0 ]; then
1551 for facet in mds client ost; do
1552 var=AT_MAX_SAVE_${facet}
1553 echo restore AT on $facet to saved value ${!var}
1554 at_max_set ${!var} $facet
1555 at_new=$(at_max_get $facet)
1556 echo Restored AT value on $facet $at_new
1557 [ $at_new -eq ${!var} ] || \
1558 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1565 local at_max_new=600
1567 # Save at_max original values
1569 if [ $AT_MAX_SET -eq 0 ]; then
1570 # Suppose that all osts have the same at_max
1571 for facet in mds client ost; do
1572 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1576 for facet in mds client ost; do
1577 at_max=$(at_max_get $facet)
1578 if [ $at_max -ne $at_max_new ]; then
1579 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1580 at_max_set $at_max_new $facet
1585 if [ -z "$ATOLDBASE" ]; then
1586 ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
1587 # speed up the timebase so we can check decreasing AT
1588 do_facet mds "lctl set_param at_history=8" || true
1589 do_facet ost1 "lctl set_param at_history=8" || true
1591 # sleep for a while to cool down, should be > 8s and also allow
1592 # at least one ping to be sent. simply use TIMEOUT to be safe.
1597 test_65a() #bug 3055
1599 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1601 at_start || return 0
1602 $LCTL dk > /dev/null
1604 sysctl -w lnet.debug="+other"
1605 # Slow down a request to the current service time, this is critical
1606 # because previous tests may have caused this value to increase.
1607 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1608 awk '/portal 12/ {print $5}'`
1609 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1611 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1612 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1613 do_facet mds sysctl -w lustre.fail_loc=0x8000050a
1614 createmany -o $DIR/$tfile 10 > /dev/null
1615 unlinkmany $DIR/$tfile 10 > /dev/null
1616 # check for log message
1617 $LCTL dk | grep "Early reply #" || error "No early reply"
1619 # client should show REQ_DELAY estimates
1620 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1622 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1624 run_test 65a "AT: verify early replies"
1626 test_65b() #bug 3055
1628 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1630 at_start || return 0
1633 sysctl -w lnet.debug="other trace"
1634 $LCTL dk > /dev/null
1635 # Slow down a request to the current service time, this is critical
1636 # because previous tests may have caused this value to increase.
1637 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1638 awk '/portal 6/ {print $5}'`
1639 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1641 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1642 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1643 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1646 lfs setstripe $DIR/$tfile --index=0 --count=1
1647 # force some real bulk transfer
1648 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1650 do_facet ost1 sysctl -w lustre.fail_loc=0
1651 # check for log message
1652 $LCTL dk | grep "Early reply #" || error "No early reply"
1654 # client should show REQ_DELAY estimates
1655 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1657 run_test 65b "AT: verify early replies on packed reply / bulk"
1659 test_66a() #bug 3055
1661 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1663 at_start || return 0
1664 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1665 # adjust 5s at a time so no early reply is sent (within deadline)
1666 do_facet mds "sysctl -w lustre.fail_val=5000"
1667 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1668 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1669 createmany -o $DIR/$tfile 20 > /dev/null
1670 unlinkmany $DIR/$tfile 20 > /dev/null
1671 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1672 do_facet mds "sysctl -w lustre.fail_val=10000"
1673 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1674 createmany -o $DIR/$tfile 20 > /dev/null
1675 unlinkmany $DIR/$tfile 20 > /dev/null
1676 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1677 do_facet mds "sysctl -w lustre.fail_loc=0"
1679 createmany -o $DIR/$tfile 20 > /dev/null
1680 unlinkmany $DIR/$tfile 20 > /dev/null
1681 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1682 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1683 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1684 echo "Current MDT timeout $CUR, worst $WORST"
1685 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1687 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1689 test_66b() #bug 3055
1691 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1693 at_start || return 0
1694 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1695 sysctl -w lustre.fail_val=$(($ORIG + 5))
1696 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1697 sysctl -w lustre.fail_loc=0x50c
1698 ls $DIR/$tfile > /dev/null 2>&1
1699 sysctl -w lustre.fail_loc=0
1700 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1701 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1702 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1703 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1705 run_test 66b "AT: verify net latency adjusts"
1707 test_67a() #bug 3055
1709 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1711 at_start || return 0
1712 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1713 # sleeping threads may drive values above this
1714 do_facet ost1 "sysctl -w lustre.fail_val=400"
1715 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1716 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1717 createmany -o $DIR/$tfile 20 > /dev/null
1718 unlinkmany $DIR/$tfile 20 > /dev/null
1719 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1720 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1721 ATTEMPTS=$(($CONN2 - $CONN1))
1722 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1723 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1726 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1728 test_67b() #bug 3055
1730 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1732 at_start || return 0
1733 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1735 # exhaust precreations on ost1
1736 local OST=$(lfs osts | grep 0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1737 local mdtosc=$(get_mdtosc_proc_path $OST)
1738 local last_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_last_id)
1739 local next_id=$(do_facet mds lctl get_param -n osc.$mdtosc.prealloc_next_id)
1741 mkdir -p $DIR/$tdir/${OST}
1742 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1743 echo "Creating to objid $last_id on ost $OST..."
1744 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1745 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1746 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1747 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1750 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1752 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1753 ATTEMPTS=$(($CONN2 - $CONN1))
1754 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1755 # do it again; should not timeout
1756 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1757 cp /etc/profile $DIR/$tfile || error "cp failed"
1758 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1760 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1761 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1762 ATTEMPTS=$(($CONN3 - $CONN2))
1763 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1764 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1767 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1769 test_68 () #bug 13813
1771 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1773 at_start || return 0
1774 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1775 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1776 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1777 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1778 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1779 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1780 echo $TIMEOUT >> $ldlm_enqueue_min
1781 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1785 lfs setstripe $DIR/$tdir --index=0 --count=1
1786 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1787 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1788 sysctl -w lustre.fail_loc=0x80000312
1789 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1790 sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1791 sysctl -w lustre.fail_loc=0x80000312
1792 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1793 sysctl -w lustre.fail_loc=0
1795 echo $ENQ_MIN >> $ldlm_enqueue_min
1796 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1800 run_test 68 "AT: verify slowing locks"
1803 # end of AT tests includes above lines
1806 # start multi-client tests
1808 [ -z "$CLIENTS" ] && \
1809 { skip "Need two or more clients." && return; }
1810 [ $CLIENTCOUNT -lt 2 ] && \
1811 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1813 echo "mount clients $CLIENTS ..."
1814 zconf_mount_clients $CLIENTS $DIR
1816 local clients=${CLIENTS//,/ }
1817 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1818 for CLIENT in $clients; do
1819 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1820 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1821 error "dd failed on $CLIENT"
1824 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1825 for C in ${CLIENTS//,/ }; do
1826 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1827 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1833 run_test 70a "check multi client t-f"
1836 local clients=${CLIENTS:-$HOSTNAME}
1838 zconf_mount_clients $clients $DIR
1841 [ "$SLOW" = "no" ] && duration=60
1842 local cmd="rundbench 1 -t $duration"
1844 do_nodes --verbose $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1845 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1846 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1849 log "Started rundbench load PID=$PID ..."
1852 START_TS=$(date +%s)
1853 CURRENT_TS=$START_TS
1854 while [ $ELAPSED -lt $duration ]; do
1856 replay_barrier $SINGLEMDS
1857 sleep 1 # give clients a time to do operations
1858 # Increment the number of failovers
1859 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1860 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1862 CURRENT_TS=$(date +%s)
1863 ELAPSED=$((CURRENT_TS - START_TS))
1865 wait $PID || error "rundbench load on $CLIENTS failed!"
1867 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1868 # end multi-client tests
1871 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1875 replay_barrier $SINGLEMDS
1876 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1877 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1880 wait $pid || return 1
1881 [ -e $DIR/$tfile ] && return 2
1884 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1887 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1891 replay_barrier $SINGLEMDS
1892 #define OBD_FAIL_LDLM_REPLY 0x30c
1893 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1896 wait $pid || return 1
1897 [ -e $DIR/$tfile ] && return 2
1900 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1903 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1907 replay_barrier $SINGLEMDS
1908 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1909 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1912 wait $pid || return 1
1913 [ -e $DIR/$tfile ] && return 2
1916 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1920 local clients=${CLIENTS:-$HOSTNAME}
1923 zconf_umount_clients $clients $MOUNT
1924 facet_failover $SINGLEMDS
1925 zconf_mount_clients $clients $MOUNT
1927 touch $DIR/$tfile || return 1
1928 rm $DIR/$tfile || return 2
1929 clients_up || error "client evicted: $?"
1932 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1935 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1939 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1940 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1942 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1945 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1948 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1952 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1953 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1955 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1958 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1961 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1964 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1966 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1967 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1969 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1971 stat $DIR/$tdir/f1002
1973 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
1976 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1980 mkdir $dir || error "mkdir $dir failed"
1984 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1986 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
1989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1993 mkdir $dir || error "mkdir $dir failed"
1997 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1999 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2003 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2004 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2005 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2006 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2008 run_test 83a "fail log_add during unlink recovery"
2012 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2013 replay_barrier $SINGLEMDS
2014 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2015 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2016 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2019 run_test 83b "fail log_add during unlink recovery"
2022 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x143
2023 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000143"
2024 createmany -o $DIR/$tfile- 1 &
2028 client_up || client_up || true # reconnect
2030 run_test 84a "stale open during export disconnect"
2032 equals_msg `basename $0`: test complete, cleaning up
2033 check_and_cleanup_lustre
2034 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true