7 # This test needs to be run on the client
10 export MULTIOP=${MULTIOP:-multiop}
11 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
14 . $LUSTRE/tests/test-framework.sh
16 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
18 CHECK_GRANT=${CHECK_GRANT:-"yes"}
19 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
21 require_dsh_mds || exit 0
24 # bug number: 17466 18857 LU-1867 LU-1473
25 ALWAYS_EXCEPT="61d 33a 33b 89 62 $REPLAY_SINGLE_EXCEPT"
27 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
28 # bug number for skipped test: LU-951
29 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 73a"
31 # 63 min 7 min AT AT AT AT"
32 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
34 [ $(facet_fstype $SINGLEMDS) = "zfs" ] &&
35 # bug number for skipped test: LU-3127
36 ALWAYS_EXCEPT="$ALWAYS_EXCEPT 73b"
40 check_and_setup_lustre
45 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
47 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
48 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
50 do_facet $SINGLEMDS sync
53 test_0a() { # was test_0
55 replay_barrier $SINGLEMDS
59 run_test 0a "empty replay"
62 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
64 # this test attempts to trigger a race in the precreation code,
65 # and must run before any other objects are created on the filesystem
67 createmany -o $DIR/$tfile 20 || return 1
68 unlinkmany $DIR/$tfile 20 || return 2
70 run_test 0b "ensure object created after recover exists. (3284)"
73 replay_barrier $SINGLEMDS
76 facet_failover $SINGLEMDS
77 zconf_mount `hostname` $MOUNT || error "mount fails"
78 client_up || error "post-failover df failed"
79 # file shouldn't exist if replay-barrier works as expected
80 rm $DIR/$tfile && error "File exists and it shouldn't"
83 run_test 0c "check replay-barrier"
86 replay_barrier $SINGLEMDS
88 facet_failover $SINGLEMDS
89 zconf_mount `hostname` $MOUNT || error "mount fails"
90 client_up || error "post-failover df failed"
92 run_test 0d "expired recovery with no clients"
95 replay_barrier $SINGLEMDS
98 $CHECKSTAT -t file $DIR/$tfile || return 1
101 run_test 1 "simple create"
104 replay_barrier $SINGLEMDS
107 $CHECKSTAT -t file $DIR/$tfile || return 1
114 replay_barrier $SINGLEMDS
117 $CHECKSTAT -t file $DIR/$tfile || return 1
123 local file=$DIR/$tfile
124 replay_barrier $SINGLEMDS
126 openfile -f O_DIRECTORY $file
128 $CHECKSTAT -t file $file || return 2
131 run_test 3a "replay failed open(O_DIRECTORY)"
134 replay_barrier $SINGLEMDS
135 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
136 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
138 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
140 $CHECKSTAT -t file $DIR/$tfile && return 2
143 run_test 3b "replay failed open -ENOMEM"
146 replay_barrier $SINGLEMDS
147 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
148 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
150 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
153 $CHECKSTAT -t file $DIR/$tfile && return 2
156 run_test 3c "replay failed open -ENOMEM"
158 test_4a() { # was test_4
159 replay_barrier $SINGLEMDS
160 for i in `seq 10`; do
161 echo "tag-$i" > $DIR/$tfile-$i
164 for i in `seq 10`; do
165 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
168 run_test 4a "|x| 10 open(O_CREAT)s"
171 replay_barrier $SINGLEMDS
174 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
176 run_test 4b "|x| rm 10 files"
178 # The idea is to get past the first block of precreated files on both
179 # osts, and then replay.
181 replay_barrier $SINGLEMDS
182 for i in `seq 220`; do
183 echo "tag-$i" > $DIR/$tfile-$i
186 for i in `seq 220`; do
187 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
191 # waiting for commitment of removal
193 run_test 5 "|x| 220 open(O_CREAT)"
196 test_6a() { # was test_6
198 replay_barrier $SINGLEMDS
199 mcreate $DIR/$tdir/$tfile
201 $CHECKSTAT -t dir $DIR/$tdir || return 1
202 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
204 # waiting for log process thread
206 run_test 6a "mkdir + contained create"
210 replay_barrier $SINGLEMDS
213 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
215 run_test 6b "|X| rmdir"
219 replay_barrier $SINGLEMDS
220 mcreate $DIR/$tdir/$tfile
222 $CHECKSTAT -t dir $DIR/$tdir || return 1
223 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
226 run_test 7 "mkdir |X| contained create"
229 # make sure no side-effect from previous test.
231 replay_barrier $SINGLEMDS
232 multiop_bg_pause $DIR/$tfile mo_c || return 4
236 $CHECKSTAT -t file $DIR/$tfile || return 1
237 kill -USR1 $MULTIPID || return 2
238 wait $MULTIPID || return 3
241 run_test 8 "creat open |X| close"
244 replay_barrier $SINGLEMDS
246 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
248 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
250 echo " old_inum == $old_inum, new_inum == $new_inum"
251 if [ $old_inum -eq $new_inum ] ;
253 echo " old_inum and new_inum match"
255 echo "!!!! old_inum and new_inum NOT match"
260 run_test 9 "|X| create (same inum/gen)"
264 replay_barrier $SINGLEMDS
265 mv $DIR/$tfile $DIR/$tfile-2
268 $CHECKSTAT $DIR/$tfile && return 1
269 $CHECKSTAT $DIR/$tfile-2 ||return 2
273 run_test 10 "create |X| rename unlink"
277 echo "old" > $DIR/$tfile
278 mv $DIR/$tfile $DIR/$tfile-2
279 replay_barrier $SINGLEMDS
280 echo "new" > $DIR/$tfile
282 grep old $DIR/$tfile-2
284 grep new $DIR/$tfile || return 1
285 grep old $DIR/$tfile-2 || return 2
287 run_test 11 "create open write rename |X| create-old-name read"
291 multiop_bg_pause $DIR/$tfile o_tSc || return 3
294 replay_barrier $SINGLEMDS
296 wait $pid || return 1
299 [ -e $DIR/$tfile ] && return 2
302 run_test 12 "open, unlink |X| close"
305 # 1777 - replay open after committed chmod that would make
306 # a regular open a failure
309 multiop_bg_pause $DIR/$tfile O_wc || return 3
312 $CHECKSTAT -p 0 $DIR/$tfile
313 replay_barrier $SINGLEMDS
316 wait $pid || return 1
318 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
319 rm $DIR/$tfile || return 4
322 run_test 13 "open chmod 0 |x| write close"
325 multiop_bg_pause $DIR/$tfile O_tSc || return 4
328 replay_barrier $SINGLEMDS
329 kill -USR1 $pid || return 1
330 wait $pid || return 2
333 [ -e $DIR/$tfile ] && return 3
336 run_test 14 "open(O_CREAT), unlink |X| close"
339 multiop_bg_pause $DIR/$tfile O_tSc || return 5
342 replay_barrier $SINGLEMDS
343 touch $DIR/g11 || return 1
345 wait $pid || return 2
348 [ -e $DIR/$tfile ] && return 3
349 touch $DIR/h11 || return 4
352 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
356 replay_barrier $SINGLEMDS
359 mcreate $DIR/$tfile-2
361 [ -e $DIR/$tfile ] && return 1
362 [ -e $DIR/$tfile-2 ] || return 2
363 munlink $DIR/$tfile-2 || return 3
365 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
368 replay_barrier $SINGLEMDS
369 multiop_bg_pause $DIR/$tfile O_c || return 4
372 kill -USR1 $pid || return 1
373 wait $pid || return 2
374 $CHECKSTAT -t file $DIR/$tfile || return 3
377 run_test 17 "|X| open(O_CREAT), |replay| close"
380 replay_barrier $SINGLEMDS
381 multiop_bg_pause $DIR/$tfile O_tSc || return 8
384 touch $DIR/$tfile-2 || return 1
385 echo "pid: $pid will close"
387 wait $pid || return 2
390 [ -e $DIR/$tfile ] && return 3
391 [ -e $DIR/$tfile-2 ] || return 4
392 # this touch frequently fails
393 touch $DIR/$tfile-3 || return 5
394 munlink $DIR/$tfile-2 || return 6
395 munlink $DIR/$tfile-3 || return 7
398 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
400 # bug 1855 (a simpler form of test_11 above)
402 replay_barrier $SINGLEMDS
404 echo "old" > $DIR/$tfile
405 mv $DIR/$tfile $DIR/$tfile-2
406 grep old $DIR/$tfile-2
408 grep old $DIR/$tfile-2 || return 2
410 run_test 19 "|X| mcreate, open, write, rename "
412 test_20a() { # was test_20
413 replay_barrier $SINGLEMDS
414 multiop_bg_pause $DIR/$tfile O_tSc || return 3
420 wait $pid || return 1
421 [ -e $DIR/$tfile ] && return 2
424 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
426 test_20b() { # bug 10480
427 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
429 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
431 while [ ! -e $DIR/$tfile ] ; do
432 usleep 60 # give dd a chance to start
435 $GETSTRIPE $DIR/$tfile || return 1
436 rm -f $DIR/$tfile || return 2 # make it an orphan
438 client_up || client_up || true # reconnect
440 fail $SINGLEMDS # start orphan recovery
441 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
442 wait_mds_ost_sync || return 3
443 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
444 log "before $BEFOREUSED, after $AFTERUSED"
445 (( $AFTERUSED > $BEFOREUSED + $(fs_log_size) )) &&
446 error "after $AFTERUSED > before $BEFOREUSED"
449 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
451 test_20c() { # bug 10480
452 multiop_bg_pause $DIR/$tfile Ow_c || return 1
458 client_up || client_up || true # reconnect
461 wait $pid || return 1
462 [ -s $DIR/$tfile ] || error "File was truncated"
466 run_test 20c "check that client eviction does not affect file content"
469 replay_barrier $SINGLEMDS
470 multiop_bg_pause $DIR/$tfile O_tSc || return 5
473 touch $DIR/g11 || return 1
477 wait $pid || return 2
478 [ -e $DIR/$tfile ] && return 3
479 touch $DIR/h11 || return 4
482 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
485 multiop_bg_pause $DIR/$tfile O_tSc || return 3
488 replay_barrier $SINGLEMDS
493 wait $pid || return 1
494 [ -e $DIR/$tfile ] && return 2
497 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
500 multiop_bg_pause $DIR/$tfile O_tSc || return 5
503 replay_barrier $SINGLEMDS
505 touch $DIR/g11 || return 1
509 wait $pid || return 2
510 [ -e $DIR/$tfile ] && return 3
511 touch $DIR/h11 || return 4
514 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
517 multiop_bg_pause $DIR/$tfile O_tSc || return 3
520 replay_barrier $SINGLEMDS
524 wait $pid || return 1
525 [ -e $DIR/$tfile ] && return 2
528 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
531 multiop_bg_pause $DIR/$tfile O_tSc || return 3
535 replay_barrier $SINGLEMDS
538 wait $pid || return 1
539 [ -e $DIR/$tfile ] && return 2
542 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
545 replay_barrier $SINGLEMDS
546 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
548 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
553 wait $pid2 || return 1
557 wait $pid1 || return 2
558 [ -e $DIR/$tfile-1 ] && return 3
559 [ -e $DIR/$tfile-2 ] && return 4
562 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
565 replay_barrier $SINGLEMDS
566 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
568 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
575 wait $pid1 || return 1
577 wait $pid2 || return 2
578 [ -e $DIR/$tfile-1 ] && return 3
579 [ -e $DIR/$tfile-2 ] && return 4
582 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
585 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
587 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
589 replay_barrier $SINGLEMDS
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 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
605 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
607 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
609 replay_barrier $SINGLEMDS
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 29 "open(O_CREAT), |X| 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
632 replay_barrier $SINGLEMDS
635 wait $pid1 || return 1
637 wait $pid2 || return 2
638 [ -e $DIR/$tfile-1 ] && return 3
639 [ -e $DIR/$tfile-2 ] && return 4
642 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (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
651 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 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
664 # tests for bug 2104; completion without crashing is success. The close is
665 # stale, but we always return 0 for close, so the app never sees it.
667 multiop_bg_pause $DIR/$tfile O_c || return 2
669 multiop_bg_pause $DIR/$tfile O_c || return 3
672 client_up || client_up || return 1
675 wait $pid1 || return 4
676 wait $pid2 || return 5
679 run_test 32 "close() notices client eviction; close() after client eviction"
682 createmany -o $DIR/$tfile-%d 10
683 replay_barrier_nosync $SINGLEMDS
684 fail_abort $SINGLEMDS
685 # recreate shouldn't fail
686 createmany -o $DIR/$tfile--%d 10 || return 1
690 run_test 33a "fid seq shouldn't be reused after abort recovery"
693 #define OBD_FAIL_SEQ_ALLOC 0x1311
694 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
696 createmany -o $DIR/$tfile-%d 10
697 replay_barrier_nosync $SINGLEMDS
698 fail_abort $SINGLEMDS
699 # recreate shouldn't fail
700 createmany -o $DIR/$tfile--%d 10 || return 1
704 run_test 33b "test fid seq allocation"
707 multiop_bg_pause $DIR/$tfile O_c || return 2
711 replay_barrier $SINGLEMDS
712 fail_abort $SINGLEMDS
714 wait $pid || return 3
715 [ -e $DIR/$tfile ] && return 1
719 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
721 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
725 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
726 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
731 # give a chance to remove from MDS
732 fail_abort $SINGLEMDS
733 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
735 run_test 35 "test recovery from llog for unlink op"
737 # b=2432 resent cancel after replay uses wrong cookie,
738 # so don't resend cancels
740 replay_barrier $SINGLEMDS
742 checkstat $DIR/$tfile
743 facet_failover $SINGLEMDS
745 if dmesg | grep "unknown lock cookie"; then
746 echo "cancel after replay failed"
750 run_test 36 "don't resend cancel"
753 # directory orphans can't be unlinked from PENDING directory
755 rmdir $DIR/$tfile 2>/dev/null
756 multiop_bg_pause $DIR/$tfile dD_c || return 2
760 replay_barrier $SINGLEMDS
761 # clear the dmesg buffer so we only see errors from this recovery
762 do_facet $SINGLEMDS dmesg -c >/dev/null
763 fail_abort $SINGLEMDS
765 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
767 wait $pid || return 3
771 start_full_debug_logging
772 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
773 stop_full_debug_logging
776 createmany -o $DIR/$tfile-%d 800
777 unlinkmany $DIR/$tfile-%d 0 400
778 replay_barrier $SINGLEMDS
780 unlinkmany $DIR/$tfile-%d 400 400
782 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
784 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
786 test_39() { # bug 4176
787 createmany -o $DIR/$tfile-%d 800
788 replay_barrier $SINGLEMDS
789 unlinkmany $DIR/$tfile-%d 0 400
791 unlinkmany $DIR/$tfile-%d 400 400
793 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
795 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
798 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
803 # always need connection to MDS to verify layout during IO. LU-2628.
804 lctl get_param mdc.*.connect_flags | grep -q layout_lock &&
805 skip "layout_lock needs MDS connection for IO" && return 0
807 $LCTL mark multiop $MOUNT/$tfile OS_c
808 multiop $MOUNT/$tfile OS_c &
810 writeme -s $MOUNT/${tfile}-2 &
813 facet_failover $SINGLEMDS
814 #define OBD_FAIL_MDS_CONNECT_NET 0x117
815 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
817 stat1=`count_ost_writes`
819 stat2=`count_ost_writes`
820 echo "$stat1, $stat2"
821 if [ $stat1 -lt $stat2 ]; then
822 echo "writes continuing during recovery"
825 echo "writes not continuing during recovery, bug 2477"
828 echo "waiting for writeme $WRITE_PID"
832 echo "waiting for multiop $PID"
833 wait $PID || return 2
834 do_facet client munlink $MOUNT/$tfile || return 3
835 do_facet client munlink $MOUNT/${tfile}-2 || return 3
838 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
842 # make sure that a read to one osc doesn't try to double-unlock its page just
843 # because another osc is invalid. trigger_group_io used to mistakenly return
844 # an error if any oscs were invalid even after having successfully put rpcs
845 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
846 # the page, guarnateeing that the unlock from the RPC completion would
847 # assert on trying to unlock the unlocked page.
849 [ $OSTCOUNT -lt 2 ] &&
850 skip_env "skipping test 41: we don't have a second OST to test with" &&
853 local f=$MOUNT/$tfile
854 # make sure the start of the file is ost1
855 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
856 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
858 # fail ost2 and read from ost1
859 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
860 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
861 grep $mdtosc | awk '{print $1}')
862 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices &&
864 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
865 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
866 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
869 run_test 41 "read from a valid osc while other oscs are invalid"
871 # test MDS recovery after ost failure
873 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
874 createmany -o $DIR/$tfile-%d 800
876 unlinkmany $DIR/$tfile-%d 0 400
878 lctl set_param debug=-1
881 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
882 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
883 #[ $blocks_after -lt $blocks ] || return 1
884 echo wait for MDS to timeout and recover
885 sleep $((TIMEOUT * 2))
887 unlinkmany $DIR/$tfile-%d 400 400
888 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
890 run_test 42 "recovery after ost failure"
892 # timeout in MDS/OST recovery RPC will LBUG MDS
893 test_43() { # bug 2530
894 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
896 replay_barrier $SINGLEMDS
898 # OBD_FAIL_OST_CREATE_NET 0x204
899 do_facet ost1 "lctl set_param fail_loc=0x80000204"
902 do_facet ost1 "lctl set_param fail_loc=0"
906 run_test 43 "mds osc import failure during recovery; don't LBUG"
908 test_44a() { # was test_44
911 local mdcdev=$($LCTL dl |
912 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
913 [ "$mdcdev" ] || return 2
914 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
915 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
917 # adaptive timeouts slow this way down
918 if at_is_enabled; then
919 at_max_saved=$(at_max_get mds)
923 for i in `seq 1 10`; do
924 echo "$i of 10 ($(date +%s))"
925 do_facet $SINGLEMDS \
926 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
927 #define OBD_FAIL_TGT_CONN_RACE 0x701
928 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
929 # lctl below may fail, it is valid case
930 $LCTL --device $mdcdev recover
933 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
934 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
937 run_test 44a "race in target handle connect"
940 local mdcdev=$($LCTL dl |
941 awk "/${FSNAME}-MDT0000-mdc-/ {if (\$2 == \"UP\") {print \$1}}")
942 [ "$mdcdev" ] || return 2
943 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
944 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
946 for i in `seq 1 10`; do
947 echo "$i of 10 ($(date +%s))"
948 do_facet $SINGLEMDS \
949 "lctl get_param -n md[ts].*.mdt.timeouts | grep service"
950 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
952 # lctl below may fail, it is valid case
953 $LCTL --device $mdcdev recover
956 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
959 run_test 44b "race in target handle connect"
962 replay_barrier $SINGLEMDS
963 createmany -m $DIR/$tfile-%d 100 || error "failed to create directories"
964 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
965 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
966 fail_abort $SINGLEMDS
967 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail abort"
969 unlinkmany $DIR/$tfile-%d 100 && error "unliked after fail"
972 run_test 44c "race in target handle connect"
974 # Handle failed close
976 local mdcdev=$($LCTL get_param -n devices |
977 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
978 [ "$mdcdev" ] || return 2
979 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
980 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
982 $LCTL --device $mdcdev recover || return 6
984 multiop_bg_pause $DIR/$tfile O_c || return 1
987 # This will cause the CLOSE to fail before even
988 # allocating a reply buffer
989 $LCTL --device $mdcdev deactivate || return 4
993 wait $pid || return 1
995 $LCTL --device $mdcdev activate || return 5
998 $CHECKSTAT -t file $DIR/$tfile || return 2
1001 run_test 45 "Handle failed close"
1005 drop_reply "touch $DIR/$tfile"
1007 # ironically, the previous test, 45, will cause a real forced close,
1008 # so just look for one for this test
1009 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1012 run_test 46 "Don't leak file handle after open resend (3325)"
1014 test_47() { # bug 2824
1015 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1017 # create some files to make sure precreate has been done on all
1018 # OSTs. (just in case this test is run independently)
1019 createmany -o $DIR/$tfile 20 || return 1
1021 # OBD_FAIL_OST_CREATE_NET 0x204
1023 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1024 client_up || return 2
1026 # let the MDS discover the OST failure, attempt to recover, fail
1027 # and recover again.
1028 sleep $((3 * TIMEOUT))
1030 # Without 2824, this createmany would hang
1031 createmany -o $DIR/$tfile 20 || return 3
1032 unlinkmany $DIR/$tfile 20 || return 4
1034 do_facet ost1 "lctl set_param fail_loc=0"
1037 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1040 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1041 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1043 replay_barrier $SINGLEMDS
1044 createmany -o $DIR/$tfile 20 || return 1
1045 # OBD_FAIL_OST_EROFS 0x216
1046 facet_failover $SINGLEMDS
1047 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1048 client_up || return 2
1050 createmany -o $DIR/$tfile 20 20 || return 2
1051 unlinkmany $DIR/$tfile 40 || return 3
1054 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1057 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1058 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1059 grep $mdtosc | awk '{print $1}')
1060 [ "$oscdev" ] || return 1
1061 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1062 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1063 # give the mds_lov_sync threads a chance to run
1066 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1068 # b3764 timed out lock replay
1071 cancel_lru_locks mdc
1073 multiop $DIR/$tfile s || return 1
1074 replay_barrier $SINGLEMDS
1075 #define OBD_FAIL_LDLM_REPLY 0x30c
1076 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1077 fail $SINGLEMDS || return 2
1078 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1080 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1082 run_test 52 "time out lock replay (3764)"
1084 # bug 3462 - simultaneous MDC requests
1086 cancel_lru_locks mdc # cleanup locks from former test cases
1087 mkdir -p $DIR/${tdir}-1
1088 mkdir -p $DIR/${tdir}-2
1089 multiop $DIR/${tdir}-1/f O_c &
1091 # give multiop a change to open
1094 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1095 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1096 kill -USR1 $close_pid
1097 cancel_lru_locks mdc # force the close
1098 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1100 mcreate $DIR/${tdir}-2/f || return 1
1102 # close should still be here
1103 [ -d /proc/$close_pid ] || return 2
1105 replay_barrier_nodf $SINGLEMDS
1107 wait $close_pid || return 3
1109 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1110 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1111 rm -rf $DIR/${tdir}-*
1113 run_test 53a "|X| close request while two MDC requests in flight"
1116 cancel_lru_locks mdc # cleanup locks from former test cases
1117 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1119 mkdir -p $DIR/${tdir}-1
1120 mkdir -p $DIR/${tdir}-2
1121 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1124 #define OBD_FAIL_MDS_REINT_NET 0x107
1125 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1126 mcreate $DIR/${tdir}-2/f &
1130 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1131 kill -USR1 $close_pid
1132 cancel_lru_locks mdc # force the close
1133 wait $close_pid || return 1
1134 # open should still be here
1135 [ -d /proc/$open_pid ] || return 2
1137 replay_barrier_nodf $SINGLEMDS
1139 wait $open_pid || return 3
1141 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1142 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1143 rm -rf $DIR/${tdir}-*
1145 run_test 53b "|X| open request while two MDC requests in flight"
1148 cancel_lru_locks mdc # cleanup locks from former test cases
1149 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1151 mkdir -p $DIR/${tdir}-1
1152 mkdir -p $DIR/${tdir}-2
1153 multiop $DIR/${tdir}-1/f O_c &
1156 #define OBD_FAIL_MDS_REINT_NET 0x107
1157 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1158 mcreate $DIR/${tdir}-2/f &
1162 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1163 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1164 kill -USR1 $close_pid
1165 cancel_lru_locks mdc # force the close
1167 #bz20647: make sure all pids are exists before failover
1168 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1169 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1170 replay_barrier_nodf $SINGLEMDS
1171 fail_nodf $SINGLEMDS
1172 wait $open_pid || return 1
1174 # close should be gone
1175 [ -d /proc/$close_pid ] && return 2
1176 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1178 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1179 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1180 rm -rf $DIR/${tdir}-*
1182 run_test 53c "|X| open request and close request while two MDC requests in flight"
1185 cancel_lru_locks mdc # cleanup locks from former test cases
1186 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1188 mkdir -p $DIR/${tdir}-1
1189 mkdir -p $DIR/${tdir}-2
1190 multiop $DIR/${tdir}-1/f O_c &
1192 # give multiop a chance to open
1195 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1196 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1197 kill -USR1 $close_pid
1198 cancel_lru_locks mdc # force the close
1199 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1200 mcreate $DIR/${tdir}-2/f || return 1
1202 # close should still be here
1203 [ -d /proc/$close_pid ] || return 2
1205 wait $close_pid || return 3
1207 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1208 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1209 rm -rf $DIR/${tdir}-*
1211 run_test 53d "|X| close reply while two MDC requests in flight"
1214 cancel_lru_locks mdc # cleanup locks from former test cases
1215 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1217 mkdir -p $DIR/${tdir}-1
1218 mkdir -p $DIR/${tdir}-2
1219 multiop $DIR/${tdir}-1/f O_c &
1222 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1223 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1224 mcreate $DIR/${tdir}-2/f &
1228 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1229 kill -USR1 $close_pid
1230 cancel_lru_locks mdc # force the close
1231 wait $close_pid || return 1
1232 # open should still be here
1233 [ -d /proc/$open_pid ] || return 2
1235 replay_barrier_nodf $SINGLEMDS
1237 wait $open_pid || return 3
1239 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1240 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1241 rm -rf $DIR/${tdir}-*
1243 run_test 53e "|X| open reply while two MDC requests in flight"
1246 cancel_lru_locks mdc # cleanup locks from former test cases
1247 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1249 mkdir -p $DIR/${tdir}-1
1250 mkdir -p $DIR/${tdir}-2
1251 multiop $DIR/${tdir}-1/f O_c &
1254 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1255 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1256 mcreate $DIR/${tdir}-2/f &
1260 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1261 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1262 kill -USR1 $close_pid
1263 cancel_lru_locks mdc # force the close
1265 #bz20647: make sure all pids are exists before failover
1266 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1267 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1268 replay_barrier_nodf $SINGLEMDS
1269 fail_nodf $SINGLEMDS
1270 wait $open_pid || return 1
1272 # close should be gone
1273 [ -d /proc/$close_pid ] && return 2
1274 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1276 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1277 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1278 rm -rf $DIR/${tdir}-*
1280 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1283 cancel_lru_locks mdc # cleanup locks from former test cases
1284 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1286 mkdir -p $DIR/${tdir}-1
1287 mkdir -p $DIR/${tdir}-2
1288 multiop $DIR/${tdir}-1/f O_c &
1291 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1292 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1293 mcreate $DIR/${tdir}-2/f &
1297 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1298 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1299 kill -USR1 $close_pid
1300 cancel_lru_locks mdc # force the close
1301 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1303 #bz20647: make sure all pids are exists before failover
1304 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1305 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1306 replay_barrier_nodf $SINGLEMDS
1307 fail_nodf $SINGLEMDS
1308 wait $open_pid || return 1
1310 # close should be gone
1311 [ -d /proc/$close_pid ] && return 2
1313 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1314 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1315 rm -rf $DIR/${tdir}-*
1317 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1320 cancel_lru_locks mdc # cleanup locks from former test cases
1321 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1323 mkdir -p $DIR/${tdir}-1
1324 mkdir -p $DIR/${tdir}-2
1325 multiop $DIR/${tdir}-1/f O_c &
1328 #define OBD_FAIL_MDS_REINT_NET 0x107
1329 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1330 mcreate $DIR/${tdir}-2/f &
1334 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1335 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1336 kill -USR1 $close_pid
1337 cancel_lru_locks mdc # force the close
1340 #bz20647: make sure all pids are exists before failover
1341 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1342 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1343 replay_barrier_nodf $SINGLEMDS
1344 fail_nodf $SINGLEMDS
1345 wait $open_pid || return 1
1347 # close should be gone
1348 [ -d /proc/$close_pid ] && return 2
1349 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1351 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1352 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1353 rm -rf $DIR/${tdir}-*
1355 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1357 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1359 #b3761 ASSERTION(hash != 0) failed
1361 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1362 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1364 # give touch a chance to run
1366 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1370 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1372 #b3440 ASSERTION(rec->ur_fid2->id) failed
1374 ln -s foo $DIR/$tfile
1375 replay_barrier $SINGLEMDS
1376 #drop_reply "cat $DIR/$tfile"
1380 run_test 56 "don't replay a symlink open request (3440)"
1382 #recovery one mds-ost setattr from llog
1384 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1385 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1387 replay_barrier $SINGLEMDS
1390 $CHECKSTAT -t file $DIR/$tfile || return 1
1391 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1394 run_test 57 "test recovery from llog for setattr op"
1396 #recovery many mds-ost setattr from llog
1399 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1400 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1401 createmany -o $DIR/$tdir/$tfile-%d 2500
1402 replay_barrier $SINGLEMDS
1405 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1406 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1407 unlinkmany $DIR/$tdir/$tfile-%d 2500
1410 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1416 large_xattr_enabled &&
1417 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1419 mount_client $MOUNT2
1421 touch $DIR/$tdir/$tfile
1422 replay_barrier $SINGLEMDS
1423 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1425 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1426 [[ "$new" = "$orig" ]] || return 1
1427 rm -f $DIR/$tdir/$tfile
1429 zconf_umount `hostname` $MOUNT2
1431 run_test 58b "test replay of setxattr op"
1433 test_58c() { # bug 16570
1438 if large_xattr_enabled; then
1439 local xattr_size=$(max_xattr_size)
1440 orig="$(generate_string $((xattr_size / 2)))"
1441 orig1="$(generate_string $xattr_size)"
1447 mount_client $MOUNT2
1449 touch $DIR/$tdir/$tfile
1450 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1452 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1453 [[ "$new" = "$orig" ]] || return 2
1454 drop_reint_reply "setfattr -n trusted.foo1 -v $orig1 $DIR/$tdir/$tfile" ||
1456 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1457 [[ "$new" = "$orig1" ]] || return 4
1458 rm -f $DIR/$tdir/$tfile
1460 zconf_umount $HOSTNAME $MOUNT2
1462 run_test 58c "resend/reconstruct setxattr op"
1464 # log_commit_thread vs filter_destroy race used to lead to import use after free
1467 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1470 createmany -o $DIR/$tdir/$tfile-%d 200
1472 unlinkmany $DIR/$tdir/$tfile-%d 200
1473 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1474 do_facet ost1 "lctl set_param fail_loc=0x507"
1477 do_facet ost1 "lctl set_param fail_loc=0x0"
1481 run_test 59 "test log_commit_thread vs filter_destroy race"
1483 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1484 # bug 12086: should no oops and No ctxt error for this test
1487 createmany -o $DIR/$tdir/$tfile-%d 200
1488 replay_barrier $SINGLEMDS
1489 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1491 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1492 local no_ctxt=`dmesg | grep "No ctxt"`
1493 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1495 run_test 60 "test llog post recovery init vs llog unlink"
1497 #test race llog recovery thread vs llog cleanup
1498 test_61a() { # was test_61
1499 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1502 createmany -o $DIR/$tdir/$tfile-%d 800
1504 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1505 unlinkmany $DIR/$tdir/$tfile-%d 800
1506 set_nodes_failloc "$(osts_nodes)" 0x80000221
1511 set_nodes_failloc "$(osts_nodes)" 0x0
1513 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1516 run_test 61a "test race llog recovery vs llog cleanup"
1518 #test race mds llog sync vs llog cleanup
1520 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1521 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1522 facet_failover $SINGLEMDS
1525 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1527 run_test 61b "test race mds llog sync vs llog cleanup"
1529 #test race cancel cookie cb vs llog cleanup
1531 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1533 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1535 set_nodes_failloc "$(osts_nodes)" 0x80000222
1539 set_nodes_failloc "$(osts_nodes)" 0x0
1541 run_test 61c "test race mds llog sync vs llog cleanup"
1543 test_61d() { # bug 16002 # bug 17466 # bug 22137
1544 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1546 do_facet mgs "lctl set_param fail_loc=0x80000605"
1547 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1548 do_facet mgs "lctl set_param fail_loc=0"
1549 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1551 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1553 test_62() { # Bug 15756 - don't mis-drop resent replay
1555 replay_barrier $SINGLEMDS
1556 createmany -o $DIR/$tdir/$tfile- 25
1557 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1558 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1560 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1561 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1564 run_test 62 "don't mis-drop resent replay"
1566 #Adaptive Timeouts (bug 3055)
1574 echo "Cleaning up AT ..."
1575 if [ -n "$ATOLDBASE" ]; then
1576 local at_history=$($LCTL get_param -n at_history)
1577 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1578 do_facet ost1 "lctl set_param at_history=$at_history" || true
1581 if [ $AT_MAX_SET -ne 0 ]; then
1582 for facet in mds client ost; do
1583 var=AT_MAX_SAVE_${facet}
1584 echo restore AT on $facet to saved value ${!var}
1585 at_max_set ${!var} $facet
1586 at_new=$(at_max_get $facet)
1587 echo Restored AT value on $facet $at_new
1588 [ $at_new -eq ${!var} ] || \
1589 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1596 local at_max_new=600
1598 # Save at_max original values
1600 if [ $AT_MAX_SET -eq 0 ]; then
1601 # Suppose that all osts have the same at_max
1602 for facet in mds client ost; do
1603 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1607 for facet in mds client ost; do
1608 at_max=$(at_max_get $facet)
1609 if [ $at_max -ne $at_max_new ]; then
1610 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1611 at_max_set $at_max_new $facet
1616 if [ -z "$ATOLDBASE" ]; then
1617 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1618 # speed up the timebase so we can check decreasing AT
1619 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1620 do_facet ost1 "lctl set_param at_history=8" || true
1622 # sleep for a while to cool down, should be > 8s and also allow
1623 # at least one ping to be sent. simply use TIMEOUT to be safe.
1628 test_65a() #bug 3055
1630 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1632 at_start || return 0
1633 $LCTL dk > /dev/null
1635 $LCTL set_param debug="other"
1636 # Slow down a request to the current service time, this is critical
1637 # because previous tests may have caused this value to increase.
1638 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1639 awk '/portal 12/ {print $5}'`
1640 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1642 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1643 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1644 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1645 createmany -o $DIR/$tfile 10 > /dev/null
1646 unlinkmany $DIR/$tfile 10 > /dev/null
1647 # check for log message
1648 $LCTL dk | grep "Early reply #" || error "No early reply"
1650 # client should show REQ_DELAY estimates
1651 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1653 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1655 run_test 65a "AT: verify early replies"
1657 test_65b() #bug 3055
1659 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1661 at_start || return 0
1664 $LCTL set_param debug="other trace"
1665 $LCTL dk > /dev/null
1666 # Slow down a request to the current service time, this is critical
1667 # because previous tests may have caused this value to increase.
1668 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1669 multiop $DIR/$tfile Ow1yc
1670 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1671 awk '/portal 6/ {print $5}'`
1672 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1674 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1675 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1676 do_facet ost1 $LCTL set_param fail_loc=0x224
1679 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1680 # force some real bulk transfer
1681 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1683 do_facet ost1 $LCTL set_param fail_loc=0
1684 # check for log message
1685 $LCTL dk | grep "Early reply #" || error "No early reply"
1687 # client should show REQ_DELAY estimates
1688 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1690 run_test 65b "AT: verify early replies on packed reply / bulk"
1692 test_66a() #bug 3055
1694 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1696 at_start || return 0
1697 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1698 # adjust 5s at a time so no early reply is sent (within deadline)
1699 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1700 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1701 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1702 createmany -o $DIR/$tfile 20 > /dev/null
1703 unlinkmany $DIR/$tfile 20 > /dev/null
1704 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1705 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1706 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1707 createmany -o $DIR/$tfile 20 > /dev/null
1708 unlinkmany $DIR/$tfile 20 > /dev/null
1709 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1710 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1712 createmany -o $DIR/$tfile 20 > /dev/null
1713 unlinkmany $DIR/$tfile 20 > /dev/null
1714 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1715 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1716 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1717 echo "Current MDT timeout $CUR, worst $WORST"
1718 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1720 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1722 test_66b() #bug 3055
1724 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1726 at_start || return 0
1727 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1728 awk '/network/ {print $4}')
1729 $LCTL set_param fail_val=$(($ORIG + 5))
1730 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1731 $LCTL set_param fail_loc=0x50c
1732 ls $DIR/$tfile > /dev/null 2>&1
1733 $LCTL set_param fail_loc=0
1734 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1735 awk '/network/ {print $4}')
1736 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1737 awk '/network/ {print $6}')
1738 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1739 [ $WORST -gt $ORIG ] ||
1740 error "Worst $WORST should be worse than orig $ORIG"
1742 run_test 66b "AT: verify net latency adjusts"
1744 test_67a() #bug 3055
1746 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1748 at_start || return 0
1749 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1750 # sleeping threads may drive values above this
1751 do_facet ost1 "$LCTL set_param fail_val=400"
1752 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1753 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1754 createmany -o $DIR/$tfile 20 > /dev/null
1755 unlinkmany $DIR/$tfile 20 > /dev/null
1756 do_facet ost1 "$LCTL set_param fail_loc=0"
1757 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1758 ATTEMPTS=$(($CONN2 - $CONN1))
1759 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1760 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1763 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1765 test_67b() #bug 3055
1767 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1769 at_start || return 0
1770 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1772 # exhaust precreations on ost1
1773 local OST=$(ostname_from_index 0)
1774 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1775 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1776 osc.$mdtosc.prealloc_last_id)
1777 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1778 osc.$mdtosc.prealloc_next_id)
1780 mkdir -p $DIR/$tdir/${OST}
1781 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE"
1782 echo "Creating to objid $last_id on ost $OST..."
1783 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1784 do_facet ost1 "$LCTL set_param fail_val=20000"
1785 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1786 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1789 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1791 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1792 ATTEMPTS=$(($CONN2 - $CONN1))
1793 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1794 # do it again; should not timeout
1795 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1796 cp /etc/profile $DIR/$tfile || error "cp failed"
1797 do_facet ost1 "$LCTL set_param fail_loc=0"
1799 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1800 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1801 ATTEMPTS=$(($CONN3 - $CONN2))
1802 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1803 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1806 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1808 test_68 () #bug 13813
1810 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1812 at_start || return 0
1813 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1814 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1815 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1816 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1817 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1818 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1819 echo $TIMEOUT >> $ldlm_enqueue_min
1820 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1824 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1825 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1826 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1827 $LCTL set_param fail_loc=0x80000312
1828 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1829 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1830 $LCTL set_param fail_loc=0x80000312
1831 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1832 $LCTL set_param fail_loc=0
1834 echo $ENQ_MIN >> $ldlm_enqueue_min
1835 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1839 run_test 68 "AT: verify slowing locks"
1842 # end of AT tests includes above lines
1845 # start multi-client tests
1847 [ -z "$CLIENTS" ] && \
1848 { skip "Need two or more clients." && return; }
1849 [ $CLIENTCOUNT -lt 2 ] && \
1850 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1852 echo "mount clients $CLIENTS ..."
1853 zconf_mount_clients $CLIENTS $MOUNT
1855 local clients=${CLIENTS//,/ }
1856 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1857 for CLIENT in $clients; do
1858 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1859 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1860 error "dd failed on $CLIENT"
1863 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1864 for C in ${CLIENTS//,/ }; do
1865 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1866 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1872 run_test 70a "check multi client t-f"
1874 check_for_process () {
1879 killall_process $clients "$prog" -0
1882 killall_process () {
1883 local clients=${1:-$(hostname)}
1888 do_nodes $clients "killall $signal $name"
1892 local clients=${CLIENTS:-$HOSTNAME}
1894 zconf_mount_clients $clients $MOUNT
1897 [ "$SLOW" = "no" ] && duration=120
1898 # set duration to 900 because it takes some time to boot node
1899 [ "$FAILURE_MODE" = HARD ] && duration=900
1902 local start_ts=$(date +%s)
1903 local cmd="rundbench 1 -t $duration"
1905 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1906 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1907 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1908 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
1911 #LU-1897 wait for all dbench copies to start
1912 while ! check_for_process $clients dbench; do
1913 elapsed=$(($(date +%s) - start_ts))
1914 if [ $elapsed -gt $duration ]; then
1915 killall_process $clients dbench
1916 error "dbench failed to start on $clients!"
1921 log "Started rundbench load pid=$pid ..."
1923 elapsed=$(($(date +%s) - start_ts))
1924 local num_failovers=0
1925 while [ $elapsed -lt $duration ]; do
1926 if ! check_for_process $clients dbench; then
1927 error_noexit "dbench stopped on some of $clients!"
1928 killall_process $clients dbench
1932 replay_barrier $SINGLEMDS
1933 sleep 1 # give clients a time to do operations
1934 # Increment the number of failovers
1935 num_failovers=$((num_failovers+1))
1936 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1938 elapsed=$(($(date +%s) - start_ts))
1941 wait $pid || error "rundbench load on $clients failed!"
1943 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1944 # end multi-client tests
1947 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1951 replay_barrier $SINGLEMDS
1952 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
1953 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1956 wait $pid || return 1
1957 [ -e $DIR/$tfile ] && return 2
1960 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1963 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1967 replay_barrier $SINGLEMDS
1968 #define OBD_FAIL_LDLM_REPLY 0x30c
1969 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1972 wait $pid || return 1
1973 [ -e $DIR/$tfile ] && return 2
1976 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1979 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1983 replay_barrier $SINGLEMDS
1984 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1985 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1988 wait $pid || return 1
1989 [ -e $DIR/$tfile ] && return 2
1992 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1996 local clients=${CLIENTS:-$HOSTNAME}
1998 zconf_umount_clients $clients $MOUNT
2000 facet_failover $SINGLEMDS
2001 zconf_mount_clients $clients $MOUNT
2003 touch $DIR/$tfile || return 1
2004 rm $DIR/$tfile || return 2
2005 clients_up || error "client evicted: $?"
2008 run_test 74 "Ensure applications don't fail waiting for OST recovery"
2010 remote_dir_check_80() {
2012 local diridx=$($GETSTRIPE -M $remote_dir)
2013 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
2015 createmany -o $remote_dir/f-%d 20 || error "creation failed"
2016 local fileidx=$($GETSTRIPE -M $remote_dir/f-1)
2017 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
2023 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2024 ([ $FAILURE_MODE == "HARD" ] &&
2025 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2026 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2030 local remote_dir=$DIR/$tdir/remote_dir
2033 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2034 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
2035 $LFS mkdir -i $MDTIDX $remote_dir &
2038 fail mds$((MDTIDX + 1))
2040 wait $CLIENT_PID || error "remote creation failed"
2042 remote_dir_check_80 || error "remote dir check failed"
2043 rm -rf $DIR/$tdir || error "rmdir failed"
2047 run_test 80a "DNE: create remote dir, drop update rep from MDT1, fail MDT1"
2050 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2051 ([ $FAILURE_MODE == "HARD" ] &&
2052 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2053 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2057 local remote_dir=$DIR/$tdir/remote_dir
2060 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2061 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
2062 $LFS mkdir -i $MDTIDX $remote_dir &
2067 wait $CLIENT_PID || error "remote creation failed"
2069 remote_dir_check_80 || error "remote dir check failed"
2070 rm -rf $DIR/$tdir || error "rmdir failed"
2074 run_test 80b "DNE: create remote dir, drop update rep from MDT1, fail MDT0"
2077 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2078 ([ $FAILURE_MODE == "HARD" ] &&
2079 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2080 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2084 local remote_dir=$DIR/$tdir/remote_dir
2087 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2088 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
2089 $LFS mkdir -i $MDTIDX $remote_dir &
2093 fail mds$((MDTIDX + 1))
2095 wait $CLIENT_PID || error "remote creation failed"
2097 remote_dir_check_80 || error "remote dir check failed"
2098 rm -rf $DIR/$tdir || error "rmdir failed"
2102 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2105 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2107 local remote_dir=$DIR/$tdir/remote_dir
2110 #define OBD_FAIL_UPDATE_OBJ_NET_REP 0x1701
2111 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x1701
2112 $LFS mkdir -i $MDTIDX $remote_dir &
2115 fail mds${MDTIDX},mds$((MDTIDX + 1))
2117 wait $CLIENT_PID || error "remote creation failed"
2119 remote_dir_check_80 || error "remote dir check failed"
2120 rm -rf $DIR/$tdir || error "rmdir failed"
2124 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2127 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2128 ([ $FAILURE_MODE == "HARD" ] &&
2129 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2130 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2134 local remote_dir=$DIR/$tdir/remote_dir
2137 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2138 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2139 $LFS mkdir -i $MDTIDX $remote_dir &
2144 wait $CLIENT_PID || error "remote creation failed"
2146 remote_dir_check_80 || error "remote dir check failed"
2147 rm -rf $DIR/$tdir || error "rmdir failed"
2151 run_test 80e "DNE: create remote dir, drop MDT0 rep, fail MDT0"
2154 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2155 ([ $FAILURE_MODE == "HARD" ] &&
2156 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2157 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2160 local remote_dir=$DIR/$tdir/remote_dir
2163 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2164 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2165 $LFS mkdir -i $MDTIDX $remote_dir &
2168 fail mds$((MDTIDX + 1))
2170 wait $CLIENT_PID || error "remote creation failed"
2172 remote_dir_check_80 || error "remote dir check failed"
2173 rm -rf $DIR/$tdir || error "rmdir failed"
2177 run_test 80f "DNE: create remote dir, drop MDT0 rep, fail MDT1"
2180 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2181 ([ $FAILURE_MODE == "HARD" ] &&
2182 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2183 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2187 local remote_dir=$DIR/$tdir/remote_dir
2190 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2191 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2192 $LFS mkdir -i $MDTIDX $remote_dir &
2196 fail mds$((MDTIDX + 1))
2198 wait $CLIENT_PID || error "remote creation failed"
2200 remote_dir_check_80 || error "remote dir check failed"
2201 rm -rf $DIR/$tdir || error "rmdir failed"
2205 run_test 80g "DNE: create remote dir, drop MDT0 rep, fail MDT0, then MDT1"
2208 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2210 local remote_dir=$DIR/$tdir/remote_dir
2213 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2214 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2215 $LFS mkdir -i $MDTIDX $remote_dir &
2218 fail mds${MDTIDX},mds$((MDTIDX + 1))
2220 wait $CLIENT_PID || return 1
2222 remote_dir_check_80 || error "remote dir check failed"
2223 rm -rf $DIR/$tdir || error "rmdir failed"
2227 run_test 80h "DNE: create remote dir, drop MDT0 rep, fail 2 MDTs"
2230 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2231 ([ $FAILURE_MODE == "HARD" ] &&
2232 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2233 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2237 local remote_dir=$DIR/$tdir/remote_dir
2240 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2243 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2244 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2248 fail mds$((MDTIDX + 1))
2250 wait $CLIENT_PID || error "rm remote dir failed"
2252 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2254 rm -rf $DIR/$tdir || error "rmdir failed"
2258 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2261 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2262 ([ $FAILURE_MODE == "HARD" ] &&
2263 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2264 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2267 local remote_dir=$DIR/$tdir/remote_dir
2270 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2272 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2273 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2279 wait $CLIENT_PID || error "rm remote dir failed"
2281 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2283 rm -rf $DIR/$tdir || error "rmdir failed"
2287 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2290 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2291 ([ $FAILURE_MODE == "HARD" ] &&
2292 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2293 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2297 local remote_dir=$DIR/$tdir/remote_dir
2300 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2302 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2303 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2308 fail mds$((MDTIDX + 1))
2310 wait $CLIENT_PID || error "rm remote dir failed"
2312 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2314 rm -rf $DIR/$tdir || error "rmdir failed"
2318 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2321 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2323 local remote_dir=$DIR/$tdir/remote_dir
2326 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2328 # OBD_FAIL_OBJ_UPDATE_NET_REP 0x1701
2329 do_facet mds${MDTIDX} lctl set_param fail_loc=0x1701
2333 fail mds${MDTIDX},mds$((MDTIDX + 1))
2335 wait $CLIENT_PID || error "rm remote dir failed"
2337 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2339 rm -rf $DIR/$tdir || error "rmdir failed"
2343 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2346 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2347 ([ $FAILURE_MODE == "HARD" ] &&
2348 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2349 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2353 local remote_dir=$DIR/$tdir/remote_dir
2356 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2358 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2359 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2362 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2366 wait $CLIENT_PID || error "rm remote dir failed"
2368 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2370 rm -rf $DIR/$tdir || error "rmdir failed"
2374 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2377 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2378 ([ $FAILURE_MODE == "HARD" ] &&
2379 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2380 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2384 local remote_dir=$DIR/$tdir/remote_dir
2387 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2389 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2390 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2394 fail mds$((MDTIDX + 1))
2396 wait $CLIENT_PID || error "rm remote dir failed"
2398 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2400 rm -rf $DIR/$tdir || error "rmdir failed"
2404 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2407 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2408 ([ $FAILURE_MODE == "HARD" ] &&
2409 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2410 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2414 local remote_dir=$DIR/$tdir/remote_dir
2417 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2419 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2420 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2425 fail mds$((MDTIDX + 1))
2427 wait $CLIENT_PID || error "rm remote dir failed"
2429 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2431 rm -rf $DIR/$tdir || error "rmdir failed"
2435 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2438 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2440 local remote_dir=$DIR/$tdir/remote_dir
2443 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2445 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2446 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x119
2450 fail mds${MDTIDX},mds$((MDTIDX + 1))
2452 wait $CLIENT_PID || error "rm remote dir failed"
2454 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2456 rm -rf $DIR/$tdir || error "rmdir failed"
2460 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2464 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2465 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2466 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2467 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2469 run_test 83a "fail log_add during unlink recovery"
2473 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2474 replay_barrier $SINGLEMDS
2475 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2476 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2477 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2480 run_test 83b "fail log_add during unlink recovery"
2483 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2484 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2485 createmany -o $DIR/$tfile- 1 &
2489 client_up || client_up || true # reconnect
2491 run_test 84a "stale open during export disconnect"
2493 test_85a() { #bug 16774
2494 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2496 for i in `seq 100`; do
2497 echo "tag-$i" > $DIR/$tfile-$i
2498 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2501 lov_id=`lctl dl | grep "clilov"`
2502 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2503 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2504 echo "before recovery: unused locks count = $count"
2508 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2509 echo "after recovery: unused locks count = $count2"
2511 if [ $count2 -ge $count ]; then
2512 error "unused locks are not canceled"
2515 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2517 test_85b() { #bug 16774
2518 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2520 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
2521 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 || return 2
2523 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2525 for i in `seq 100`; do
2526 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2529 cancel_lru_locks osc
2531 for i in `seq 100`; do
2532 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2535 lov_id=`lctl dl | grep "clilov"`
2536 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2537 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2538 echo "before recovery: unused locks count = $count"
2539 [ $count != 0 ] || return 3
2543 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2544 echo "after recovery: unused locks count = $count2"
2546 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 || return 4
2547 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
2549 if [ $count2 -ge $count ]; then
2550 error "unused locks are not canceled"
2553 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2556 local clients=${CLIENTS:-$HOSTNAME}
2558 zconf_umount_clients $clients $MOUNT
2559 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2560 remount_facet $SINGLEMDS
2561 zconf_mount_clients $clients $MOUNT
2563 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2566 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2569 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2570 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2571 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2572 cancel_lru_locks osc
2574 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2575 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2576 if [ $cksum != $cksum2 ] ; then
2577 error "New checksum $cksum2 does not match original $cksum"
2580 run_test 87 "write replay"
2583 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2586 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2587 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2588 sleep 1 # Give it a chance to flush dirty data
2589 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2590 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2591 cancel_lru_locks osc
2593 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2594 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2595 if [ $cksum != $cksum2 ] ; then
2596 error "New checksum $cksum2 does not match original $cksum"
2599 run_test 87b "write replay with changed data (checksum resend)"
2601 test_88() { #bug 17485
2605 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2608 replay_barrier $SINGLEMDS
2610 # exhaust precreations on ost1
2611 local OST=$(ostname_from_index 0)
2612 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2613 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2614 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2615 echo "before test: last_id = $last_id, next_id = $next_id"
2617 echo "Creating to objid $last_id on ost $OST..."
2618 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2620 #create some files to use some uncommitted objids
2621 last_id=$(($last_id + 1))
2622 createmany -o $DIR/$tdir/f-%d $last_id 8
2624 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2625 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2626 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2628 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2629 # it has to take care about the affected facets, bug20407
2630 local affected_mds1=$(affected_facets mds1)
2631 local affected_ost1=$(affected_facets ost1)
2633 shutdown_facet $SINGLEMDS
2636 reboot_facet $SINGLEMDS
2637 change_active $affected_mds1
2638 wait_for_facet $affected_mds1
2639 mount_facets $affected_mds1 || error "Restart of mds failed"
2642 change_active $affected_ost1
2643 wait_for_facet $affected_ost1
2644 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2648 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2649 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2650 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2652 # create new files, which should use new objids, and ensure the orphan
2653 # cleanup phase for ost1 is completed at the same time
2654 for i in `seq 8`; do
2655 file_id=$(($last_id + 10 + $i))
2656 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2659 # if the objids were not recreated, then "ls" will failed for -ENOENT
2660 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2663 # write into previously created files
2664 for i in `seq 8`; do
2665 file_id=$(($last_id + $i))
2666 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2667 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2670 # compare the content
2671 for i in `seq 8`; do
2672 file_id=$(($last_id + $i))
2673 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2674 "of file is modified!"
2679 run_test 88 "MDS should not assign same objid to different files "
2682 cancel_lru_locks osc
2684 rm -f $DIR/$tdir/$tfile
2686 wait_delete_completed
2687 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2688 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2689 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2692 facet_failover $SINGLEMDS
2693 rm $DIR/$tdir/$tfile
2696 zconf_mount $(hostname) $MOUNT
2697 client_up || return 1
2699 wait_delete_completed
2700 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2701 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] || \
2702 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2705 run_test 89 "no disk space leak on late ost connection"
2711 change_active $facet
2712 wait_for_facet $facet
2713 mount_facet $facet || error "Restart of $facet failed"
2717 test_90() { # bug 19494
2718 local dir=$DIR/$tdir
2719 local ostfail=$(get_random_entry $(get_facets OST))
2721 if [[ $FAILURE_MODE = HARD ]]; then
2722 local affected=$(affected_facets $ostfail);
2723 if [[ "$affected" != $ostfail ]]; then
2724 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2731 echo "Create the files"
2733 # file "f${index}" striped over 1 OST
2734 # file "all" striped over all OSTs
2736 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2737 error "setstripe failed to create $dir/all"
2739 for (( i=0; i<$OSTCOUNT; i++ )); do
2741 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2743 # confirm setstripe actually created the stripe on the requested OST
2744 local uuid=$(ostuuid_from_index $i)
2745 for file in f$i all; do
2746 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2747 $GETSTRIPE $dir/$file
2748 error wrong stripe: $file, uuid: $uuid
2753 # Before failing an OST, get its obd name and index
2754 local varsvc=${ostfail}_svc
2755 local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
2756 local index=$(($(facet_number $ostfail) - 1))
2758 echo "Fail $ostfail $obd, display the list of affected files"
2759 shutdown_facet $ostfail || return 2
2761 trap "cleanup_90 $ostfail" EXIT INT
2762 echo "General Query: lfs find $dir"
2763 local list=$($LFS find $dir)
2765 for (( i=0; i<$OSTCOUNT; i++ )); do
2766 list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
2768 list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
2770 # focus on the missing OST,
2771 # we expect to see only two files affected: "f$(index)" and "all"
2773 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2774 list=$($LFS find --obd $obd $dir)
2776 for file in all f$index; do
2777 list_member "$list" $dir/$file ||
2778 error_noexit "lfs find does not report the affected $obd for $file"
2781 [[ $(echo $list | wc -w) -eq 2 ]] ||
2782 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2784 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2785 list=$($GETSTRIPE -r --obd $obd $dir)
2787 for file in all f$index; do
2788 echo "$list" | grep $dir/$file ||
2789 error_noexit "lfs getsripe does not report the affected $obd for $file"
2794 run_test 90 "lfs find identifies the missing striped file segments"
2797 check_and_cleanup_lustre