7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-`dirname $0`/..}
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:-""}
21 # bug number: 2766 4176 11404
22 ALWAYS_EXCEPT="0b 39 56 $REPLAY_SINGLE_EXCEPT"
24 # 63 min 7 min AT AT AT AT"
25 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 6b 12 16 44 44b 65 66 67 68"
29 cleanup_and_setup_lustre
33 rm -rf $DIR/[df][0-9]*
38 replay_barrier $SINGLEMDS
42 run_test 0 "empty replay"
45 # this test attempts to trigger a race in the precreation code,
46 # and must run before any other objects are created on the filesystem
48 createmany -o $DIR/$tfile 20 || return 1
49 unlinkmany $DIR/$tfile 20 || return 2
51 run_test 0b "ensure object created after recover exists. (3284)"
57 local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
64 local file=`ls /proc/fs/lustre/seq/cli-srv-$mds-mdc-*/width`
68 # This test should pass for single-mds and multi-mds configs.
69 # But for different configurations it tests different things.
73 # (1) fld_create replay should happen;
75 # (2) fld_create replay should not return -EEXISTS, if it does
76 # this means sequence manager recovery code is buggy and allocated
77 # same sequence two times after recovery.
81 # (1) fld_create replay may not happen, because its home MDS is
82 # MDS2 which is not involved to revovery;
84 # (2) as fld_create does not happen on MDS1, it does not make any
87 local label=`mdsdevlabel 1`
88 [ -z "$label" ] && echo "No label for mds1" && return 1
90 replay_barrier $SINGLEMDS
91 local sw=`seq_get_width $label`
93 # make seq manager switch to next sequence each
94 # time as new fid is needed.
95 seq_set_width $label 1
97 # make sure that fld has created at least one new
99 touch $DIR/$tfile || return 2
100 seq_set_width $label $sw
102 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
105 # wait for recovery finish
109 # flush fld cache and dentry cache to make it lookup
110 # created entry instead of revalidating existent one
112 zconf_mount `hostname` $MOUNT
114 # issue lookup which should call fld lookup which
115 # should fail if client did not replay fld create
116 # correctly and server has no fld entry
117 touch $DIR/$tfile || return 3
118 rm $DIR/$tfile || return 4
120 run_test 0c "fld create"
123 replay_barrier $SINGLEMDS
126 $CHECKSTAT -t file $DIR/$tfile || return 1
129 run_test 1 "simple create"
132 replay_barrier $SINGLEMDS
135 $CHECKSTAT -t file $DIR/$tfile || return 1
142 replay_barrier $SINGLEMDS
145 $CHECKSTAT -t file $DIR/$tfile || return 1
151 replay_barrier $SINGLEMDS
153 o_directory $DIR/$tfile
155 $CHECKSTAT -t file $DIR/$tfile || return 2
158 run_test 3a "replay failed open(O_DIRECTORY)"
161 replay_barrier $SINGLEMDS
162 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
163 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000114"
165 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
167 $CHECKSTAT -t file $DIR/$tfile && return 2
170 run_test 3b "replay failed open -ENOMEM"
173 replay_barrier $SINGLEMDS
174 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
175 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000128"
177 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
180 $CHECKSTAT -t file $DIR/$tfile && return 2
183 run_test 3c "replay failed open -ENOMEM"
186 replay_barrier $SINGLEMDS
187 for i in `seq 10`; do
188 echo "tag-$i" > $DIR/$tfile-$i
191 for i in `seq 10`; do
192 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
195 run_test 4 "|x| 10 open(O_CREAT)s"
198 replay_barrier $SINGLEMDS
201 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
203 run_test 4b "|x| rm 10 files"
205 # The idea is to get past the first block of precreated files on both
206 # osts, and then replay.
208 replay_barrier $SINGLEMDS
209 for i in `seq 220`; do
210 echo "tag-$i" > $DIR/$tfile-$i
213 for i in `seq 220`; do
214 grep -q "tag-$i" $DIR/$tfile-$i || error "f1c-$i"
218 # waiting for commitment of removal
220 run_test 5 "|x| 220 open(O_CREAT)"
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 6 "mkdir + contained create"
235 replay_barrier $SINGLEMDS
238 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
240 run_test 6b "|X| rmdir"
243 replay_barrier $SINGLEMDS
244 mcreate $DIR/$tdir/$tfile
246 $CHECKSTAT -t dir $DIR/$tdir || return 1
247 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
250 run_test 7 "mkdir |X| contained create"
253 # make sure no side-effect from previous test.
255 replay_barrier $SINGLEMDS
256 multiop_bg_pause $DIR/$tfile mo_c || return 4
260 $CHECKSTAT -t file $DIR/$tfile || return 1
261 kill -USR1 $MULTIPID || return 2
262 wait $MULTIPID || return 3
265 run_test 8 "creat open |X| close"
268 replay_barrier $SINGLEMDS
270 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
272 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
274 echo " old_inum == $old_inum, new_inum == $new_inum"
275 if [ $old_inum -eq $new_inum ] ;
277 echo " old_inum and new_inum match"
279 echo "!!!! old_inum and new_inum NOT match"
284 run_test 9 "|X| create (same inum/gen)"
288 replay_barrier $SINGLEMDS
289 mv $DIR/$tfile $DIR/$tfile-2
292 $CHECKSTAT $DIR/$tfile && return 1
293 $CHECKSTAT $DIR/$tfile-2 ||return 2
297 run_test 10 "create |X| rename unlink"
301 echo "old" > $DIR/$tfile
302 mv $DIR/$tfile $DIR/$tfile-2
303 replay_barrier $SINGLEMDS
304 echo "new" > $DIR/$tfile
306 grep old $DIR/$tfile-2
308 grep new $DIR/$tfile || return 1
309 grep old $DIR/$tfile-2 || return 2
311 run_test 11 "create open write rename |X| create-old-name read"
315 multiop_bg_pause $DIR/$tfile o_tSc || return 3
318 replay_barrier $SINGLEMDS
320 wait $pid || return 1
323 [ -e $DIR/$tfile ] && return 2
326 run_test 12 "open, unlink |X| close"
329 # 1777 - replay open after committed chmod that would make
330 # a regular open a failure
333 multiop_bg_pause $DIR/$tfile O_wc || return 3
336 $CHECKSTAT -p 0 $DIR/$tfile
337 replay_barrier $SINGLEMDS
340 wait $pid || return 1
342 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
345 run_test 13 "open chmod 0 |x| write close"
348 multiop_bg_pause $DIR/$tfile O_tSc || return 4
351 replay_barrier $SINGLEMDS
352 kill -USR1 $pid || return 1
353 wait $pid || return 2
356 [ -e $DIR/$tfile ] && return 3
359 run_test 14 "open(O_CREAT), unlink |X| close"
362 multiop_bg_pause $DIR/$tfile O_tSc || return 5
365 replay_barrier $SINGLEMDS
366 touch $DIR/g11 || return 1
368 wait $pid || return 2
371 [ -e $DIR/$tfile ] && return 3
372 touch $DIR/h11 || return 4
375 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
379 replay_barrier $SINGLEMDS
382 mcreate $DIR/$tfile-2
384 [ -e $DIR/$tfile ] && return 1
385 [ -e $DIR/$tfile-2 ] || return 2
386 munlink $DIR/$tfile-2 || return 3
388 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
391 replay_barrier $SINGLEMDS
392 multiop_bg_pause $DIR/$tfile O_c || return 4
395 kill -USR1 $pid || return 1
396 wait $pid || return 2
397 $CHECKSTAT -t file $DIR/$tfile || return 3
400 run_test 17 "|X| open(O_CREAT), |replay| close"
403 replay_barrier $SINGLEMDS
404 multiop_bg_pause $DIR/$tfile O_tSc || return 8
407 touch $DIR/$tfile-2 || return 1
408 echo "pid: $pid will close"
410 wait $pid || return 2
413 [ -e $DIR/$tfile ] && return 3
414 [ -e $DIR/$tfile-2 ] || return 4
415 # this touch frequently fails
416 touch $DIR/$tfile-3 || return 5
417 munlink $DIR/$tfile-2 || return 6
418 munlink $DIR/$tfile-3 || return 7
421 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
423 # bug 1855 (a simpler form of test_11 above)
425 replay_barrier $SINGLEMDS
427 echo "old" > $DIR/$tfile
428 mv $DIR/$tfile $DIR/$tfile-2
429 grep old $DIR/$tfile-2
431 grep old $DIR/$tfile-2 || return 2
433 run_test 19 "|X| mcreate, open, write, rename "
436 replay_barrier $SINGLEMDS
437 multiop_bg_pause $DIR/$tfile O_tSc || return 3
443 wait $pid || return 1
444 [ -e $DIR/$tfile ] && return 2
447 run_test 20 "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
449 test_20b() { # bug 10480
450 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
452 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
454 while [ ! -e $DIR/$tfile ] ; do
455 usleep 60 # give dd a chance to start
458 lfs getstripe $DIR/$tfile || return 1
459 rm -f $DIR/$tfile || return 2 # make it an orphan
461 df -P $DIR || df -P $DIR || true # reconnect
463 fail $SINGLEMDS # start orphan recovery
464 df -P $DIR || df -P $DIR || true # reconnect
465 wait_mds_recovery_done || error "MDS recovery not done"
467 # FIXME just because recovery is done doesn't mean we've finished
468 # orphan cleanup. Fake it with a sleep for now...
470 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
471 log "before $BEFOREUSED, after $AFTERUSED"
472 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
473 error "after $AFTERUSED > before $BEFOREUSED"
476 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
478 test_20c() { # bug 10480
479 multiop_bg_pause $DIR/$tfile Ow_c || return 1
486 df -P $DIR || df -P $DIR || true # reconnect
489 test -s $DIR/$tfile || error "File was truncated"
493 run_test 20c "check that client eviction does not affect file content"
496 replay_barrier $SINGLEMDS
497 multiop_bg_pause $DIR/$tfile O_tSc || return 5
500 touch $DIR/g11 || return 1
504 wait $pid || return 2
505 [ -e $DIR/$tfile ] && return 3
506 touch $DIR/h11 || return 4
509 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
512 multiop_bg_pause $DIR/$tfile O_tSc || return 3
515 replay_barrier $SINGLEMDS
520 wait $pid || return 1
521 [ -e $DIR/$tfile ] && return 2
524 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
527 multiop_bg_pause $DIR/$tfile O_tSc || return 5
530 replay_barrier $SINGLEMDS
532 touch $DIR/g11 || return 1
536 wait $pid || return 2
537 [ -e $DIR/$tfile ] && return 3
538 touch $DIR/h11 || return 4
541 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
544 multiop_bg_pause $DIR/$tfile O_tSc || return 3
547 replay_barrier $SINGLEMDS
551 wait $pid || return 1
552 [ -e $DIR/$tfile ] && return 2
555 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
558 multiop_bg_pause $DIR/$tfile O_tSc || return 3
562 replay_barrier $SINGLEMDS
565 wait $pid || return 1
566 [ -e $DIR/$tfile ] && return 2
569 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
572 replay_barrier $SINGLEMDS
573 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
575 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
580 wait $pid2 || return 1
584 wait $pid1 || return 2
585 [ -e $DIR/$tfile-1 ] && return 3
586 [ -e $DIR/$tfile-2 ] && return 4
589 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
592 replay_barrier $SINGLEMDS
593 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
595 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
602 wait $pid1 || return 1
604 wait $pid2 || return 2
605 [ -e $DIR/$tfile-1 ] && return 3
606 [ -e $DIR/$tfile-2 ] && return 4
609 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
612 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
614 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
616 replay_barrier $SINGLEMDS
620 wait $pid2 || return 1
624 wait $pid1 || return 2
625 [ -e $DIR/$tfile-1 ] && return 3
626 [ -e $DIR/$tfile-2 ] && return 4
629 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
632 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
634 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
636 replay_barrier $SINGLEMDS
642 wait $pid1 || return 1
644 wait $pid2 || return 2
645 [ -e $DIR/$tfile-1 ] && return 3
646 [ -e $DIR/$tfile-2 ] && return 4
649 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
652 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
654 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
659 replay_barrier $SINGLEMDS
662 wait $pid1 || return 1
664 wait $pid2 || return 2
665 [ -e $DIR/$tfile-1 ] && return 3
666 [ -e $DIR/$tfile-2 ] && return 4
669 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
672 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
674 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
678 replay_barrier $SINGLEMDS
682 wait $pid1 || return 1
684 wait $pid2 || return 2
685 [ -e $DIR/$tfile-1 ] && return 3
686 [ -e $DIR/$tfile-2 ] && return 4
689 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
691 # tests for bug 2104; completion without crashing is success. The close is
692 # stale, but we always return 0 for close, so the app never sees it.
694 multiop_bg_pause $DIR/$tfile O_c || return 2
696 multiop_bg_pause $DIR/$tfile O_c || return 3
699 df $MOUNT || sleep 1 && df $MOUNT || return 1
705 run_test 32 "close() notices client eviction; close() after client eviction"
707 # Abort recovery before client complete
709 replay_barrier $SINGLEMDS
710 createmany -o $DIR/$tfile-%d 100
711 fail_abort $SINGLEMDS
712 # this file should be gone, because the replay was aborted
713 $CHECKSTAT -t file $DIR/$tfile-* && return 3
714 unlinkmany $DIR/$tfile-%d 0 100
717 run_test 33 "abort recovery before client does replay"
721 replay_barrier $SINGLEMDS
722 createmany -o $DIR/$tfile-%d 10
723 fail_abort $SINGLEMDS
724 unlinkmany $DIR/$tfile-%d 0 10
725 # recreate shouldn't fail
726 createmany -o $DIR/$tfile-%d 10 || return 3
727 unlinkmany $DIR/$tfile-%d 0 10
730 run_test 33a "fid shouldn't be reused after abort recovery"
733 multiop_bg_pause $DIR/$tfile O_c || return 2
737 replay_barrier $SINGLEMDS
738 fail_abort $SINGLEMDS
740 [ -e $DIR/$tfile ] && return 1
744 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
746 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
750 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
751 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000119"
756 # give a chance to remove from MDS
757 fail_abort $SINGLEMDS
758 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
760 run_test 35 "test recovery from llog for unlink op"
762 # b=2432 resent cancel after replay uses wrong cookie,
763 # so don't resend cancels
765 replay_barrier $SINGLEMDS
767 checkstat $DIR/$tfile
768 facet_failover $SINGLEMDS
770 if dmesg | grep "unknown lock cookie"; then
771 echo "cancel after replay failed"
775 run_test 36 "don't resend cancel"
778 # directory orphans can't be unlinked from PENDING directory
780 rmdir $DIR/$tfile 2>/dev/null
781 multiop_bg_pause $DIR/$tfile dD_c || return 2
785 replay_barrier $SINGLEMDS
786 # clear the dmesg buffer so we only see errors from this recovery
788 fail_abort $SINGLEMDS
790 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
794 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
797 createmany -o $DIR/$tfile-%d 800
798 unlinkmany $DIR/$tfile-%d 0 400
799 replay_barrier $SINGLEMDS
801 unlinkmany $DIR/$tfile-%d 400 400
803 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
805 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
807 test_39() { # bug 4176
808 createmany -o $DIR/$tfile-%d 800
809 replay_barrier $SINGLEMDS
810 unlinkmany $DIR/$tfile-%d 0 400
812 unlinkmany $DIR/$tfile-%d 400 400
814 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
816 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
819 awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }' $LPROC/osc/*/stats
824 $LCTL mark multiop $MOUNT/$tfile OS_c
825 multiop $MOUNT/$tfile OS_c &
827 writeme -s $MOUNT/${tfile}-2 &
830 facet_failover $SINGLEMDS
831 #define OBD_FAIL_MDS_CONNECT_NET 0x117
832 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000117"
834 stat1=`count_ost_writes`
836 stat2=`count_ost_writes`
837 echo "$stat1, $stat2"
838 if [ $stat1 -lt $stat2 ]; then
839 echo "writes continuing during recovery"
842 echo "writes not continuing during recovery, bug 2477"
845 echo "waiting for writeme $WRITE_PID"
849 echo "waiting for multiop $PID"
850 wait $PID || return 2
851 do_facet client munlink $MOUNT/$tfile || return 3
852 do_facet client munlink $MOUNT/${tfile}-2 || return 3
855 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
859 # make sure that a read to one osc doesn't try to double-unlock its page just
860 # because another osc is invalid. trigger_group_io used to mistakenly return
861 # an error if any oscs were invalid even after having successfully put rpcs
862 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
863 # the page, guarnateeing that the unlock from the RPC completion would
864 # assert on trying to unlock the unlocked page.
866 [ $OSTCOUNT -lt 2 ] && \
867 skip "skipping test 41: we don't have a second OST to test with" && \
870 local f=$MOUNT/$tfile
871 # make sure the start of the file is ost1
872 lfs setstripe $f -s $((128 * 1024)) -i 0
873 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
875 # fail ost2 and read from ost1
876 local osc2dev=`do_facet mds "grep ${ost2_svc}-osc-MDT0000 $LPROC/devices" | awk '{print $1}'`
877 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && cat $LPROC/devices && return 4
878 do_facet mds $LCTL --device $osc2dev deactivate || return 1
879 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
880 do_facet mds $LCTL --device $osc2dev activate || return 2
883 run_test 41 "read from a valid osc while other oscs are invalid"
885 # test MDS recovery after ost failure
887 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
888 createmany -o $DIR/$tfile-%d 800
890 unlinkmany $DIR/$tfile-%d 0 400
892 sysctl -w lnet.debug=-1
895 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
896 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
897 #[ $blocks_after -lt $blocks ] || return 1
898 echo wait for MDS to timeout and recover
899 sleep $((TIMEOUT * 2))
901 unlinkmany $DIR/$tfile-%d 400 400
902 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
904 run_test 42 "recovery after ost failure"
906 # timeout in MDS/OST recovery RPC will LBUG MDS
907 test_43() { # bug 2530
908 replay_barrier $SINGLEMDS
910 # OBD_FAIL_OST_CREATE_NET 0x204
911 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
914 do_facet ost1 "sysctl -w lustre.fail_loc=0"
918 run_test 43 "mds osc import failure during recovery; don't LBUG"
921 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
922 [ "$mdcdev" ] || exit 2
923 for i in `seq 1 10`; do
924 #define OBD_FAIL_TGT_CONN_RACE 0x701
925 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000701"
926 $LCTL --device $mdcdev recover
929 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
932 run_test 44 "race in target handle connect"
935 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
936 [ "$mdcdev" ] || exit 2
937 for i in `seq 1 10`; do
938 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
939 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000704"
940 $LCTL --device $mdcdev recover
943 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
946 run_test 44b "race in target handle connect"
948 # Handle failed close
950 mdcdev=`awk '/MDT0000-mdc-/ {print $1}' $LPROC/devices`
951 [ "$mdcdev" ] || exit 2
952 $LCTL --device $mdcdev recover
954 multiop_bg_pause $DIR/$tfile O_c || return 1
957 # This will cause the CLOSE to fail before even
958 # allocating a reply buffer
959 $LCTL --device $mdcdev deactivate || return 4
963 wait $pid || return 1
965 $LCTL --device $mdcdev activate || return 5
968 $CHECKSTAT -t file $DIR/$tfile || return 2
971 run_test 45 "Handle failed close"
975 drop_reply "touch $DIR/$tfile"
977 # ironically, the previous test, 45, will cause a real forced close,
978 # so just look for one for this test
979 dmesg | grep -i "force closing client file handle for $tfile" && return 1
982 run_test 46 "Don't leak file handle after open resend (3325)"
984 test_47() { # bug 2824
985 # create some files to make sure precreate has been done on all
986 # OSTs. (just in case this test is run independently)
987 createmany -o $DIR/$tfile 20 || return 1
989 # OBD_FAIL_OST_CREATE_NET 0x204
991 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000204"
992 df $MOUNT || return 2
994 # let the MDS discover the OST failure, attempt to recover, fail
996 sleep $((3 * TIMEOUT))
998 # Without 2824, this createmany would hang
999 createmany -o $DIR/$tfile 20 || return 3
1000 unlinkmany $DIR/$tfile 20 || return 4
1002 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1005 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1008 replay_barrier $SINGLEMDS
1009 createmany -o $DIR/$tfile 20 || return 1
1010 # OBD_FAIL_OST_EROFS 0x216
1012 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000216"
1013 df $MOUNT || return 2
1015 createmany -o $DIR/$tfile 20 20 || return 2
1016 unlinkmany $DIR/$tfile 40 || return 3
1018 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1021 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1024 local oscdev=`do_facet $SINGLEMDS grep ${ost1_svc}-osc-MDT0000 $LPROC/devices | awk '{print $1}'`
1025 [ "$oscdev" ] || return 1
1026 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1027 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1028 # give the mds_lov_sync threads a chance to run
1031 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1033 # b3764 timed out lock replay
1036 cancel_lru_locks mdc
1038 multiop $DIR/$tfile s || return 1
1039 replay_barrier $SINGLEMDS
1040 #define OBD_FAIL_LDLM_REPLY 0x30c
1041 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000030c"
1042 fail $SINGLEMDS || return 2
1043 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1045 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1047 run_test 52 "time out lock replay (3764)"
1049 # bug 3462 - simultaneous MDC requests
1051 mkdir -p $DIR/${tdir}-1
1052 mkdir -p $DIR/${tdir}-2
1053 multiop $DIR/${tdir}-1/f O_c &
1055 # give multiop a change to open
1058 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1059 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1060 kill -USR1 $close_pid
1061 cancel_lru_locks mdc # force the close
1062 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1064 mcreate $DIR/${tdir}-2/f || return 1
1066 # close should still be here
1067 [ -d /proc/$close_pid ] || return 2
1069 replay_barrier_nodf $SINGLEMDS
1071 wait $close_pid || return 3
1073 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1074 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1075 rm -rf $DIR/${tdir}-*
1077 run_test 53a "|X| close request while two MDC requests in flight"
1080 mkdir -p $DIR/${tdir}-1
1081 mkdir -p $DIR/${tdir}-2
1082 multiop $DIR/${tdir}-1/f O_c &
1085 #define OBD_FAIL_MDS_REINT_NET 0x107
1086 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1087 mcreate $DIR/${tdir}-2/f &
1091 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1092 kill -USR1 $close_pid
1093 cancel_lru_locks mdc # force the close
1094 wait $close_pid || return 1
1095 # open should still be here
1096 [ -d /proc/$open_pid ] || return 2
1098 replay_barrier_nodf $SINGLEMDS
1100 wait $open_pid || return 3
1102 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1103 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1104 rm -rf $DIR/${tdir}-*
1106 run_test 53b "|X| open request while two MDC requests in flight"
1109 mkdir -p $DIR/${tdir}-1
1110 mkdir -p $DIR/${tdir}-2
1111 multiop $DIR/${tdir}-1/f O_c &
1114 #define OBD_FAIL_MDS_REINT_NET 0x107
1115 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1116 mcreate $DIR/${tdir}-2/f &
1120 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1121 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1122 kill -USR1 $close_pid
1123 cancel_lru_locks mdc # force the close
1125 replay_barrier_nodf $SINGLEMDS
1126 fail_nodf $SINGLEMDS
1127 wait $open_pid || return 1
1129 # close should be gone
1130 [ -d /proc/$close_pid ] && return 2
1131 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1133 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1134 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1135 rm -rf $DIR/${tdir}-*
1137 run_test 53c "|X| open request and close request while two MDC requests in flight"
1140 mkdir -p $DIR/${tdir}-1
1141 mkdir -p $DIR/${tdir}-2
1142 multiop $DIR/${tdir}-1/f O_c &
1144 # give multiop a chance to open
1147 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1148 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1149 kill -USR1 $close_pid
1150 cancel_lru_locks mdc # force the close
1151 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1152 mcreate $DIR/${tdir}-2/f || return 1
1154 # close should still be here
1155 [ -d /proc/$close_pid ] || return 2
1157 wait $close_pid || return 3
1159 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1160 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1161 rm -rf $DIR/${tdir}-*
1163 run_test 53d "|X| close reply while two MDC requests in flight"
1166 mkdir -p $DIR/${tdir}-1
1167 mkdir -p $DIR/${tdir}-2
1168 multiop $DIR/${tdir}-1/f O_c &
1171 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1172 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1173 mcreate $DIR/${tdir}-2/f &
1177 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1178 kill -USR1 $close_pid
1179 cancel_lru_locks mdc # force the close
1180 wait $close_pid || return 1
1181 # open should still be here
1182 [ -d /proc/$open_pid ] || return 2
1184 replay_barrier_nodf $SINGLEMDS
1186 wait $open_pid || return 3
1188 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1189 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1190 rm -rf $DIR/${tdir}-*
1192 run_test 53e "|X| open reply while two MDC requests in flight"
1195 mkdir -p $DIR/${tdir}-1
1196 mkdir -p $DIR/${tdir}-2
1197 multiop $DIR/${tdir}-1/f O_c &
1200 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1201 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1202 mcreate $DIR/${tdir}-2/f &
1206 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1207 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1208 kill -USR1 $close_pid
1209 cancel_lru_locks mdc # force the close
1211 replay_barrier_nodf $SINGLEMDS
1212 fail_nodf $SINGLEMDS
1213 wait $open_pid || return 1
1215 # close should be gone
1216 [ -d /proc/$close_pid ] && return 2
1217 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1219 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1220 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1221 rm -rf $DIR/${tdir}-*
1223 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1226 mkdir -p $DIR/${tdir}-1
1227 mkdir -p $DIR/${tdir}-2
1228 multiop $DIR/${tdir}-1/f O_c &
1231 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1232 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x119"
1233 mcreate $DIR/${tdir}-2/f &
1237 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1238 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000115"
1239 kill -USR1 $close_pid
1240 cancel_lru_locks mdc # force the close
1242 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1243 replay_barrier_nodf $SINGLEMDS
1244 fail_nodf $SINGLEMDS
1245 wait $open_pid || return 1
1247 # close should be gone
1248 [ -d /proc/$close_pid ] && return 2
1250 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1251 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1252 rm -rf $DIR/${tdir}-*
1254 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1257 mkdir -p $DIR/${tdir}-1
1258 mkdir -p $DIR/${tdir}-2
1259 multiop $DIR/${tdir}-1/f O_c &
1262 #define OBD_FAIL_MDS_REINT_NET 0x107
1263 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000107"
1264 mcreate $DIR/${tdir}-2/f &
1268 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13f
1269 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000013f"
1270 kill -USR1 $close_pid
1271 cancel_lru_locks mdc # force the close
1274 replay_barrier_nodf $SINGLEMDS
1275 fail_nodf $SINGLEMDS
1276 wait $open_pid || return 1
1278 # close should be gone
1279 [ -d /proc/$close_pid ] && return 2
1280 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1282 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1283 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1284 rm -rf $DIR/${tdir}-*
1286 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1288 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1290 #b3761 ASSERTION(hash != 0) failed
1292 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1293 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012b"
1295 # give touch a chance to run
1297 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1301 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1303 #b3440 ASSERTION(rec->ur_fid2->id) failed
1305 ln -s foo $DIR/$tfile
1306 replay_barrier $SINGLEMDS
1307 #drop_reply "cat $DIR/$tfile"
1311 run_test 56 "don't replay a symlink open request (3440)"
1313 #recovery one mds-ost setattr from llog
1315 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1316 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1318 replay_barrier $SINGLEMDS
1321 $CHECKSTAT -t file $DIR/$tfile || return 1
1322 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1325 run_test 57 "test recovery from llog for setattr op"
1327 #recovery many mds-ost setattr from llog
1329 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1330 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000012c"
1331 createmany -o $DIR/$tdir/$tfile-%d 2500
1332 replay_barrier $SINGLEMDS
1335 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1336 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x0"
1337 unlinkmany $DIR/$tdir/$tfile-%d 2500
1340 run_test 58 "test recovery from llog for setattr op (test llog_gen_rec)"
1342 # log_commit_thread vs filter_destroy race used to lead to import use after free
1345 createmany -o $DIR/$tdir/$tfile-%d 200
1347 unlinkmany $DIR/$tdir/$tfile-%d 200
1348 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1349 do_facet ost1 "sysctl -w lustre.fail_loc=0x507"
1352 do_facet ost1 "sysctl -w lustre.fail_loc=0x0"
1356 run_test 59 "test log_commit_thread vs filter_destroy race"
1358 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1359 # bug 12086: should no oops and No ctxt error for this test
1361 createmany -o $DIR/$tdir/$tfile-%d 200
1362 replay_barrier $SINGLEMDS
1363 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1365 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1366 local no_ctxt=`dmesg | grep "No ctxt"`
1367 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1369 run_test 60 "test llog post recovery init vs llog unlink"
1371 #test race llog recovery thread vs llog cleanup
1374 createmany -o $DIR/$tdir/$tfile-%d 800
1376 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1377 unlinkmany $DIR/$tdir/$tfile-%d 800
1378 do_facet ost "sysctl -w lustre.fail_loc=0x80000221"
1383 do_facet ost "sysctl -w lustre.fail_loc=0x0"
1384 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1387 run_test 61 "test race llog recovery vs llog cleanup"
1389 #test race mds llog sync vs llog cleanup
1391 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x140
1392 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x80000140"
1393 facet_failover $SINGLEMDS
1396 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1398 run_test 61b "test race mds llog sync vs llog cleanup"
1400 #test race cancel cookie cb vs llog cleanup
1402 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1404 do_facet ost "sysctl -w lustre.fail_loc=0x80000222"
1409 run_test 61c "test race mds llog sync vs llog cleanup"
1411 equals_msg `basename $0`: test complete, cleaning up
1412 check_and_cleanup_lustre
1413 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG || true