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:-""}
22 ALWAYS_EXCEPT="$REPLAY_SINGLE_EXCEPT"
24 # 63 min 7 min AT AT AT AT"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
29 cleanup_and_setup_lustre
34 rm -rf $DIR/[df][0-9]*
36 test_0a() { # was test_0
39 replay_barrier $SINGLEMDS
43 run_test 0a "empty replay"
46 # this test attempts to trigger a race in the precreation code,
47 # and must run before any other objects are created on the filesystem
49 createmany -o $DIR/$tfile 20 || return 1
50 unlinkmany $DIR/$tfile 20 || return 2
52 run_test 0b "ensure object created after recover exists. (3284)"
58 lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
64 lctl get_param -n seq.cli-srv-$mds-mdc-*.width
67 # This test should pass for single-mds and multi-mds configs.
68 # But for different configurations it tests different things.
72 # (1) fld_create replay should happen;
74 # (2) fld_create replay should not return -EEXISTS, if it does
75 # this means sequence manager recovery code is buggy and allocated
76 # same sequence two times after recovery.
80 # (1) fld_create replay may not happen, because its home MDS is
81 # MDS2 which is not involved to revovery;
83 # (2) as fld_create does not happen on MDS1, it does not make any
86 local label=`mdsdevlabel 1`
87 [ -z "$label" ] && echo "No label for mds1" && return 1
89 replay_barrier $SINGLEMDS
90 local sw=`seq_get_width $label`
92 # make seq manager switch to next sequence each
93 # time as new fid is needed.
94 seq_set_width $label 1
96 # make sure that fld has created at least one new
98 touch $DIR/$tfile || return 2
99 seq_set_width $label $sw
101 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
104 # wait for recovery finish
108 # flush fld cache and dentry cache to make it lookup
109 # created entry instead of revalidating existent one
111 zconf_mount `hostname` $MOUNT
113 # issue lookup which should call fld lookup which
114 # should fail if client did not replay fld create
115 # correctly and server has no fld entry
116 touch $DIR/$tfile || return 3
117 rm $DIR/$tfile || return 4
119 run_test 0c "fld create"
122 replay_barrier $SINGLEMDS
125 $CHECKSTAT -t file $DIR/$tfile || return 1
128 run_test 1 "simple create"
131 replay_barrier $SINGLEMDS
134 $CHECKSTAT -t file $DIR/$tfile || return 1
141 replay_barrier $SINGLEMDS
144 $CHECKSTAT -t file $DIR/$tfile || return 1
150 replay_barrier $SINGLEMDS
152 o_directory $DIR/$tfile
154 $CHECKSTAT -t file $DIR/$tfile || return 2
157 run_test 3a "replay failed open(O_DIRECTORY)"
160 replay_barrier $SINGLEMDS
161 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
162 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
164 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
166 $CHECKSTAT -t file $DIR/$tfile && return 2
169 run_test 3b "replay failed open -ENOMEM"
172 replay_barrier $SINGLEMDS
173 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
176 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
179 $CHECKSTAT -t file $DIR/$tfile && return 2
182 run_test 3c "replay failed open -ENOMEM"
184 test_4a() { # was test_4
185 replay_barrier $SINGLEMDS
186 for i in `seq 10`; do
187 echo "tag-$i" > $DIR/$tfile-$i
190 for i in `seq 10`; do
191 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
194 run_test 4a "|x| 10 open(O_CREAT)s"
197 replay_barrier $SINGLEMDS
200 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
202 run_test 4b "|x| rm 10 files"
204 # The idea is to get past the first block of precreated files on both
205 # osts, and then replay.
207 replay_barrier $SINGLEMDS
208 for i in `seq 220`; do
209 echo "tag-$i" > $DIR/$tfile-$i
212 for i in `seq 220`; do
213 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
217 # waiting for commitment of removal
219 run_test 5 "|x| 220 open(O_CREAT)"
222 test_6a() { # was test_6
224 replay_barrier $SINGLEMDS
225 mcreate $DIR/$tdir/$tfile
227 $CHECKSTAT -t dir $DIR/$tdir || return 1
228 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
230 # waiting for log process thread
232 run_test 6a "mkdir + contained create"
236 replay_barrier $SINGLEMDS
239 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
241 run_test 6b "|X| rmdir"
245 replay_barrier $SINGLEMDS
246 mcreate $DIR/$tdir/$tfile
248 $CHECKSTAT -t dir $DIR/$tdir || return 1
249 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
252 run_test 7 "mkdir |X| contained create"
255 # make sure no side-effect from previous test.
257 replay_barrier $SINGLEMDS
258 multiop_bg_pause $DIR/$tfile mo_c || return 4
262 $CHECKSTAT -t file $DIR/$tfile || return 1
263 kill -USR1 $MULTIPID || return 2
264 wait $MULTIPID || return 3
267 run_test 8 "creat open |X| close"
270 replay_barrier $SINGLEMDS
272 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
274 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
276 echo " old_inum == $old_inum, new_inum == $new_inum"
277 if [ $old_inum -eq $new_inum ] ;
279 echo " old_inum and new_inum match"
281 echo "!!!! old_inum and new_inum NOT match"
286 run_test 9 "|X| create (same inum/gen)"
290 replay_barrier $SINGLEMDS
291 mv $DIR/$tfile $DIR/$tfile-2
294 $CHECKSTAT $DIR/$tfile && return 1
295 $CHECKSTAT $DIR/$tfile-2 ||return 2
299 run_test 10 "create |X| rename unlink"
303 echo "old" > $DIR/$tfile
304 mv $DIR/$tfile $DIR/$tfile-2
305 replay_barrier $SINGLEMDS
306 echo "new" > $DIR/$tfile
308 grep old $DIR/$tfile-2
310 grep new $DIR/$tfile || return 1
311 grep old $DIR/$tfile-2 || return 2
313 run_test 11 "create open write rename |X| create-old-name read"
317 multiop_bg_pause $DIR/$tfile o_tSc || return 3
320 replay_barrier $SINGLEMDS
322 wait $pid || return 1
325 [ -e $DIR/$tfile ] && return 2
328 run_test 12 "open, unlink |X| close"
331 # 1777 - replay open after committed chmod that would make
332 # a regular open a failure
335 multiop_bg_pause $DIR/$tfile O_wc || return 3
338 $CHECKSTAT -p 0 $DIR/$tfile
339 replay_barrier $SINGLEMDS
342 wait $pid || return 1
344 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
347 run_test 13 "open chmod 0 |x| write close"
350 multiop_bg_pause $DIR/$tfile O_tSc || return 4
353 replay_barrier $SINGLEMDS
354 kill -USR1 $pid || return 1
355 wait $pid || return 2
358 [ -e $DIR/$tfile ] && return 3
361 run_test 14 "open(O_CREAT), unlink |X| close"
364 multiop_bg_pause $DIR/$tfile O_tSc || return 5
367 replay_barrier $SINGLEMDS
368 touch $DIR/g11 || return 1
370 wait $pid || return 2
373 [ -e $DIR/$tfile ] && return 3
374 touch $DIR/h11 || return 4
377 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
381 replay_barrier $SINGLEMDS
384 mcreate $DIR/$tfile-2
386 [ -e $DIR/$tfile ] && return 1
387 [ -e $DIR/$tfile-2 ] || return 2
388 munlink $DIR/$tfile-2 || return 3
390 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
393 replay_barrier $SINGLEMDS
394 multiop_bg_pause $DIR/$tfile O_c || return 4
397 kill -USR1 $pid || return 1
398 wait $pid || return 2
399 $CHECKSTAT -t file $DIR/$tfile || return 3
402 run_test 17 "|X| open(O_CREAT), |replay| close"
405 replay_barrier $SINGLEMDS
406 multiop_bg_pause $DIR/$tfile O_tSc || return 8
409 touch $DIR/$tfile-2 || return 1
410 echo "pid: $pid will close"
412 wait $pid || return 2
415 [ -e $DIR/$tfile ] && return 3
416 [ -e $DIR/$tfile-2 ] || return 4
417 # this touch frequently fails
418 touch $DIR/$tfile-3 || return 5
419 munlink $DIR/$tfile-2 || return 6
420 munlink $DIR/$tfile-3 || return 7
423 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
425 # bug 1855 (a simpler form of test_11 above)
427 replay_barrier $SINGLEMDS
429 echo "old" > $DIR/$tfile
430 mv $DIR/$tfile $DIR/$tfile-2
431 grep old $DIR/$tfile-2
433 grep old $DIR/$tfile-2 || return 2
435 run_test 19 "|X| mcreate, open, write, rename "
437 test_20a() { # was test_20
438 replay_barrier $SINGLEMDS
439 multiop_bg_pause $DIR/$tfile O_tSc || return 3
445 wait $pid || return 1
446 [ -e $DIR/$tfile ] && return 2
449 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
451 test_20b() { # bug 10480
452 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
454 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
456 while [ ! -e $DIR/$tfile ] ; do
457 usleep 60 # give dd a chance to start
460 lfs getstripe $DIR/$tfile || return 1
461 rm -f $DIR/$tfile || return 2 # make it an orphan
463 df -P $DIR || df -P $DIR || true # reconnect
465 fail $SINGLEMDS # start orphan recovery
466 df -P $DIR || df -P $DIR || true # reconnect
467 wait_mds_recovery_done || error "MDS recovery not done"
469 # FIXME just because recovery is done doesn't mean we've finished
470 # orphan cleanup. Fake it with a sleep for now...
472 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
473 log "before $BEFOREUSED, after $AFTERUSED"
474 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
475 error "after $AFTERUSED > before $BEFOREUSED"
478 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
480 test_20c() { # bug 10480
481 multiop_bg_pause $DIR/$tfile Ow_c || return 1
488 df -P $DIR || df -P $DIR || true # reconnect
491 test -s $DIR/$tfile || error "File was truncated"
495 run_test 20c "check that client eviction does not affect file content"
498 replay_barrier $SINGLEMDS
499 multiop_bg_pause $DIR/$tfile O_tSc || return 5
502 touch $DIR/g11 || return 1
506 wait $pid || return 2
507 [ -e $DIR/$tfile ] && return 3
508 touch $DIR/h11 || return 4
511 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
514 multiop_bg_pause $DIR/$tfile O_tSc || return 3
517 replay_barrier $SINGLEMDS
522 wait $pid || return 1
523 [ -e $DIR/$tfile ] && return 2
526 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
529 multiop_bg_pause $DIR/$tfile O_tSc || return 5
532 replay_barrier $SINGLEMDS
534 touch $DIR/g11 || return 1
538 wait $pid || return 2
539 [ -e $DIR/$tfile ] && return 3
540 touch $DIR/h11 || return 4
543 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
546 multiop_bg_pause $DIR/$tfile O_tSc || return 3
549 replay_barrier $SINGLEMDS
553 wait $pid || return 1
554 [ -e $DIR/$tfile ] && return 2
557 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
560 multiop_bg_pause $DIR/$tfile O_tSc || return 3
564 replay_barrier $SINGLEMDS
567 wait $pid || return 1
568 [ -e $DIR/$tfile ] && return 2
571 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
574 replay_barrier $SINGLEMDS
575 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
577 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
582 wait $pid2 || return 1
586 wait $pid1 || return 2
587 [ -e $DIR/$tfile-1 ] && return 3
588 [ -e $DIR/$tfile-2 ] && return 4
591 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
594 replay_barrier $SINGLEMDS
595 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
597 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
604 wait $pid1 || return 1
606 wait $pid2 || return 2
607 [ -e $DIR/$tfile-1 ] && return 3
608 [ -e $DIR/$tfile-2 ] && return 4
611 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
614 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
616 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
618 replay_barrier $SINGLEMDS
622 wait $pid2 || return 1
626 wait $pid1 || return 2
627 [ -e $DIR/$tfile-1 ] && return 3
628 [ -e $DIR/$tfile-2 ] && return 4
631 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
634 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
636 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
638 replay_barrier $SINGLEMDS
644 wait $pid1 || return 1
646 wait $pid2 || return 2
647 [ -e $DIR/$tfile-1 ] && return 3
648 [ -e $DIR/$tfile-2 ] && return 4
651 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
654 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
656 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
661 replay_barrier $SINGLEMDS
664 wait $pid1 || return 1
666 wait $pid2 || return 2
667 [ -e $DIR/$tfile-1 ] && return 3
668 [ -e $DIR/$tfile-2 ] && return 4
671 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
674 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
676 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
680 replay_barrier $SINGLEMDS
684 wait $pid1 || return 1
686 wait $pid2 || return 2
687 [ -e $DIR/$tfile-1 ] && return 3
688 [ -e $DIR/$tfile-2 ] && return 4
691 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
693 # tests for bug 2104; completion without crashing is success. The close is
694 # stale, but we always return 0 for close, so the app never sees it.
696 multiop_bg_pause $DIR/$tfile O_c || return 2
698 multiop_bg_pause $DIR/$tfile O_c || return 3
701 df $MOUNT || sleep 1 && df $MOUNT || return 1
707 run_test 32 "close() notices client eviction; close() after client eviction"
709 # Abort recovery before client complete
710 test_33a() { # was test_33
711 replay_barrier $SINGLEMDS
712 createmany -o $DIR/$tfile-%d 100
713 fail_abort $SINGLEMDS
714 # this file should be gone, because the replay was aborted
715 $CHECKSTAT -t file $DIR/$tfile-* && return 3
716 unlinkmany $DIR/$tfile-%d 0 100
719 run_test 33a "abort recovery before client does replay"
722 test_33b() { # was test_33a
723 replay_barrier $SINGLEMDS
724 createmany -o $DIR/$tfile-%d 10
725 fail_abort $SINGLEMDS
726 unlinkmany $DIR/$tfile-%d 0 10
727 # recreate shouldn't fail
728 createmany -o $DIR/$tfile-%d 10 || return 3
729 unlinkmany $DIR/$tfile-%d 0 10
732 run_test 33b "fid shouldn't be reused after abort recovery"
735 multiop_bg_pause $DIR/$tfile O_c || return 2
739 replay_barrier $SINGLEMDS
740 fail_abort $SINGLEMDS
742 [ -e $DIR/$tfile ] && return 1
746 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
748 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
752 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
753 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
758 # give a chance to remove from MDS
759 fail_abort $SINGLEMDS
760 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
762 run_test 35 "test recovery from llog for unlink op"
764 # b=2432 resent cancel after replay uses wrong cookie,
765 # so don't resend cancels
767 replay_barrier $SINGLEMDS
769 checkstat $DIR/$tfile
770 facet_failover $SINGLEMDS
772 if dmesg | grep "unknown lock cookie"; then
773 echo "cancel after replay failed"
777 run_test 36 "don't resend cancel"
780 # directory orphans can't be unlinked from PENDING directory
782 rmdir $DIR/$tfile 2>/dev/null
783 multiop_bg_pause $DIR/$tfile dD_c || return 2
787 replay_barrier $SINGLEMDS
788 # clear the dmesg buffer so we only see errors from this recovery
790 fail_abort $SINGLEMDS
792 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
796 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
799 createmany -o $DIR/$tfile-%d 800
800 unlinkmany $DIR/$tfile-%d 0 400
801 replay_barrier $SINGLEMDS
803 unlinkmany $DIR/$tfile-%d 400 400
805 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
807 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
809 test_39() { # bug 4176
810 createmany -o $DIR/$tfile-%d 800
811 replay_barrier $SINGLEMDS
812 unlinkmany $DIR/$tfile-%d 0 400
814 unlinkmany $DIR/$tfile-%d 400 400
816 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
818 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
821 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
826 $LCTL mark multiop $MOUNT/$tfile OS_c
827 multiop $MOUNT/$tfile OS_c &
829 writeme -s $MOUNT/${tfile}-2 &
832 facet_failover $SINGLEMDS
833 #define OBD_FAIL_MDS_CONNECT_NET 0x117
834 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
836 stat1=`count_ost_writes`
838 stat2=`count_ost_writes`
839 echo "$stat1, $stat2"
840 if [ $stat1 -lt $stat2 ]; then
841 echo "writes continuing during recovery"
844 echo "writes not continuing during recovery, bug 2477"
847 echo "waiting for writeme $WRITE_PID"
851 echo "waiting for multiop $PID"
852 wait $PID || return 2
853 do_facet client munlink $MOUNT/$tfile || return 3
854 do_facet client munlink $MOUNT/${tfile}-2 || return 3
857 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
861 # make sure that a read to one osc doesn't try to double-unlock its page just
862 # because another osc is invalid. trigger_group_io used to mistakenly return
863 # an error if any oscs were invalid even after having successfully put rpcs
864 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
865 # the page, guarnateeing that the unlock from the RPC completion would
866 # assert on trying to unlock the unlocked page.
868 [ $OSTCOUNT -lt 2 ] && \
869 skip "skipping test 41: we don't have a second OST to test with" && \
872 local f=$MOUNT/$tfile
873 # make sure the start of the file is ost1
874 lfs setstripe $f -s $((128 * 1024)) -i 0
875 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
877 # fail ost2 and read from ost1
878 local osc2dev=`do_facet mds "lctl get_param -n devices | grep ${ost2_svc}-osc-MDT0000" | awk '{print $1}'`
879 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
880 do_facet mds $LCTL --device $osc2dev deactivate || return 1
881 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
882 do_facet mds $LCTL --device $osc2dev activate || return 2
885 run_test 41 "read from a valid osc while other oscs are invalid"
887 # test MDS recovery after ost failure
889 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
890 createmany -o $DIR/$tfile-%d 800
892 unlinkmany $DIR/$tfile-%d 0 400
894 lctl set_param debug=-1
897 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
898 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
899 #[ $blocks_after -lt $blocks ] || return 1
900 echo wait for MDS to timeout and recover
901 sleep $((TIMEOUT * 2))
903 unlinkmany $DIR/$tfile-%d 400 400
904 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
906 run_test 42 "recovery after ost failure"
908 # timeout in MDS/OST recovery RPC will LBUG MDS
909 test_43() { # bug 2530
910 replay_barrier $SINGLEMDS
912 # OBD_FAIL_OST_CREATE_NET 0x204
913 do_facet ost1 "lctl set_param fail_loc=0x80000204"
916 do_facet ost1 "lctl set_param fail_loc=0"
920 run_test 43 "mds osc import failure during recovery; don't LBUG"
922 test_44a() { # was test_44
923 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
924 [ "$mdcdev" ] || exit 2
925 for i in `seq 1 10`; do
926 #define OBD_FAIL_TGT_CONN_RACE 0x701
927 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
928 $LCTL --device $mdcdev recover
931 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
934 run_test 44a "race in target handle connect"
937 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
938 [ "$mdcdev" ] || exit 2
939 for i in `seq 1 10`; do
940 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
941 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
942 $LCTL --device $mdcdev recover
945 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
948 run_test 44b "race in target handle connect"
950 # Handle failed close
952 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
953 [ "$mdcdev" ] || exit 2
954 $LCTL --device $mdcdev recover
956 multiop_bg_pause $DIR/$tfile O_c || return 1
959 # This will cause the CLOSE to fail before even
960 # allocating a reply buffer
961 $LCTL --device $mdcdev deactivate || return 4
965 wait $pid || return 1
967 $LCTL --device $mdcdev activate || return 5
970 $CHECKSTAT -t file $DIR/$tfile || return 2
973 run_test 45 "Handle failed close"
977 drop_reply "touch $DIR/$tfile"
979 # ironically, the previous test, 45, will cause a real forced close,
980 # so just look for one for this test
981 dmesg | grep -i "force closing client file handle for $tfile" && return 1
984 run_test 46 "Don't leak file handle after open resend (3325)"
986 test_47() { # bug 2824
987 # create some files to make sure precreate has been done on all
988 # OSTs. (just in case this test is run independently)
989 createmany -o $DIR/$tfile 20 || return 1
991 # OBD_FAIL_OST_CREATE_NET 0x204
993 do_facet ost1 "lctl set_param fail_loc=0x80000204"
994 df $MOUNT || return 2
996 # let the MDS discover the OST failure, attempt to recover, fail
998 sleep $((3 * TIMEOUT))
1000 # Without 2824, this createmany would hang
1001 createmany -o $DIR/$tfile 20 || return 3
1002 unlinkmany $DIR/$tfile 20 || return 4
1004 do_facet ost1 "lctl set_param fail_loc=0"
1007 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1010 replay_barrier $SINGLEMDS
1011 createmany -o $DIR/$tfile 20 || return 1
1012 # OBD_FAIL_OST_EROFS 0x216
1014 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1015 df $MOUNT || return 2
1017 createmany -o $DIR/$tfile 20 20 || return 2
1018 unlinkmany $DIR/$tfile 40 || return 3
1020 do_facet ost1 "lctl set_param fail_loc=0"
1023 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1026 local oscdev=`do_facet $SINGLEMDS lctl get_param -n devices | grep ${ost1_svc}-osc-MDT0000 | awk '{print $1}'`
1027 [ "$oscdev" ] || return 1
1028 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1029 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1030 # give the mds_lov_sync threads a chance to run
1033 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1035 # b3764 timed out lock replay
1038 cancel_lru_locks mdc
1040 multiop $DIR/$tfile s || return 1
1041 replay_barrier $SINGLEMDS
1042 #define OBD_FAIL_LDLM_REPLY 0x30c
1043 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1044 fail $SINGLEMDS || return 2
1045 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1047 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1049 run_test 52 "time out lock replay (3764)"
1051 # bug 3462 - simultaneous MDC requests
1053 mkdir -p $DIR/${tdir}-1
1054 mkdir -p $DIR/${tdir}-2
1055 multiop $DIR/${tdir}-1/f O_c &
1057 # give multiop a change to open
1060 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1061 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1062 kill -USR1 $close_pid
1063 cancel_lru_locks mdc # force the close
1064 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1066 mcreate $DIR/${tdir}-2/f || return 1
1068 # close should still be here
1069 [ -d /proc/$close_pid ] || return 2
1071 replay_barrier_nodf $SINGLEMDS
1073 wait $close_pid || return 3
1075 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1076 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1077 rm -rf $DIR/${tdir}-*
1079 run_test 53a "|X| close request while two MDC requests in flight"
1082 mkdir -p $DIR/${tdir}-1
1083 mkdir -p $DIR/${tdir}-2
1084 multiop $DIR/${tdir}-1/f O_c &
1087 #define OBD_FAIL_MDS_REINT_NET 0x107
1088 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1089 mcreate $DIR/${tdir}-2/f &
1093 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1094 kill -USR1 $close_pid
1095 cancel_lru_locks mdc # force the close
1096 wait $close_pid || return 1
1097 # open should still be here
1098 [ -d /proc/$open_pid ] || return 2
1100 replay_barrier_nodf $SINGLEMDS
1102 wait $open_pid || return 3
1104 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1105 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1106 rm -rf $DIR/${tdir}-*
1108 run_test 53b "|X| open request while two MDC requests in flight"
1111 mkdir -p $DIR/${tdir}-1
1112 mkdir -p $DIR/${tdir}-2
1113 multiop $DIR/${tdir}-1/f O_c &
1116 #define OBD_FAIL_MDS_REINT_NET 0x107
1117 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1118 mcreate $DIR/${tdir}-2/f &
1122 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1123 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1124 kill -USR1 $close_pid
1125 cancel_lru_locks mdc # force the close
1127 replay_barrier_nodf $SINGLEMDS
1128 fail_nodf $SINGLEMDS
1129 wait $open_pid || return 1
1131 # close should be gone
1132 [ -d /proc/$close_pid ] && return 2
1133 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1135 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1136 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1137 rm -rf $DIR/${tdir}-*
1139 run_test 53c "|X| open request and close request while two MDC requests in flight"
1142 mkdir -p $DIR/${tdir}-1
1143 mkdir -p $DIR/${tdir}-2
1144 multiop $DIR/${tdir}-1/f O_c &
1146 # give multiop a chance to open
1149 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1150 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1151 kill -USR1 $close_pid
1152 cancel_lru_locks mdc # force the close
1153 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1154 mcreate $DIR/${tdir}-2/f || return 1
1156 # close should still be here
1157 [ -d /proc/$close_pid ] || return 2
1159 wait $close_pid || return 3
1161 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1162 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1163 rm -rf $DIR/${tdir}-*
1165 run_test 53d "|X| close reply while two MDC requests in flight"
1168 mkdir -p $DIR/${tdir}-1
1169 mkdir -p $DIR/${tdir}-2
1170 multiop $DIR/${tdir}-1/f O_c &
1173 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1174 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1175 mcreate $DIR/${tdir}-2/f &
1179 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1180 kill -USR1 $close_pid
1181 cancel_lru_locks mdc # force the close
1182 wait $close_pid || return 1
1183 # open should still be here
1184 [ -d /proc/$open_pid ] || return 2
1186 replay_barrier_nodf $SINGLEMDS
1188 wait $open_pid || return 3
1190 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1191 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1192 rm -rf $DIR/${tdir}-*
1194 run_test 53e "|X| open reply while two MDC requests in flight"
1197 mkdir -p $DIR/${tdir}-1
1198 mkdir -p $DIR/${tdir}-2
1199 multiop $DIR/${tdir}-1/f O_c &
1202 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1203 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1204 mcreate $DIR/${tdir}-2/f &
1208 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1209 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1210 kill -USR1 $close_pid
1211 cancel_lru_locks mdc # force the close
1213 replay_barrier_nodf $SINGLEMDS
1214 fail_nodf $SINGLEMDS
1215 wait $open_pid || return 1
1217 # close should be gone
1218 [ -d /proc/$close_pid ] && return 2
1219 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1221 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1222 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1223 rm -rf $DIR/${tdir}-*
1225 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1228 mkdir -p $DIR/${tdir}-1
1229 mkdir -p $DIR/${tdir}-2
1230 multiop $DIR/${tdir}-1/f O_c &
1233 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1234 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1235 mcreate $DIR/${tdir}-2/f &
1239 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1240 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1241 kill -USR1 $close_pid
1242 cancel_lru_locks mdc # force the close
1244 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1245 replay_barrier_nodf $SINGLEMDS
1246 fail_nodf $SINGLEMDS
1247 wait $open_pid || return 1
1249 # close should be gone
1250 [ -d /proc/$close_pid ] && return 2
1252 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1253 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1254 rm -rf $DIR/${tdir}-*
1256 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1259 mkdir -p $DIR/${tdir}-1
1260 mkdir -p $DIR/${tdir}-2
1261 multiop $DIR/${tdir}-1/f O_c &
1264 #define OBD_FAIL_MDS_REINT_NET 0x107
1265 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1266 mcreate $DIR/${tdir}-2/f &
1270 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1271 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013f"
1272 kill -USR1 $close_pid
1273 cancel_lru_locks mdc # force the close
1276 replay_barrier_nodf $SINGLEMDS
1277 fail_nodf $SINGLEMDS
1278 wait $open_pid || return 1
1280 # close should be gone
1281 [ -d /proc/$close_pid ] && return 2
1282 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1284 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1285 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1286 rm -rf $DIR/${tdir}-*
1288 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1290 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1292 #b3761 ASSERTION(hash != 0) failed
1294 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1295 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1297 # give touch a chance to run
1299 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1303 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1305 #b3440 ASSERTION(rec->ur_fid2->id) failed
1307 ln -s foo $DIR/$tfile
1308 replay_barrier $SINGLEMDS
1309 #drop_reply "cat $DIR/$tfile"
1313 run_test 56 "don't replay a symlink open request (3440)"
1315 #recovery one mds-ost setattr from llog
1317 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1318 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1320 replay_barrier $SINGLEMDS
1323 $CHECKSTAT -t file $DIR/$tfile || return 1
1324 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1327 run_test 57 "test recovery from llog for setattr op"
1329 #recovery many mds-ost setattr from llog
1332 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1333 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1334 createmany -o $DIR/$tdir/$tfile-%d 2500
1335 replay_barrier $SINGLEMDS
1338 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1339 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1340 unlinkmany $DIR/$tdir/$tfile-%d 2500
1343 run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)"
1345 # log_commit_thread vs filter_destroy race used to lead to import use after free
1349 createmany -o $DIR/$tdir/$tfile-%d 200
1351 unlinkmany $DIR/$tdir/$tfile-%d 200
1352 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1353 do_facet ost1 "lctl set_param fail_loc=0x507"
1356 do_facet ost1 "lctl set_param fail_loc=0x0"
1360 run_test 59 "test log_commit_thread vs filter_destroy race"
1362 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1363 # bug 12086: should no oops and No ctxt error for this test
1366 createmany -o $DIR/$tdir/$tfile-%d 200
1367 replay_barrier $SINGLEMDS
1368 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1370 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1371 local no_ctxt=`dmesg | grep "No ctxt"`
1372 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1374 run_test 60 "test llog post recovery init vs llog unlink"
1376 #test race llog recovery thread vs llog cleanup
1377 test_61a() { # was test_61
1379 createmany -o $DIR/$tdir/$tfile-%d 800
1381 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1382 unlinkmany $DIR/$tdir/$tfile-%d 800
1383 set_nodes_failloc "$(osts_nodes)" 0x80000221
1388 set_nodes_failloc "$(osts_nodes)" 0x0
1390 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1393 run_test 61a "test race llog recovery vs llog cleanup"
1395 #test race mds llog sync vs llog cleanup
1397 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x140
1398 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
1399 facet_failover $SINGLEMDS
1402 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1404 run_test 61b "test race mds llog sync vs llog cleanup"
1406 #test race cancel cookie cb vs llog cleanup
1408 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1410 set_nodes_failloc "$(osts_nodes)" 0x80000222
1414 set_nodes_failloc "$(osts_nodes)" 0x0
1416 run_test 61c "test race mds llog sync vs llog cleanup"
1418 # start multi-client tests
1420 [ -z "$CLIENTS" ] && \
1421 { skip "Need two or more clients." && return; }
1422 [ $CLIENTCOUNT -lt 2 ] && \
1423 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1425 echo "mount clients $CLIENTS ..."
1426 zconf_mount_clients $CLIENTS $DIR
1428 local clients=${CLIENTS//,/ }
1429 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1430 for CLIENT in $clients; do
1431 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1432 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1433 error "dd failed on $CLIENT"
1436 local prev_client=$(echo $clients | sed 's/^.* \(\w\+\)$/\1/')
1437 for C in ${CLIENTS//,/ }; do
1438 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1439 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1445 zconf_umount_clients $CLIENTS $DIR
1447 run_test 70a "check multi client t-f"
1450 [ -z "$CLIENTS" ] && \
1451 { skip "Need two or more clients." && return; }
1452 [ $CLIENTCOUNT -lt 2 ] && \
1453 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1455 zconf_mount_clients $CLIENTS $DIR
1457 local duration="-t 60"
1458 local cmd="rundbench 1 $duration "
1460 for CLIENT in ${CLIENTS//,/ }; do
1461 $PDSH $CLIENT "set -x; PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:${DBENCH_LIB} DBENCH_LIB=${DBENCH_LIB} $cmd" &
1463 echo $PID >pid.$CLIENT
1464 echo "Started load PID=`cat pid.$CLIENT`"
1467 replay_barrier $SINGLEMDS
1468 sleep 3 # give clients a time to do operations
1470 log "$TESTNAME fail mds 1"
1473 # wait for client to reconnect to MDS
1476 for CLIENT in ${CLIENTS//,/ }; do
1477 PID=`cat pid.$CLIENT`
1480 echo "load on ${CLIENT} returned $rc"
1483 zconf_umount_clients $CLIENTS $DIR
1485 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1486 # end multi-client tests
1488 equals_msg `basename $0`: test complete, cleaning up
1489 check_and_cleanup_lustre
1490 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true