7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
16 CHECK_GRANT=${CHECK_GRANT:-"yes"}
17 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
19 remote_mds_nodsh && log "SKIP: remote MDS with nodsh" && exit 0
22 # bug number: 17466 15962
23 ALWAYS_EXCEPT="61d 33b $REPLAY_SINGLE_EXCEPT"
25 if [ "$FAILURE_MODE" = "HARD" ] && mixed_ost_devs; then
26 CONFIG_EXCEPTIONS="0b 42 47 61a 61c"
27 echo -n "Several ost services on one ost node are used with FAILURE_MODE=$FAILURE_MODE. "
28 echo "Except the tests: $CONFIG_EXCEPTIONS"
29 ALWAYS_EXCEPT="$ALWAYS_EXCEPT $CONFIG_EXCEPTIONS"
32 # 63 min 7 min AT AT AT AT"
33 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
37 check_and_setup_lustre
42 rm -rf $DIR/[df][0-9]*
44 test_0a() { # was test_0
47 replay_barrier $SINGLEMDS
51 run_test 0a "empty replay"
54 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
56 # this test attempts to trigger a race in the precreation code,
57 # and must run before any other objects are created on the filesystem
59 createmany -o $DIR/$tfile 20 || return 1
60 unlinkmany $DIR/$tfile 20 || return 2
62 run_test 0b "ensure object created after recover exists. (3284)"
68 lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
74 lctl get_param -n seq.cli-srv-$mds-mdc-*.width
77 # This test should pass for single-mds and multi-mds configs.
78 # But for different configurations it tests different things.
82 # (1) fld_create replay should happen;
84 # (2) fld_create replay should not return -EEXISTS, if it does
85 # this means sequence manager recovery code is buggy and allocated
86 # same sequence two times after recovery.
90 # (1) fld_create replay may not happen, because its home MDS is
91 # MDS2 which is not involved to revovery;
93 # (2) as fld_create does not happen on MDS1, it does not make any
96 local label=`mdsdevlabel 1`
97 [ -z "$label" ] && echo "No label for mds1" && return 1
99 replay_barrier $SINGLEMDS
100 local sw=`seq_get_width $label`
102 # make seq manager switch to next sequence each
103 # time as new fid is needed.
104 seq_set_width $label 1
106 # make sure that fld has created at least one new
108 touch $DIR/$tfile || return 2
109 seq_set_width $label $sw
111 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
114 # wait for recovery finish
118 # flush fld cache and dentry cache to make it lookup
119 # created entry instead of revalidating existent one
121 zconf_mount `hostname` $MOUNT
123 # issue lookup which should call fld lookup which
124 # should fail if client did not replay fld create
125 # correctly and server has no fld entry
126 touch $DIR/$tfile || return 3
127 rm $DIR/$tfile || return 4
129 run_test 0c "fld create"
132 replay_barrier $SINGLEMDS
135 $CHECKSTAT -t file $DIR/$tfile || return 1
138 run_test 1 "simple create"
141 replay_barrier $SINGLEMDS
144 $CHECKSTAT -t file $DIR/$tfile || return 1
151 replay_barrier $SINGLEMDS
154 $CHECKSTAT -t file $DIR/$tfile || return 1
160 local file=$DIR/$tfile
161 replay_barrier $SINGLEMDS
163 openfile -f O_DIRECTORY $file
165 $CHECKSTAT -t file $file || return 2
168 run_test 3a "replay failed open(O_DIRECTORY)"
171 replay_barrier $SINGLEMDS
172 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
173 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
175 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
177 $CHECKSTAT -t file $DIR/$tfile && return 2
180 run_test 3b "replay failed open -ENOMEM"
183 replay_barrier $SINGLEMDS
184 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
185 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
187 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
190 $CHECKSTAT -t file $DIR/$tfile && return 2
193 run_test 3c "replay failed open -ENOMEM"
195 test_4a() { # was test_4
196 replay_barrier $SINGLEMDS
197 for i in `seq 10`; do
198 echo "tag-$i" > $DIR/$tfile-$i
201 for i in `seq 10`; do
202 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
205 run_test 4a "|x| 10 open(O_CREAT)s"
208 replay_barrier $SINGLEMDS
211 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
213 run_test 4b "|x| rm 10 files"
215 # The idea is to get past the first block of precreated files on both
216 # osts, and then replay.
218 replay_barrier $SINGLEMDS
219 for i in `seq 220`; do
220 echo "tag-$i" > $DIR/$tfile-$i
223 for i in `seq 220`; do
224 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
228 # waiting for commitment of removal
230 run_test 5 "|x| 220 open(O_CREAT)"
233 test_6a() { # was test_6
235 replay_barrier $SINGLEMDS
236 mcreate $DIR/$tdir/$tfile
238 $CHECKSTAT -t dir $DIR/$tdir || return 1
239 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
241 # waiting for log process thread
243 run_test 6a "mkdir + contained create"
247 replay_barrier $SINGLEMDS
250 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
252 run_test 6b "|X| rmdir"
256 replay_barrier $SINGLEMDS
257 mcreate $DIR/$tdir/$tfile
259 $CHECKSTAT -t dir $DIR/$tdir || return 1
260 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
263 run_test 7 "mkdir |X| contained create"
266 # make sure no side-effect from previous test.
268 replay_barrier $SINGLEMDS
269 multiop_bg_pause $DIR/$tfile mo_c || return 4
273 $CHECKSTAT -t file $DIR/$tfile || return 1
274 kill -USR1 $MULTIPID || return 2
275 wait $MULTIPID || return 3
278 run_test 8 "creat open |X| close"
281 replay_barrier $SINGLEMDS
283 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
285 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
287 echo " old_inum == $old_inum, new_inum == $new_inum"
288 if [ $old_inum -eq $new_inum ] ;
290 echo " old_inum and new_inum match"
292 echo "!!!! old_inum and new_inum NOT match"
297 run_test 9 "|X| create (same inum/gen)"
301 replay_barrier $SINGLEMDS
302 mv $DIR/$tfile $DIR/$tfile-2
305 $CHECKSTAT $DIR/$tfile && return 1
306 $CHECKSTAT $DIR/$tfile-2 ||return 2
310 run_test 10 "create |X| rename unlink"
314 echo "old" > $DIR/$tfile
315 mv $DIR/$tfile $DIR/$tfile-2
316 replay_barrier $SINGLEMDS
317 echo "new" > $DIR/$tfile
319 grep old $DIR/$tfile-2
321 grep new $DIR/$tfile || return 1
322 grep old $DIR/$tfile-2 || return 2
324 run_test 11 "create open write rename |X| create-old-name read"
328 multiop_bg_pause $DIR/$tfile o_tSc || return 3
331 replay_barrier $SINGLEMDS
333 wait $pid || return 1
336 [ -e $DIR/$tfile ] && return 2
339 run_test 12 "open, unlink |X| close"
342 # 1777 - replay open after committed chmod that would make
343 # a regular open a failure
346 multiop_bg_pause $DIR/$tfile O_wc || return 3
349 $CHECKSTAT -p 0 $DIR/$tfile
350 replay_barrier $SINGLEMDS
353 wait $pid || return 1
355 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
358 run_test 13 "open chmod 0 |x| write close"
361 multiop_bg_pause $DIR/$tfile O_tSc || return 4
364 replay_barrier $SINGLEMDS
365 kill -USR1 $pid || return 1
366 wait $pid || return 2
369 [ -e $DIR/$tfile ] && return 3
372 run_test 14 "open(O_CREAT), unlink |X| close"
375 multiop_bg_pause $DIR/$tfile O_tSc || return 5
378 replay_barrier $SINGLEMDS
379 touch $DIR/g11 || return 1
381 wait $pid || return 2
384 [ -e $DIR/$tfile ] && return 3
385 touch $DIR/h11 || return 4
388 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
392 replay_barrier $SINGLEMDS
395 mcreate $DIR/$tfile-2
397 [ -e $DIR/$tfile ] && return 1
398 [ -e $DIR/$tfile-2 ] || return 2
399 munlink $DIR/$tfile-2 || return 3
401 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
404 replay_barrier $SINGLEMDS
405 multiop_bg_pause $DIR/$tfile O_c || return 4
408 kill -USR1 $pid || return 1
409 wait $pid || return 2
410 $CHECKSTAT -t file $DIR/$tfile || return 3
413 run_test 17 "|X| open(O_CREAT), |replay| close"
416 replay_barrier $SINGLEMDS
417 multiop_bg_pause $DIR/$tfile O_tSc || return 8
420 touch $DIR/$tfile-2 || return 1
421 echo "pid: $pid will close"
423 wait $pid || return 2
426 [ -e $DIR/$tfile ] && return 3
427 [ -e $DIR/$tfile-2 ] || return 4
428 # this touch frequently fails
429 touch $DIR/$tfile-3 || return 5
430 munlink $DIR/$tfile-2 || return 6
431 munlink $DIR/$tfile-3 || return 7
434 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
436 # bug 1855 (a simpler form of test_11 above)
438 replay_barrier $SINGLEMDS
440 echo "old" > $DIR/$tfile
441 mv $DIR/$tfile $DIR/$tfile-2
442 grep old $DIR/$tfile-2
444 grep old $DIR/$tfile-2 || return 2
446 run_test 19 "|X| mcreate, open, write, rename "
448 test_20a() { # was test_20
449 replay_barrier $SINGLEMDS
450 multiop_bg_pause $DIR/$tfile O_tSc || return 3
456 wait $pid || return 1
457 [ -e $DIR/$tfile ] && return 2
460 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
462 test_20b() { # bug 10480
463 # XXX increase the debug level temporary
464 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=0x33f0406; $LCTL set_param debug_mb=150"
465 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
467 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
469 while [ ! -e $DIR/$tfile ] ; do
470 usleep 60 # give dd a chance to start
473 lfs getstripe $DIR/$tfile || return 1
474 rm -f $DIR/$tfile || return 2 # make it an orphan
476 df -P $DIR || df -P $DIR || true # reconnect
478 fail $SINGLEMDS # start orphan recovery
479 df -P $DIR || df -P $DIR || true # reconnect
480 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
482 # FIXME just because recovery is done doesn't mean we've finished
483 # orphan cleanup. Fake it with a sleep for now...
485 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
486 log "before $BEFOREUSED, after $AFTERUSED"
487 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
488 error "after $AFTERUSED > before $BEFOREUSED"
489 # XXX decrease it back
490 do_nodes $(comma_list $(nodes_list)) "$LCTL set_param debug=$PTLDEBUG; $LCTL set_param debug_mb=$DEBUG_SIZE"
493 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
495 test_20c() { # bug 10480
496 multiop_bg_pause $DIR/$tfile Ow_c || return 1
503 df -P $DIR || df -P $DIR || true # reconnect
506 test -s $DIR/$tfile || error "File was truncated"
508 wait $pid || return 1
511 run_test 20c "check that client eviction does not affect file content"
514 replay_barrier $SINGLEMDS
515 multiop_bg_pause $DIR/$tfile O_tSc || return 5
518 touch $DIR/g11 || return 1
522 wait $pid || return 2
523 [ -e $DIR/$tfile ] && return 3
524 touch $DIR/h11 || return 4
527 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
530 multiop_bg_pause $DIR/$tfile O_tSc || return 3
533 replay_barrier $SINGLEMDS
538 wait $pid || return 1
539 [ -e $DIR/$tfile ] && return 2
542 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
545 multiop_bg_pause $DIR/$tfile O_tSc || return 5
548 replay_barrier $SINGLEMDS
550 touch $DIR/g11 || return 1
554 wait $pid || return 2
555 [ -e $DIR/$tfile ] && return 3
556 touch $DIR/h11 || return 4
559 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
562 multiop_bg_pause $DIR/$tfile O_tSc || return 3
565 replay_barrier $SINGLEMDS
569 wait $pid || return 1
570 [ -e $DIR/$tfile ] && return 2
573 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
576 multiop_bg_pause $DIR/$tfile O_tSc || return 3
580 replay_barrier $SINGLEMDS
583 wait $pid || return 1
584 [ -e $DIR/$tfile ] && return 2
587 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
590 replay_barrier $SINGLEMDS
591 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
593 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
598 wait $pid2 || return 1
602 wait $pid1 || return 2
603 [ -e $DIR/$tfile-1 ] && return 3
604 [ -e $DIR/$tfile-2 ] && return 4
607 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
610 replay_barrier $SINGLEMDS
611 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
613 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
620 wait $pid1 || return 1
622 wait $pid2 || return 2
623 [ -e $DIR/$tfile-1 ] && return 3
624 [ -e $DIR/$tfile-2 ] && return 4
627 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
630 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
632 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
634 replay_barrier $SINGLEMDS
638 wait $pid2 || return 1
642 wait $pid1 || return 2
643 [ -e $DIR/$tfile-1 ] && return 3
644 [ -e $DIR/$tfile-2 ] && return 4
647 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
650 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
652 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
654 replay_barrier $SINGLEMDS
660 wait $pid1 || return 1
662 wait $pid2 || return 2
663 [ -e $DIR/$tfile-1 ] && return 3
664 [ -e $DIR/$tfile-2 ] && return 4
667 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
670 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
672 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
677 replay_barrier $SINGLEMDS
680 wait $pid1 || return 1
682 wait $pid2 || return 2
683 [ -e $DIR/$tfile-1 ] && return 3
684 [ -e $DIR/$tfile-2 ] && return 4
687 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
690 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
692 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
696 replay_barrier $SINGLEMDS
700 wait $pid1 || return 1
702 wait $pid2 || return 2
703 [ -e $DIR/$tfile-1 ] && return 3
704 [ -e $DIR/$tfile-2 ] && return 4
707 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
709 # tests for bug 2104; completion without crashing is success. The close is
710 # stale, but we always return 0 for close, so the app never sees it.
712 multiop_bg_pause $DIR/$tfile O_c || return 2
714 multiop_bg_pause $DIR/$tfile O_c || return 3
717 df $MOUNT || sleep 1 && df $MOUNT || return 1
720 wait $pid1 || return 4
721 wait $pid2 || return 5
724 run_test 32 "close() notices client eviction; close() after client eviction"
726 # Abort recovery before client complete
727 test_33a() { # was test_33
728 replay_barrier $SINGLEMDS
729 createmany -o $DIR/$tfile-%d 100
730 fail_abort $SINGLEMDS
731 # this file should be gone, because the replay was aborted
732 $CHECKSTAT -t file $DIR/$tfile-* && return 3
733 unlinkmany $DIR/$tfile-%d 0 100
736 run_test 33a "abort recovery before client does replay"
738 # Stale FID sequence bug 15962
739 test_33b() { # was test_33a
740 replay_barrier $SINGLEMDS
741 createmany -o $DIR/$tfile-%d 10
742 fail_abort $SINGLEMDS
743 unlinkmany $DIR/$tfile-%d 0 10
744 # recreate shouldn't fail
745 createmany -o $DIR/$tfile-%d 10 || return 3
746 unlinkmany $DIR/$tfile-%d 0 10
749 run_test 33b "fid shouldn't be reused after abort recovery"
752 multiop_bg_pause $DIR/$tfile O_c || return 2
756 replay_barrier $SINGLEMDS
757 fail_abort $SINGLEMDS
759 wait $pid || return 3
760 [ -e $DIR/$tfile ] && return 1
764 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
766 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
770 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
771 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
776 # give a chance to remove from MDS
777 fail_abort $SINGLEMDS
778 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
780 run_test 35 "test recovery from llog for unlink op"
782 # b=2432 resent cancel after replay uses wrong cookie,
783 # so don't resend cancels
785 replay_barrier $SINGLEMDS
787 checkstat $DIR/$tfile
788 facet_failover $SINGLEMDS
790 if dmesg | grep "unknown lock cookie"; then
791 echo "cancel after replay failed"
795 run_test 36 "don't resend cancel"
798 # directory orphans can't be unlinked from PENDING directory
800 rmdir $DIR/$tfile 2>/dev/null
801 multiop_bg_pause $DIR/$tfile dD_c || return 2
805 replay_barrier $SINGLEMDS
806 # clear the dmesg buffer so we only see errors from this recovery
808 fail_abort $SINGLEMDS
810 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
811 wait $pid || return 3
815 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
818 createmany -o $DIR/$tfile-%d 800
819 unlinkmany $DIR/$tfile-%d 0 400
820 replay_barrier $SINGLEMDS
822 unlinkmany $DIR/$tfile-%d 400 400
824 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
826 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
828 test_39() { # bug 4176
829 createmany -o $DIR/$tfile-%d 800
830 replay_barrier $SINGLEMDS
831 unlinkmany $DIR/$tfile-%d 0 400
833 unlinkmany $DIR/$tfile-%d 400 400
835 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
837 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
840 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
845 $LCTL mark multiop $MOUNT/$tfile OS_c
846 multiop $MOUNT/$tfile OS_c &
848 writeme -s $MOUNT/${tfile}-2 &
851 facet_failover $SINGLEMDS
852 #define OBD_FAIL_MDS_CONNECT_NET 0x117
853 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
855 stat1=`count_ost_writes`
857 stat2=`count_ost_writes`
858 echo "$stat1, $stat2"
859 if [ $stat1 -lt $stat2 ]; then
860 echo "writes continuing during recovery"
863 echo "writes not continuing during recovery, bug 2477"
866 echo "waiting for writeme $WRITE_PID"
870 echo "waiting for multiop $PID"
871 wait $PID || return 2
872 do_facet client munlink $MOUNT/$tfile || return 3
873 do_facet client munlink $MOUNT/${tfile}-2 || return 3
876 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
880 # make sure that a read to one osc doesn't try to double-unlock its page just
881 # because another osc is invalid. trigger_group_io used to mistakenly return
882 # an error if any oscs were invalid even after having successfully put rpcs
883 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
884 # the page, guarnateeing that the unlock from the RPC completion would
885 # assert on trying to unlock the unlocked page.
887 [ $OSTCOUNT -lt 2 ] && \
888 skip "skipping test 41: we don't have a second OST to test with" && \
891 local f=$MOUNT/$tfile
892 # make sure the start of the file is ost1
893 lfs setstripe $f -s $((128 * 1024)) -i 0
894 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
896 # fail ost2 and read from ost1
897 local osc2dev=`do_facet $SINGLEMDS "lctl get_param -n devices | grep ${ost2_svc}-osc-MDT0000" | awk '{print $1}'`
898 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
899 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
900 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
901 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
904 run_test 41 "read from a valid osc while other oscs are invalid"
906 # test MDS recovery after ost failure
908 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
909 createmany -o $DIR/$tfile-%d 800
911 unlinkmany $DIR/$tfile-%d 0 400
913 lctl set_param debug=-1
916 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
917 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
918 #[ $blocks_after -lt $blocks ] || return 1
919 echo wait for MDS to timeout and recover
920 sleep $((TIMEOUT * 2))
922 unlinkmany $DIR/$tfile-%d 400 400
923 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
925 run_test 42 "recovery after ost failure"
927 # timeout in MDS/OST recovery RPC will LBUG MDS
928 test_43() { # bug 2530
929 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
931 replay_barrier $SINGLEMDS
933 # OBD_FAIL_OST_CREATE_NET 0x204
934 do_facet ost1 "lctl set_param fail_loc=0x80000204"
937 do_facet ost1 "lctl set_param fail_loc=0"
941 run_test 43 "mds osc import failure during recovery; don't LBUG"
943 test_44a() { # was test_44
946 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
947 [ "$mdcdev" ] || exit 2
949 # adaptive timeouts slow this way down
950 if at_is_valid && 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 --device $mdcdev recover
963 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
964 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
967 run_test 44a "race in target handle connect"
970 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
971 [ "$mdcdev" ] || exit 2
972 for i in `seq 1 10`; do
973 echo "$i of 10 ($(date +%s))"
974 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
975 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
976 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
977 $LCTL --device $mdcdev recover
980 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
983 run_test 44b "race in target handle connect"
985 # Handle failed close
987 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
988 [ "$mdcdev" ] || exit 2
989 $LCTL --device $mdcdev recover
991 multiop_bg_pause $DIR/$tfile O_c || return 1
994 # This will cause the CLOSE to fail before even
995 # allocating a reply buffer
996 $LCTL --device $mdcdev deactivate || return 4
1000 wait $pid || return 1
1002 $LCTL --device $mdcdev activate || return 5
1005 $CHECKSTAT -t file $DIR/$tfile || return 2
1008 run_test 45 "Handle failed close"
1012 drop_reply "touch $DIR/$tfile"
1014 # ironically, the previous test, 45, will cause a real forced close,
1015 # so just look for one for this test
1016 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1019 run_test 46 "Don't leak file handle after open resend (3325)"
1021 test_47() { # bug 2824
1022 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1024 # create some files to make sure precreate has been done on all
1025 # OSTs. (just in case this test is run independently)
1026 createmany -o $DIR/$tfile 20 || return 1
1028 # OBD_FAIL_OST_CREATE_NET 0x204
1030 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1031 df $MOUNT || return 2
1033 # let the MDS discover the OST failure, attempt to recover, fail
1034 # and recover again.
1035 sleep $((3 * TIMEOUT))
1037 # Without 2824, this createmany would hang
1038 createmany -o $DIR/$tfile 20 || return 3
1039 unlinkmany $DIR/$tfile 20 || return 4
1041 do_facet ost1 "lctl set_param fail_loc=0"
1044 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1047 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1048 [ "$OSTCOUNT" -lt "2" ] && skip "$OSTCOUNT < 2 OSTs -- skipping" && return
1050 replay_barrier $SINGLEMDS
1051 createmany -o $DIR/$tfile 20 || return 1
1052 # OBD_FAIL_OST_EROFS 0x216
1053 facet_failover $SINGLEMDS
1054 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1055 df $MOUNT || return 2
1057 createmany -o $DIR/$tfile 20 20 || return 2
1058 unlinkmany $DIR/$tfile 40 || return 3
1061 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1064 local oscdev=`do_facet $SINGLEMDS lctl get_param -n devices | grep ${ost1_svc}-osc-MDT0000 | awk '{print $1}'`
1065 [ "$oscdev" ] || return 1
1066 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1067 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1068 # give the mds_lov_sync threads a chance to run
1071 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1073 # b3764 timed out lock replay
1076 cancel_lru_locks mdc
1078 multiop $DIR/$tfile s || return 1
1079 replay_barrier $SINGLEMDS
1080 #define OBD_FAIL_LDLM_REPLY 0x30c
1081 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1082 fail $SINGLEMDS || return 2
1083 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1085 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1087 run_test 52 "time out lock replay (3764)"
1089 # bug 3462 - simultaneous MDC requests
1091 mkdir -p $DIR/${tdir}-1
1092 mkdir -p $DIR/${tdir}-2
1093 multiop $DIR/${tdir}-1/f O_c &
1095 # give multiop a change to open
1098 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1099 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1100 kill -USR1 $close_pid
1101 cancel_lru_locks mdc # force the close
1102 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1104 mcreate $DIR/${tdir}-2/f || return 1
1106 # close should still be here
1107 [ -d /proc/$close_pid ] || return 2
1109 replay_barrier_nodf $SINGLEMDS
1111 wait $close_pid || return 3
1113 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1114 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1115 rm -rf $DIR/${tdir}-*
1117 run_test 53a "|X| close request while two MDC requests in flight"
1120 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1122 mkdir -p $DIR/${tdir}-1
1123 mkdir -p $DIR/${tdir}-2
1124 multiop $DIR/${tdir}-1/f O_c &
1127 #define OBD_FAIL_MDS_REINT_NET 0x107
1128 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1129 mcreate $DIR/${tdir}-2/f &
1133 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1134 kill -USR1 $close_pid
1135 cancel_lru_locks mdc # force the close
1136 wait $close_pid || return 1
1137 # open should still be here
1138 [ -d /proc/$open_pid ] || return 2
1140 replay_barrier_nodf $SINGLEMDS
1142 wait $open_pid || return 3
1144 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1145 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1146 rm -rf $DIR/${tdir}-*
1148 run_test 53b "|X| open request while two MDC requests in flight"
1151 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1153 mkdir -p $DIR/${tdir}-1
1154 mkdir -p $DIR/${tdir}-2
1155 multiop $DIR/${tdir}-1/f O_c &
1158 #define OBD_FAIL_MDS_REINT_NET 0x107
1159 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1160 mcreate $DIR/${tdir}-2/f &
1164 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1165 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1166 kill -USR1 $close_pid
1167 cancel_lru_locks mdc # force the close
1169 replay_barrier_nodf $SINGLEMDS
1170 fail_nodf $SINGLEMDS
1171 wait $open_pid || return 1
1173 # close should be gone
1174 [ -d /proc/$close_pid ] && return 2
1175 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1177 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1178 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1179 rm -rf $DIR/${tdir}-*
1181 run_test 53c "|X| open request and close request while two MDC requests in flight"
1184 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1186 mkdir -p $DIR/${tdir}-1
1187 mkdir -p $DIR/${tdir}-2
1188 multiop $DIR/${tdir}-1/f O_c &
1190 # give multiop a chance to open
1193 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1194 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1195 kill -USR1 $close_pid
1196 cancel_lru_locks mdc # force the close
1197 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1198 mcreate $DIR/${tdir}-2/f || return 1
1200 # close should still be here
1201 [ -d /proc/$close_pid ] || return 2
1203 wait $close_pid || return 3
1205 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1206 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1207 rm -rf $DIR/${tdir}-*
1209 run_test 53d "|X| close reply while two MDC requests in flight"
1212 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1214 mkdir -p $DIR/${tdir}-1
1215 mkdir -p $DIR/${tdir}-2
1216 multiop $DIR/${tdir}-1/f O_c &
1219 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1220 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1221 mcreate $DIR/${tdir}-2/f &
1225 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1226 kill -USR1 $close_pid
1227 cancel_lru_locks mdc # force the close
1228 wait $close_pid || return 1
1229 # open should still be here
1230 [ -d /proc/$open_pid ] || return 2
1232 replay_barrier_nodf $SINGLEMDS
1234 wait $open_pid || return 3
1236 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1237 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1238 rm -rf $DIR/${tdir}-*
1240 run_test 53e "|X| open reply while two MDC requests in flight"
1243 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1245 mkdir -p $DIR/${tdir}-1
1246 mkdir -p $DIR/${tdir}-2
1247 multiop $DIR/${tdir}-1/f O_c &
1250 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1251 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1252 mcreate $DIR/${tdir}-2/f &
1256 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1257 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1258 kill -USR1 $close_pid
1259 cancel_lru_locks mdc # force the close
1261 replay_barrier_nodf $SINGLEMDS
1262 fail_nodf $SINGLEMDS
1263 wait $open_pid || return 1
1265 # close should be gone
1266 [ -d /proc/$close_pid ] && return 2
1267 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1269 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1270 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1271 rm -rf $DIR/${tdir}-*
1273 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1276 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1278 mkdir -p $DIR/${tdir}-1
1279 mkdir -p $DIR/${tdir}-2
1280 multiop $DIR/${tdir}-1/f O_c &
1283 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1284 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1285 mcreate $DIR/${tdir}-2/f &
1289 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1290 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1291 kill -USR1 $close_pid
1292 cancel_lru_locks mdc # force the close
1294 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1295 replay_barrier_nodf $SINGLEMDS
1296 fail_nodf $SINGLEMDS
1297 wait $open_pid || return 1
1299 # close should be gone
1300 [ -d /proc/$close_pid ] && return 2
1302 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1303 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1304 rm -rf $DIR/${tdir}-*
1306 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1309 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1311 mkdir -p $DIR/${tdir}-1
1312 mkdir -p $DIR/${tdir}-2
1313 multiop $DIR/${tdir}-1/f O_c &
1316 #define OBD_FAIL_MDS_REINT_NET 0x107
1317 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1318 mcreate $DIR/${tdir}-2/f &
1322 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1323 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1324 kill -USR1 $close_pid
1325 cancel_lru_locks mdc # force the close
1328 replay_barrier_nodf $SINGLEMDS
1329 fail_nodf $SINGLEMDS
1330 wait $open_pid || return 1
1332 # close should be gone
1333 [ -d /proc/$close_pid ] && return 2
1334 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1336 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1337 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1338 rm -rf $DIR/${tdir}-*
1340 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1342 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1344 #b3761 ASSERTION(hash != 0) failed
1346 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1347 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1349 # give touch a chance to run
1351 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1355 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1357 #b3440 ASSERTION(rec->ur_fid2->id) failed
1359 ln -s foo $DIR/$tfile
1360 replay_barrier $SINGLEMDS
1361 #drop_reply "cat $DIR/$tfile"
1365 run_test 56 "don't replay a symlink open request (3440)"
1367 #recovery one mds-ost setattr from llog
1369 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1370 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1372 replay_barrier $SINGLEMDS
1375 $CHECKSTAT -t file $DIR/$tfile || return 1
1376 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1379 run_test 57 "test recovery from llog for setattr op"
1381 #recovery many mds-ost setattr from llog
1384 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1385 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1386 createmany -o $DIR/$tdir/$tfile-%d 2500
1387 replay_barrier $SINGLEMDS
1390 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1392 unlinkmany $DIR/$tdir/$tfile-%d 2500
1395 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1398 mount_client $MOUNT2
1400 touch $DIR/$tdir/$tfile
1401 replay_barrier $SINGLEMDS
1402 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1404 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1405 [ x$VAL = x"bar" ] || return 1
1406 rm -f $DIR/$tdir/$tfile
1408 zconf_umount `hostname` $MOUNT2
1410 run_test 58b "test replay of setxattr op"
1412 test_58c() { # bug 16570
1413 mount_client $MOUNT2
1415 touch $DIR/$tdir/$tfile
1416 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1418 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1419 [ x$VAL = x"bar" ] || return 2
1420 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1422 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1423 [ x$VAL = x"bar1" ] || return 4
1424 rm -f $DIR/$tdir/$tfile
1426 zconf_umount `hostname` $MOUNT2
1428 run_test 58c "resend/reconstruct setxattr op"
1430 # log_commit_thread vs filter_destroy race used to lead to import use after free
1433 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1436 createmany -o $DIR/$tdir/$tfile-%d 200
1438 unlinkmany $DIR/$tdir/$tfile-%d 200
1439 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1440 do_facet ost1 "lctl set_param fail_loc=0x507"
1443 do_facet ost1 "lctl set_param fail_loc=0x0"
1447 run_test 59 "test log_commit_thread vs filter_destroy race"
1449 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1450 # bug 12086: should no oops and No ctxt error for this test
1453 createmany -o $DIR/$tdir/$tfile-%d 200
1454 replay_barrier $SINGLEMDS
1455 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1457 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1458 local no_ctxt=`dmesg | grep "No ctxt"`
1459 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1461 run_test 60 "test llog post recovery init vs llog unlink"
1463 #test race llog recovery thread vs llog cleanup
1464 test_61a() { # was test_61
1465 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1468 createmany -o $DIR/$tdir/$tfile-%d 800
1470 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1471 unlinkmany $DIR/$tdir/$tfile-%d 800
1472 set_nodes_failloc "$(osts_nodes)" 0x80000221
1477 set_nodes_failloc "$(osts_nodes)" 0x0
1479 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1482 run_test 61a "test race llog recovery vs llog cleanup"
1484 #test race mds llog sync vs llog cleanup
1486 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1488 facet_failover $SINGLEMDS
1491 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1493 run_test 61b "test race mds llog sync vs llog cleanup"
1495 #test race cancel cookie cb vs llog cleanup
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1499 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1501 set_nodes_failloc "$(osts_nodes)" 0x80000222
1505 set_nodes_failloc "$(osts_nodes)" 0x0
1507 run_test 61c "test race mds llog sync vs llog cleanup"
1509 test_61d() { # bug 16002 # bug 17466
1510 shutdown_facet $SINGLEMDS
1511 #define OBD_FAIL_OBD_LLOG_SETUP 0x605
1512 do_facet $SINGLEMDS "lctl set_param fail_loc=0x605"
1513 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS && error "mds start should have failed"
1514 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1515 start $SINGLEMDS `mdsdevname 1` $MDS_MOUNT_OPTS || error "cannot restart mds"
1517 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1519 test_62() { # Bug 15756 - don't mis-drop resent replay
1521 replay_barrier $SINGLEMDS
1522 createmany -o $DIR/$tdir/$tfile- 25
1523 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1524 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1525 facet_failover $SINGLEMDS
1526 df $MOUNT || return 1
1527 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1528 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1531 run_test 62 "don't mis-drop resent replay"
1533 #Adaptive Timeouts (bug 3055)
1541 echo "Cleaning up AT ..."
1542 if [ -n "$ATOLDBASE" ]; then
1543 local at_history=$(do_facet mds "find /sys/ -name at_history")
1544 do_facet mds "echo $ATOLDBASE >> $at_history" || true
1545 do_facet ost1 "echo $ATOLDBASE >> $at_history" || true
1548 if [ $AT_MAX_SET -ne 0 ]; then
1549 for facet in mds client ost; do
1550 var=AT_MAX_SAVE_${facet}
1551 echo restore AT on $facet to saved value ${!var}
1552 at_max_set ${!var} $facet
1553 at_new=$(at_max_get $facet)
1554 echo Restored AT value on $facet $at_new
1555 [ $at_new -eq ${!var} ] || \
1556 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1563 local at_max_new=600
1564 if ! at_is_valid; then
1565 skip "AT env is invalid"
1569 # Save at_max original values
1571 if [ $AT_MAX_SET -eq 0 ]; then
1572 # Suppose that all osts have the same at_max
1573 for facet in mds client ost; do
1574 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1578 for facet in mds client ost; do
1579 at_max=$(at_max_get $facet)
1580 if [ $at_max -ne $at_max_new ]; then
1581 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1582 at_max_set $at_max_new $facet
1587 if [ -z "$ATOLDBASE" ]; then
1588 local at_history=$(do_facet mds "find /sys/ -name at_history")
1589 [ -z "$at_history" ] && skip "missing /sys/.../at_history " && return 1
1590 ATOLDBASE=$(do_facet mds "cat $at_history")
1591 # speed up the timebase so we can check decreasing AT
1592 do_facet mds "echo 8 >> $at_history"
1593 do_facet ost1 "echo 8 >> $at_history"
1595 # sleep for a while to cool down, should be > 8s and also allow
1596 # at least one ping to be sent. simply use TIMEOUT to be safe.
1601 test_65a() #bug 3055
1603 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1605 at_start || return 0
1606 $LCTL dk > /dev/null
1608 sysctl -w lnet.debug="+other"
1609 # Slow down a request to the current service time, this is critical
1610 # because previous tests may have caused this value to increase.
1611 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1612 awk '/portal 12/ {print $5}'`
1613 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1615 do_facet mds lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1616 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1617 do_facet mds sysctl -w lustre.fail_loc=0x8000050a
1618 createmany -o $DIR/$tfile 10 > /dev/null
1619 unlinkmany $DIR/$tfile 10 > /dev/null
1620 # check for log message
1621 $LCTL dk | grep "Early reply #" || error "No early reply"
1623 # client should show REQ_DELAY estimates
1624 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1626 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1628 run_test 65a "AT: verify early replies"
1630 test_65b() #bug 3055
1632 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1634 at_start || return 0
1637 sysctl -w lnet.debug="other trace"
1638 $LCTL dk > /dev/null
1639 # Slow down a request to the current service time, this is critical
1640 # because previous tests may have caused this value to increase.
1641 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1642 awk '/portal 6/ {print $5}'`
1643 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1645 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1646 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1647 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1650 lfs setstripe $DIR/$tfile --index=0 --count=1
1651 # force some real bulk transfer
1652 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1654 do_facet ost1 sysctl -w lustre.fail_loc=0
1655 # check for log message
1656 $LCTL dk | grep "Early reply #" || error "No early reply"
1658 # client should show REQ_DELAY estimates
1659 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1661 run_test 65b "AT: verify early replies on packed reply / bulk"
1663 test_66a() #bug 3055
1665 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1667 at_start || return 0
1668 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1669 # adjust 5s at a time so no early reply is sent (within deadline)
1670 do_facet mds "sysctl -w lustre.fail_val=5000"
1671 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1672 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1673 createmany -o $DIR/$tfile 20 > /dev/null
1674 unlinkmany $DIR/$tfile 20 > /dev/null
1675 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1676 do_facet mds "sysctl -w lustre.fail_val=10000"
1677 do_facet mds "sysctl -w lustre.fail_loc=0x8000050a"
1678 createmany -o $DIR/$tfile 20 > /dev/null
1679 unlinkmany $DIR/$tfile 20 > /dev/null
1680 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1681 do_facet mds "sysctl -w lustre.fail_loc=0"
1683 createmany -o $DIR/$tfile 20 > /dev/null
1684 unlinkmany $DIR/$tfile 20 > /dev/null
1685 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1686 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1687 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1688 echo "Current MDT timeout $CUR, worst $WORST"
1689 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1691 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1693 test_66b() #bug 3055
1695 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1697 at_start || return 0
1698 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1699 sysctl -w lustre.fail_val=$(($ORIG + 5))
1700 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1701 sysctl -w lustre.fail_loc=0x50c
1702 ls $DIR/$tfile > /dev/null 2>&1
1703 sysctl -w lustre.fail_loc=0
1704 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1705 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1706 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1707 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1709 run_test 66b "AT: verify net latency adjusts"
1711 test_67a() #bug 3055
1713 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1715 at_start || return 0
1716 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1717 # sleeping threads may drive values above this
1718 do_facet ost1 "sysctl -w lustre.fail_val=400"
1719 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1720 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1721 createmany -o $DIR/$tfile 20 > /dev/null
1722 unlinkmany $DIR/$tfile 20 > /dev/null
1723 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1724 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1725 ATTEMPTS=$(($CONN2 - $CONN1))
1726 echo "$ATTEMPTS osc reconnect attemps on gradual slow"
1727 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1730 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1732 test_67b() #bug 3055
1734 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1736 at_start || return 0
1737 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1738 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1739 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1740 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1741 cp /etc/profile $DIR/$tfile || error "cp failed"
1743 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1745 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1746 ATTEMPTS=$(($CONN2 - $CONN1))
1747 echo "$ATTEMPTS osc reconnect attemps on instant slow"
1748 # do it again; should not timeout
1749 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1750 cp /etc/profile $DIR/$tfile || error "cp failed"
1751 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1753 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1754 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1755 ATTEMPTS=$(($CONN3 - $CONN2))
1756 echo "$ATTEMPTS osc reconnect attemps on 2nd slow"
1757 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1760 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1762 test_68 () #bug 13813
1764 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1766 at_start || return 0
1767 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1768 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1769 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1770 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1771 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1772 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1773 echo $TIMEOUT >> $ldlm_enqueue_min
1774 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1778 lfs setstripe $DIR/$tdir --index=0 --count=1
1779 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1780 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1781 sysctl -w lustre.fail_loc=0x80000312
1782 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1783 sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1784 sysctl -w lustre.fail_loc=0x80000312
1785 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1786 sysctl -w lustre.fail_loc=0
1788 echo $ENQ_MIN >> $ldlm_enqueue_min
1789 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1793 run_test 68 "AT: verify slowing locks"
1796 # end of AT tests includes above lines
1799 # start multi-client tests
1801 [ -z "$CLIENTS" ] && \
1802 { skip "Need two or more clients." && return; }
1803 [ $CLIENTCOUNT -lt 2 ] && \
1804 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1806 echo "mount clients $CLIENTS ..."
1807 zconf_mount_clients $CLIENTS $DIR
1809 local clients=${CLIENTS//,/ }
1810 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1811 for CLIENT in $clients; do
1812 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1813 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1814 error "dd failed on $CLIENT"
1817 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1818 for C in ${CLIENTS//,/ }; do
1819 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1820 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1826 run_test 70a "check multi client t-f"
1829 local clients=${CLIENTS:-$HOSTNAME}
1831 zconf_mount_clients $clients $DIR
1834 [ "$SLOW" = "no" ] && duration=60
1835 local cmd="rundbench 1 -t $duration"
1837 do_nodes $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1838 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1839 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1842 log "Started rundbench load PID=$PID ..."
1845 START_TS=$(date +%s)
1846 CURRENT_TS=$START_TS
1847 while [ $ELAPSED -lt $duration ]; do
1849 replay_barrier $SINGLEMDS
1850 sleep 1 # give clients a time to do operations
1851 # Increment the number of failovers
1852 NUM_FAILOVERS=$((NUM_FAILOVERS+1))
1853 log "$TESTNAME fail mds1 $NUM_FAILOVERS times"
1854 facet_failover $SINGLEMDS
1855 CURRENT_TS=$(date +%s)
1856 ELAPSED=$((CURRENT_TS - START_TS))
1858 wait $PID || error "rundbench load on $CLIENTS failed!"
1860 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1861 # end multi-client tests
1864 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1868 replay_barrier $SINGLEMDS
1869 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1870 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1873 wait $pid || return 1
1874 [ -e $DIR/$tfile ] && return 2
1877 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1880 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1884 replay_barrier $SINGLEMDS
1885 #define OBD_FAIL_LDLM_REPLY 0x30c
1886 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1889 wait $pid || return 1
1890 [ -e $DIR/$tfile ] && return 2
1893 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1896 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1900 replay_barrier $SINGLEMDS
1901 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1902 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1905 wait $pid || return 1
1906 [ -e $DIR/$tfile ] && return 2
1909 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1914 zconf_umount $(hostname) $MOUNT
1916 zconf_mount $(hostname) $MOUNT
1918 touch $DIR/$tfile || return 1
1919 rm $DIR/$tfile || return 2
1920 df $MOUNT || error "df failed: $?"
1923 run_test 74 "Ensure applications don't fail waiting for OST reocvery"
1926 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1930 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1931 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1933 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1936 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1939 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1943 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1944 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1946 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1949 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1952 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1955 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1957 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1958 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1960 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1962 stat $DIR/$tdir/f1002
1964 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
1967 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1971 mkdir $dir || error "mkdir $dir failed"
1975 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1977 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
1980 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1984 mkdir $dir || error "mkdir $dir failed"
1988 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1990 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
1992 equals_msg `basename $0`: test complete, cleaning up
1993 check_and_cleanup_lustre
1994 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true