7 # This test needs to be run on the client
10 LUSTRE=${LUSTRE:-$(cd $(dirname $0)/..; echo $PWD)}
13 . $LUSTRE/tests/test-framework.sh
15 . ${CONFIG:=$LUSTRE/tests/cfg/$NAME.sh}
17 CHECK_GRANT=${CHECK_GRANT:-"yes"}
18 GRANT_CHECK_LIST=${GRANT_CHECK_LIST:-""}
20 require_dsh_mds || exit 0
23 # bug number: 17466 18857
24 ALWAYS_EXCEPT="61d 33a 33b $REPLAY_SINGLE_EXCEPT"
26 # 63 min 7 min AT AT AT AT"
27 [ "$SLOW" = "no" ] && EXCEPT_SLOW="1 2 3 4 6 12 16 44a 44b 65 66 67 68"
31 check_and_setup_lustre
36 rm -rf $DIR/[df][0-9]*
38 test_0a() { # was test_0
41 replay_barrier $SINGLEMDS
45 run_test 0a "empty replay"
48 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
50 # this test attempts to trigger a race in the precreation code,
51 # and must run before any other objects are created on the filesystem
53 createmany -o $DIR/$tfile 20 || return 1
54 unlinkmany $DIR/$tfile 20 || return 2
56 run_test 0b "ensure object created after recover exists. (3284)"
59 replay_barrier $SINGLEMDS
61 facet_failover $SINGLEMDS
62 zconf_mount `hostname` $MOUNT || error "mount fails"
63 client_up || error "post-failover df failed"
65 run_test 0d "expired recovery with no clients"
68 replay_barrier $SINGLEMDS
71 $CHECKSTAT -t file $DIR/$tfile || return 1
74 run_test 1 "simple create"
77 replay_barrier $SINGLEMDS
80 $CHECKSTAT -t file $DIR/$tfile || return 1
87 replay_barrier $SINGLEMDS
90 $CHECKSTAT -t file $DIR/$tfile || return 1
96 local file=$DIR/$tfile
97 replay_barrier $SINGLEMDS
99 openfile -f O_DIRECTORY $file
101 $CHECKSTAT -t file $file || return 2
104 run_test 3a "replay failed open(O_DIRECTORY)"
107 replay_barrier $SINGLEMDS
108 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
109 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
111 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
113 $CHECKSTAT -t file $DIR/$tfile && return 2
116 run_test 3b "replay failed open -ENOMEM"
119 replay_barrier $SINGLEMDS
120 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
121 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
123 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
126 $CHECKSTAT -t file $DIR/$tfile && return 2
129 run_test 3c "replay failed open -ENOMEM"
131 test_4a() { # was test_4
132 replay_barrier $SINGLEMDS
133 for i in `seq 10`; do
134 echo "tag-$i" > $DIR/$tfile-$i
137 for i in `seq 10`; do
138 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
141 run_test 4a "|x| 10 open(O_CREAT)s"
144 replay_barrier $SINGLEMDS
147 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
149 run_test 4b "|x| rm 10 files"
151 # The idea is to get past the first block of precreated files on both
152 # osts, and then replay.
154 replay_barrier $SINGLEMDS
155 for i in `seq 220`; do
156 echo "tag-$i" > $DIR/$tfile-$i
159 for i in `seq 220`; do
160 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
164 # waiting for commitment of removal
166 run_test 5 "|x| 220 open(O_CREAT)"
169 test_6a() { # was test_6
171 replay_barrier $SINGLEMDS
172 mcreate $DIR/$tdir/$tfile
174 $CHECKSTAT -t dir $DIR/$tdir || return 1
175 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
177 # waiting for log process thread
179 run_test 6a "mkdir + contained create"
183 replay_barrier $SINGLEMDS
186 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
188 run_test 6b "|X| rmdir"
192 replay_barrier $SINGLEMDS
193 mcreate $DIR/$tdir/$tfile
195 $CHECKSTAT -t dir $DIR/$tdir || return 1
196 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
199 run_test 7 "mkdir |X| contained create"
202 # make sure no side-effect from previous test.
204 replay_barrier $SINGLEMDS
205 multiop_bg_pause $DIR/$tfile mo_c || return 4
209 $CHECKSTAT -t file $DIR/$tfile || return 1
210 kill -USR1 $MULTIPID || return 2
211 wait $MULTIPID || return 3
214 run_test 8 "creat open |X| close"
217 replay_barrier $SINGLEMDS
219 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
221 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
223 echo " old_inum == $old_inum, new_inum == $new_inum"
224 if [ $old_inum -eq $new_inum ] ;
226 echo " old_inum and new_inum match"
228 echo "!!!! old_inum and new_inum NOT match"
233 run_test 9 "|X| create (same inum/gen)"
237 replay_barrier $SINGLEMDS
238 mv $DIR/$tfile $DIR/$tfile-2
241 $CHECKSTAT $DIR/$tfile && return 1
242 $CHECKSTAT $DIR/$tfile-2 ||return 2
246 run_test 10 "create |X| rename unlink"
250 echo "old" > $DIR/$tfile
251 mv $DIR/$tfile $DIR/$tfile-2
252 replay_barrier $SINGLEMDS
253 echo "new" > $DIR/$tfile
255 grep old $DIR/$tfile-2
257 grep new $DIR/$tfile || return 1
258 grep old $DIR/$tfile-2 || return 2
260 run_test 11 "create open write rename |X| create-old-name read"
264 multiop_bg_pause $DIR/$tfile o_tSc || return 3
267 replay_barrier $SINGLEMDS
269 wait $pid || return 1
272 [ -e $DIR/$tfile ] && return 2
275 run_test 12 "open, unlink |X| close"
278 # 1777 - replay open after committed chmod that would make
279 # a regular open a failure
282 multiop_bg_pause $DIR/$tfile O_wc || return 3
285 $CHECKSTAT -p 0 $DIR/$tfile
286 replay_barrier $SINGLEMDS
289 wait $pid || return 1
291 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
292 rm $DIR/$tfile || return 4
295 run_test 13 "open chmod 0 |x| write close"
298 multiop_bg_pause $DIR/$tfile O_tSc || return 4
301 replay_barrier $SINGLEMDS
302 kill -USR1 $pid || return 1
303 wait $pid || return 2
306 [ -e $DIR/$tfile ] && return 3
309 run_test 14 "open(O_CREAT), unlink |X| close"
312 multiop_bg_pause $DIR/$tfile O_tSc || return 5
315 replay_barrier $SINGLEMDS
316 touch $DIR/g11 || return 1
318 wait $pid || return 2
321 [ -e $DIR/$tfile ] && return 3
322 touch $DIR/h11 || return 4
325 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
329 replay_barrier $SINGLEMDS
332 mcreate $DIR/$tfile-2
334 [ -e $DIR/$tfile ] && return 1
335 [ -e $DIR/$tfile-2 ] || return 2
336 munlink $DIR/$tfile-2 || return 3
338 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
341 replay_barrier $SINGLEMDS
342 multiop_bg_pause $DIR/$tfile O_c || return 4
345 kill -USR1 $pid || return 1
346 wait $pid || return 2
347 $CHECKSTAT -t file $DIR/$tfile || return 3
350 run_test 17 "|X| open(O_CREAT), |replay| close"
353 replay_barrier $SINGLEMDS
354 multiop_bg_pause $DIR/$tfile O_tSc || return 8
357 touch $DIR/$tfile-2 || return 1
358 echo "pid: $pid will close"
360 wait $pid || return 2
363 [ -e $DIR/$tfile ] && return 3
364 [ -e $DIR/$tfile-2 ] || return 4
365 # this touch frequently fails
366 touch $DIR/$tfile-3 || return 5
367 munlink $DIR/$tfile-2 || return 6
368 munlink $DIR/$tfile-3 || return 7
371 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
373 # bug 1855 (a simpler form of test_11 above)
375 replay_barrier $SINGLEMDS
377 echo "old" > $DIR/$tfile
378 mv $DIR/$tfile $DIR/$tfile-2
379 grep old $DIR/$tfile-2
381 grep old $DIR/$tfile-2 || return 2
383 run_test 19 "|X| mcreate, open, write, rename "
385 test_20a() { # was test_20
386 replay_barrier $SINGLEMDS
387 multiop_bg_pause $DIR/$tfile O_tSc || return 3
393 wait $pid || return 1
394 [ -e $DIR/$tfile ] && return 2
397 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
399 test_20b() { # bug 10480
400 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
402 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
404 while [ ! -e $DIR/$tfile ] ; do
405 usleep 60 # give dd a chance to start
408 lfs getstripe $DIR/$tfile || return 1
409 rm -f $DIR/$tfile || return 2 # make it an orphan
411 client_up || client_up || true # reconnect
413 fail $SINGLEMDS # start orphan recovery
414 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
415 wait_mds_ost_sync || return 3
416 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
417 log "before $BEFOREUSED, after $AFTERUSED"
418 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
419 error "after $AFTERUSED > before $BEFOREUSED"
422 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
424 test_20c() { # bug 10480
425 multiop_bg_pause $DIR/$tfile Ow_c || return 1
431 client_up || client_up || true # reconnect
434 wait $pid || return 1
435 [ -s $DIR/$tfile ] || error "File was truncated"
439 run_test 20c "check that client eviction does not affect file content"
442 replay_barrier $SINGLEMDS
443 multiop_bg_pause $DIR/$tfile O_tSc || return 5
446 touch $DIR/g11 || return 1
450 wait $pid || return 2
451 [ -e $DIR/$tfile ] && return 3
452 touch $DIR/h11 || return 4
455 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
458 multiop_bg_pause $DIR/$tfile O_tSc || return 3
461 replay_barrier $SINGLEMDS
466 wait $pid || return 1
467 [ -e $DIR/$tfile ] && return 2
470 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
473 multiop_bg_pause $DIR/$tfile O_tSc || return 5
476 replay_barrier $SINGLEMDS
478 touch $DIR/g11 || return 1
482 wait $pid || return 2
483 [ -e $DIR/$tfile ] && return 3
484 touch $DIR/h11 || return 4
487 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
490 multiop_bg_pause $DIR/$tfile O_tSc || return 3
493 replay_barrier $SINGLEMDS
497 wait $pid || return 1
498 [ -e $DIR/$tfile ] && return 2
501 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
504 multiop_bg_pause $DIR/$tfile O_tSc || return 3
508 replay_barrier $SINGLEMDS
511 wait $pid || return 1
512 [ -e $DIR/$tfile ] && return 2
515 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
518 replay_barrier $SINGLEMDS
519 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
521 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
526 wait $pid2 || return 1
530 wait $pid1 || return 2
531 [ -e $DIR/$tfile-1 ] && return 3
532 [ -e $DIR/$tfile-2 ] && return 4
535 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
538 replay_barrier $SINGLEMDS
539 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
541 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
548 wait $pid1 || return 1
550 wait $pid2 || return 2
551 [ -e $DIR/$tfile-1 ] && return 3
552 [ -e $DIR/$tfile-2 ] && return 4
555 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
558 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
560 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
562 replay_barrier $SINGLEMDS
566 wait $pid2 || return 1
570 wait $pid1 || return 2
571 [ -e $DIR/$tfile-1 ] && return 3
572 [ -e $DIR/$tfile-2 ] && return 4
575 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
578 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
580 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
582 replay_barrier $SINGLEMDS
588 wait $pid1 || return 1
590 wait $pid2 || return 2
591 [ -e $DIR/$tfile-1 ] && return 3
592 [ -e $DIR/$tfile-2 ] && return 4
595 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
598 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
600 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
605 replay_barrier $SINGLEMDS
608 wait $pid1 || return 1
610 wait $pid2 || return 2
611 [ -e $DIR/$tfile-1 ] && return 3
612 [ -e $DIR/$tfile-2 ] && return 4
615 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
618 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
620 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
624 replay_barrier $SINGLEMDS
628 wait $pid1 || return 1
630 wait $pid2 || return 2
631 [ -e $DIR/$tfile-1 ] && return 3
632 [ -e $DIR/$tfile-2 ] && return 4
635 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
637 # tests for bug 2104; completion without crashing is success. The close is
638 # stale, but we always return 0 for close, so the app never sees it.
640 multiop_bg_pause $DIR/$tfile O_c || return 2
642 multiop_bg_pause $DIR/$tfile O_c || return 3
645 client_up || client_up || return 1
648 wait $pid1 || return 4
649 wait $pid2 || return 5
652 run_test 32 "close() notices client eviction; close() after client eviction"
655 createmany -o $DIR/$tfile-%d 10
656 replay_barrier_nosync $SINGLEMDS
657 fail_abort $SINGLEMDS
658 # recreate shouldn't fail
659 createmany -o $DIR/$tfile--%d 10 || return 1
663 run_test 33a "fid seq shouldn't be reused after abort recovery"
666 #define OBD_FAIL_SEQ_ALLOC 0x1311
667 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
669 createmany -o $DIR/$tfile-%d 10
670 replay_barrier_nosync $SINGLEMDS
671 fail_abort $SINGLEMDS
672 # recreate shouldn't fail
673 createmany -o $DIR/$tfile--%d 10 || return 1
677 run_test 33b "test fid seq allocation"
680 multiop_bg_pause $DIR/$tfile O_c || return 2
684 replay_barrier $SINGLEMDS
685 fail_abort $SINGLEMDS
687 wait $pid || return 3
688 [ -e $DIR/$tfile ] && return 1
692 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
694 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
698 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
699 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
704 # give a chance to remove from MDS
705 fail_abort $SINGLEMDS
706 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
708 run_test 35 "test recovery from llog for unlink op"
710 # b=2432 resent cancel after replay uses wrong cookie,
711 # so don't resend cancels
713 replay_barrier $SINGLEMDS
715 checkstat $DIR/$tfile
716 facet_failover $SINGLEMDS
718 if dmesg | grep "unknown lock cookie"; then
719 echo "cancel after replay failed"
723 run_test 36 "don't resend cancel"
726 # directory orphans can't be unlinked from PENDING directory
728 rmdir $DIR/$tfile 2>/dev/null
729 multiop_bg_pause $DIR/$tfile dD_c || return 2
733 replay_barrier $SINGLEMDS
734 # clear the dmesg buffer so we only see errors from this recovery
736 fail_abort $SINGLEMDS
738 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
739 wait $pid || return 3
743 start_full_debug_logging
744 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
745 stop_full_debug_logging
748 createmany -o $DIR/$tfile-%d 800
749 unlinkmany $DIR/$tfile-%d 0 400
750 replay_barrier $SINGLEMDS
752 unlinkmany $DIR/$tfile-%d 400 400
754 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
756 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
758 test_39() { # bug 4176
759 createmany -o $DIR/$tfile-%d 800
760 replay_barrier $SINGLEMDS
761 unlinkmany $DIR/$tfile-%d 0 400
763 unlinkmany $DIR/$tfile-%d 400 400
765 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
767 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
770 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
775 $LCTL mark multiop $MOUNT/$tfile OS_c
776 multiop $MOUNT/$tfile OS_c &
778 writeme -s $MOUNT/${tfile}-2 &
781 facet_failover $SINGLEMDS
782 #define OBD_FAIL_MDS_CONNECT_NET 0x117
783 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
785 stat1=`count_ost_writes`
787 stat2=`count_ost_writes`
788 echo "$stat1, $stat2"
789 if [ $stat1 -lt $stat2 ]; then
790 echo "writes continuing during recovery"
793 echo "writes not continuing during recovery, bug 2477"
796 echo "waiting for writeme $WRITE_PID"
800 echo "waiting for multiop $PID"
801 wait $PID || return 2
802 do_facet client munlink $MOUNT/$tfile || return 3
803 do_facet client munlink $MOUNT/${tfile}-2 || return 3
806 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
810 # make sure that a read to one osc doesn't try to double-unlock its page just
811 # because another osc is invalid. trigger_group_io used to mistakenly return
812 # an error if any oscs were invalid even after having successfully put rpcs
813 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
814 # the page, guarnateeing that the unlock from the RPC completion would
815 # assert on trying to unlock the unlocked page.
817 [ $OSTCOUNT -lt 2 ] && \
818 skip_env "skipping test 41: we don't have a second OST to test with" && \
821 local f=$MOUNT/$tfile
822 # make sure the start of the file is ost1
823 lfs setstripe $f -s $((128 * 1024)) -i 0
824 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
826 # fail ost2 and read from ost1
827 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
828 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
829 grep $mdtosc | awk '{print $1}')
830 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
831 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
832 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
833 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
836 run_test 41 "read from a valid osc while other oscs are invalid"
838 # test MDS recovery after ost failure
840 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
841 createmany -o $DIR/$tfile-%d 800
843 unlinkmany $DIR/$tfile-%d 0 400
845 lctl set_param debug=-1
848 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
849 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
850 #[ $blocks_after -lt $blocks ] || return 1
851 echo wait for MDS to timeout and recover
852 sleep $((TIMEOUT * 2))
854 unlinkmany $DIR/$tfile-%d 400 400
855 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
857 run_test 42 "recovery after ost failure"
859 # timeout in MDS/OST recovery RPC will LBUG MDS
860 test_43() { # bug 2530
861 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
863 replay_barrier $SINGLEMDS
865 # OBD_FAIL_OST_CREATE_NET 0x204
866 do_facet ost1 "lctl set_param fail_loc=0x80000204"
869 do_facet ost1 "lctl set_param fail_loc=0"
873 run_test 43 "mds osc import failure during recovery; don't LBUG"
875 test_44a() { # was test_44
878 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
879 [ "$mdcdev" ] || return 2
880 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
882 # adaptive timeouts slow this way down
883 if at_is_enabled; then
884 at_max_saved=$(at_max_get mds)
888 for i in `seq 1 10`; do
889 echo "$i of 10 ($(date +%s))"
890 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
891 #define OBD_FAIL_TGT_CONN_RACE 0x701
892 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
893 # lctl below may fail, it is valid case
894 $LCTL --device $mdcdev recover
897 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
898 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
901 run_test 44a "race in target handle connect"
904 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
905 [ "$mdcdev" ] || return 2
906 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
908 for i in `seq 1 10`; do
909 echo "$i of 10 ($(date +%s))"
910 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
911 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
912 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
913 # lctl below may fail, it is valid case
914 $LCTL --device $mdcdev recover
917 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
920 run_test 44b "race in target handle connect"
923 replay_barrier $SINGLEMDS
924 createmany -m $DIR/$tfile-%d 100
925 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
926 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
927 fail_abort $SINGLEMDS
928 unlinkmany $DIR/$tfile-%d 100 && return 1
930 unlinkmany $DIR/$tfile-%d 100 && return 1
933 run_test 44c "race in target handle connect"
935 # Handle failed close
937 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
938 [ "$mdcdev" ] || return 2
939 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
941 $LCTL --device $mdcdev recover || return 6
943 multiop_bg_pause $DIR/$tfile O_c || return 1
946 # This will cause the CLOSE to fail before even
947 # allocating a reply buffer
948 $LCTL --device $mdcdev deactivate || return 4
952 wait $pid || return 1
954 $LCTL --device $mdcdev activate || return 5
957 $CHECKSTAT -t file $DIR/$tfile || return 2
960 run_test 45 "Handle failed close"
964 drop_reply "touch $DIR/$tfile"
966 # ironically, the previous test, 45, will cause a real forced close,
967 # so just look for one for this test
968 dmesg | grep -i "force closing client file handle for $tfile" && return 1
971 run_test 46 "Don't leak file handle after open resend (3325)"
973 test_47() { # bug 2824
974 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
976 # create some files to make sure precreate has been done on all
977 # OSTs. (just in case this test is run independently)
978 createmany -o $DIR/$tfile 20 || return 1
980 # OBD_FAIL_OST_CREATE_NET 0x204
982 do_facet ost1 "lctl set_param fail_loc=0x80000204"
983 client_up || return 2
985 # let the MDS discover the OST failure, attempt to recover, fail
987 sleep $((3 * TIMEOUT))
989 # Without 2824, this createmany would hang
990 createmany -o $DIR/$tfile 20 || return 3
991 unlinkmany $DIR/$tfile 20 || return 4
993 do_facet ost1 "lctl set_param fail_loc=0"
996 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
999 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1000 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1002 replay_barrier $SINGLEMDS
1003 createmany -o $DIR/$tfile 20 || return 1
1004 # OBD_FAIL_OST_EROFS 0x216
1005 facet_failover $SINGLEMDS
1006 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1007 client_up || return 2
1009 createmany -o $DIR/$tfile 20 20 || return 2
1010 unlinkmany $DIR/$tfile 40 || return 3
1013 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1016 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1017 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1018 grep $mdtosc | awk '{print $1}')
1019 [ "$oscdev" ] || return 1
1020 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1021 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1022 # give the mds_lov_sync threads a chance to run
1025 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1027 # b3764 timed out lock replay
1030 cancel_lru_locks mdc
1032 multiop $DIR/$tfile s || return 1
1033 replay_barrier $SINGLEMDS
1034 #define OBD_FAIL_LDLM_REPLY 0x30c
1035 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1036 fail $SINGLEMDS || return 2
1037 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1039 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1041 run_test 52 "time out lock replay (3764)"
1043 # bug 3462 - simultaneous MDC requests
1045 cancel_lru_locks mdc # cleanup locks from former test cases
1046 mkdir -p $DIR/${tdir}-1
1047 mkdir -p $DIR/${tdir}-2
1048 multiop $DIR/${tdir}-1/f O_c &
1050 # give multiop a change to open
1053 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1054 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1055 kill -USR1 $close_pid
1056 cancel_lru_locks mdc # force the close
1057 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1059 mcreate $DIR/${tdir}-2/f || return 1
1061 # close should still be here
1062 [ -d /proc/$close_pid ] || return 2
1064 replay_barrier_nodf $SINGLEMDS
1066 wait $close_pid || return 3
1068 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1069 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1070 rm -rf $DIR/${tdir}-*
1072 run_test 53a "|X| close request while two MDC requests in flight"
1075 cancel_lru_locks mdc # cleanup locks from former test cases
1076 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1078 mkdir -p $DIR/${tdir}-1
1079 mkdir -p $DIR/${tdir}-2
1080 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1083 #define OBD_FAIL_MDS_REINT_NET 0x107
1084 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1085 mcreate $DIR/${tdir}-2/f &
1089 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1090 kill -USR1 $close_pid
1091 cancel_lru_locks mdc # force the close
1092 wait $close_pid || return 1
1093 # open should still be here
1094 [ -d /proc/$open_pid ] || return 2
1096 replay_barrier_nodf $SINGLEMDS
1098 wait $open_pid || return 3
1100 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1101 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1102 rm -rf $DIR/${tdir}-*
1104 run_test 53b "|X| open request while two MDC requests in flight"
1107 cancel_lru_locks mdc # cleanup locks from former test cases
1108 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1110 mkdir -p $DIR/${tdir}-1
1111 mkdir -p $DIR/${tdir}-2
1112 multiop $DIR/${tdir}-1/f O_c &
1115 #define OBD_FAIL_MDS_REINT_NET 0x107
1116 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1117 mcreate $DIR/${tdir}-2/f &
1121 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1122 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1123 kill -USR1 $close_pid
1124 cancel_lru_locks mdc # force the close
1126 #bz20647: make sure all pids are exists before failover
1127 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1128 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1129 replay_barrier_nodf $SINGLEMDS
1130 fail_nodf $SINGLEMDS
1131 wait $open_pid || return 1
1133 # close should be gone
1134 [ -d /proc/$close_pid ] && return 2
1135 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1137 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1138 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1139 rm -rf $DIR/${tdir}-*
1141 run_test 53c "|X| open request and close request while two MDC requests in flight"
1144 cancel_lru_locks mdc # cleanup locks from former test cases
1145 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1147 mkdir -p $DIR/${tdir}-1
1148 mkdir -p $DIR/${tdir}-2
1149 multiop $DIR/${tdir}-1/f O_c &
1151 # give multiop a chance to open
1154 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1155 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1156 kill -USR1 $close_pid
1157 cancel_lru_locks mdc # force the close
1158 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1159 mcreate $DIR/${tdir}-2/f || return 1
1161 # close should still be here
1162 [ -d /proc/$close_pid ] || return 2
1164 wait $close_pid || return 3
1166 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1167 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1168 rm -rf $DIR/${tdir}-*
1170 run_test 53d "|X| close reply while two MDC requests in flight"
1173 cancel_lru_locks mdc # cleanup locks from former test cases
1174 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1176 mkdir -p $DIR/${tdir}-1
1177 mkdir -p $DIR/${tdir}-2
1178 multiop $DIR/${tdir}-1/f O_c &
1181 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1182 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1183 mcreate $DIR/${tdir}-2/f &
1187 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1188 kill -USR1 $close_pid
1189 cancel_lru_locks mdc # force the close
1190 wait $close_pid || return 1
1191 # open should still be here
1192 [ -d /proc/$open_pid ] || return 2
1194 replay_barrier_nodf $SINGLEMDS
1196 wait $open_pid || return 3
1198 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1199 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1200 rm -rf $DIR/${tdir}-*
1202 run_test 53e "|X| open reply while two MDC requests in flight"
1205 cancel_lru_locks mdc # cleanup locks from former test cases
1206 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1208 mkdir -p $DIR/${tdir}-1
1209 mkdir -p $DIR/${tdir}-2
1210 multiop $DIR/${tdir}-1/f O_c &
1213 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1214 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1215 mcreate $DIR/${tdir}-2/f &
1219 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1220 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1221 kill -USR1 $close_pid
1222 cancel_lru_locks mdc # force the close
1224 #bz20647: make sure all pids are exists before failover
1225 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1226 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1227 replay_barrier_nodf $SINGLEMDS
1228 fail_nodf $SINGLEMDS
1229 wait $open_pid || return 1
1231 # close should be gone
1232 [ -d /proc/$close_pid ] && return 2
1233 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1235 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1236 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1237 rm -rf $DIR/${tdir}-*
1239 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1242 cancel_lru_locks mdc # cleanup locks from former test cases
1243 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1245 mkdir -p $DIR/${tdir}-1
1246 mkdir -p $DIR/${tdir}-2
1247 multiop $DIR/${tdir}-1/f O_c &
1250 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1251 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1252 mcreate $DIR/${tdir}-2/f &
1256 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1257 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1258 kill -USR1 $close_pid
1259 cancel_lru_locks mdc # force the close
1260 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1262 #bz20647: make sure all pids are exists before failover
1263 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1264 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1265 replay_barrier_nodf $SINGLEMDS
1266 fail_nodf $SINGLEMDS
1267 wait $open_pid || return 1
1269 # close should be gone
1270 [ -d /proc/$close_pid ] && return 2
1272 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1273 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1274 rm -rf $DIR/${tdir}-*
1276 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1279 cancel_lru_locks mdc # cleanup locks from former test cases
1280 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1282 mkdir -p $DIR/${tdir}-1
1283 mkdir -p $DIR/${tdir}-2
1284 multiop $DIR/${tdir}-1/f O_c &
1287 #define OBD_FAIL_MDS_REINT_NET 0x107
1288 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1289 mcreate $DIR/${tdir}-2/f &
1293 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1294 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1295 kill -USR1 $close_pid
1296 cancel_lru_locks mdc # force the close
1299 #bz20647: make sure all pids are exists before failover
1300 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1301 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1302 replay_barrier_nodf $SINGLEMDS
1303 fail_nodf $SINGLEMDS
1304 wait $open_pid || return 1
1306 # close should be gone
1307 [ -d /proc/$close_pid ] && return 2
1308 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1310 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1311 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1312 rm -rf $DIR/${tdir}-*
1314 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1316 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1318 #b3761 ASSERTION(hash != 0) failed
1320 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1321 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1323 # give touch a chance to run
1325 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1329 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1331 #b3440 ASSERTION(rec->ur_fid2->id) failed
1333 ln -s foo $DIR/$tfile
1334 replay_barrier $SINGLEMDS
1335 #drop_reply "cat $DIR/$tfile"
1339 run_test 56 "don't replay a symlink open request (3440)"
1341 #recovery one mds-ost setattr from llog
1343 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1344 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1346 replay_barrier $SINGLEMDS
1349 $CHECKSTAT -t file $DIR/$tfile || return 1
1350 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1353 run_test 57 "test recovery from llog for setattr op"
1355 #recovery many mds-ost setattr from llog
1358 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1359 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1360 createmany -o $DIR/$tdir/$tfile-%d 2500
1361 replay_barrier $SINGLEMDS
1364 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1365 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1366 unlinkmany $DIR/$tdir/$tfile-%d 2500
1369 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1372 mount_client $MOUNT2
1374 touch $DIR/$tdir/$tfile
1375 replay_barrier $SINGLEMDS
1376 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1378 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1379 [ x$VAL = x"bar" ] || return 1
1380 rm -f $DIR/$tdir/$tfile
1382 zconf_umount `hostname` $MOUNT2
1384 run_test 58b "test replay of setxattr op"
1386 test_58c() { # bug 16570
1387 mount_client $MOUNT2
1389 touch $DIR/$tdir/$tfile
1390 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1392 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1393 [ x$VAL = x"bar" ] || return 2
1394 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1396 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1397 [ x$VAL = x"bar1" ] || return 4
1398 rm -f $DIR/$tdir/$tfile
1400 zconf_umount `hostname` $MOUNT2
1402 run_test 58c "resend/reconstruct setxattr op"
1404 # log_commit_thread vs filter_destroy race used to lead to import use after free
1407 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1410 createmany -o $DIR/$tdir/$tfile-%d 200
1412 unlinkmany $DIR/$tdir/$tfile-%d 200
1413 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1414 do_facet ost1 "lctl set_param fail_loc=0x507"
1417 do_facet ost1 "lctl set_param fail_loc=0x0"
1421 run_test 59 "test log_commit_thread vs filter_destroy race"
1423 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1424 # bug 12086: should no oops and No ctxt error for this test
1427 createmany -o $DIR/$tdir/$tfile-%d 200
1428 replay_barrier $SINGLEMDS
1429 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1431 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1432 local no_ctxt=`dmesg | grep "No ctxt"`
1433 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1435 run_test 60 "test llog post recovery init vs llog unlink"
1437 #test race llog recovery thread vs llog cleanup
1438 test_61a() { # was test_61
1439 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1442 createmany -o $DIR/$tdir/$tfile-%d 800
1444 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1445 unlinkmany $DIR/$tdir/$tfile-%d 800
1446 set_nodes_failloc "$(osts_nodes)" 0x80000221
1451 set_nodes_failloc "$(osts_nodes)" 0x0
1453 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1456 run_test 61a "test race llog recovery vs llog cleanup"
1458 #test race mds llog sync vs llog cleanup
1460 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1461 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1462 facet_failover $SINGLEMDS
1465 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1467 run_test 61b "test race mds llog sync vs llog cleanup"
1469 #test race cancel cookie cb vs llog cleanup
1471 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1473 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1475 set_nodes_failloc "$(osts_nodes)" 0x80000222
1479 set_nodes_failloc "$(osts_nodes)" 0x0
1481 run_test 61c "test race mds llog sync vs llog cleanup"
1483 test_61d() { # bug 16002 # bug 17466 # bug 22137
1484 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1486 do_facet mgs "lctl set_param fail_loc=0x80000605"
1487 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1488 do_facet mgs "lctl set_param fail_loc=0"
1489 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1491 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1493 test_62() { # Bug 15756 - don't mis-drop resent replay
1495 replay_barrier $SINGLEMDS
1496 createmany -o $DIR/$tdir/$tfile- 25
1497 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1498 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1500 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1501 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1504 run_test 62 "don't mis-drop resent replay"
1506 #Adaptive Timeouts (bug 3055)
1514 echo "Cleaning up AT ..."
1515 if [ -n "$ATOLDBASE" ]; then
1516 local at_history=$($LCTL get_param -n at_history)
1517 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1518 do_facet ost1 "lctl set_param at_history=$at_history" || true
1521 if [ $AT_MAX_SET -ne 0 ]; then
1522 for facet in mds client ost; do
1523 var=AT_MAX_SAVE_${facet}
1524 echo restore AT on $facet to saved value ${!var}
1525 at_max_set ${!var} $facet
1526 at_new=$(at_max_get $facet)
1527 echo Restored AT value on $facet $at_new
1528 [ $at_new -eq ${!var} ] || \
1529 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1536 local at_max_new=600
1538 # Save at_max original values
1540 if [ $AT_MAX_SET -eq 0 ]; then
1541 # Suppose that all osts have the same at_max
1542 for facet in mds client ost; do
1543 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1547 for facet in mds client ost; do
1548 at_max=$(at_max_get $facet)
1549 if [ $at_max -ne $at_max_new ]; then
1550 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1551 at_max_set $at_max_new $facet
1556 if [ -z "$ATOLDBASE" ]; then
1557 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1558 # speed up the timebase so we can check decreasing AT
1559 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1560 do_facet ost1 "lctl set_param at_history=8" || true
1562 # sleep for a while to cool down, should be > 8s and also allow
1563 # at least one ping to be sent. simply use TIMEOUT to be safe.
1568 test_65a() #bug 3055
1570 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1572 at_start || return 0
1573 $LCTL dk > /dev/null
1575 $LCTL set_param debug="other"
1576 # Slow down a request to the current service time, this is critical
1577 # because previous tests may have caused this value to increase.
1578 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1579 awk '/portal 12/ {print $5}'`
1580 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1582 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1583 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1584 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1585 createmany -o $DIR/$tfile 10 > /dev/null
1586 unlinkmany $DIR/$tfile 10 > /dev/null
1587 # check for log message
1588 $LCTL dk | grep "Early reply #" || error "No early reply"
1590 # client should show REQ_DELAY estimates
1591 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1593 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1595 run_test 65a "AT: verify early replies"
1597 test_65b() #bug 3055
1599 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1601 at_start || return 0
1604 $LCTL set_param debug="other trace"
1605 $LCTL dk > /dev/null
1606 # Slow down a request to the current service time, this is critical
1607 # because previous tests may have caused this value to increase.
1608 lfs setstripe $DIR/$tfile --index=0 --count=1
1609 multiop $DIR/$tfile Ow1yc
1610 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1611 awk '/portal 6/ {print $5}'`
1612 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1614 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1615 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1616 do_facet ost1 $LCTL set_param fail_loc=0x224
1619 lfs setstripe $DIR/$tfile --index=0 --count=1
1620 # force some real bulk transfer
1621 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1623 do_facet ost1 $LCTL set_param fail_loc=0
1624 # check for log message
1625 $LCTL dk | grep "Early reply #" || error "No early reply"
1627 # client should show REQ_DELAY estimates
1628 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1630 run_test 65b "AT: verify early replies on packed reply / bulk"
1632 test_66a() #bug 3055
1634 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1636 at_start || return 0
1637 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1638 # adjust 5s at a time so no early reply is sent (within deadline)
1639 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1640 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1641 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1642 createmany -o $DIR/$tfile 20 > /dev/null
1643 unlinkmany $DIR/$tfile 20 > /dev/null
1644 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1645 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1646 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1647 createmany -o $DIR/$tfile 20 > /dev/null
1648 unlinkmany $DIR/$tfile 20 > /dev/null
1649 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1650 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1652 createmany -o $DIR/$tfile 20 > /dev/null
1653 unlinkmany $DIR/$tfile 20 > /dev/null
1654 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1655 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1656 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1657 echo "Current MDT timeout $CUR, worst $WORST"
1658 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1660 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1662 test_66b() #bug 3055
1664 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1666 at_start || return 0
1667 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1668 $LCTL set_param fail_val=$(($ORIG + 5))
1669 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1670 $LCTL set_param fail_loc=0x50c
1671 ls $DIR/$tfile > /dev/null 2>&1
1672 $LCTL set_param fail_loc=0
1673 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1674 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1675 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1676 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1678 run_test 66b "AT: verify net latency adjusts"
1680 test_67a() #bug 3055
1682 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1684 at_start || return 0
1685 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1686 # sleeping threads may drive values above this
1687 do_facet ost1 "$LCTL set_param fail_val=400"
1688 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1689 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1690 createmany -o $DIR/$tfile 20 > /dev/null
1691 unlinkmany $DIR/$tfile 20 > /dev/null
1692 do_facet ost1 "$LCTL set_param fail_loc=0"
1693 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1694 ATTEMPTS=$(($CONN2 - $CONN1))
1695 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1696 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1699 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1701 test_67b() #bug 3055
1703 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1705 at_start || return 0
1706 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1708 # exhaust precreations on ost1
1709 local OST=$(ostname_from_index 0)
1710 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1711 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1712 osc.$mdtosc.prealloc_last_id)
1713 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1714 osc.$mdtosc.prealloc_next_id)
1716 mkdir -p $DIR/$tdir/${OST}
1717 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1718 echo "Creating to objid $last_id on ost $OST..."
1719 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1720 do_facet ost1 "$LCTL set_param fail_val=20000"
1721 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1722 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1725 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1727 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1728 ATTEMPTS=$(($CONN2 - $CONN1))
1729 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1730 # do it again; should not timeout
1731 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1732 cp /etc/profile $DIR/$tfile || error "cp failed"
1733 do_facet ost1 "$LCTL set_param fail_loc=0"
1735 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1736 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1737 ATTEMPTS=$(($CONN3 - $CONN2))
1738 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1739 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1742 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1744 test_68 () #bug 13813
1746 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1748 at_start || return 0
1749 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1750 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1751 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1752 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1753 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1754 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1755 echo $TIMEOUT >> $ldlm_enqueue_min
1756 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1760 lfs setstripe $DIR/$tdir --index=0 --count=1
1761 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1762 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1763 $LCTL set_param fail_loc=0x80000312
1764 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1765 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1766 $LCTL set_param fail_loc=0x80000312
1767 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1768 $LCTL set_param fail_loc=0
1770 echo $ENQ_MIN >> $ldlm_enqueue_min
1771 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1775 run_test 68 "AT: verify slowing locks"
1778 # end of AT tests includes above lines
1781 # start multi-client tests
1783 [ -z "$CLIENTS" ] && \
1784 { skip "Need two or more clients." && return; }
1785 [ $CLIENTCOUNT -lt 2 ] && \
1786 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1788 echo "mount clients $CLIENTS ..."
1789 zconf_mount_clients $CLIENTS $MOUNT
1791 local clients=${CLIENTS//,/ }
1792 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1793 for CLIENT in $clients; do
1794 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1795 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1796 error "dd failed on $CLIENT"
1799 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1800 for C in ${CLIENTS//,/ }; do
1801 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1802 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1808 run_test 70a "check multi client t-f"
1810 check_for_process () {
1815 killall_process $clients "$prog" -0
1818 killall_process () {
1819 local clients=${1:-$(hostname)}
1824 do_nodes $clients "killall $signal $name"
1828 local clients=${CLIENTS:-$HOSTNAME}
1830 zconf_mount_clients $clients $MOUNT
1833 [ "$SLOW" = "no" ] && duration=60
1834 # set duration to 900 because it takes some time to boot node
1835 [ "$FAILURE_MODE" = HARD ] && duration=900
1837 local cmd="rundbench 1 -t $duration"
1839 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1840 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1841 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1844 log "Started rundbench load pid=$pid ..."
1846 # give rundbench a chance to start, bug 24118
1849 local num_failovers=0
1850 local start_ts=$(date +%s)
1851 while [ $elapsed -lt $duration ]; do
1852 if ! check_for_process $clients rundbench; then
1853 error_noexit "rundbench not found on some of $clients!"
1854 killall_process $clients dbench
1858 replay_barrier $SINGLEMDS
1859 sleep 1 # give clients a time to do operations
1860 # Increment the number of failovers
1861 num_failovers=$((num_failovers+1))
1862 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1864 elapsed=$(($(date +%s) - start_ts))
1867 wait $pid || error "rundbench load on $clients failed!"
1869 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1870 # end multi-client tests
1873 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1877 replay_barrier $SINGLEMDS
1878 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1879 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1882 wait $pid || return 1
1883 [ -e $DIR/$tfile ] && return 2
1886 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1889 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1893 replay_barrier $SINGLEMDS
1894 #define OBD_FAIL_LDLM_REPLY 0x30c
1895 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1898 wait $pid || return 1
1899 [ -e $DIR/$tfile ] && return 2
1902 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1905 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1909 replay_barrier $SINGLEMDS
1910 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1911 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1914 wait $pid || return 1
1915 [ -e $DIR/$tfile ] && return 2
1918 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1922 local clients=${CLIENTS:-$HOSTNAME}
1925 zconf_umount_clients $clients $MOUNT
1926 facet_failover $SINGLEMDS
1927 zconf_mount_clients $clients $MOUNT
1929 touch $DIR/$tfile || return 1
1930 rm $DIR/$tfile || return 2
1931 clients_up || error "client evicted: $?"
1934 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1941 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1942 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1944 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1947 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1950 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1953 replay_barrier $SINGLEMDS
1954 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1955 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1957 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1960 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1963 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1966 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1968 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1969 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1970 replay_barrier $SINGLEMDS
1971 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1973 stat $DIR/$tdir/f1002
1975 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
1978 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1982 mkdir $dir || error "mkdir $dir failed"
1986 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1988 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
1991 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1994 replay_barrier $SINGLEMDS
1995 mkdir $dir || error "mkdir $dir failed"
1999 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2001 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2005 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2006 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2007 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2008 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2010 run_test 83a "fail log_add during unlink recovery"
2014 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2015 replay_barrier $SINGLEMDS
2016 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2017 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2018 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2021 run_test 83b "fail log_add during unlink recovery"
2024 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2025 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2026 createmany -o $DIR/$tfile- 1 &
2030 client_up || client_up || true # reconnect
2032 run_test 84a "stale open during export disconnect"
2034 test_85a() { #bug 16774
2035 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2037 for i in `seq 100`; do
2038 echo "tag-$i" > $DIR/$tfile-$i
2039 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2042 lov_id=`lctl dl | grep "clilov"`
2043 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2044 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2045 echo "before recovery: unused locks count = $count"
2049 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2050 echo "after recovery: unused locks count = $count2"
2052 if [ $count2 -ge $count ]; then
2053 error "unused locks are not canceled"
2056 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2058 test_85b() { #bug 16774
2059 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2061 lfs setstripe -o 0 -c 1 $DIR
2063 for i in `seq 100`; do
2064 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2067 cancel_lru_locks osc
2069 for i in `seq 100`; do
2070 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2073 lov_id=`lctl dl | grep "clilov"`
2074 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2075 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2076 echo "before recovery: unused locks count = $count"
2080 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2081 echo "after recovery: unused locks count = $count2"
2083 if [ $count2 -ge $count ]; then
2084 error "unused locks are not canceled"
2087 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2090 local clients=${CLIENTS:-$HOSTNAME}
2092 zconf_umount_clients $clients $MOUNT
2093 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2094 remount_facet $SINGLEMDS
2095 zconf_mount_clients $clients $MOUNT
2097 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2100 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2103 lfs setstripe -i 0 -c 1 $DIR/$tfile
2104 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2105 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2106 cancel_lru_locks osc
2108 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2109 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2110 if [ $cksum != $cksum2 ] ; then
2111 error "New checksum $cksum2 does not match original $cksum"
2114 run_test 87 "write replay"
2117 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2120 lfs setstripe -i 0 -c 1 $DIR/$tfile
2121 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2122 sleep 1 # Give it a chance to flush dirty data
2123 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2124 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2125 cancel_lru_locks osc
2127 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2128 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2129 if [ $cksum != $cksum2 ] ; then
2130 error "New checksum $cksum2 does not match original $cksum"
2133 run_test 87b "write replay with changed data (checksum resend)"
2135 test_88() { #bug 17485
2139 lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe"
2142 replay_barrier $SINGLEMDS
2144 # exhaust precreations on ost1
2145 local OST=$(ostname_from_index 0)
2146 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2147 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2148 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2149 echo "before test: last_id = $last_id, next_id = $next_id"
2151 echo "Creating to objid $last_id on ost $OST..."
2152 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2154 #create some files to use some uncommitted objids
2155 last_id=$(($last_id + 1))
2156 createmany -o $DIR/$tdir/f-%d $last_id 8
2158 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2159 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2160 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2162 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2163 # it has to take care about the affected facets, bug20407
2164 local affected_mds1=$(affected_facets mds1)
2165 local affected_ost1=$(affected_facets ost1)
2167 shutdown_facet $SINGLEMDS
2170 reboot_facet $SINGLEMDS
2171 change_active $affected_mds1
2172 wait_for_facet $affected_mds1
2173 mount_facets $affected_mds1 || error "Restart of mds failed"
2176 change_active $affected_ost1
2177 wait_for_facet $affected_ost1
2178 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2182 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2183 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2184 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2186 # create new files, which should use new objids, and ensure the orphan
2187 # cleanup phase for ost1 is completed at the same time
2188 for i in `seq 8`; do
2189 file_id=$(($last_id + 10 + $i))
2190 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2193 # if the objids were not recreated, then "ls" will failed for -ENOENT
2194 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2197 # write into previously created files
2198 for i in `seq 8`; do
2199 file_id=$(($last_id + $i))
2200 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2201 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2204 # compare the content
2205 for i in `seq 8`; do
2206 file_id=$(($last_id + $i))
2207 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2208 "of file is modified!"
2213 run_test 88 "MDS should not assign same objid to different files "
2216 cancel_lru_locks osc
2218 rm -f $DIR/$tdir/$tfile
2220 wait_destroy_complete
2221 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2222 lfs setstripe -i 0 -c 1 $DIR/$tdir/$tfile
2223 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2226 facet_failover $SINGLEMDS
2227 rm $DIR/$tdir/$tfile
2230 zconf_mount $(hostname) $MOUNT
2231 client_up || return 1
2233 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2234 [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2237 run_test 89 "no disk space leak on late ost connection"
2243 change_active $facet
2244 wait_for_facet $facet
2245 mount_facet $facet || error "Restart of $facet failed"
2249 test_90() { # bug 19494
2250 local dir=$DIR/$tdir
2251 local ostfail=$(get_random_entry $(get_facets OST))
2253 if [[ $FAILURE_MODE = HARD ]]; then
2254 local affected=$(affected_facets $ostfail);
2255 if [[ "$affected" != $ostfail ]]; then
2256 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2263 echo "Create the files"
2265 # file "f${index}" striped over 1 OST
2266 # file "all" striped over all OSTs
2268 $LFS setstripe -c $OSTCOUNT $dir/all || error "setstripe failed to create $dir/all"
2270 for (( i=0; i<$OSTCOUNT; i++ )); do
2272 $LFS setstripe -i $i -c 1 $f || error "setstripe failed to create $f"
2274 # confirm that setstripe actually created the stripe on the requested OST
2275 local uuid=$(ostuuid_from_index $i)
2276 for file in f$i all; do
2277 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2278 $LFS getstripe $dir/file
2279 error wrong stripe: $file, uuid: $uuid
2284 # Before failing an OST, get its obd name and index
2285 local varsvc=${ostfail}_svc
2286 local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
2287 local index=${obd:(-6):1}
2289 echo "Fail $ostfail $obd, display the list of affected files"
2290 shutdown_facet $ostfail || return 2
2292 trap "cleanup_90 $ostfail" EXIT INT
2293 echo "General Query: lfs find $dir"
2294 local list=$($LFS find $dir)
2296 for (( i=0; i<$OSTCOUNT; i++ )); do
2297 list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
2299 list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
2301 # focus on the missing OST,
2302 # we expect to see only two files affected: "f$(index)" and "all"
2304 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2305 list=$($LFS find --obd $obd $dir)
2307 for file in all f$index; do
2308 list_member "$list" $dir/$file ||
2309 error_noexit "lfs find does not report the affected $obd for $file"
2312 [[ $(echo $list | wc -w) -eq 2 ]] ||
2313 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2315 echo "Check getstripe: lfs getstripe -r --obd $obd"
2316 list=$($LFS getstripe -r --obd $obd $dir)
2318 for file in all f$index; do
2319 echo "$list" | grep $dir/$file ||
2320 error_noexit "lfs getsripe does not report the affected $obd for $file"
2325 run_test 90 "lfs find identifies the missing striped file segments"
2327 complete $(basename $0) $SECONDS
2328 check_and_cleanup_lustre