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}
17 CHECK_GRANT=${CHECK_GRANT:-"yes"}
18 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
20 require_dsh_mds || exit 0
23 # bug number: 17466 18857
24 ALWAYS_EXCEPT="61d 33a 33b $REPLAY_SINGLE_EXCEPT"
26 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
27 CONFIG_EXCEPTIONS="0b 42 47 61a 61c"
28 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
29 echo "Except the tests: $CONFIG_EXCEPTIONS"
30 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
33 # 63 min 7 min AT AT AT AT"
34 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
38 check_and_setup_lustre
43 rm -rf $DIR/[df][0-9]*
45 test_0a() { # was test_0
48 replay_barrier $SINGLEMDS
52 run_test 0a "empty replay"
55 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
57 # this test attempts to trigger a race in the precreation code,
58 # and must run before any other objects are created on the filesystem
60 createmany -o $DIR/$tfile 20 || return 1
61 unlinkmany $DIR/$tfile 20 || return 2
63 run_test 0b "ensure object created after recover exists. (3284)"
69 lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
75 lctl get_param -n seq.cli-srv-$mds-mdc-*.width
78 # This test should pass for single-mds and multi-mds configs.
79 # But for different configurations it tests different things.
83 # (1) fld_create replay should happen;
85 # (2) fld_create replay should not return -EEXISTS, if it does
86 # this means sequence manager recovery code is buggy and allocated
87 # same sequence two times after recovery.
91 # (1) fld_create replay may not happen, because its home MDS is
92 # MDS2 which is not involved to revovery;
94 # (2) as fld_create does not happen on MDS1, it does not make any
97 local label=`mdsdevlabel 1`
98 [ -z "$label" ] && echo "No label for mds1" && return 1
100 replay_barrier $SINGLEMDS
101 local sw=`seq_get_width $label`
103 # make seq manager switch to next sequence each
104 # time as new fid is needed.
105 seq_set_width $label 1
107 # make sure that fld has created at least one new
109 touch $DIR/$tfile || return 2
110 seq_set_width $label $sw
112 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
115 # wait for recovery finish
119 # flush fld cache and dentry cache to make it lookup
120 # created entry instead of revalidating existent one
122 zconf_mount `hostname` $MOUNT
124 # issue lookup which should call fld lookup which
125 # should fail if client did not replay fld create
126 # correctly and server has no fld entry
127 touch $DIR/$tfile || return 3
128 rm $DIR/$tfile || return 4
130 start_full_debug_logging
131 run_test 0c "fld create"
132 stop_full_debug_logging
135 replay_barrier $SINGLEMDS
138 $CHECKSTAT -t file $DIR/$tfile || return 1
141 run_test 1 "simple create"
144 replay_barrier $SINGLEMDS
147 $CHECKSTAT -t file $DIR/$tfile || return 1
154 replay_barrier $SINGLEMDS
157 $CHECKSTAT -t file $DIR/$tfile || return 1
163 local file=$DIR/$tfile
164 replay_barrier $SINGLEMDS
166 openfile -f O_DIRECTORY $file
168 $CHECKSTAT -t file $file || return 2
171 run_test 3a "replay failed open(O_DIRECTORY)"
174 replay_barrier $SINGLEMDS
175 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
176 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
178 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
180 $CHECKSTAT -t file $DIR/$tfile && return 2
183 run_test 3b "replay failed open -ENOMEM"
186 replay_barrier $SINGLEMDS
187 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
188 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
190 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
193 $CHECKSTAT -t file $DIR/$tfile && return 2
196 run_test 3c "replay failed open -ENOMEM"
198 test_4a() { # was test_4
199 replay_barrier $SINGLEMDS
200 for i in `seq 10`; do
201 echo "tag-$i" > $DIR/$tfile-$i
204 for i in `seq 10`; do
205 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
208 run_test 4a "|x| 10 open(O_CREAT)s"
211 replay_barrier $SINGLEMDS
214 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
216 run_test 4b "|x| rm 10 files"
218 # The idea is to get past the first block of precreated files on both
219 # osts, and then replay.
221 replay_barrier $SINGLEMDS
222 for i in `seq 220`; do
223 echo "tag-$i" > $DIR/$tfile-$i
226 for i in `seq 220`; do
227 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
231 # waiting for commitment of removal
233 run_test 5 "|x| 220 open(O_CREAT)"
236 test_6a() { # was test_6
238 replay_barrier $SINGLEMDS
239 mcreate $DIR/$tdir/$tfile
241 $CHECKSTAT -t dir $DIR/$tdir || return 1
242 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
244 # waiting for log process thread
246 run_test 6a "mkdir + contained create"
250 replay_barrier $SINGLEMDS
253 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
255 run_test 6b "|X| rmdir"
259 replay_barrier $SINGLEMDS
260 mcreate $DIR/$tdir/$tfile
262 $CHECKSTAT -t dir $DIR/$tdir || return 1
263 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
266 run_test 7 "mkdir |X| contained create"
269 # make sure no side-effect from previous test.
271 replay_barrier $SINGLEMDS
272 multiop_bg_pause $DIR/$tfile mo_c || return 4
276 $CHECKSTAT -t file $DIR/$tfile || return 1
277 kill -USR1 $MULTIPID || return 2
278 wait $MULTIPID || return 3
281 run_test 8 "creat open |X| close"
284 replay_barrier $SINGLEMDS
286 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
288 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
290 echo " old_inum == $old_inum, new_inum == $new_inum"
291 if [ $old_inum -eq $new_inum ] ;
293 echo " old_inum and new_inum match"
295 echo "!!!! old_inum and new_inum NOT match"
300 run_test 9 "|X| create (same inum/gen)"
304 replay_barrier $SINGLEMDS
305 mv $DIR/$tfile $DIR/$tfile-2
308 $CHECKSTAT $DIR/$tfile && return 1
309 $CHECKSTAT $DIR/$tfile-2 ||return 2
313 run_test 10 "create |X| rename unlink"
317 echo "old" > $DIR/$tfile
318 mv $DIR/$tfile $DIR/$tfile-2
319 replay_barrier $SINGLEMDS
320 echo "new" > $DIR/$tfile
322 grep old $DIR/$tfile-2
324 grep new $DIR/$tfile || return 1
325 grep old $DIR/$tfile-2 || return 2
327 run_test 11 "create open write rename |X| create-old-name read"
331 multiop_bg_pause $DIR/$tfile o_tSc || return 3
334 replay_barrier $SINGLEMDS
336 wait $pid || return 1
339 [ -e $DIR/$tfile ] && return 2
342 run_test 12 "open, unlink |X| close"
345 # 1777 - replay open after committed chmod that would make
346 # a regular open a failure
349 multiop_bg_pause $DIR/$tfile O_wc || return 3
352 $CHECKSTAT -p 0 $DIR/$tfile
353 replay_barrier $SINGLEMDS
356 wait $pid || return 1
358 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
359 rm $DIR/$tfile || return 4
362 run_test 13 "open chmod 0 |x| write close"
365 multiop_bg_pause $DIR/$tfile O_tSc || return 4
368 replay_barrier $SINGLEMDS
369 kill -USR1 $pid || return 1
370 wait $pid || return 2
373 [ -e $DIR/$tfile ] && return 3
376 run_test 14 "open(O_CREAT), unlink |X| close"
379 multiop_bg_pause $DIR/$tfile O_tSc || return 5
382 replay_barrier $SINGLEMDS
383 touch $DIR/g11 || return 1
385 wait $pid || return 2
388 [ -e $DIR/$tfile ] && return 3
389 touch $DIR/h11 || return 4
392 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
396 replay_barrier $SINGLEMDS
399 mcreate $DIR/$tfile-2
401 [ -e $DIR/$tfile ] && return 1
402 [ -e $DIR/$tfile-2 ] || return 2
403 munlink $DIR/$tfile-2 || return 3
405 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
408 replay_barrier $SINGLEMDS
409 multiop_bg_pause $DIR/$tfile O_c || return 4
412 kill -USR1 $pid || return 1
413 wait $pid || return 2
414 $CHECKSTAT -t file $DIR/$tfile || return 3
417 run_test 17 "|X| open(O_CREAT), |replay| close"
420 replay_barrier $SINGLEMDS
421 multiop_bg_pause $DIR/$tfile O_tSc || return 8
424 touch $DIR/$tfile-2 || return 1
425 echo "pid: $pid will close"
427 wait $pid || return 2
430 [ -e $DIR/$tfile ] && return 3
431 [ -e $DIR/$tfile-2 ] || return 4
432 # this touch frequently fails
433 touch $DIR/$tfile-3 || return 5
434 munlink $DIR/$tfile-2 || return 6
435 munlink $DIR/$tfile-3 || return 7
438 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
440 # bug 1855 (a simpler form of test_11 above)
442 replay_barrier $SINGLEMDS
444 echo "old" > $DIR/$tfile
445 mv $DIR/$tfile $DIR/$tfile-2
446 grep old $DIR/$tfile-2
448 grep old $DIR/$tfile-2 || return 2
450 run_test 19 "|X| mcreate, open, write, rename "
452 test_20a() { # was test_20
453 replay_barrier $SINGLEMDS
454 multiop_bg_pause $DIR/$tfile O_tSc || return 3
460 wait $pid || return 1
461 [ -e $DIR/$tfile ] && return 2
464 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
466 test_20b() { # bug 10480
467 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
469 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
471 while [ ! -e $DIR/$tfile ] ; do
472 usleep 60 # give dd a chance to start
475 lfs getstripe $DIR/$tfile || return 1
476 rm -f $DIR/$tfile || return 2 # make it an orphan
478 client_up || client_up || true # reconnect
480 fail $SINGLEMDS # start orphan recovery
481 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
482 wait_mds_ost_sync || return 3
483 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
484 log "before $BEFOREUSED, after $AFTERUSED"
485 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
486 error "after $AFTERUSED > before $BEFOREUSED"
489 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
491 test_20c() { # bug 10480
492 multiop_bg_pause $DIR/$tfile Ow_c || return 1
498 client_up || client_up || true # reconnect
501 wait $pid || return 1
502 [ -s $DIR/$tfile ] || error "File was truncated"
506 run_test 20c "check that client eviction does not affect file content"
509 replay_barrier $SINGLEMDS
510 multiop_bg_pause $DIR/$tfile O_tSc || return 5
513 touch $DIR/g11 || return 1
517 wait $pid || return 2
518 [ -e $DIR/$tfile ] && return 3
519 touch $DIR/h11 || return 4
522 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
525 multiop_bg_pause $DIR/$tfile O_tSc || return 3
528 replay_barrier $SINGLEMDS
533 wait $pid || return 1
534 [ -e $DIR/$tfile ] && return 2
537 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
540 multiop_bg_pause $DIR/$tfile O_tSc || return 5
543 replay_barrier $SINGLEMDS
545 touch $DIR/g11 || return 1
549 wait $pid || return 2
550 [ -e $DIR/$tfile ] && return 3
551 touch $DIR/h11 || return 4
554 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
557 multiop_bg_pause $DIR/$tfile O_tSc || return 3
560 replay_barrier $SINGLEMDS
564 wait $pid || return 1
565 [ -e $DIR/$tfile ] && return 2
568 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
571 multiop_bg_pause $DIR/$tfile O_tSc || return 3
575 replay_barrier $SINGLEMDS
578 wait $pid || return 1
579 [ -e $DIR/$tfile ] && return 2
582 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
585 replay_barrier $SINGLEMDS
586 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
588 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
593 wait $pid2 || return 1
597 wait $pid1 || return 2
598 [ -e $DIR/$tfile-1 ] && return 3
599 [ -e $DIR/$tfile-2 ] && return 4
602 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
605 replay_barrier $SINGLEMDS
606 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
608 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
615 wait $pid1 || return 1
617 wait $pid2 || return 2
618 [ -e $DIR/$tfile-1 ] && return 3
619 [ -e $DIR/$tfile-2 ] && return 4
622 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
625 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
627 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
629 replay_barrier $SINGLEMDS
633 wait $pid2 || return 1
637 wait $pid1 || return 2
638 [ -e $DIR/$tfile-1 ] && return 3
639 [ -e $DIR/$tfile-2 ] && return 4
642 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
645 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
647 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
649 replay_barrier $SINGLEMDS
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 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
665 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
667 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
672 replay_barrier $SINGLEMDS
675 wait $pid1 || return 1
677 wait $pid2 || return 2
678 [ -e $DIR/$tfile-1 ] && return 3
679 [ -e $DIR/$tfile-2 ] && return 4
682 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
685 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
687 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
691 replay_barrier $SINGLEMDS
695 wait $pid1 || return 1
697 wait $pid2 || return 2
698 [ -e $DIR/$tfile-1 ] && return 3
699 [ -e $DIR/$tfile-2 ] && return 4
702 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
704 # tests for bug 2104; completion without crashing is success. The close is
705 # stale, but we always return 0 for close, so the app never sees it.
707 multiop_bg_pause $DIR/$tfile O_c || return 2
709 multiop_bg_pause $DIR/$tfile O_c || return 3
712 client_up || client_up || return 1
715 wait $pid1 || return 4
716 wait $pid2 || return 5
719 run_test 32 "close() notices client eviction; close() after client eviction"
722 createmany -o $DIR/$tfile-%d 10
723 replay_barrier_nosync $SINGLEMDS
724 fail_abort $SINGLEMDS
725 # recreate shouldn't fail
726 createmany -o $DIR/$tfile--%d 10 || return 1
730 run_test 33a "fid seq shouldn't be reused after abort recovery"
733 #define OBD_FAIL_SEQ_ALLOC 0x1311
734 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
736 createmany -o $DIR/$tfile-%d 10
737 replay_barrier_nosync $SINGLEMDS
738 fail_abort $SINGLEMDS
739 # recreate shouldn't fail
740 createmany -o $DIR/$tfile--%d 10 || return 1
744 run_test 33b "test fid seq allocation"
747 multiop_bg_pause $DIR/$tfile O_c || return 2
751 replay_barrier $SINGLEMDS
752 fail_abort $SINGLEMDS
754 wait $pid || return 3
755 [ -e $DIR/$tfile ] && return 1
759 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
761 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
765 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
766 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
771 # give a chance to remove from MDS
772 fail_abort $SINGLEMDS
773 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
775 run_test 35 "test recovery from llog for unlink op"
777 # b=2432 resent cancel after replay uses wrong cookie,
778 # so don't resend cancels
780 replay_barrier $SINGLEMDS
782 checkstat $DIR/$tfile
783 facet_failover $SINGLEMDS
785 if dmesg | grep "unknown lock cookie"; then
786 echo "cancel after replay failed"
790 run_test 36 "don't resend cancel"
793 # directory orphans can't be unlinked from PENDING directory
795 rmdir $DIR/$tfile 2>/dev/null
796 multiop_bg_pause $DIR/$tfile dD_c || return 2
800 replay_barrier $SINGLEMDS
801 # clear the dmesg buffer so we only see errors from this recovery
803 fail_abort $SINGLEMDS
805 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
806 wait $pid || return 3
810 start_full_debug_logging
811 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
812 stop_full_debug_logging
815 createmany -o $DIR/$tfile-%d 800
816 unlinkmany $DIR/$tfile-%d 0 400
817 replay_barrier $SINGLEMDS
819 unlinkmany $DIR/$tfile-%d 400 400
821 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
823 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
825 test_39() { # bug 4176
826 createmany -o $DIR/$tfile-%d 800
827 replay_barrier $SINGLEMDS
828 unlinkmany $DIR/$tfile-%d 0 400
830 unlinkmany $DIR/$tfile-%d 400 400
832 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
834 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
837 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
842 $LCTL mark multiop $MOUNT/$tfile OS_c
843 multiop $MOUNT/$tfile OS_c &
845 writeme -s $MOUNT/${tfile}-2 &
848 facet_failover $SINGLEMDS
849 #define OBD_FAIL_MDS_CONNECT_NET 0x117
850 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
852 stat1=`count_ost_writes`
854 stat2=`count_ost_writes`
855 echo "$stat1, $stat2"
856 if [ $stat1 -lt $stat2 ]; then
857 echo "writes continuing during recovery"
860 echo "writes not continuing during recovery, bug 2477"
863 echo "waiting for writeme $WRITE_PID"
867 echo "waiting for multiop $PID"
868 wait $PID || return 2
869 do_facet client munlink $MOUNT/$tfile || return 3
870 do_facet client munlink $MOUNT/${tfile}-2 || return 3
873 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
877 # make sure that a read to one osc doesn't try to double-unlock its page just
878 # because another osc is invalid. trigger_group_io used to mistakenly return
879 # an error if any oscs were invalid even after having successfully put rpcs
880 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
881 # the page, guarnateeing that the unlock from the RPC completion would
882 # assert on trying to unlock the unlocked page.
884 [ $OSTCOUNT -lt 2 ] && \
885 skip_env "skipping test 41: we don't have a second OST to test with" && \
888 local f=$MOUNT/$tfile
889 # make sure the start of the file is ost1
890 lfs setstripe $f -s $((128 * 1024)) -i 0
891 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
893 # fail ost2 and read from ost1
894 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
895 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
896 grep $mdtosc | awk '{print $1}')
897 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
898 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
899 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
900 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
903 run_test 41 "read from a valid osc while other oscs are invalid"
905 # test MDS recovery after ost failure
907 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
908 createmany -o $DIR/$tfile-%d 800
910 unlinkmany $DIR/$tfile-%d 0 400
912 lctl set_param debug=-1
915 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
916 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
917 #[ $blocks_after -lt $blocks ] || return 1
918 echo wait for MDS to timeout and recover
919 sleep $((TIMEOUT * 2))
921 unlinkmany $DIR/$tfile-%d 400 400
922 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
924 run_test 42 "recovery after ost failure"
926 # timeout in MDS/OST recovery RPC will LBUG MDS
927 test_43() { # bug 2530
928 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
930 replay_barrier $SINGLEMDS
932 # OBD_FAIL_OST_CREATE_NET 0x204
933 do_facet ost1 "lctl set_param fail_loc=0x80000204"
936 do_facet ost1 "lctl set_param fail_loc=0"
940 run_test 43 "mds osc import failure during recovery; don't LBUG"
942 test_44a() { # was test_44
945 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
946 [ "$mdcdev" ] || return 2
947 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
949 # adaptive timeouts slow this way down
950 if at_is_enabled; then
951 at_max_saved=$(at_max_get mds)
955 for i in `seq 1 10`; do
956 echo "$i of 10 ($(date +%s))"
957 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
958 #define OBD_FAIL_TGT_CONN_RACE 0x701
959 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
960 # lctl below may fail, it is valid case
961 $LCTL --device $mdcdev recover
964 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
965 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
968 run_test 44a "race in target handle connect"
971 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
972 [ "$mdcdev" ] || return 2
973 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
975 for i in `seq 1 10`; do
976 echo "$i of 10 ($(date +%s))"
977 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
978 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
979 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
980 # lctl below may fail, it is valid case
981 $LCTL --device $mdcdev recover
984 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
987 run_test 44b "race in target handle connect"
989 # Handle failed close
991 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
992 [ "$mdcdev" ] || return 2
993 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
995 $LCTL --device $mdcdev recover || return 6
997 multiop_bg_pause $DIR/$tfile O_c || return 1
1000 # This will cause the CLOSE to fail before even
1001 # allocating a reply buffer
1002 $LCTL --device $mdcdev deactivate || return 4
1006 wait $pid || return 1
1008 $LCTL --device $mdcdev activate || return 5
1011 $CHECKSTAT -t file $DIR/$tfile || return 2
1014 run_test 45 "Handle failed close"
1018 drop_reply "touch $DIR/$tfile"
1020 # ironically, the previous test, 45, will cause a real forced close,
1021 # so just look for one for this test
1022 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1025 run_test 46 "Don't leak file handle after open resend (3325)"
1027 test_47() { # bug 2824
1028 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1030 # create some files to make sure precreate has been done on all
1031 # OSTs. (just in case this test is run independently)
1032 createmany -o $DIR/$tfile 20 || return 1
1034 # OBD_FAIL_OST_CREATE_NET 0x204
1036 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1037 client_up || return 2
1039 # let the MDS discover the OST failure, attempt to recover, fail
1040 # and recover again.
1041 sleep $((3 * TIMEOUT))
1043 # Without 2824, this createmany would hang
1044 createmany -o $DIR/$tfile 20 || return 3
1045 unlinkmany $DIR/$tfile 20 || return 4
1047 do_facet ost1 "lctl set_param fail_loc=0"
1050 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1053 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1054 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1056 replay_barrier $SINGLEMDS
1057 createmany -o $DIR/$tfile 20 || return 1
1058 # OBD_FAIL_OST_EROFS 0x216
1059 facet_failover $SINGLEMDS
1060 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1061 client_up || return 2
1063 createmany -o $DIR/$tfile 20 20 || return 2
1064 unlinkmany $DIR/$tfile 40 || return 3
1067 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1070 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1071 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1072 grep $mdtosc | awk '{print $1}')
1073 [ "$oscdev" ] || return 1
1074 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1075 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1076 # give the mds_lov_sync threads a chance to run
1079 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1081 # b3764 timed out lock replay
1084 cancel_lru_locks mdc
1086 multiop $DIR/$tfile s || return 1
1087 replay_barrier $SINGLEMDS
1088 #define OBD_FAIL_LDLM_REPLY 0x30c
1089 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1090 fail $SINGLEMDS || return 2
1091 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1093 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1095 run_test 52 "time out lock replay (3764)"
1097 # bug 3462 - simultaneous MDC requests
1099 cancel_lru_locks mdc # cleanup locks from former test cases
1100 mkdir -p $DIR/${tdir}-1
1101 mkdir -p $DIR/${tdir}-2
1102 multiop $DIR/${tdir}-1/f O_c &
1104 # give multiop a change to open
1107 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1108 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1109 kill -USR1 $close_pid
1110 cancel_lru_locks mdc # force the close
1111 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1113 mcreate $DIR/${tdir}-2/f || return 1
1115 # close should still be here
1116 [ -d /proc/$close_pid ] || return 2
1118 replay_barrier_nodf $SINGLEMDS
1120 wait $close_pid || return 3
1122 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1123 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1124 rm -rf $DIR/${tdir}-*
1126 run_test 53a "|X| close request while two MDC requests in flight"
1129 cancel_lru_locks mdc # cleanup locks from former test cases
1130 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1132 mkdir -p $DIR/${tdir}-1
1133 mkdir -p $DIR/${tdir}-2
1134 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1137 #define OBD_FAIL_MDS_REINT_NET 0x107
1138 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1139 mcreate $DIR/${tdir}-2/f &
1143 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1144 kill -USR1 $close_pid
1145 cancel_lru_locks mdc # force the close
1146 wait $close_pid || return 1
1147 # open should still be here
1148 [ -d /proc/$open_pid ] || return 2
1150 replay_barrier_nodf $SINGLEMDS
1152 wait $open_pid || return 3
1154 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1155 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1156 rm -rf $DIR/${tdir}-*
1158 run_test 53b "|X| open request while two MDC requests in flight"
1161 cancel_lru_locks mdc # cleanup locks from former test cases
1162 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1164 mkdir -p $DIR/${tdir}-1
1165 mkdir -p $DIR/${tdir}-2
1166 multiop $DIR/${tdir}-1/f O_c &
1169 #define OBD_FAIL_MDS_REINT_NET 0x107
1170 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1171 mcreate $DIR/${tdir}-2/f &
1175 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1176 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1177 kill -USR1 $close_pid
1178 cancel_lru_locks mdc # force the close
1180 #bz20647: make sure all pids are exists before failover
1181 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1182 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1183 replay_barrier_nodf $SINGLEMDS
1184 fail_nodf $SINGLEMDS
1185 wait $open_pid || return 1
1187 # close should be gone
1188 [ -d /proc/$close_pid ] && return 2
1189 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1191 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1192 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1193 rm -rf $DIR/${tdir}-*
1195 run_test 53c "|X| open request and close request while two MDC requests in flight"
1198 cancel_lru_locks mdc # cleanup locks from former test cases
1199 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1201 mkdir -p $DIR/${tdir}-1
1202 mkdir -p $DIR/${tdir}-2
1203 multiop $DIR/${tdir}-1/f O_c &
1205 # give multiop a chance to open
1208 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1209 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1210 kill -USR1 $close_pid
1211 cancel_lru_locks mdc # force the close
1212 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1213 mcreate $DIR/${tdir}-2/f || return 1
1215 # close should still be here
1216 [ -d /proc/$close_pid ] || return 2
1218 wait $close_pid || return 3
1220 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1221 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1222 rm -rf $DIR/${tdir}-*
1224 run_test 53d "|X| close reply while two MDC requests in flight"
1227 cancel_lru_locks mdc # cleanup locks from former test cases
1228 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1230 mkdir -p $DIR/${tdir}-1
1231 mkdir -p $DIR/${tdir}-2
1232 multiop $DIR/${tdir}-1/f O_c &
1235 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1236 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1237 mcreate $DIR/${tdir}-2/f &
1241 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1242 kill -USR1 $close_pid
1243 cancel_lru_locks mdc # force the close
1244 wait $close_pid || return 1
1245 # open should still be here
1246 [ -d /proc/$open_pid ] || return 2
1248 replay_barrier_nodf $SINGLEMDS
1250 wait $open_pid || return 3
1252 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1253 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1254 rm -rf $DIR/${tdir}-*
1256 run_test 53e "|X| open reply while two MDC requests in flight"
1259 cancel_lru_locks mdc # cleanup locks from former test cases
1260 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1262 mkdir -p $DIR/${tdir}-1
1263 mkdir -p $DIR/${tdir}-2
1264 multiop $DIR/${tdir}-1/f O_c &
1267 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1268 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1269 mcreate $DIR/${tdir}-2/f &
1273 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1274 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1275 kill -USR1 $close_pid
1276 cancel_lru_locks mdc # force the close
1278 #bz20647: make sure all pids are exists before failover
1279 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1280 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1281 replay_barrier_nodf $SINGLEMDS
1282 fail_nodf $SINGLEMDS
1283 wait $open_pid || return 1
1285 # close should be gone
1286 [ -d /proc/$close_pid ] && return 2
1287 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1289 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1290 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1291 rm -rf $DIR/${tdir}-*
1293 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1296 cancel_lru_locks mdc # cleanup locks from former test cases
1297 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1299 mkdir -p $DIR/${tdir}-1
1300 mkdir -p $DIR/${tdir}-2
1301 multiop $DIR/${tdir}-1/f O_c &
1304 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1305 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1306 mcreate $DIR/${tdir}-2/f &
1310 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1311 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1312 kill -USR1 $close_pid
1313 cancel_lru_locks mdc # force the close
1314 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1316 #bz20647: make sure all pids are exists before failover
1317 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1318 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1319 replay_barrier_nodf $SINGLEMDS
1320 fail_nodf $SINGLEMDS
1321 wait $open_pid || return 1
1323 # close should be gone
1324 [ -d /proc/$close_pid ] && return 2
1326 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1327 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1328 rm -rf $DIR/${tdir}-*
1330 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1333 cancel_lru_locks mdc # cleanup locks from former test cases
1334 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1336 mkdir -p $DIR/${tdir}-1
1337 mkdir -p $DIR/${tdir}-2
1338 multiop $DIR/${tdir}-1/f O_c &
1341 #define OBD_FAIL_MDS_REINT_NET 0x107
1342 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1343 mcreate $DIR/${tdir}-2/f &
1347 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1348 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1349 kill -USR1 $close_pid
1350 cancel_lru_locks mdc # force the close
1353 #bz20647: make sure all pids are exists before failover
1354 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1355 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1356 replay_barrier_nodf $SINGLEMDS
1357 fail_nodf $SINGLEMDS
1358 wait $open_pid || return 1
1360 # close should be gone
1361 [ -d /proc/$close_pid ] && return 2
1362 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1364 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1365 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1366 rm -rf $DIR/${tdir}-*
1368 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1370 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1372 #b3761 ASSERTION(hash != 0) failed
1374 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1375 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1377 # give touch a chance to run
1379 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1383 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1385 #b3440 ASSERTION(rec->ur_fid2->id) failed
1387 ln -s foo $DIR/$tfile
1388 replay_barrier $SINGLEMDS
1389 #drop_reply "cat $DIR/$tfile"
1393 run_test 56 "don't replay a symlink open request (3440)"
1395 #recovery one mds-ost setattr from llog
1397 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1398 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1400 replay_barrier $SINGLEMDS
1403 $CHECKSTAT -t file $DIR/$tfile || return 1
1404 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1407 run_test 57 "test recovery from llog for setattr op"
1409 #recovery many mds-ost setattr from llog
1412 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1413 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1414 createmany -o $DIR/$tdir/$tfile-%d 2500
1415 replay_barrier $SINGLEMDS
1418 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1419 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1420 unlinkmany $DIR/$tdir/$tfile-%d 2500
1423 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1426 mount_client $MOUNT2
1428 touch $DIR/$tdir/$tfile
1429 replay_barrier $SINGLEMDS
1430 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1432 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1433 [ x$VAL = x"bar" ] || return 1
1434 rm -f $DIR/$tdir/$tfile
1436 zconf_umount `hostname` $MOUNT2
1438 run_test 58b "test replay of setxattr op"
1440 test_58c() { # bug 16570
1441 mount_client $MOUNT2
1443 touch $DIR/$tdir/$tfile
1444 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1446 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1447 [ x$VAL = x"bar" ] || return 2
1448 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1450 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1451 [ x$VAL = x"bar1" ] || return 4
1452 rm -f $DIR/$tdir/$tfile
1454 zconf_umount `hostname` $MOUNT2
1456 run_test 58c "resend/reconstruct setxattr op"
1458 # log_commit_thread vs filter_destroy race used to lead to import use after free
1461 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1464 createmany -o $DIR/$tdir/$tfile-%d 200
1466 unlinkmany $DIR/$tdir/$tfile-%d 200
1467 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1468 do_facet ost1 "lctl set_param fail_loc=0x507"
1471 do_facet ost1 "lctl set_param fail_loc=0x0"
1475 run_test 59 "test log_commit_thread vs filter_destroy race"
1477 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1478 # bug 12086: should no oops and No ctxt error for this test
1481 createmany -o $DIR/$tdir/$tfile-%d 200
1482 replay_barrier $SINGLEMDS
1483 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1485 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1486 local no_ctxt=`dmesg | grep "No ctxt"`
1487 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1489 run_test 60 "test llog post recovery init vs llog unlink"
1491 #test race llog recovery thread vs llog cleanup
1492 test_61a() { # was test_61
1493 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1496 createmany -o $DIR/$tdir/$tfile-%d 800
1498 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1499 unlinkmany $DIR/$tdir/$tfile-%d 800
1500 set_nodes_failloc "$(osts_nodes)" 0x80000221
1505 set_nodes_failloc "$(osts_nodes)" 0x0
1507 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1510 run_test 61a "test race llog recovery vs llog cleanup"
1512 #test race mds llog sync vs llog cleanup
1514 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1515 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1516 facet_failover $SINGLEMDS
1519 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1521 run_test 61b "test race mds llog sync vs llog cleanup"
1523 #test race cancel cookie cb vs llog cleanup
1525 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1527 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1529 set_nodes_failloc "$(osts_nodes)" 0x80000222
1533 set_nodes_failloc "$(osts_nodes)" 0x0
1535 run_test 61c "test race mds llog sync vs llog cleanup"
1537 test_61d() { # bug 16002 # bug 17466 # bug 22137
1538 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1540 do_facet mgs "lctl set_param fail_loc=0x80000605"
1541 start mgs $MGSDEV $mgs_MOUNT_OPTS && error "mgs start should have failed"
1542 do_facet mgs "lctl set_param fail_loc=0"
1543 start mgs $MGSDEV $mgs_MOUNT_OPTS || error "cannot restart mgs"
1545 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1547 test_62() { # Bug 15756 - don't mis-drop resent replay
1549 replay_barrier $SINGLEMDS
1550 createmany -o $DIR/$tdir/$tfile- 25
1551 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1552 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1554 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1555 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1558 run_test 62 "don't mis-drop resent replay"
1560 #Adaptive Timeouts (bug 3055)
1568 echo "Cleaning up AT ..."
1569 if [ -n "$ATOLDBASE" ]; then
1570 local at_history=$($LCTL get_param -n at_history)
1571 do_facet mds "lctl set_param at_history=$at_history" || true
1572 do_facet ost1 "lctl set_param at_history=$at_history" || true
1575 if [ $AT_MAX_SET -ne 0 ]; then
1576 for facet in mds client ost; do
1577 var=AT_MAX_SAVE_${facet}
1578 echo restore AT on $facet to saved value ${!var}
1579 at_max_set ${!var} $facet
1580 at_new=$(at_max_get $facet)
1581 echo Restored AT value on $facet $at_new
1582 [ $at_new -eq ${!var} ] || \
1583 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1590 local at_max_new=600
1592 # Save at_max original values
1594 if [ $AT_MAX_SET -eq 0 ]; then
1595 # Suppose that all osts have the same at_max
1596 for facet in mds client ost; do
1597 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1601 for facet in mds client ost; do
1602 at_max=$(at_max_get $facet)
1603 if [ $at_max -ne $at_max_new ]; then
1604 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1605 at_max_set $at_max_new $facet
1610 if [ -z "$ATOLDBASE" ]; then
1611 ATOLDBASE=$(do_facet mds "lctl get_param -n at_history")
1612 # speed up the timebase so we can check decreasing AT
1613 do_facet mds "lctl set_param at_history=8" || true
1614 do_facet ost1 "lctl set_param at_history=8" || true
1616 # sleep for a while to cool down, should be > 8s and also allow
1617 # at least one ping to be sent. simply use TIMEOUT to be safe.
1622 test_65a() #bug 3055
1624 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1626 at_start || return 0
1627 $LCTL dk > /dev/null
1629 sysctl -w lnet.debug="+other"
1630 # Slow down a request to the current service time, this is critical
1631 # because previous tests may have caused this value to increase.
1632 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1633 awk '/portal 12/ {print $5}'`
1634 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1636 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1637 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1638 do_facet mds sysctl -w lustre.fail_loc=0x8000050a
1639 createmany -o $DIR/$tfile 10 > /dev/null
1640 unlinkmany $DIR/$tfile 10 > /dev/null
1641 # check for log message
1642 $LCTL dk | grep "Early reply #" || error "No early reply"
1644 # client should show REQ_DELAY estimates
1645 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1647 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1649 run_test 65a "AT: verify early replies"
1651 test_65b() #bug 3055
1653 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1655 at_start || return 0
1658 sysctl -w lnet.debug="other trace"
1659 $LCTL dk > /dev/null
1660 # Slow down a request to the current service time, this is critical
1661 # because previous tests may have caused this value to increase.
1662 lfs setstripe $DIR/$tfile --index=0 --count=1
1663 multiop $DIR/$tfile Ow1yc
1664 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1665 awk '/portal 6/ {print $5}'`
1666 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1668 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1669 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1670 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1673 lfs setstripe $DIR/$tfile --index=0 --count=1
1674 # force some real bulk transfer
1675 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1677 do_facet ost1 sysctl -w lustre.fail_loc=0
1678 # check for log message
1679 $LCTL dk | grep "Early reply #" || error "No early reply"
1681 # client should show REQ_DELAY estimates
1682 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1684 run_test 65b "AT: verify early replies on packed reply / bulk"
1686 test_66a() #bug 3055
1688 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1690 at_start || return 0
1691 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1692 # adjust 5s at a time so no early reply is sent (within deadline)
1693 do_facet mds "sysctl -w lustre.fail_val=5000"
1694 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1695 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1696 createmany -o $DIR/$tfile 20 > /dev/null
1697 unlinkmany $DIR/$tfile 20 > /dev/null
1698 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1699 do_facet mds "sysctl -w lustre.fail_val=10000"
1700 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1701 createmany -o $DIR/$tfile 20 > /dev/null
1702 unlinkmany $DIR/$tfile 20 > /dev/null
1703 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1704 do_facet mds "sysctl -w lustre.fail_loc=0"
1706 createmany -o $DIR/$tfile 20 > /dev/null
1707 unlinkmany $DIR/$tfile 20 > /dev/null
1708 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1709 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1710 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1711 echo "Current MDT timeout $CUR, worst $WORST"
1712 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1714 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1716 test_66b() #bug 3055
1718 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1720 at_start || return 0
1721 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1722 sysctl -w lustre.fail_val=$(($ORIG + 5))
1723 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1724 sysctl -w lustre.fail_loc=0x50c
1725 ls $DIR/$tfile > /dev/null 2>&1
1726 sysctl -w lustre.fail_loc=0
1727 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1728 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1729 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1730 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1732 run_test 66b "AT: verify net latency adjusts"
1734 test_67a() #bug 3055
1736 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1738 at_start || return 0
1739 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1740 # sleeping threads may drive values above this
1741 do_facet ost1 "sysctl -w lustre.fail_val=400"
1742 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1743 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1744 createmany -o $DIR/$tfile 20 > /dev/null
1745 unlinkmany $DIR/$tfile 20 > /dev/null
1746 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1747 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1748 ATTEMPTS=$(($CONN2 - $CONN1))
1749 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1750 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1753 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1755 test_67b() #bug 3055
1757 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1759 at_start || return 0
1760 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1762 # exhaust precreations on ost1
1763 local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1764 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1765 local last_id=$(do_facet mds lctl get_param -n \
1766 osc.$mdtosc.prealloc_last_id)
1767 local next_id=$(do_facet mds lctl get_param -n \
1768 osc.$mdtosc.prealloc_next_id)
1770 mkdir -p $DIR/$tdir/${OST}
1771 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1772 echo "Creating to objid $last_id on ost $OST..."
1773 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1774 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1775 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1776 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1779 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1781 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1782 ATTEMPTS=$(($CONN2 - $CONN1))
1783 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1784 # do it again; should not timeout
1785 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1786 cp /etc/profile $DIR/$tfile || error "cp failed"
1787 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1789 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1790 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1791 ATTEMPTS=$(($CONN3 - $CONN2))
1792 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1793 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1796 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1798 test_68 () #bug 13813
1800 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1802 at_start || return 0
1803 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1804 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1805 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1806 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1807 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1808 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1809 echo $TIMEOUT >> $ldlm_enqueue_min
1810 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1814 lfs setstripe $DIR/$tdir --index=0 --count=1
1815 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1816 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1817 sysctl -w lustre.fail_loc=0x80000312
1818 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1819 sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1820 sysctl -w lustre.fail_loc=0x80000312
1821 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1822 sysctl -w lustre.fail_loc=0
1824 echo $ENQ_MIN >> $ldlm_enqueue_min
1825 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1829 run_test 68 "AT: verify slowing locks"
1832 # end of AT tests includes above lines
1835 # start multi-client tests
1837 [ -z "$CLIENTS" ] && \
1838 { skip "Need two or more clients." && return; }
1839 [ $CLIENTCOUNT -lt 2 ] && \
1840 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1842 echo "mount clients $CLIENTS ..."
1843 zconf_mount_clients $CLIENTS $DIR
1845 local clients=${CLIENTS//,/ }
1846 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1847 for CLIENT in $clients; do
1848 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1849 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1850 error "dd failed on $CLIENT"
1853 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1854 for C in ${CLIENTS//,/ }; do
1855 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1856 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1862 run_test 70a "check multi client t-f"
1864 check_dbench_load () {
1865 local clients=${1//,/ }
1868 for client in $clients; do
1869 if ! do_node $client "ps ax | grep -v grep | awk '{ print $6 }' | grep -q rundbench"; then
1870 error_noexit "rundbench load on $client failed!"
1877 kill_dbench_load () {
1878 local clients=${1:-$(hostname)}
1879 do_nodes $clients "killall dbench"
1883 local clients=${CLIENTS:-$HOSTNAME}
1885 zconf_mount_clients $clients $DIR
1888 [ "$SLOW" = "no" ] && duration=60
1889 local cmd="rundbench 1 -t $duration"
1891 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1892 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1893 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1896 log "Started rundbench load PID=$PID ..."
1899 START_TS=$(date +%s)
1900 CURRENT_TS=$START_TS
1901 while [ $ELAPSED -lt $duration ]; do
1902 if ! check_dbench_load $clients; then
1903 kill_dbench_load $clients
1907 replay_barrier $SINGLEMDS
1908 sleep 1 # give clients a time to do operations
1909 # Increment the number of failovers
1910 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1911 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1913 CURRENT_TS=$(date +%s)
1914 ELAPSED=$((CURRENT_TS - START_TS))
1916 wait $PID || error "rundbench load on $CLIENTS failed!"
1918 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1919 # end multi-client tests
1922 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1926 replay_barrier $SINGLEMDS
1927 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1928 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1931 wait $pid || return 1
1932 [ -e $DIR/$tfile ] && return 2
1935 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1938 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1942 replay_barrier $SINGLEMDS
1943 #define OBD_FAIL_LDLM_REPLY 0x30c
1944 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1947 wait $pid || return 1
1948 [ -e $DIR/$tfile ] && return 2
1951 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1954 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1958 replay_barrier $SINGLEMDS
1959 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1960 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1963 wait $pid || return 1
1964 [ -e $DIR/$tfile ] && return 2
1967 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1971 local clients=${CLIENTS:-$HOSTNAME}
1974 zconf_umount_clients $clients $MOUNT
1975 facet_failover $SINGLEMDS
1976 zconf_mount_clients $clients $MOUNT
1978 touch $DIR/$tfile || return 1
1979 rm $DIR/$tfile || return 2
1980 clients_up || error "client evicted: $?"
1983 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1986 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1990 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1991 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1993 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1996 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2003 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
2004 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
2006 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
2009 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
2012 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2015 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
2017 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
2018 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
2020 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
2022 stat $DIR/$tdir/f1002
2024 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
2027 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2031 mkdir $dir || error "mkdir $dir failed"
2035 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2037 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
2040 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2044 mkdir $dir || error "mkdir $dir failed"
2048 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2050 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2054 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2055 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2056 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2057 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2059 run_test 83a "fail log_add during unlink recovery"
2063 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2064 replay_barrier $SINGLEMDS
2065 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2066 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2067 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2070 run_test 83b "fail log_add during unlink recovery"
2073 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2074 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2075 createmany -o $DIR/$tfile- 1 &
2079 client_up || client_up || true # reconnect
2081 run_test 84a "stale open during export disconnect"
2084 local clients=${CLIENTS:-$HOSTNAME}
2086 zconf_umount_clients $clients $MOUNT
2087 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2088 remount_facet $SINGLEMDS
2089 zconf_mount_clients $clients $MOUNT
2091 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2094 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2097 lfs setstripe -i 0 -c 1 $DIR/$tfile
2098 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2099 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2100 cancel_lru_locks osc
2102 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2103 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2104 if [ $cksum != $cksum2 ] ; then
2105 error "New checksum $cksum2 does not match original $cksum"
2108 run_test 87 "write replay"
2111 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2114 lfs setstripe -i 0 -c 1 $DIR/$tfile
2115 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2116 sleep 1 # Give it a chance to flush dirty data
2117 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2118 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2119 cancel_lru_locks osc
2121 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2122 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2123 if [ $cksum != $cksum2 ] ; then
2124 error "New checksum $cksum2 does not match original $cksum"
2127 run_test 87b "write replay with changed data (checksum resend)"
2129 equals_msg `basename $0`: test complete, cleaning up
2130 check_and_cleanup_lustre
2131 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true