7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
11 . $LUSTRE/tests/test-framework.sh
13 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 # bug number: 2766 4176
18 ALWAYS_EXCEPT="0b 39 $REPLAY_SINGLE_EXCEPT"
22 add_mds $SINGLEMDS --dev $MDSDEV --size $MDSSIZE
23 if [ ! -z "$mdsfailover_HOST" ]; then
24 add_mdsfailover $SINGLEMDS --dev $MDSDEV --size $MDSSIZE
27 add_lov lov1 $SINGLEMDS --stripe_sz $STRIPE_BYTES \
28 --stripe_cnt $STRIPES_PER_OBJ --stripe_pattern 0
29 add_ost ost --lov lov1 --dev `ostdevname 1` --size $OSTSIZE
30 add_ost ost2 --lov lov1 --dev `ostdevname 2` --size $OSTSIZE
31 add_client client $SINGLEMDS --lov lov1 --path $MOUNT
36 SETUP=${SETUP:-"setup"}
37 CLEANUP=${CLEANUP:-"cleanupall"}
39 if [ "$ONLY" == "cleanup" ]; then
40 sysctl -w lnet.debug=0 || true
46 [ "$REFORMAT" ] && formatall
52 if [ "$ONLY" == "setup" ]; then
61 replay_barrier $SINGLEMDS
65 run_test 0 "empty replay"
68 # this test attempts to trigger a race in the precreation code,
69 # and must run before any other objects are created on the filesystem
71 createmany -o $DIR/$tfile 20 || return 1
72 unlinkmany $DIR/$tfile 20 || return 2
74 run_test 0b "ensure object created after recover exists. (3284)"
80 local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
87 local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
91 # This test should pass for single-mds and multi-mds configs.
92 # But for different configurations it tests different things.
96 # (1) fld_create replay should happen;
98 # (2) fld_create replay should not return -EEXISTS, if it does
99 # this means sequence manager recovery code is buggy and allocated
100 # same sequence two times after recovery.
104 # (1) fld_create replay may not happen, because its home MDS is
105 # MDS2 which is not involved to revovery;
107 # (2) as fld_create does not happen on MDS1, it does not make any
110 local label=`mdsdevlabel 1`
111 [ -z "$label" ] && echo "No label for mds1" && return 1
113 replay_barrier $SINGLEMDS
114 local sw=`seq_get_width $label`
116 # make seq manager switch to next sequence each
117 # time as new fid is needed.
118 seq_set_width $label 1
120 # make sure that fld has created at least one new
122 touch $DIR/$tfile || return 2
123 seq_set_width $label $sw
125 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
128 # wait for recovery finish
132 # flush fld cache and dentry cache to make it lookup
133 # created entry instead of revalidating existent one
135 zconf_mount `hostname` $MOUNT
137 # issue lookup which should call fld lookup which
138 # should fail if client did not replay fld create
139 # correctly and server has no fld entry
140 touch $DIR/$tfile || return 3
141 rm $DIR/$tfile || return 4
143 run_test 0c "fld create"
146 replay_barrier $SINGLEMDS
149 $CHECKSTAT -t file $DIR/$tfile || return 1
152 run_test 1 "simple create"
155 replay_barrier $SINGLEMDS
158 $CHECKSTAT -t file $DIR/$tfile || return 1
164 ./mcreate $DIR/$tfile
165 replay_barrier $SINGLEMDS
168 $CHECKSTAT -t file $DIR/$tfile || return 1
174 replay_barrier $SINGLEMDS
176 o_directory $DIR/$tfile
178 $CHECKSTAT -t file $DIR/$tfile || return 2
181 run_test 3a "replay failed open(O_DIRECTORY)"
184 replay_barrier $SINGLEMDS
185 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
186 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000114"
188 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
190 $CHECKSTAT -t file $DIR/$tfile && return 2
193 run_test 3b "replay failed open -ENOMEM"
196 replay_barrier $SINGLEMDS
197 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
198 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000128"
200 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
203 $CHECKSTAT -t file $DIR/$tfile && return 2
206 run_test 3c "replay failed open -ENOMEM"
209 replay_barrier $SINGLEMDS
210 for i in `seq 10`; do
211 echo "tag-$i" > $DIR/$tfile-$i
214 for i in `seq 10`; do
215 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
218 run_test 4 "|x| 10 open(O_CREAT)s"
221 replay_barrier $SINGLEMDS
224 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
226 run_test 4b "|x| rm 10 files"
228 # The idea is to get past the first block of precreated files on both
229 # osts, and then replay.
231 replay_barrier $SINGLEMDS
232 for i in `seq 220`; do
233 echo "tag-$i" > $DIR/$tfile-$i
236 for i in `seq 220`; do
237 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
241 # waiting for commitment of removal
243 run_test 5 "|x| 220 open(O_CREAT)"
247 replay_barrier $SINGLEMDS
249 mcreate $DIR/$tdir/$tfile
251 $CHECKSTAT -t dir $DIR/$tdir || return 1
252 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
254 # waiting for log process thread
256 run_test 6 "mkdir + contained create"
259 replay_barrier $SINGLEMDS
262 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
264 run_test 6b "|X| rmdir"
268 replay_barrier $SINGLEMDS
269 mcreate $DIR/$tdir/$tfile
271 $CHECKSTAT -t dir $DIR/$tdir || return 1
272 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
275 run_test 7 "mkdir |X| contained create"
278 # make sure no side-effect from previous test.
280 replay_barrier $SINGLEMDS
281 multiop $DIR/$tfile mo_c &
286 $CHECKSTAT -t file $DIR/$tfile || return 1
287 kill -USR1 $MULTIPID || return 2
288 wait $MULTIPID || return 3
291 run_test 8 "creat open |X| close"
294 replay_barrier $SINGLEMDS
296 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
298 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
300 echo " old_inum == $old_inum, new_inum == $new_inum"
301 if [ $old_inum -eq $new_inum ] ;
303 echo " old_inum and new_inum match"
305 echo "!!!! old_inum and new_inum NOT match"
310 run_test 9 "|X| create (same inum/gen)"
314 replay_barrier $SINGLEMDS
315 mv $DIR/$tfile $DIR/$tfile-2
318 $CHECKSTAT $DIR/$tfile && return 1
319 $CHECKSTAT $DIR/$tfile-2 ||return 2
323 run_test 10 "create |X| rename unlink"
327 echo "old" > $DIR/$tfile
328 mv $DIR/$tfile $DIR/$tfile-2
329 replay_barrier $SINGLEMDS
330 echo "new" > $DIR/$tfile
332 grep old $DIR/$tfile-2
334 grep new $DIR/$tfile || return 1
335 grep old $DIR/$tfile-2 || return 2
337 run_test 11 "create open write rename |X| create-old-name read"
341 multiop $DIR/$tfile o_tSc &
343 # give multiop a chance to open
346 replay_barrier $SINGLEMDS
348 wait $pid || return 1
351 [ -e $DIR/$tfile ] && return 2
354 run_test 12 "open, unlink |X| close"
357 # 1777 - replay open after committed chmod that would make
358 # a regular open a failure
361 multiop $DIR/$tfile O_wc &
363 # give multiop a chance to open
366 $CHECKSTAT -p 0 $DIR/$tfile
367 replay_barrier $SINGLEMDS
370 wait $pid || return 1
372 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
375 run_test 13 "open chmod 0 |x| write close"
378 multiop $DIR/$tfile O_tSc &
380 # give multiop a chance to open
383 replay_barrier $SINGLEMDS
384 kill -USR1 $pid || return 1
385 wait $pid || return 2
388 [ -e $DIR/$tfile ] && return 3
391 run_test 14 "open(O_CREAT), unlink |X| close"
394 multiop $DIR/$tfile O_tSc &
396 # give multiop a chance to open
399 replay_barrier $SINGLEMDS
400 touch $DIR/g11 || return 1
402 wait $pid || return 2
405 [ -e $DIR/$tfile ] && return 3
406 touch $DIR/h11 || return 4
409 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
413 replay_barrier $SINGLEMDS
416 mcreate $DIR/$tfile-2
418 [ -e $DIR/$tfile ] && return 1
419 [ -e $DIR/$tfile-2 ] || return 2
420 munlink $DIR/$tfile-2 || return 3
422 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
425 replay_barrier $SINGLEMDS
426 multiop $DIR/$tfile O_c &
428 # give multiop a chance to open
431 kill -USR1 $pid || return 1
432 wait $pid || return 2
433 $CHECKSTAT -t file $DIR/$tfile || return 3
436 run_test 17 "|X| open(O_CREAT), |replay| close"
439 replay_barrier $SINGLEMDS
440 multiop $DIR/$tfile O_tSc &
442 # give multiop a chance to open
445 touch $DIR/$tfile-2 || return 1
446 echo "pid: $pid will close"
448 wait $pid || return 2
451 [ -e $DIR/$tfile ] && return 3
452 [ -e $DIR/$tfile-2 ] || return 4
453 # this touch frequently fails
454 touch $DIR/$tfile-3 || return 5
455 munlink $DIR/$tfile-2 || return 6
456 munlink $DIR/$tfile-3 || return 7
459 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
461 # bug 1855 (a simpler form of test_11 above)
463 replay_barrier $SINGLEMDS
465 echo "old" > $DIR/$tfile
466 mv $DIR/$tfile $DIR/$tfile-2
467 grep old $DIR/$tfile-2
469 grep old $DIR/$tfile-2 || return 2
471 run_test 19 "|X| mcreate, open, write, rename "
474 replay_barrier $SINGLEMDS
475 multiop $DIR/$tfile O_tSc &
477 # give multiop a chance to open
483 wait $pid || return 1
484 [ -e $DIR/$tfile ] && return 2
487 run_test 20 "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
489 test_20b() { # bug 10480
490 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
492 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
494 while [ ! -e $DIR/$tfile ] ; do
495 usleep 60 # give dd a chance to start
498 lfs getstripe $DIR/$tfile || return 1
499 rm -f $DIR/$tfile || return 2 # make it an orphan
501 df -P $DIR || df -P $DIR || true # reconnect
503 fail $SINGLEMDS # start orphan recovery
504 df -P $DIR || df -P $DIR || true # reconnect
507 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
508 log "before $BEFOREUSED, after $AFTERUSED"
509 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
510 error "after $AFTERUSED > before $BEFOREUSED" && return 5
513 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
515 test_20c() { # bug 10480
516 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000
518 exec 100< $DIR/$tfile
524 df -P $DIR || df -P $DIR || true # reconnect
528 test -s $DIR/$tfile || error "File was truncated"
532 run_test 20c "check that client eviction does not affect file content"
535 replay_barrier $SINGLEMDS
536 multiop $DIR/$tfile O_tSc &
538 # give multiop a chance to open
541 touch $DIR/g11 || return 1
545 wait $pid || return 2
546 [ -e $DIR/$tfile ] && return 3
547 touch $DIR/h11 || return 4
550 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
553 multiop $DIR/$tfile O_tSc &
555 # give multiop a chance to open
558 replay_barrier $SINGLEMDS
563 wait $pid || return 1
564 [ -e $DIR/$tfile ] && return 2
567 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
570 multiop $DIR/$tfile O_tSc &
572 # give multiop a chance to open
575 replay_barrier $SINGLEMDS
577 touch $DIR/g11 || return 1
581 wait $pid || return 2
582 [ -e $DIR/$tfile ] && return 3
583 touch $DIR/h11 || return 4
586 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
589 multiop $DIR/$tfile O_tSc &
591 # give multiop a chance to open
594 replay_barrier $SINGLEMDS
598 wait $pid || return 1
599 [ -e $DIR/$tfile ] && return 2
602 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
605 multiop $DIR/$tfile O_tSc &
607 # give multiop a chance to open
611 replay_barrier $SINGLEMDS
614 wait $pid || return 1
615 [ -e $DIR/$tfile ] && return 2
618 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
621 replay_barrier $SINGLEMDS
622 multiop $DIR/$tfile-1 O_tSc &
624 multiop $DIR/$tfile-2 O_tSc &
626 # give multiop a chance to open
631 wait $pid2 || return 1
635 wait $pid1 || return 2
636 [ -e $DIR/$tfile-1 ] && return 3
637 [ -e $DIR/$tfile-2 ] && return 4
640 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
643 replay_barrier $SINGLEMDS
644 multiop $DIR/$tfile-1 O_tSc &
646 multiop $DIR/$tfile-2 O_tSc &
648 # give multiop a chance to open
655 wait $pid1 || return 1
657 wait $pid2 || return 2
658 [ -e $DIR/$tfile-1 ] && return 3
659 [ -e $DIR/$tfile-2 ] && return 4
662 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
665 multiop $DIR/$tfile-1 O_tSc &
667 multiop $DIR/$tfile-2 O_tSc &
669 # give multiop a chance to open
671 replay_barrier $SINGLEMDS
675 wait $pid2 || return 1
679 wait $pid1 || return 2
680 [ -e $DIR/$tfile-1 ] && return 3
681 [ -e $DIR/$tfile-2 ] && return 4
684 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
687 multiop $DIR/$tfile-1 O_tSc &
689 multiop $DIR/$tfile-2 O_tSc &
691 # give multiop a chance to open
693 replay_barrier $SINGLEMDS
699 wait $pid1 || return 1
701 wait $pid2 || return 2
702 [ -e $DIR/$tfile-1 ] && return 3
703 [ -e $DIR/$tfile-2 ] && return 4
706 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
709 multiop $DIR/$tfile-1 O_tSc &
711 multiop $DIR/$tfile-2 O_tSc &
713 # give multiop a chance to open
718 replay_barrier $SINGLEMDS
721 wait $pid1 || return 1
723 wait $pid2 || return 2
724 [ -e $DIR/$tfile-1 ] && return 3
725 [ -e $DIR/$tfile-2 ] && return 4
728 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
731 multiop $DIR/$tfile-1 O_tSc &
733 multiop $DIR/$tfile-2 O_tSc &
735 # give multiop a chance to open
739 replay_barrier $SINGLEMDS
743 wait $pid1 || return 1
745 wait $pid2 || return 2
746 [ -e $DIR/$tfile-1 ] && return 3
747 [ -e $DIR/$tfile-2 ] && return 4
750 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
752 # tests for bug 2104; completion without crashing is success. The close is
753 # stale, but we always return 0 for close, so the app never sees it.
755 multiop $DIR/$tfile O_c &
757 multiop $DIR/$tfile O_c &
759 # give multiop a chance to open
762 df $MOUNT || sleep 1 && df $MOUNT || return 1
768 run_test 32 "close() notices client eviction; close() after client eviction"
770 # Abort recovery before client complete
772 replay_barrier $SINGLEMDS
773 createmany -o $DIR/$tfile-%d 100
774 fail_abort $SINGLEMDS
775 # this file should be gone, because the replay was aborted
776 $CHECKSTAT -t file $DIR/$tfile-* && return 3
777 unlinkmany $DIR/$tfile-%d 0 100
780 run_test 33 "abort recovery before client does replay"
784 replay_barrier $SINGLEMDS
785 createmany -o $DIR/$tfile-%d 10
786 fail_abort $SINGLEMDS
787 unlinkmany $DIR/$tfile-%d 0 10
788 # recreate shouldn't fail
789 createmany -o $DIR/$tfile-%d 10 || return 3
790 unlinkmany $DIR/$tfile-%d 0 10
793 run_test 33a "fid shouldn't be reused after abort recovery"
796 multiop $DIR/$tfile O_c &
798 # give multiop a chance to open
802 replay_barrier $SINGLEMDS
803 fail_abort $SINGLEMDS
805 [ -e $DIR/$tfile ] && return 1
809 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
811 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
815 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
816 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
821 # give a chance to remove from MDS
822 fail_abort $SINGLEMDS
823 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
825 run_test 35 "test recovery from llog for unlink op"
827 # b=2432 resent cancel after replay uses wrong cookie,
828 # so don't resend cancels
830 replay_barrier $SINGLEMDS
832 checkstat $DIR/$tfile
833 facet_failover $SINGLEMDS
835 if dmesg | grep "unknown lock cookie"; then
836 echo "cancel after replay failed"
840 run_test 36 "don't resend cancel"
843 # directory orphans can't be unlinked from PENDING directory
845 rmdir $DIR/$tfile 2>/dev/null
846 multiop $DIR/$tfile dD_c &
848 # give multiop a chance to open
852 replay_barrier $SINGLEMDS
853 # clear the dmesg buffer so we only see errors from this recovery
855 fail_abort $SINGLEMDS
857 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
861 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
864 createmany -o $DIR/$tfile-%d 800
865 unlinkmany $DIR/$tfile-%d 0 400
866 replay_barrier $SINGLEMDS
868 unlinkmany $DIR/$tfile-%d 400 400
870 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
872 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
874 test_39() { # bug 4176
875 createmany -o $DIR/$tfile-%d 800
876 replay_barrier $SINGLEMDS
877 unlinkmany $DIR/$tfile-%d 0 400
879 unlinkmany $DIR/$tfile-%d 400 400
881 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
883 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
886 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }' $LPROC/osc/*/stats
891 $LCTL mark multiop $MOUNT/$tfile OS_c
892 multiop $MOUNT/$tfile OS_c &
894 writeme -s $MOUNT/${tfile}-2 &
897 facet_failover $SINGLEMDS
898 #define OBD_FAIL_MDS_CONNECT_NET 0x117
899 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000117"
901 stat1=`count_ost_writes`
903 stat2=`count_ost_writes`
904 echo "$stat1, $stat2"
905 if [ $stat1 -lt $stat2 ]; then
906 echo "writes continuing during recovery"
909 echo "writes not continuing during recovery, bug 2477"
912 echo "waiting for writeme $WRITE_PID"
916 echo "waiting for multiop $PID"
917 wait $PID || return 2
918 do_facet client munlink $MOUNT/$tfile || return 3
919 do_facet client munlink $MOUNT/${tfile}-2 || return 3
922 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
926 # make sure that a read to one osc doesn't try to double-unlock its page just
927 # because another osc is invalid. trigger_group_io used to mistakenly return
928 # an error if any oscs were invalid even after having successfully put rpcs
929 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
930 # the page, guarnateeing that the unlock from the RPC completion would
931 # assert on trying to unlock the unlocked page.
933 local f=$MOUNT/$tfile
934 # make sure the start of the file is ost1
935 lfs setstripe $f $((128 * 1024)) 0 0
936 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
938 # fail ost2 and read from ost1
939 local osc2dev=`do_facet mds "grep ${ost2_svc}-osc-MDT0000 $LPROC/devices" | awk '{print $1}'`
940 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && cat $LPROC/devices && return 4
941 do_facet mds $LCTL --device $osc2dev deactivate || return 1
942 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
943 do_facet mds $LCTL --device $osc2dev activate || return 2
946 run_test 41 "read from a valid osc while other oscs are invalid"
948 # test MDS recovery after ost failure
950 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
951 createmany -o $DIR/$tfile-%d 800
953 unlinkmany $DIR/$tfile-%d 0 400
954 DEBUG42=`sysctl -n lnet.debug`
955 sysctl -w lnet.debug=-1
958 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
959 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
960 #[ $blocks_after -lt $blocks ] || return 1
961 echo wait for MDS to timeout and recover
962 sleep $((TIMEOUT * 2))
963 sysctl -w lnet.debug="$DEBUG42"
964 unlinkmany $DIR/$tfile-%d 400 400
965 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
967 run_test 42 "recovery after ost failure"
969 # timeout in MDS/OST recovery RPC will LBUG MDS
970 test_43() { # bug 2530
971 replay_barrier $SINGLEMDS
973 # OBD_FAIL_OST_CREATE_NET 0x204
974 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
977 do_facet ost1 "sysctl -w lustre.fail_loc=0"
981 run_test 43 "mds osc import failure during recovery; don't LBUG"
984 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
985 [ "$mdcdev" ] || exit 2
986 for i in `seq 1 10`; do
987 #define OBD_FAIL_TGT_CONN_RACE 0x701
988 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000701"
989 $LCTL --device $mdcdev recover
992 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
995 run_test 44 "race in target handle connect"
998 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
999 [ "$mdcdev" ] || exit 2
1000 for i in `seq 1 10`; do
1001 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
1002 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000704"
1003 $LCTL --device $mdcdev recover
1006 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1009 run_test 44b "race in target handle connect"
1011 # Handle failed close
1013 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
1014 [ "$mdcdev" ] || exit 2
1015 $LCTL --device $mdcdev recover
1017 multiop $DIR/$tfile O_c &
1021 # This will cause the CLOSE to fail before even
1022 # allocating a reply buffer
1023 $LCTL --device $mdcdev deactivate || return 4
1027 wait $pid || return 1
1029 $LCTL --device $mdcdev activate || return 5
1032 $CHECKSTAT -t file $DIR/$tfile || return 2
1035 run_test 45 "Handle failed close"
1039 drop_reply "touch $DIR/$tfile"
1041 # ironically, the previous test, 45, will cause a real forced close,
1042 # so just look for one for this test
1043 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1046 run_test 46 "Don't leak file handle after open resend (3325)"
1048 test_47() { # bug 2824
1049 # create some files to make sure precreate has been done on all
1050 # OSTs. (just in case this test is run independently)
1051 createmany -o $DIR/$tfile 20 || return 1
1053 # OBD_FAIL_OST_CREATE_NET 0x204
1055 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
1056 df $MOUNT || return 2
1058 # let the MDS discover the OST failure, attempt to recover, fail
1059 # and recover again.
1060 sleep $((3 * TIMEOUT))
1062 # Without 2824, this createmany would hang
1063 createmany -o $DIR/$tfile 20 || return 3
1064 unlinkmany $DIR/$tfile 20 || return 4
1066 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1069 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1072 replay_barrier $SINGLEMDS
1073 createmany -o $DIR/$tfile 20 || return 1
1074 # OBD_FAIL_OST_EROFS 0x216
1076 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000216"
1077 df $MOUNT || return 2
1079 createmany -o $DIR/$tfile 20 20 || return 2
1080 unlinkmany $DIR/$tfile 40 || return 3
1082 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1085 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1088 local oscdev=`grep ${ost1_svc}-osc-MDT0000 $LPROC/devices | awk '{print $1}'`
1089 [ "$oscdev" ] || return 1
1090 $LCTL --device $oscdev recover && $LCTL --device $oscdev recover
1091 # give the mds_lov_sync threads a chance to run
1094 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1096 # b3764 timed out lock replay
1099 cancel_lru_locks mdc
1101 multiop $DIR/$tfile s || return 1
1102 replay_barrier $SINGLEMDS
1103 #define OBD_FAIL_LDLM_REPLY 0x30c
1104 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000030c"
1105 fail $SINGLEMDS || return 2
1106 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1108 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1110 run_test 52 "time out lock replay (3764)"
1112 #b_cray 53 "|X| open request and close reply while two MDC requests in flight"
1113 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1115 #b3761 ASSERTION(hash != 0) failed
1117 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1118 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012b"
1120 # give touch a chance to run
1122 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1126 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1128 #b3440 ASSERTION(rec->ur_fid2->id) failed
1130 ln -s foo $DIR/$tfile
1131 replay_barrier $SINGLEMDS
1132 #drop_reply "cat $DIR/$tfile"
1136 run_test 56 "don't replay a symlink open request (3440)"
1138 #recovery one mds-ost setattr from llog
1140 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1141 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1143 replay_barrier $SINGLEMDS
1146 $CHECKSTAT -t file $DIR/$tfile || return 1
1147 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1150 run_test 57 "test recovery from llog for setattr op"
1152 #recovery many mds-ost setattr from llog
1154 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1155 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1157 createmany -o $DIR/$tdir/$tfile-%d 2500
1158 replay_barrier $SINGLEMDS
1161 $CHECKSTAT -t file $DIR/$tdir/$tfile-* || return 1
1162 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1163 unlinkmany $DIR/$tdir/$tfile-%d 2500
1166 run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)"
1168 # log_commit_thread vs filter_destroy race used to lead to import use after free
1172 createmany -o $DIR/$tdir/$tfile-%d 200
1174 unlinkmany $DIR/$tdir/$tfile-%d 200
1175 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1176 do_facet ost1 "sysctl -w lustre.fail_loc=0x507"
1179 do_facet ost1 "sysctl -w lustre.fail_loc=0x0"
1183 run_test 59 "test log_commit_thread vs filter_destroy race"
1185 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1186 # bug 12086: should no oops and No ctxt error for this test
1189 createmany -o $DIR/$tdir/$tfile-%d 200
1190 replay_barrier $SINGLEMDS
1191 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1193 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1194 local no_ctxt=`dmesg | grep "No ctxt"`
1195 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1197 run_test 60 "test llog post recovery init vs llog unlink"
1199 equals_msg `basename $0`: test complete, cleaning up