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 LU1867
25 ALWAYS_EXCEPT="61d 33a 33b 89 $REPLAY_SINGLE_EXCEPT"
27 # 63 min 7 min AT AT AT AT"
28 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
32 check_and_setup_lustre
37 rm -rf $DIR/[df][0-9]* $DIR/f.$TESTSUITE.*
39 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
40 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
42 do_facet $SINGLEMDS sync
45 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)"
65 replay_barrier $SINGLEMDS
68 facet_failover $SINGLEMDS
69 zconf_mount `hostname` $MOUNT || error "mount fails"
70 client_up || error "post-failover df failed"
71 # file shouldn't exist if replay-barrier works as expected
72 rm $DIR/$tfile && return 1
75 run_test 0c "check replay-barrier"
78 replay_barrier $SINGLEMDS
80 facet_failover $SINGLEMDS
81 zconf_mount `hostname` $MOUNT || error "mount fails"
82 client_up || error "post-failover df failed"
84 run_test 0d "expired recovery with no clients"
87 replay_barrier $SINGLEMDS
90 $CHECKSTAT -t file $DIR/$tfile || return 1
93 run_test 1 "simple create"
96 replay_barrier $SINGLEMDS
99 $CHECKSTAT -t file $DIR/$tfile || return 1
106 replay_barrier $SINGLEMDS
109 $CHECKSTAT -t file $DIR/$tfile || return 1
115 local file=$DIR/$tfile
116 replay_barrier $SINGLEMDS
118 openfile -f O_DIRECTORY $file
120 $CHECKSTAT -t file $file || return 2
123 run_test 3a "replay failed open(O_DIRECTORY)"
126 replay_barrier $SINGLEMDS
127 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
128 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
130 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
132 $CHECKSTAT -t file $DIR/$tfile && return 2
135 run_test 3b "replay failed open -ENOMEM"
138 replay_barrier $SINGLEMDS
139 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
140 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
142 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
145 $CHECKSTAT -t file $DIR/$tfile && return 2
148 run_test 3c "replay failed open -ENOMEM"
150 test_4a() { # was test_4
151 replay_barrier $SINGLEMDS
152 for i in `seq 10`; do
153 echo "tag-$i" > $DIR/$tfile-$i
156 for i in `seq 10`; do
157 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
160 run_test 4a "|x| 10 open(O_CREAT)s"
163 replay_barrier $SINGLEMDS
166 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
168 run_test 4b "|x| rm 10 files"
170 # The idea is to get past the first block of precreated files on both
171 # osts, and then replay.
173 replay_barrier $SINGLEMDS
174 for i in `seq 220`; do
175 echo "tag-$i" > $DIR/$tfile-$i
178 for i in `seq 220`; do
179 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
183 # waiting for commitment of removal
185 run_test 5 "|x| 220 open(O_CREAT)"
188 test_6a() { # was test_6
190 replay_barrier $SINGLEMDS
191 mcreate $DIR/$tdir/$tfile
193 $CHECKSTAT -t dir $DIR/$tdir || return 1
194 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
196 # waiting for log process thread
198 run_test 6a "mkdir + contained create"
202 replay_barrier $SINGLEMDS
205 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
207 run_test 6b "|X| rmdir"
211 replay_barrier $SINGLEMDS
212 mcreate $DIR/$tdir/$tfile
214 $CHECKSTAT -t dir $DIR/$tdir || return 1
215 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
218 run_test 7 "mkdir |X| contained create"
221 # make sure no side-effect from previous test.
223 replay_barrier $SINGLEMDS
224 multiop_bg_pause $DIR/$tfile mo_c || return 4
228 $CHECKSTAT -t file $DIR/$tfile || return 1
229 kill -USR1 $MULTIPID || return 2
230 wait $MULTIPID || return 3
233 run_test 8 "creat open |X| close"
236 replay_barrier $SINGLEMDS
238 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
240 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
242 echo " old_inum == $old_inum, new_inum == $new_inum"
243 if [ $old_inum -eq $new_inum ] ;
245 echo " old_inum and new_inum match"
247 echo "!!!! old_inum and new_inum NOT match"
252 run_test 9 "|X| create (same inum/gen)"
256 replay_barrier $SINGLEMDS
257 mv $DIR/$tfile $DIR/$tfile-2
260 $CHECKSTAT $DIR/$tfile && return 1
261 $CHECKSTAT $DIR/$tfile-2 ||return 2
265 run_test 10 "create |X| rename unlink"
269 echo "old" > $DIR/$tfile
270 mv $DIR/$tfile $DIR/$tfile-2
271 replay_barrier $SINGLEMDS
272 echo "new" > $DIR/$tfile
274 grep old $DIR/$tfile-2
276 grep new $DIR/$tfile || return 1
277 grep old $DIR/$tfile-2 || return 2
279 run_test 11 "create open write rename |X| create-old-name read"
283 multiop_bg_pause $DIR/$tfile o_tSc || return 3
286 replay_barrier $SINGLEMDS
288 wait $pid || return 1
291 [ -e $DIR/$tfile ] && return 2
294 run_test 12 "open, unlink |X| close"
297 # 1777 - replay open after committed chmod that would make
298 # a regular open a failure
301 multiop_bg_pause $DIR/$tfile O_wc || return 3
304 $CHECKSTAT -p 0 $DIR/$tfile
305 replay_barrier $SINGLEMDS
308 wait $pid || return 1
310 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
311 rm $DIR/$tfile || return 4
314 run_test 13 "open chmod 0 |x| write close"
317 multiop_bg_pause $DIR/$tfile O_tSc || return 4
320 replay_barrier $SINGLEMDS
321 kill -USR1 $pid || return 1
322 wait $pid || return 2
325 [ -e $DIR/$tfile ] && return 3
328 run_test 14 "open(O_CREAT), unlink |X| close"
331 multiop_bg_pause $DIR/$tfile O_tSc || return 5
334 replay_barrier $SINGLEMDS
335 touch $DIR/g11 || return 1
337 wait $pid || return 2
340 [ -e $DIR/$tfile ] && return 3
341 touch $DIR/h11 || return 4
344 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
348 replay_barrier $SINGLEMDS
351 mcreate $DIR/$tfile-2
353 [ -e $DIR/$tfile ] && return 1
354 [ -e $DIR/$tfile-2 ] || return 2
355 munlink $DIR/$tfile-2 || return 3
357 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
360 replay_barrier $SINGLEMDS
361 multiop_bg_pause $DIR/$tfile O_c || return 4
364 kill -USR1 $pid || return 1
365 wait $pid || return 2
366 $CHECKSTAT -t file $DIR/$tfile || return 3
369 run_test 17 "|X| open(O_CREAT), |replay| close"
372 replay_barrier $SINGLEMDS
373 multiop_bg_pause $DIR/$tfile O_tSc || return 8
376 touch $DIR/$tfile-2 || return 1
377 echo "pid: $pid will close"
379 wait $pid || return 2
382 [ -e $DIR/$tfile ] && return 3
383 [ -e $DIR/$tfile-2 ] || return 4
384 # this touch frequently fails
385 touch $DIR/$tfile-3 || return 5
386 munlink $DIR/$tfile-2 || return 6
387 munlink $DIR/$tfile-3 || return 7
390 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
392 # bug 1855 (a simpler form of test_11 above)
394 replay_barrier $SINGLEMDS
396 echo "old" > $DIR/$tfile
397 mv $DIR/$tfile $DIR/$tfile-2
398 grep old $DIR/$tfile-2
400 grep old $DIR/$tfile-2 || return 2
402 run_test 19 "|X| mcreate, open, write, rename "
404 test_20a() { # was test_20
405 replay_barrier $SINGLEMDS
406 multiop_bg_pause $DIR/$tfile O_tSc || return 3
412 wait $pid || return 1
413 [ -e $DIR/$tfile ] && return 2
416 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
418 test_20b() { # bug 10480
419 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
421 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
423 while [ ! -e $DIR/$tfile ] ; do
424 usleep 60 # give dd a chance to start
427 $GETSTRIPE $DIR/$tfile || return 1
428 rm -f $DIR/$tfile || return 2 # make it an orphan
430 client_up || client_up || true # reconnect
432 fail $SINGLEMDS # start orphan recovery
433 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
434 wait_mds_ost_sync || return 3
435 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
436 log "before $BEFOREUSED, after $AFTERUSED"
437 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
438 error "after $AFTERUSED > before $BEFOREUSED"
441 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
443 test_20c() { # bug 10480
444 multiop_bg_pause $DIR/$tfile Ow_c || return 1
450 client_up || client_up || true # reconnect
453 wait $pid || return 1
454 [ -s $DIR/$tfile ] || error "File was truncated"
458 run_test 20c "check that client eviction does not affect file content"
461 replay_barrier $SINGLEMDS
462 multiop_bg_pause $DIR/$tfile O_tSc || return 5
465 touch $DIR/g11 || return 1
469 wait $pid || return 2
470 [ -e $DIR/$tfile ] && return 3
471 touch $DIR/h11 || return 4
474 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
477 multiop_bg_pause $DIR/$tfile O_tSc || return 3
480 replay_barrier $SINGLEMDS
485 wait $pid || return 1
486 [ -e $DIR/$tfile ] && return 2
489 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
492 multiop_bg_pause $DIR/$tfile O_tSc || return 5
495 replay_barrier $SINGLEMDS
497 touch $DIR/g11 || return 1
501 wait $pid || return 2
502 [ -e $DIR/$tfile ] && return 3
503 touch $DIR/h11 || return 4
506 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
509 multiop_bg_pause $DIR/$tfile O_tSc || return 3
512 replay_barrier $SINGLEMDS
516 wait $pid || return 1
517 [ -e $DIR/$tfile ] && return 2
520 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
523 multiop_bg_pause $DIR/$tfile O_tSc || return 3
527 replay_barrier $SINGLEMDS
530 wait $pid || return 1
531 [ -e $DIR/$tfile ] && return 2
534 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
537 replay_barrier $SINGLEMDS
538 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
540 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
545 wait $pid2 || return 1
549 wait $pid1 || return 2
550 [ -e $DIR/$tfile-1 ] && return 3
551 [ -e $DIR/$tfile-2 ] && return 4
554 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
557 replay_barrier $SINGLEMDS
558 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
560 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
567 wait $pid1 || return 1
569 wait $pid2 || return 2
570 [ -e $DIR/$tfile-1 ] && return 3
571 [ -e $DIR/$tfile-2 ] && return 4
574 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
577 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
579 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
581 replay_barrier $SINGLEMDS
585 wait $pid2 || return 1
589 wait $pid1 || return 2
590 [ -e $DIR/$tfile-1 ] && return 3
591 [ -e $DIR/$tfile-2 ] && return 4
594 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
597 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
599 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
601 replay_barrier $SINGLEMDS
607 wait $pid1 || return 1
609 wait $pid2 || return 2
610 [ -e $DIR/$tfile-1 ] && return 3
611 [ -e $DIR/$tfile-2 ] && return 4
614 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
617 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
619 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
624 replay_barrier $SINGLEMDS
627 wait $pid1 || return 1
629 wait $pid2 || return 2
630 [ -e $DIR/$tfile-1 ] && return 3
631 [ -e $DIR/$tfile-2 ] && return 4
634 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
637 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
639 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
643 replay_barrier $SINGLEMDS
647 wait $pid1 || return 1
649 wait $pid2 || return 2
650 [ -e $DIR/$tfile-1 ] && return 3
651 [ -e $DIR/$tfile-2 ] && return 4
654 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
656 # tests for bug 2104; completion without crashing is success. The close is
657 # stale, but we always return 0 for close, so the app never sees it.
659 multiop_bg_pause $DIR/$tfile O_c || return 2
661 multiop_bg_pause $DIR/$tfile O_c || return 3
664 client_up || client_up || return 1
667 wait $pid1 || return 4
668 wait $pid2 || return 5
671 run_test 32 "close() notices client eviction; close() after client eviction"
674 createmany -o $DIR/$tfile-%d 10
675 replay_barrier_nosync $SINGLEMDS
676 fail_abort $SINGLEMDS
677 # recreate shouldn't fail
678 createmany -o $DIR/$tfile--%d 10 || return 1
682 run_test 33a "fid seq shouldn't be reused after abort recovery"
685 #define OBD_FAIL_SEQ_ALLOC 0x1311
686 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
688 createmany -o $DIR/$tfile-%d 10
689 replay_barrier_nosync $SINGLEMDS
690 fail_abort $SINGLEMDS
691 # recreate shouldn't fail
692 createmany -o $DIR/$tfile--%d 10 || return 1
696 run_test 33b "test fid seq allocation"
699 multiop_bg_pause $DIR/$tfile O_c || return 2
703 replay_barrier $SINGLEMDS
704 fail_abort $SINGLEMDS
706 wait $pid || return 3
707 [ -e $DIR/$tfile ] && return 1
711 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
713 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
717 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
718 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
723 # give a chance to remove from MDS
724 fail_abort $SINGLEMDS
725 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
727 run_test 35 "test recovery from llog for unlink op"
729 # b=2432 resent cancel after replay uses wrong cookie,
730 # so don't resend cancels
732 replay_barrier $SINGLEMDS
734 checkstat $DIR/$tfile
735 facet_failover $SINGLEMDS
737 if dmesg | grep "unknown lock cookie"; then
738 echo "cancel after replay failed"
742 run_test 36 "don't resend cancel"
745 # directory orphans can't be unlinked from PENDING directory
747 rmdir $DIR/$tfile 2>/dev/null
748 multiop_bg_pause $DIR/$tfile dD_c || return 2
752 replay_barrier $SINGLEMDS
753 # clear the dmesg buffer so we only see errors from this recovery
754 do_facet $SINGLEMDS dmesg -c >/dev/null
755 fail_abort $SINGLEMDS
757 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
759 wait $pid || return 3
763 start_full_debug_logging
764 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
765 stop_full_debug_logging
768 createmany -o $DIR/$tfile-%d 800
769 unlinkmany $DIR/$tfile-%d 0 400
770 replay_barrier $SINGLEMDS
772 unlinkmany $DIR/$tfile-%d 400 400
774 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
776 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
778 test_39() { # bug 4176
779 createmany -o $DIR/$tfile-%d 800
780 replay_barrier $SINGLEMDS
781 unlinkmany $DIR/$tfile-%d 0 400
783 unlinkmany $DIR/$tfile-%d 400 400
785 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
787 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
790 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
795 $LCTL mark multiop $MOUNT/$tfile OS_c
796 multiop $MOUNT/$tfile OS_c &
798 writeme -s $MOUNT/${tfile}-2 &
801 facet_failover $SINGLEMDS
802 #define OBD_FAIL_MDS_CONNECT_NET 0x117
803 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
805 stat1=`count_ost_writes`
807 stat2=`count_ost_writes`
808 echo "$stat1, $stat2"
809 if [ $stat1 -lt $stat2 ]; then
810 echo "writes continuing during recovery"
813 echo "writes not continuing during recovery, bug 2477"
816 echo "waiting for writeme $WRITE_PID"
820 echo "waiting for multiop $PID"
821 wait $PID || return 2
822 do_facet client munlink $MOUNT/$tfile || return 3
823 do_facet client munlink $MOUNT/${tfile}-2 || return 3
826 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
830 # make sure that a read to one osc doesn't try to double-unlock its page just
831 # because another osc is invalid. trigger_group_io used to mistakenly return
832 # an error if any oscs were invalid even after having successfully put rpcs
833 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
834 # the page, guarnateeing that the unlock from the RPC completion would
835 # assert on trying to unlock the unlocked page.
837 [ $OSTCOUNT -lt 2 ] &&
838 skip_env "skipping test 41: we don't have a second OST to test with" &&
841 local f=$MOUNT/$tfile
842 # make sure the start of the file is ost1
843 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
844 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
846 # fail ost2 and read from ost1
847 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
848 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
849 grep $mdtosc | awk '{print $1}')
850 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices &&
852 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
853 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
854 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
857 run_test 41 "read from a valid osc while other oscs are invalid"
859 # test MDS recovery after ost failure
861 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
862 createmany -o $DIR/$tfile-%d 800
864 unlinkmany $DIR/$tfile-%d 0 400
866 lctl set_param debug=-1
869 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
870 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
871 #[ $blocks_after -lt $blocks ] || return 1
872 echo wait for MDS to timeout and recover
873 sleep $((TIMEOUT * 2))
875 unlinkmany $DIR/$tfile-%d 400 400
876 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
878 run_test 42 "recovery after ost failure"
880 # timeout in MDS/OST recovery RPC will LBUG MDS
881 test_43() { # bug 2530
882 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
884 replay_barrier $SINGLEMDS
886 # OBD_FAIL_OST_CREATE_NET 0x204
887 do_facet ost1 "lctl set_param fail_loc=0x80000204"
890 do_facet ost1 "lctl set_param fail_loc=0"
894 run_test 43 "mds osc import failure during recovery; don't LBUG"
896 test_44a() { # was test_44
899 local mdcdev=$($LCTL get_param -n devices |
900 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
901 [ "$mdcdev" ] || return 2
902 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
903 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
905 # adaptive timeouts slow this way down
906 if at_is_enabled; then
907 at_max_saved=$(at_max_get mds)
911 for i in `seq 1 10`; do
912 echo "$i of 10 ($(date +%s))"
913 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
914 #define OBD_FAIL_TGT_CONN_RACE 0x701
915 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
916 # lctl below may fail, it is valid case
917 $LCTL --device $mdcdev recover
920 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
921 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
924 run_test 44a "race in target handle connect"
927 local mdcdev=$($LCTL get_param -n devices |
928 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
929 [ "$mdcdev" ] || return 2
930 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
931 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
933 for i in `seq 1 10`; do
934 echo "$i of 10 ($(date +%s))"
935 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
936 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
937 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
938 # lctl below may fail, it is valid case
939 $LCTL --device $mdcdev recover
942 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
945 run_test 44b "race in target handle connect"
948 replay_barrier $SINGLEMDS
949 createmany -m $DIR/$tfile-%d 100
950 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
951 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
952 fail_abort $SINGLEMDS
953 unlinkmany $DIR/$tfile-%d 100 && return 1
955 unlinkmany $DIR/$tfile-%d 100 && return 1
958 run_test 44c "race in target handle connect"
960 # Handle failed close
962 local mdcdev=$($LCTL get_param -n devices |
963 awk "/ ${FSNAME}-MDT0000-mdc-/ {print \$1}")
964 [ "$mdcdev" ] || return 2
965 [ $(echo $mdcdev | wc -w) -eq 1 ] ||
966 { echo mdcdev=$mdcdev; $LCTL dl; return 3; }
968 $LCTL --device $mdcdev recover || return 6
970 multiop_bg_pause $DIR/$tfile O_c || return 1
973 # This will cause the CLOSE to fail before even
974 # allocating a reply buffer
975 $LCTL --device $mdcdev deactivate || return 4
979 wait $pid || return 1
981 $LCTL --device $mdcdev activate || return 5
984 $CHECKSTAT -t file $DIR/$tfile || return 2
987 run_test 45 "Handle failed close"
991 drop_reply "touch $DIR/$tfile"
993 # ironically, the previous test, 45, will cause a real forced close,
994 # so just look for one for this test
995 dmesg | grep -i "force closing client file handle for $tfile" && return 1
998 run_test 46 "Don't leak file handle after open resend (3325)"
1000 test_47() { # bug 2824
1001 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1003 # create some files to make sure precreate has been done on all
1004 # OSTs. (just in case this test is run independently)
1005 createmany -o $DIR/$tfile 20 || return 1
1007 # OBD_FAIL_OST_CREATE_NET 0x204
1009 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1010 client_up || return 2
1012 # let the MDS discover the OST failure, attempt to recover, fail
1013 # and recover again.
1014 sleep $((3 * TIMEOUT))
1016 # Without 2824, this createmany would hang
1017 createmany -o $DIR/$tfile 20 || return 3
1018 unlinkmany $DIR/$tfile 20 || return 4
1020 do_facet ost1 "lctl set_param fail_loc=0"
1023 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1026 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1027 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1029 replay_barrier $SINGLEMDS
1030 createmany -o $DIR/$tfile 20 || return 1
1031 # OBD_FAIL_OST_EROFS 0x216
1032 facet_failover $SINGLEMDS
1033 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1034 client_up || return 2
1036 createmany -o $DIR/$tfile 20 20 || return 2
1037 unlinkmany $DIR/$tfile 40 || return 3
1040 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1043 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1044 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1045 grep $mdtosc | awk '{print $1}')
1046 [ "$oscdev" ] || return 1
1047 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1048 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1049 # give the mds_lov_sync threads a chance to run
1052 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1054 # b3764 timed out lock replay
1057 cancel_lru_locks mdc
1059 multiop $DIR/$tfile s || return 1
1060 replay_barrier $SINGLEMDS
1061 #define OBD_FAIL_LDLM_REPLY 0x30c
1062 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1063 fail $SINGLEMDS || return 2
1064 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1066 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1068 run_test 52 "time out lock replay (3764)"
1070 # bug 3462 - simultaneous MDC requests
1072 cancel_lru_locks mdc # cleanup locks from former test cases
1073 mkdir -p $DIR/${tdir}-1
1074 mkdir -p $DIR/${tdir}-2
1075 multiop $DIR/${tdir}-1/f O_c &
1077 # give multiop a change to open
1080 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1081 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1082 kill -USR1 $close_pid
1083 cancel_lru_locks mdc # force the close
1084 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1086 mcreate $DIR/${tdir}-2/f || return 1
1088 # close should still be here
1089 [ -d /proc/$close_pid ] || return 2
1091 replay_barrier_nodf $SINGLEMDS
1093 wait $close_pid || return 3
1095 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1096 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1097 rm -rf $DIR/${tdir}-*
1099 run_test 53a "|X| close request while two MDC requests in flight"
1102 cancel_lru_locks mdc # cleanup locks from former test cases
1103 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1105 mkdir -p $DIR/${tdir}-1
1106 mkdir -p $DIR/${tdir}-2
1107 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1110 #define OBD_FAIL_MDS_REINT_NET 0x107
1111 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1112 mcreate $DIR/${tdir}-2/f &
1116 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1117 kill -USR1 $close_pid
1118 cancel_lru_locks mdc # force the close
1119 wait $close_pid || return 1
1120 # open should still be here
1121 [ -d /proc/$open_pid ] || return 2
1123 replay_barrier_nodf $SINGLEMDS
1125 wait $open_pid || return 3
1127 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1128 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1129 rm -rf $DIR/${tdir}-*
1131 run_test 53b "|X| open request while two MDC requests in flight"
1134 cancel_lru_locks mdc # cleanup locks from former test cases
1135 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1137 mkdir -p $DIR/${tdir}-1
1138 mkdir -p $DIR/${tdir}-2
1139 multiop $DIR/${tdir}-1/f O_c &
1142 #define OBD_FAIL_MDS_REINT_NET 0x107
1143 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1144 mcreate $DIR/${tdir}-2/f &
1148 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1149 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1150 kill -USR1 $close_pid
1151 cancel_lru_locks mdc # force the close
1153 #bz20647: make sure all pids are exists before failover
1154 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1155 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1156 replay_barrier_nodf $SINGLEMDS
1157 fail_nodf $SINGLEMDS
1158 wait $open_pid || return 1
1160 # close should be gone
1161 [ -d /proc/$close_pid ] && return 2
1162 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1164 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1165 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1166 rm -rf $DIR/${tdir}-*
1168 run_test 53c "|X| open request and close request while two MDC requests in flight"
1171 cancel_lru_locks mdc # cleanup locks from former test cases
1172 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1174 mkdir -p $DIR/${tdir}-1
1175 mkdir -p $DIR/${tdir}-2
1176 multiop $DIR/${tdir}-1/f O_c &
1178 # give multiop a chance to open
1181 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1182 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1183 kill -USR1 $close_pid
1184 cancel_lru_locks mdc # force the close
1185 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1186 mcreate $DIR/${tdir}-2/f || return 1
1188 # close should still be here
1189 [ -d /proc/$close_pid ] || return 2
1191 wait $close_pid || return 3
1193 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1194 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1195 rm -rf $DIR/${tdir}-*
1197 run_test 53d "|X| close reply while two MDC requests in flight"
1200 cancel_lru_locks mdc # cleanup locks from former test cases
1201 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1203 mkdir -p $DIR/${tdir}-1
1204 mkdir -p $DIR/${tdir}-2
1205 multiop $DIR/${tdir}-1/f O_c &
1208 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1209 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1210 mcreate $DIR/${tdir}-2/f &
1214 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1215 kill -USR1 $close_pid
1216 cancel_lru_locks mdc # force the close
1217 wait $close_pid || return 1
1218 # open should still be here
1219 [ -d /proc/$open_pid ] || return 2
1221 replay_barrier_nodf $SINGLEMDS
1223 wait $open_pid || return 3
1225 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1226 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1227 rm -rf $DIR/${tdir}-*
1229 run_test 53e "|X| open reply while two MDC requests in flight"
1232 cancel_lru_locks mdc # cleanup locks from former test cases
1233 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1235 mkdir -p $DIR/${tdir}-1
1236 mkdir -p $DIR/${tdir}-2
1237 multiop $DIR/${tdir}-1/f O_c &
1240 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1241 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1242 mcreate $DIR/${tdir}-2/f &
1246 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1247 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1248 kill -USR1 $close_pid
1249 cancel_lru_locks mdc # force the close
1251 #bz20647: make sure all pids are exists before failover
1252 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1253 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1254 replay_barrier_nodf $SINGLEMDS
1255 fail_nodf $SINGLEMDS
1256 wait $open_pid || return 1
1258 # close should be gone
1259 [ -d /proc/$close_pid ] && return 2
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1262 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1263 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1264 rm -rf $DIR/${tdir}-*
1266 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1269 cancel_lru_locks mdc # cleanup locks from former test cases
1270 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1272 mkdir -p $DIR/${tdir}-1
1273 mkdir -p $DIR/${tdir}-2
1274 multiop $DIR/${tdir}-1/f O_c &
1277 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1278 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1279 mcreate $DIR/${tdir}-2/f &
1283 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1284 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1285 kill -USR1 $close_pid
1286 cancel_lru_locks mdc # force the close
1287 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1289 #bz20647: make sure all pids are exists before failover
1290 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1291 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1292 replay_barrier_nodf $SINGLEMDS
1293 fail_nodf $SINGLEMDS
1294 wait $open_pid || return 1
1296 # close should be gone
1297 [ -d /proc/$close_pid ] && return 2
1299 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1300 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1301 rm -rf $DIR/${tdir}-*
1303 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1306 cancel_lru_locks mdc # cleanup locks from former test cases
1307 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1309 mkdir -p $DIR/${tdir}-1
1310 mkdir -p $DIR/${tdir}-2
1311 multiop $DIR/${tdir}-1/f O_c &
1314 #define OBD_FAIL_MDS_REINT_NET 0x107
1315 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1316 mcreate $DIR/${tdir}-2/f &
1320 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1321 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1322 kill -USR1 $close_pid
1323 cancel_lru_locks mdc # force the close
1326 #bz20647: make sure all pids are exists before failover
1327 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1328 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1329 replay_barrier_nodf $SINGLEMDS
1330 fail_nodf $SINGLEMDS
1331 wait $open_pid || return 1
1333 # close should be gone
1334 [ -d /proc/$close_pid ] && return 2
1335 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1337 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1338 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1339 rm -rf $DIR/${tdir}-*
1341 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1343 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1345 #b3761 ASSERTION(hash != 0) failed
1347 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1348 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1350 # give touch a chance to run
1352 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1356 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1358 #b3440 ASSERTION(rec->ur_fid2->id) failed
1360 ln -s foo $DIR/$tfile
1361 replay_barrier $SINGLEMDS
1362 #drop_reply "cat $DIR/$tfile"
1366 run_test 56 "don't replay a symlink open request (3440)"
1368 #recovery one mds-ost setattr from llog
1370 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1371 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1373 replay_barrier $SINGLEMDS
1376 $CHECKSTAT -t file $DIR/$tfile || return 1
1377 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1380 run_test 57 "test recovery from llog for setattr op"
1382 #recovery many mds-ost setattr from llog
1385 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1386 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1387 createmany -o $DIR/$tdir/$tfile-%d 2500
1388 replay_barrier $SINGLEMDS
1391 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1392 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1393 unlinkmany $DIR/$tdir/$tfile-%d 2500
1396 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1402 large_xattr_enabled &&
1403 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1405 mount_client $MOUNT2
1407 touch $DIR/$tdir/$tfile
1408 replay_barrier $SINGLEMDS
1409 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1411 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1412 [[ "$new" = "$orig" ]] || return 1
1413 rm -f $DIR/$tdir/$tfile
1415 zconf_umount `hostname` $MOUNT2
1417 run_test 58b "test replay of setxattr op"
1419 test_58c() { # bug 16570
1424 if large_xattr_enabled; then
1425 local xattr_size=$(max_xattr_size)
1426 orig="$(generate_string $((xattr_size / 2)))"
1427 orig1="$(generate_string $xattr_size)"
1433 mount_client $MOUNT2
1435 touch $DIR/$tdir/$tfile
1436 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1438 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1439 [[ "$new" = "$orig" ]] || return 2
1440 drop_reint_reply "setfattr -n trusted.foo1 -v $orig1 $DIR/$tdir/$tfile" ||
1442 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1443 [[ "$new" = "$orig1" ]] || return 4
1444 rm -f $DIR/$tdir/$tfile
1446 zconf_umount $HOSTNAME $MOUNT2
1448 run_test 58c "resend/reconstruct setxattr op"
1450 # log_commit_thread vs filter_destroy race used to lead to import use after free
1453 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1456 createmany -o $DIR/$tdir/$tfile-%d 200
1458 unlinkmany $DIR/$tdir/$tfile-%d 200
1459 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1460 do_facet ost1 "lctl set_param fail_loc=0x507"
1463 do_facet ost1 "lctl set_param fail_loc=0x0"
1467 run_test 59 "test log_commit_thread vs filter_destroy race"
1469 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1470 # bug 12086: should no oops and No ctxt error for this test
1473 createmany -o $DIR/$tdir/$tfile-%d 200
1474 replay_barrier $SINGLEMDS
1475 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1477 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1478 local no_ctxt=`dmesg | grep "No ctxt"`
1479 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1481 run_test 60 "test llog post recovery init vs llog unlink"
1483 #test race llog recovery thread vs llog cleanup
1484 test_61a() { # was test_61
1485 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1488 createmany -o $DIR/$tdir/$tfile-%d 800
1490 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1491 unlinkmany $DIR/$tdir/$tfile-%d 800
1492 set_nodes_failloc "$(osts_nodes)" 0x80000221
1497 set_nodes_failloc "$(osts_nodes)" 0x0
1499 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1502 run_test 61a "test race llog recovery vs llog cleanup"
1504 #test race mds llog sync vs llog cleanup
1506 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1507 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1508 facet_failover $SINGLEMDS
1511 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1513 run_test 61b "test race mds llog sync vs llog cleanup"
1515 #test race cancel cookie cb vs llog cleanup
1517 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1519 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1521 set_nodes_failloc "$(osts_nodes)" 0x80000222
1525 set_nodes_failloc "$(osts_nodes)" 0x0
1527 run_test 61c "test race mds llog sync vs llog cleanup"
1529 test_61d() { # bug 16002 # bug 17466 # bug 22137
1530 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1532 do_facet mgs "lctl set_param fail_loc=0x80000605"
1533 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1534 do_facet mgs "lctl set_param fail_loc=0"
1535 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1537 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1539 test_62() { # Bug 15756 - don't mis-drop resent replay
1541 replay_barrier $SINGLEMDS
1542 createmany -o $DIR/$tdir/$tfile- 25
1543 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1544 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1546 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1547 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1550 run_test 62 "don't mis-drop resent replay"
1552 #Adaptive Timeouts (bug 3055)
1560 echo "Cleaning up AT ..."
1561 if [ -n "$ATOLDBASE" ]; then
1562 local at_history=$($LCTL get_param -n at_history)
1563 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1564 do_facet ost1 "lctl set_param at_history=$at_history" || true
1567 if [ $AT_MAX_SET -ne 0 ]; then
1568 for facet in mds client ost; do
1569 var=AT_MAX_SAVE_${facet}
1570 echo restore AT on $facet to saved value ${!var}
1571 at_max_set ${!var} $facet
1572 at_new=$(at_max_get $facet)
1573 echo Restored AT value on $facet $at_new
1574 [ $at_new -eq ${!var} ] || \
1575 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1582 local at_max_new=600
1584 # Save at_max original values
1586 if [ $AT_MAX_SET -eq 0 ]; then
1587 # Suppose that all osts have the same at_max
1588 for facet in mds client ost; do
1589 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1593 for facet in mds client ost; do
1594 at_max=$(at_max_get $facet)
1595 if [ $at_max -ne $at_max_new ]; then
1596 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1597 at_max_set $at_max_new $facet
1602 if [ -z "$ATOLDBASE" ]; then
1603 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1604 # speed up the timebase so we can check decreasing AT
1605 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1606 do_facet ost1 "lctl set_param at_history=8" || true
1608 # sleep for a while to cool down, should be > 8s and also allow
1609 # at least one ping to be sent. simply use TIMEOUT to be safe.
1614 test_65a() #bug 3055
1616 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1618 at_start || return 0
1619 $LCTL dk > /dev/null
1621 $LCTL set_param debug="other"
1622 # Slow down a request to the current service time, this is critical
1623 # because previous tests may have caused this value to increase.
1624 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1625 awk '/portal 12/ {print $5}'`
1626 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1628 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1629 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1630 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1631 createmany -o $DIR/$tfile 10 > /dev/null
1632 unlinkmany $DIR/$tfile 10 > /dev/null
1633 # check for log message
1634 $LCTL dk | grep "Early reply #" || error "No early reply"
1636 # client should show REQ_DELAY estimates
1637 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1639 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1641 run_test 65a "AT: verify early replies"
1643 test_65b() #bug 3055
1645 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1647 at_start || return 0
1650 $LCTL set_param debug="other trace"
1651 $LCTL dk > /dev/null
1652 # Slow down a request to the current service time, this is critical
1653 # because previous tests may have caused this value to increase.
1654 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1655 multiop $DIR/$tfile Ow1yc
1656 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1657 awk '/portal 6/ {print $5}'`
1658 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1660 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1661 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1662 do_facet ost1 $LCTL set_param fail_loc=0x224
1665 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1666 # force some real bulk transfer
1667 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1669 do_facet ost1 $LCTL set_param fail_loc=0
1670 # check for log message
1671 $LCTL dk | grep "Early reply #" || error "No early reply"
1673 # client should show REQ_DELAY estimates
1674 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1676 run_test 65b "AT: verify early replies on packed reply / bulk"
1678 test_66a() #bug 3055
1680 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1682 at_start || return 0
1683 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1684 # adjust 5s at a time so no early reply is sent (within deadline)
1685 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1686 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1687 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1688 createmany -o $DIR/$tfile 20 > /dev/null
1689 unlinkmany $DIR/$tfile 20 > /dev/null
1690 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1691 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1692 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1693 createmany -o $DIR/$tfile 20 > /dev/null
1694 unlinkmany $DIR/$tfile 20 > /dev/null
1695 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1696 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1698 createmany -o $DIR/$tfile 20 > /dev/null
1699 unlinkmany $DIR/$tfile 20 > /dev/null
1700 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1701 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1702 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1703 echo "Current MDT timeout $CUR, worst $WORST"
1704 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1706 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1708 test_66b() #bug 3055
1710 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1712 at_start || return 0
1713 ORIG=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1714 awk '/network/ {print $4}')
1715 $LCTL set_param fail_val=$(($ORIG + 5))
1716 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1717 $LCTL set_param fail_loc=0x50c
1718 ls $DIR/$tfile > /dev/null 2>&1
1719 $LCTL set_param fail_loc=0
1720 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1721 awk '/network/ {print $4}')
1722 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000*.timeouts |
1723 awk '/network/ {print $6}')
1724 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1725 [ $WORST -gt $ORIG ] ||
1726 error "Worst $WORST should be worse than orig $ORIG"
1728 run_test 66b "AT: verify net latency adjusts"
1730 test_67a() #bug 3055
1732 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1734 at_start || return 0
1735 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1736 # sleeping threads may drive values above this
1737 do_facet ost1 "$LCTL set_param fail_val=400"
1738 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1739 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1740 createmany -o $DIR/$tfile 20 > /dev/null
1741 unlinkmany $DIR/$tfile 20 > /dev/null
1742 do_facet ost1 "$LCTL set_param fail_loc=0"
1743 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1744 ATTEMPTS=$(($CONN2 - $CONN1))
1745 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1746 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1749 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1751 test_67b() #bug 3055
1753 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1755 at_start || return 0
1756 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1758 # exhaust precreations on ost1
1759 local OST=$(ostname_from_index 0)
1760 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1761 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1762 osc.$mdtosc.prealloc_last_id)
1763 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1764 osc.$mdtosc.prealloc_next_id)
1766 mkdir -p $DIR/$tdir/${OST}
1767 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE"
1768 echo "Creating to objid $last_id on ost $OST..."
1769 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1770 do_facet ost1 "$LCTL set_param fail_val=20000"
1771 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1772 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1775 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1777 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1778 ATTEMPTS=$(($CONN2 - $CONN1))
1779 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1780 # do it again; should not timeout
1781 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1782 cp /etc/profile $DIR/$tfile || error "cp failed"
1783 do_facet ost1 "$LCTL set_param fail_loc=0"
1785 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1786 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1787 ATTEMPTS=$(($CONN3 - $CONN2))
1788 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1789 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1792 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1794 test_68 () #bug 13813
1796 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1798 at_start || return 0
1799 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1800 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1801 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1802 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1803 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1804 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1805 echo $TIMEOUT >> $ldlm_enqueue_min
1806 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1810 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1811 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1812 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1813 $LCTL set_param fail_loc=0x80000312
1814 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1815 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1816 $LCTL set_param fail_loc=0x80000312
1817 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1818 $LCTL set_param fail_loc=0
1820 echo $ENQ_MIN >> $ldlm_enqueue_min
1821 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1825 run_test 68 "AT: verify slowing locks"
1828 # end of AT tests includes above lines
1831 # start multi-client tests
1833 [ -z "$CLIENTS" ] && \
1834 { skip "Need two or more clients." && return; }
1835 [ $CLIENTCOUNT -lt 2 ] && \
1836 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1838 echo "mount clients $CLIENTS ..."
1839 zconf_mount_clients $CLIENTS $MOUNT
1841 local clients=${CLIENTS//,/ }
1842 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1843 for CLIENT in $clients; do
1844 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1845 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1846 error "dd failed on $CLIENT"
1849 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1850 for C in ${CLIENTS//,/ }; do
1851 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1852 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1858 run_test 70a "check multi client t-f"
1860 check_for_process () {
1865 killall_process $clients "$prog" -0
1868 killall_process () {
1869 local clients=${1:-$(hostname)}
1874 do_nodes $clients "killall $signal $name"
1878 local clients=${CLIENTS:-$HOSTNAME}
1880 zconf_mount_clients $clients $MOUNT
1883 [ "$SLOW" = "no" ] && duration=60
1884 # set duration to 900 because it takes some time to boot node
1885 [ "$FAILURE_MODE" = HARD ] && duration=900
1887 local cmd="rundbench 1 -t $duration"
1889 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1890 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1891 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1892 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
1894 log "Started rundbench load pid=$pid ..."
1896 # give rundbench a chance to start, bug 24118
1899 local num_failovers=0
1900 local start_ts=$(date +%s)
1901 while [ $elapsed -lt $duration ]; do
1902 if ! check_for_process $clients dbench; then
1903 error_noexit "dbench not found on some of $clients!"
1904 killall_process $clients dbench
1908 replay_barrier $SINGLEMDS
1909 sleep 1 # give clients a time to do operations
1910 # Increment the number of failovers
1911 num_failovers=$((num_failovers+1))
1912 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1914 elapsed=$(($(date +%s) - start_ts))
1917 wait $pid || error "rundbench load on $clients failed!"
1919 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1920 # end multi-client tests
1923 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1927 replay_barrier $SINGLEMDS
1928 #define OBD_FAIL_LDLM_ENQUEUE_NET 0x302
1929 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1932 wait $pid || return 1
1933 [ -e $DIR/$tfile ] && return 2
1936 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1939 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1943 replay_barrier $SINGLEMDS
1944 #define OBD_FAIL_LDLM_REPLY 0x30c
1945 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1948 wait $pid || return 1
1949 [ -e $DIR/$tfile ] && return 2
1952 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1955 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1959 replay_barrier $SINGLEMDS
1960 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1961 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1964 wait $pid || return 1
1965 [ -e $DIR/$tfile ] && return 2
1968 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1972 local clients=${CLIENTS:-$HOSTNAME}
1974 zconf_umount_clients $clients $MOUNT
1976 facet_failover $SINGLEMDS
1977 zconf_mount_clients $clients $MOUNT
1979 touch $DIR/$tfile || return 1
1980 rm $DIR/$tfile || return 2
1981 clients_up || error "client evicted: $?"
1984 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1986 remote_dir_check_80() {
1988 local diridx=$($GETSTRIPE -M $remote_dir)
1989 [ $diridx -eq $MDTIDX ] || error "$diridx != $MDTIDX"
1991 createmany -o $remote_dir/f-%d 20 || error "creation failed"
1992 local fileidx=$($GETSTRIPE -M $remote_dir/f-1)
1993 [ $fileidx -eq $MDTIDX ] || error "$fileidx != $MDTIDX"
1999 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2000 ([ $FAILURE_MODE == "HARD" ] &&
2001 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2002 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2006 local remote_dir=$DIR/$tdir/remote_dir
2009 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2010 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x188
2011 $LFS mkdir -i $MDTIDX $remote_dir &
2013 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2015 fail mds$((MDTIDX + 1))
2017 wait $CLIENT_PID || error "remote creation failed"
2019 remote_dir_check_80 || error "remote dir check failed"
2020 rm -rf $DIR/$tdir || error "rmdir failed"
2024 run_test 80a "DNE: create remote dir, drop update rep from MDT1, fail MDT1"
2027 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2028 ([ $FAILURE_MODE == "HARD" ] &&
2029 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2030 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2034 local remote_dir=$DIR/$tdir/remote_dir
2037 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2038 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x188
2039 $LFS mkdir -i $MDTIDX $remote_dir &
2041 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2045 wait $CLIENT_PID || error "remote creation failed"
2047 remote_dir_check_80 || error "remote dir check failed"
2048 rm -rf $DIR/$tdir || error "rmdir failed"
2052 run_test 80b "DNE: create remote dir, drop update rep from MDT1, fail MDT0"
2055 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2056 ([ $FAILURE_MODE == "HARD" ] &&
2057 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2058 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2062 local remote_dir=$DIR/$tdir/remote_dir
2065 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2066 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x188
2067 $LFS mkdir -i $MDTIDX $remote_dir &
2069 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2072 fail mds$((MDTIDX + 1))
2074 wait $CLIENT_PID || error "remote creation failed"
2076 remote_dir_check_80 || error "remote dir check failed"
2077 rm -rf $DIR/$tdir || error "rmdir failed"
2081 run_test 80c "DNE: create remote dir, drop update rep from MDT1, fail MDT[0,1]"
2084 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2086 local remote_dir=$DIR/$tdir/remote_dir
2089 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2090 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0x188
2091 $LFS mkdir -i $MDTIDX $remote_dir &
2093 do_facet mds$((MDTIDX + 1)) lctl set_param fail_loc=0
2095 fail mds${MDTIDX},mds$((MDTIDX + 1))
2097 wait $CLIENT_PID || error "remote creation failed"
2099 remote_dir_check_80 || error "remote dir check failed"
2100 rm -rf $DIR/$tdir || error "rmdir failed"
2104 run_test 80d "DNE: create remote dir, drop update rep from MDT1, fail 2 MDTs"
2107 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2108 ([ $FAILURE_MODE == "HARD" ] &&
2109 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2110 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2114 local remote_dir=$DIR/$tdir/remote_dir
2117 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2118 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2119 $LFS mkdir -i $MDTIDX $remote_dir &
2121 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2125 wait $CLIENT_PID || error "remote creation failed"
2127 remote_dir_check_80 || error "remote dir check failed"
2128 rm -rf $DIR/$tdir || error "rmdir failed"
2132 run_test 80e "DNE: create remote dir, drop MDT0 rep, fail MDT0"
2135 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2136 ([ $FAILURE_MODE == "HARD" ] &&
2137 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2138 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2141 local remote_dir=$DIR/$tdir/remote_dir
2144 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2145 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2146 $LFS mkdir -i $MDTIDX $remote_dir &
2148 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2150 fail mds$((MDTIDX + 1))
2152 wait $CLIENT_PID || error "remote creation failed"
2154 remote_dir_check_80 || error "remote dir check failed"
2155 rm -rf $DIR/$tdir || error "rmdir failed"
2159 run_test 80f "DNE: create remote dir, drop MDT0 rep, fail MDT1"
2162 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2163 ([ $FAILURE_MODE == "HARD" ] &&
2164 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2165 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2169 local remote_dir=$DIR/$tdir/remote_dir
2172 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2173 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2174 $LFS mkdir -i $MDTIDX $remote_dir &
2176 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2179 fail mds$((MDTIDX + 1))
2181 wait $CLIENT_PID || error "remote creation failed"
2183 remote_dir_check_80 || error "remote dir check failed"
2184 rm -rf $DIR/$tdir || error "rmdir failed"
2188 run_test 80g "DNE: create remote dir, drop MDT0 rep, fail MDT0, then MDT1"
2191 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2193 local remote_dir=$DIR/$tdir/remote_dir
2196 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2197 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2198 $LFS mkdir -i $MDTIDX $remote_dir &
2200 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2202 fail mds${MDTIDX},mds$((MDTIDX + 1))
2204 wait $CLIENT_PID || return 1
2206 remote_dir_check_80 || error "remote dir check failed"
2207 rm -rf $DIR/$tdir || error "rmdir failed"
2211 run_test 80h "DNE: create remote dir, drop MDT0 rep, fail 2 MDTs"
2214 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2215 ([ $FAILURE_MODE == "HARD" ] &&
2216 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2217 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2221 local remote_dir=$DIR/$tdir/remote_dir
2224 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2226 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2227 do_facet mds${MDTIDX} lctl set_param fail_loc=0x188
2230 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2232 fail mds$((MDTIDX + 1))
2234 wait $CLIENT_PID || error "rm remote dir failed"
2236 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2238 rm -rf $DIR/$tdir || error "rmdir failed"
2242 run_test 81a "DNE: unlink remote dir, drop MDT0 update rep, fail MDT1"
2245 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2246 ([ $FAILURE_MODE == "HARD" ] &&
2247 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2248 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2251 local remote_dir=$DIR/$tdir/remote_dir
2254 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2256 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2257 do_facet mds${MDTIDX} lctl set_param fail_loc=0x188
2260 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2264 wait $CLIENT_PID || error "rm remote dir failed"
2266 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2268 rm -rf $DIR/$tdir || error "rmdir failed"
2272 run_test 81b "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0"
2275 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2276 ([ $FAILURE_MODE == "HARD" ] &&
2277 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2278 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2282 local remote_dir=$DIR/$tdir/remote_dir
2285 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2287 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2288 do_facet mds${MDTIDX} lctl set_param fail_loc=0x188
2291 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2294 fail mds$((MDTIDX + 1))
2296 wait $CLIENT_PID || error "rm remote dir failed"
2298 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2300 rm -rf $DIR/$tdir || error "rmdir failed"
2304 run_test 81c "DNE: unlink remote dir, drop MDT0 update reply, fail MDT0,MDT1"
2307 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2309 local remote_dir=$DIR/$tdir/remote_dir
2312 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2314 # OBD_FAIL_MDS_DROP_OBJ_UPDATE 0x188
2315 do_facet mds${MDTIDX} lctl set_param fail_loc=0x188
2318 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2320 fail mds${MDTIDX},mds$((MDTIDX + 1))
2322 wait $CLIENT_PID || error "rm remote dir failed"
2324 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2326 rm -rf $DIR/$tdir || error "rmdir failed"
2330 run_test 81d "DNE: unlink remote dir, drop MDT0 update reply, fail 2 MDTs"
2333 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2334 ([ $FAILURE_MODE == "HARD" ] &&
2335 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2336 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2340 local remote_dir=$DIR/$tdir/remote_dir
2343 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2345 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2346 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2349 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2353 wait $CLIENT_PID || error "rm remote dir failed"
2355 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2357 rm -rf $DIR/$tdir || error "rmdir failed"
2361 run_test 81e "DNE: unlink remote dir, drop MDT1 req reply, fail MDT0"
2364 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2365 ([ $FAILURE_MODE == "HARD" ] &&
2366 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2367 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2371 local remote_dir=$DIR/$tdir/remote_dir
2374 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2376 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2377 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2380 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2382 fail mds$((MDTIDX + 1))
2384 wait $CLIENT_PID || error "rm remote dir failed"
2386 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2388 rm -rf $DIR/$tdir || error "rmdir failed"
2392 run_test 81f "DNE: unlink remote dir, drop MDT1 req reply, fail MDT1"
2395 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2396 ([ $FAILURE_MODE == "HARD" ] &&
2397 [ "$(facet_host mds1)" == "$(facet_host mds2)" ]) &&
2398 skip "MDTs needs to be on diff hosts for HARD fail mode" &&
2402 local remote_dir=$DIR/$tdir/remote_dir
2405 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2407 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2408 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2411 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2414 fail mds$((MDTIDX + 1))
2416 wait $CLIENT_PID || error "rm remote dir failed"
2418 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2420 rm -rf $DIR/$tdir || error "rmdir failed"
2424 run_test 81g "DNE: unlink remote dir, drop req reply, fail M0, then M1"
2427 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2429 local remote_dir=$DIR/$tdir/remote_dir
2432 $LFS mkdir -i $MDTIDX $remote_dir || error "lfs mkdir failed"
2434 # OBD_FAIL_MDS_REINT_NET_REP 0x119
2435 do_facet mds${MDTIDX} lctl set_param fail_loc=0x119
2438 do_facet mds${MDTIDX} lctl set_param fail_loc=0
2440 fail mds${MDTIDX},mds$((MDTIDX + 1))
2442 wait $CLIENT_PID || error "rm remote dir failed"
2444 stat $remote_dir 2&>/dev/null && error "$remote_dir still exist!"
2446 rm -rf $DIR/$tdir || error "rmdir failed"
2450 run_test 81h "DNE: unlink remote dir, drop request reply, fail 2 MDTs"
2454 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2455 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2456 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2457 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2459 run_test 83a "fail log_add during unlink recovery"
2463 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2464 replay_barrier $SINGLEMDS
2465 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2466 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2467 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2470 run_test 83b "fail log_add during unlink recovery"
2473 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2474 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2475 createmany -o $DIR/$tfile- 1 &
2479 client_up || client_up || true # reconnect
2481 run_test 84a "stale open during export disconnect"
2483 test_85a() { #bug 16774
2484 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2486 for i in `seq 100`; do
2487 echo "tag-$i" > $DIR/$tfile-$i
2488 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2491 lov_id=`lctl dl | grep "clilov"`
2492 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2493 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2494 echo "before recovery: unused locks count = $count"
2498 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2499 echo "after recovery: unused locks count = $count2"
2501 if [ $count2 -ge $count ]; then
2502 error "unused locks are not canceled"
2505 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2507 test_85b() { #bug 16774
2508 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2510 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
2511 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 || return 2
2513 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2515 for i in `seq 100`; do
2516 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2519 cancel_lru_locks osc
2521 for i in `seq 100`; do
2522 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2525 lov_id=`lctl dl | grep "clilov"`
2526 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2527 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2528 echo "before recovery: unused locks count = $count"
2529 [ $count != 0 ] || return 3
2533 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2534 echo "after recovery: unused locks count = $count2"
2536 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 || return 4
2537 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
2539 if [ $count2 -ge $count ]; then
2540 error "unused locks are not canceled"
2543 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2546 local clients=${CLIENTS:-$HOSTNAME}
2548 zconf_umount_clients $clients $MOUNT
2549 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2550 remount_facet $SINGLEMDS
2551 zconf_mount_clients $clients $MOUNT
2553 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2556 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2559 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2560 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2561 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2562 cancel_lru_locks osc
2564 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2565 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2566 if [ $cksum != $cksum2 ] ; then
2567 error "New checksum $cksum2 does not match original $cksum"
2570 run_test 87 "write replay"
2573 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2576 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2577 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2578 sleep 1 # Give it a chance to flush dirty data
2579 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2580 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2581 cancel_lru_locks osc
2583 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2584 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2585 if [ $cksum != $cksum2 ] ; then
2586 error "New checksum $cksum2 does not match original $cksum"
2589 run_test 87b "write replay with changed data (checksum resend)"
2591 test_88() { #bug 17485
2595 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2598 replay_barrier $SINGLEMDS
2600 # exhaust precreations on ost1
2601 local OST=$(ostname_from_index 0)
2602 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2603 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2604 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2605 echo "before test: last_id = $last_id, next_id = $next_id"
2607 echo "Creating to objid $last_id on ost $OST..."
2608 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2610 #create some files to use some uncommitted objids
2611 last_id=$(($last_id + 1))
2612 createmany -o $DIR/$tdir/f-%d $last_id 8
2614 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2615 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2616 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2618 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2619 # it has to take care about the affected facets, bug20407
2620 local affected_mds1=$(affected_facets mds1)
2621 local affected_ost1=$(affected_facets ost1)
2623 shutdown_facet $SINGLEMDS
2626 reboot_facet $SINGLEMDS
2627 change_active $affected_mds1
2628 wait_for_facet $affected_mds1
2629 mount_facets $affected_mds1 || error "Restart of mds failed"
2632 change_active $affected_ost1
2633 wait_for_facet $affected_ost1
2634 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2638 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2639 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2640 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2642 # create new files, which should use new objids, and ensure the orphan
2643 # cleanup phase for ost1 is completed at the same time
2644 for i in `seq 8`; do
2645 file_id=$(($last_id + 10 + $i))
2646 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2649 # if the objids were not recreated, then "ls" will failed for -ENOENT
2650 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2653 # write into previously created files
2654 for i in `seq 8`; do
2655 file_id=$(($last_id + $i))
2656 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2657 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2660 # compare the content
2661 for i in `seq 8`; do
2662 file_id=$(($last_id + $i))
2663 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2664 "of file is modified!"
2669 run_test 88 "MDS should not assign same objid to different files "
2672 cancel_lru_locks osc
2674 rm -f $DIR/$tdir/$tfile
2676 wait_delete_completed
2677 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2678 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2679 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2682 facet_failover $SINGLEMDS
2683 rm $DIR/$tdir/$tfile
2686 zconf_mount $(hostname) $MOUNT
2687 client_up || return 1
2689 wait_delete_completed
2690 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2691 [ $((BLOCKS2 - BLOCKS1)) -le 4 ] || \
2692 error $((BLOCKS2 - BLOCKS1)) blocks leaked
2695 run_test 89 "no disk space leak on late ost connection"
2701 change_active $facet
2702 wait_for_facet $facet
2703 mount_facet $facet || error "Restart of $facet failed"
2707 test_90() { # bug 19494
2708 local dir=$DIR/$tdir
2709 local ostfail=$(get_random_entry $(get_facets OST))
2711 if [[ $FAILURE_MODE = HARD ]]; then
2712 local affected=$(affected_facets $ostfail);
2713 if [[ "$affected" != $ostfail ]]; then
2714 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2721 echo "Create the files"
2723 # file "f${index}" striped over 1 OST
2724 # file "all" striped over all OSTs
2726 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2727 error "setstripe failed to create $dir/all"
2729 for (( i=0; i<$OSTCOUNT; i++ )); do
2731 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2733 # confirm setstripe actually created the stripe on the requested OST
2734 local uuid=$(ostuuid_from_index $i)
2735 for file in f$i all; do
2736 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2737 $GETSTRIPE $dir/file
2738 error wrong stripe: $file, uuid: $uuid
2743 # Before failing an OST, get its obd name and index
2744 local varsvc=${ostfail}_svc
2745 local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
2746 local index=${obd:(-6):1}
2748 echo "Fail $ostfail $obd, display the list of affected files"
2749 shutdown_facet $ostfail || return 2
2751 trap "cleanup_90 $ostfail" EXIT INT
2752 echo "General Query: lfs find $dir"
2753 local list=$($LFS find $dir)
2755 for (( i=0; i<$OSTCOUNT; i++ )); do
2756 list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
2758 list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
2760 # focus on the missing OST,
2761 # we expect to see only two files affected: "f$(index)" and "all"
2763 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2764 list=$($LFS find --obd $obd $dir)
2766 for file in all f$index; do
2767 list_member "$list" $dir/$file ||
2768 error_noexit "lfs find does not report the affected $obd for $file"
2771 [[ $(echo $list | wc -w) -eq 2 ]] ||
2772 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2774 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2775 list=$($GETSTRIPE -r --obd $obd $dir)
2777 for file in all f$index; do
2778 echo "$list" | grep $dir/$file ||
2779 error_noexit "lfs getsripe does not report the affected $obd for $file"
2784 run_test 90 "lfs find identifies the missing striped file segments"
2787 check_and_cleanup_lustre