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"
922 # Handle failed close
924 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
925 [ "$mdcdev" ] || return 2
926 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
928 $LCTL --device $mdcdev recover || return 6
930 multiop_bg_pause $DIR/$tfile O_c || return 1
933 # This will cause the CLOSE to fail before even
934 # allocating a reply buffer
935 $LCTL --device $mdcdev deactivate || return 4
939 wait $pid || return 1
941 $LCTL --device $mdcdev activate || return 5
944 $CHECKSTAT -t file $DIR/$tfile || return 2
947 run_test 45 "Handle failed close"
951 drop_reply "touch $DIR/$tfile"
953 # ironically, the previous test, 45, will cause a real forced close,
954 # so just look for one for this test
955 dmesg | grep -i "force closing client file handle for $tfile" && return 1
958 run_test 46 "Don't leak file handle after open resend (3325)"
960 test_47() { # bug 2824
961 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
963 # create some files to make sure precreate has been done on all
964 # OSTs. (just in case this test is run independently)
965 createmany -o $DIR/$tfile 20 || return 1
967 # OBD_FAIL_OST_CREATE_NET 0x204
969 do_facet ost1 "lctl set_param fail_loc=0x80000204"
970 client_up || return 2
972 # let the MDS discover the OST failure, attempt to recover, fail
974 sleep $((3 * TIMEOUT))
976 # Without 2824, this createmany would hang
977 createmany -o $DIR/$tfile 20 || return 3
978 unlinkmany $DIR/$tfile 20 || return 4
980 do_facet ost1 "lctl set_param fail_loc=0"
983 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
986 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
987 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
989 replay_barrier $SINGLEMDS
990 createmany -o $DIR/$tfile 20 || return 1
991 # OBD_FAIL_OST_EROFS 0x216
992 facet_failover $SINGLEMDS
993 do_facet ost1 "lctl set_param fail_loc=0x80000216"
994 client_up || return 2
996 createmany -o $DIR/$tfile 20 20 || return 2
997 unlinkmany $DIR/$tfile 40 || return 3
1000 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1003 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1004 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1005 grep $mdtosc | awk '{print $1}')
1006 [ "$oscdev" ] || return 1
1007 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1008 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1009 # give the mds_lov_sync threads a chance to run
1012 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1014 # b3764 timed out lock replay
1017 cancel_lru_locks mdc
1019 multiop $DIR/$tfile s || return 1
1020 replay_barrier $SINGLEMDS
1021 #define OBD_FAIL_LDLM_REPLY 0x30c
1022 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1023 fail $SINGLEMDS || return 2
1024 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1026 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1028 run_test 52 "time out lock replay (3764)"
1030 # bug 3462 - simultaneous MDC requests
1032 cancel_lru_locks mdc # cleanup locks from former test cases
1033 mkdir -p $DIR/${tdir}-1
1034 mkdir -p $DIR/${tdir}-2
1035 multiop $DIR/${tdir}-1/f O_c &
1037 # give multiop a change to open
1040 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1041 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1042 kill -USR1 $close_pid
1043 cancel_lru_locks mdc # force the close
1044 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1046 mcreate $DIR/${tdir}-2/f || return 1
1048 # close should still be here
1049 [ -d /proc/$close_pid ] || return 2
1051 replay_barrier_nodf $SINGLEMDS
1053 wait $close_pid || return 3
1055 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1056 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1057 rm -rf $DIR/${tdir}-*
1059 run_test 53a "|X| close request while two MDC requests in flight"
1062 cancel_lru_locks mdc # cleanup locks from former test cases
1063 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1065 mkdir -p $DIR/${tdir}-1
1066 mkdir -p $DIR/${tdir}-2
1067 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1070 #define OBD_FAIL_MDS_REINT_NET 0x107
1071 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1072 mcreate $DIR/${tdir}-2/f &
1076 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1077 kill -USR1 $close_pid
1078 cancel_lru_locks mdc # force the close
1079 wait $close_pid || return 1
1080 # open should still be here
1081 [ -d /proc/$open_pid ] || return 2
1083 replay_barrier_nodf $SINGLEMDS
1085 wait $open_pid || return 3
1087 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1088 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1089 rm -rf $DIR/${tdir}-*
1091 run_test 53b "|X| open request while two MDC requests in flight"
1094 cancel_lru_locks mdc # cleanup locks from former test cases
1095 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1097 mkdir -p $DIR/${tdir}-1
1098 mkdir -p $DIR/${tdir}-2
1099 multiop $DIR/${tdir}-1/f O_c &
1102 #define OBD_FAIL_MDS_REINT_NET 0x107
1103 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1104 mcreate $DIR/${tdir}-2/f &
1108 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1109 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1110 kill -USR1 $close_pid
1111 cancel_lru_locks mdc # force the close
1113 #bz20647: make sure all pids are exists before failover
1114 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1115 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1116 replay_barrier_nodf $SINGLEMDS
1117 fail_nodf $SINGLEMDS
1118 wait $open_pid || return 1
1120 # close should be gone
1121 [ -d /proc/$close_pid ] && return 2
1122 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1124 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1125 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1126 rm -rf $DIR/${tdir}-*
1128 run_test 53c "|X| open request and close request while two MDC requests in flight"
1131 cancel_lru_locks mdc # cleanup locks from former test cases
1132 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1134 mkdir -p $DIR/${tdir}-1
1135 mkdir -p $DIR/${tdir}-2
1136 multiop $DIR/${tdir}-1/f O_c &
1138 # give multiop a chance to open
1141 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1142 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1143 kill -USR1 $close_pid
1144 cancel_lru_locks mdc # force the close
1145 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1146 mcreate $DIR/${tdir}-2/f || return 1
1148 # close should still be here
1149 [ -d /proc/$close_pid ] || return 2
1151 wait $close_pid || return 3
1153 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1154 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1155 rm -rf $DIR/${tdir}-*
1157 run_test 53d "|X| close reply while two MDC requests in flight"
1160 cancel_lru_locks mdc # cleanup locks from former test cases
1161 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1163 mkdir -p $DIR/${tdir}-1
1164 mkdir -p $DIR/${tdir}-2
1165 multiop $DIR/${tdir}-1/f O_c &
1168 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1169 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1170 mcreate $DIR/${tdir}-2/f &
1174 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1175 kill -USR1 $close_pid
1176 cancel_lru_locks mdc # force the close
1177 wait $close_pid || return 1
1178 # open should still be here
1179 [ -d /proc/$open_pid ] || return 2
1181 replay_barrier_nodf $SINGLEMDS
1183 wait $open_pid || return 3
1185 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1186 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1187 rm -rf $DIR/${tdir}-*
1189 run_test 53e "|X| open reply while two MDC requests in flight"
1192 cancel_lru_locks mdc # cleanup locks from former test cases
1193 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1195 mkdir -p $DIR/${tdir}-1
1196 mkdir -p $DIR/${tdir}-2
1197 multiop $DIR/${tdir}-1/f O_c &
1200 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1201 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1202 mcreate $DIR/${tdir}-2/f &
1206 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1207 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1208 kill -USR1 $close_pid
1209 cancel_lru_locks mdc # force the close
1211 #bz20647: make sure all pids are exists before failover
1212 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1213 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1214 replay_barrier_nodf $SINGLEMDS
1215 fail_nodf $SINGLEMDS
1216 wait $open_pid || return 1
1218 # close should be gone
1219 [ -d /proc/$close_pid ] && return 2
1220 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1222 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1223 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1224 rm -rf $DIR/${tdir}-*
1226 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1229 cancel_lru_locks mdc # cleanup locks from former test cases
1230 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1232 mkdir -p $DIR/${tdir}-1
1233 mkdir -p $DIR/${tdir}-2
1234 multiop $DIR/${tdir}-1/f O_c &
1237 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1238 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1239 mcreate $DIR/${tdir}-2/f &
1243 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1244 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1245 kill -USR1 $close_pid
1246 cancel_lru_locks mdc # force the close
1247 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1249 #bz20647: make sure all pids are exists before failover
1250 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1251 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1252 replay_barrier_nodf $SINGLEMDS
1253 fail_nodf $SINGLEMDS
1254 wait $open_pid || return 1
1256 # close should be gone
1257 [ -d /proc/$close_pid ] && return 2
1259 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1260 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1261 rm -rf $DIR/${tdir}-*
1263 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1266 cancel_lru_locks mdc # cleanup locks from former test cases
1267 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1269 mkdir -p $DIR/${tdir}-1
1270 mkdir -p $DIR/${tdir}-2
1271 multiop $DIR/${tdir}-1/f O_c &
1274 #define OBD_FAIL_MDS_REINT_NET 0x107
1275 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1276 mcreate $DIR/${tdir}-2/f &
1280 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1281 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1282 kill -USR1 $close_pid
1283 cancel_lru_locks mdc # force the close
1286 #bz20647: make sure all pids are exists before failover
1287 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1288 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1289 replay_barrier_nodf $SINGLEMDS
1290 fail_nodf $SINGLEMDS
1291 wait $open_pid || return 1
1293 # close should be gone
1294 [ -d /proc/$close_pid ] && return 2
1295 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1297 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1298 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1299 rm -rf $DIR/${tdir}-*
1301 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1303 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1305 #b3761 ASSERTION(hash != 0) failed
1307 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1308 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1310 # give touch a chance to run
1312 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1316 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1318 #b3440 ASSERTION(rec->ur_fid2->id) failed
1320 ln -s foo $DIR/$tfile
1321 replay_barrier $SINGLEMDS
1322 #drop_reply "cat $DIR/$tfile"
1326 run_test 56 "don't replay a symlink open request (3440)"
1328 #recovery one mds-ost setattr from llog
1330 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1331 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1333 replay_barrier $SINGLEMDS
1336 $CHECKSTAT -t file $DIR/$tfile || return 1
1337 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1340 run_test 57 "test recovery from llog for setattr op"
1342 #recovery many mds-ost setattr from llog
1345 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1346 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1347 createmany -o $DIR/$tdir/$tfile-%d 2500
1348 replay_barrier $SINGLEMDS
1351 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1352 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1353 unlinkmany $DIR/$tdir/$tfile-%d 2500
1356 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1359 mount_client $MOUNT2
1361 touch $DIR/$tdir/$tfile
1362 replay_barrier $SINGLEMDS
1363 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1365 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1366 [ x$VAL = x"bar" ] || return 1
1367 rm -f $DIR/$tdir/$tfile
1369 zconf_umount `hostname` $MOUNT2
1371 run_test 58b "test replay of setxattr op"
1373 test_58c() { # bug 16570
1374 mount_client $MOUNT2
1376 touch $DIR/$tdir/$tfile
1377 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1379 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1380 [ x$VAL = x"bar" ] || return 2
1381 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1383 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1384 [ x$VAL = x"bar1" ] || return 4
1385 rm -f $DIR/$tdir/$tfile
1387 zconf_umount `hostname` $MOUNT2
1389 run_test 58c "resend/reconstruct setxattr op"
1391 # log_commit_thread vs filter_destroy race used to lead to import use after free
1394 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1397 createmany -o $DIR/$tdir/$tfile-%d 200
1399 unlinkmany $DIR/$tdir/$tfile-%d 200
1400 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1401 do_facet ost1 "lctl set_param fail_loc=0x507"
1404 do_facet ost1 "lctl set_param fail_loc=0x0"
1408 run_test 59 "test log_commit_thread vs filter_destroy race"
1410 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1411 # bug 12086: should no oops and No ctxt error for this test
1414 createmany -o $DIR/$tdir/$tfile-%d 200
1415 replay_barrier $SINGLEMDS
1416 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1418 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1419 local no_ctxt=`dmesg | grep "No ctxt"`
1420 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1422 run_test 60 "test llog post recovery init vs llog unlink"
1424 #test race llog recovery thread vs llog cleanup
1425 test_61a() { # was test_61
1426 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1429 createmany -o $DIR/$tdir/$tfile-%d 800
1431 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1432 unlinkmany $DIR/$tdir/$tfile-%d 800
1433 set_nodes_failloc "$(osts_nodes)" 0x80000221
1438 set_nodes_failloc "$(osts_nodes)" 0x0
1440 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1443 run_test 61a "test race llog recovery vs llog cleanup"
1445 #test race mds llog sync vs llog cleanup
1447 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1448 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1449 facet_failover $SINGLEMDS
1452 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1454 run_test 61b "test race mds llog sync vs llog cleanup"
1456 #test race cancel cookie cb vs llog cleanup
1458 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1460 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1462 set_nodes_failloc "$(osts_nodes)" 0x80000222
1466 set_nodes_failloc "$(osts_nodes)" 0x0
1468 run_test 61c "test race mds llog sync vs llog cleanup"
1470 test_61d() { # bug 16002 # bug 17466 # bug 22137
1471 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1473 do_facet mgs "lctl set_param fail_loc=0x80000605"
1474 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1475 do_facet mgs "lctl set_param fail_loc=0"
1476 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1478 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1480 test_62() { # Bug 15756 - don't mis-drop resent replay
1482 replay_barrier $SINGLEMDS
1483 createmany -o $DIR/$tdir/$tfile- 25
1484 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1485 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1488 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1491 run_test 62 "don't mis-drop resent replay"
1493 #Adaptive Timeouts (bug 3055)
1501 echo "Cleaning up AT ..."
1502 if [ -n "$ATOLDBASE" ]; then
1503 local at_history=$($LCTL get_param -n at_history)
1504 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1505 do_facet ost1 "lctl set_param at_history=$at_history" || true
1508 if [ $AT_MAX_SET -ne 0 ]; then
1509 for facet in mds client ost; do
1510 var=AT_MAX_SAVE_${facet}
1511 echo restore AT on $facet to saved value ${!var}
1512 at_max_set ${!var} $facet
1513 at_new=$(at_max_get $facet)
1514 echo Restored AT value on $facet $at_new
1515 [ $at_new -eq ${!var} ] || \
1516 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1523 local at_max_new=600
1525 # Save at_max original values
1527 if [ $AT_MAX_SET -eq 0 ]; then
1528 # Suppose that all osts have the same at_max
1529 for facet in mds client ost; do
1530 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1534 for facet in mds client ost; do
1535 at_max=$(at_max_get $facet)
1536 if [ $at_max -ne $at_max_new ]; then
1537 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1538 at_max_set $at_max_new $facet
1543 if [ -z "$ATOLDBASE" ]; then
1544 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1545 # speed up the timebase so we can check decreasing AT
1546 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1547 do_facet ost1 "lctl set_param at_history=8" || true
1549 # sleep for a while to cool down, should be > 8s and also allow
1550 # at least one ping to be sent. simply use TIMEOUT to be safe.
1555 test_65a() #bug 3055
1557 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1559 at_start || return 0
1560 $LCTL dk > /dev/null
1562 sysctl -w lnet.debug="+other"
1563 # Slow down a request to the current service time, this is critical
1564 # because previous tests may have caused this value to increase.
1565 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1566 awk '/portal 12/ {print $5}'`
1567 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1569 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1570 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1571 do_facet $SINGLEMDS sysctl -w lustre.fail_loc=0x8000050a
1572 createmany -o $DIR/$tfile 10 > /dev/null
1573 unlinkmany $DIR/$tfile 10 > /dev/null
1574 # check for log message
1575 $LCTL dk | grep "Early reply #" || error "No early reply"
1577 # client should show REQ_DELAY estimates
1578 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1580 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1582 run_test 65a "AT: verify early replies"
1584 test_65b() #bug 3055
1586 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1588 at_start || return 0
1591 sysctl -w lnet.debug="other trace"
1592 $LCTL dk > /dev/null
1593 # Slow down a request to the current service time, this is critical
1594 # because previous tests may have caused this value to increase.
1595 lfs setstripe $DIR/$tfile --index=0 --count=1
1596 multiop $DIR/$tfile Ow1yc
1597 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1598 awk '/portal 6/ {print $5}'`
1599 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1601 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1602 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1603 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1606 lfs setstripe $DIR/$tfile --index=0 --count=1
1607 # force some real bulk transfer
1608 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1610 do_facet ost1 sysctl -w lustre.fail_loc=0
1611 # check for log message
1612 $LCTL dk | grep "Early reply #" || error "No early reply"
1614 # client should show REQ_DELAY estimates
1615 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1617 run_test 65b "AT: verify early replies on packed reply / bulk"
1619 test_66a() #bug 3055
1621 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1623 at_start || return 0
1624 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1625 # adjust 5s at a time so no early reply is sent (within deadline)
1626 do_facet $SINGLEMDS "sysctl -w lustre.fail_val=5000"
1627 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1628 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1629 createmany -o $DIR/$tfile 20 > /dev/null
1630 unlinkmany $DIR/$tfile 20 > /dev/null
1631 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1632 do_facet $SINGLEMDS "sysctl -w lustre.fail_val=10000"
1633 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1634 createmany -o $DIR/$tfile 20 > /dev/null
1635 unlinkmany $DIR/$tfile 20 > /dev/null
1636 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1637 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1639 createmany -o $DIR/$tfile 20 > /dev/null
1640 unlinkmany $DIR/$tfile 20 > /dev/null
1641 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1642 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1643 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1644 echo "Current MDT timeout $CUR, worst $WORST"
1645 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1647 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1649 test_66b() #bug 3055
1651 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1653 at_start || return 0
1654 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1655 sysctl -w lustre.fail_val=$(($ORIG + 5))
1656 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1657 sysctl -w lustre.fail_loc=0x50c
1658 ls $DIR/$tfile > /dev/null 2>&1
1659 sysctl -w lustre.fail_loc=0
1660 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1661 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1662 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1663 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1665 run_test 66b "AT: verify net latency adjusts"
1667 test_67a() #bug 3055
1669 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1671 at_start || return 0
1672 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1673 # sleeping threads may drive values above this
1674 do_facet ost1 "sysctl -w lustre.fail_val=400"
1675 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1676 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1677 createmany -o $DIR/$tfile 20 > /dev/null
1678 unlinkmany $DIR/$tfile 20 > /dev/null
1679 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1680 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1681 ATTEMPTS=$(($CONN2 - $CONN1))
1682 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1683 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1686 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1688 test_67b() #bug 3055
1690 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1692 at_start || return 0
1693 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1695 # exhaust precreations on ost1
1696 local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1697 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1698 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1699 osc.$mdtosc.prealloc_last_id)
1700 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1701 osc.$mdtosc.prealloc_next_id)
1703 mkdir -p $DIR/$tdir/${OST}
1704 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1705 echo "Creating to objid $last_id on ost $OST..."
1706 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1707 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1708 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1709 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1712 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1714 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1715 ATTEMPTS=$(($CONN2 - $CONN1))
1716 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1717 # do it again; should not timeout
1718 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1719 cp /etc/profile $DIR/$tfile || error "cp failed"
1720 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1722 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1723 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1724 ATTEMPTS=$(($CONN3 - $CONN2))
1725 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1726 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1729 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1731 test_68 () #bug 13813
1733 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1735 at_start || return 0
1736 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1737 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1738 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1739 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1740 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1741 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1742 echo $TIMEOUT >> $ldlm_enqueue_min
1743 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1747 lfs setstripe $DIR/$tdir --index=0 --count=1
1748 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1749 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1750 sysctl -w lustre.fail_loc=0x80000312
1751 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1752 sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1753 sysctl -w lustre.fail_loc=0x80000312
1754 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1755 sysctl -w lustre.fail_loc=0
1757 echo $ENQ_MIN >> $ldlm_enqueue_min
1758 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1762 run_test 68 "AT: verify slowing locks"
1765 # end of AT tests includes above lines
1768 # start multi-client tests
1770 [ -z "$CLIENTS" ] && \
1771 { skip "Need two or more clients." && return; }
1772 [ $CLIENTCOUNT -lt 2 ] && \
1773 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1775 echo "mount clients $CLIENTS ..."
1776 zconf_mount_clients $CLIENTS $MOUNT
1778 local clients=${CLIENTS//,/ }
1779 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1780 for CLIENT in $clients; do
1781 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1782 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1783 error "dd failed on $CLIENT"
1786 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1787 for C in ${CLIENTS//,/ }; do
1788 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1789 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1795 run_test 70a "check multi client t-f"
1797 check_for_process () {
1802 killall_process $clients "$prog" -0
1805 killall_process () {
1806 local clients=${1:-$(hostname)}
1811 do_nodes $clients "killall $signal $name"
1815 local clients=${CLIENTS:-$HOSTNAME}
1817 zconf_mount_clients $clients $MOUNT
1820 [ "$SLOW" = "no" ] && duration=60
1821 # set duration to 900 because it takes some time to boot node
1822 [ "$FAILURE_MODE" = HARD ] && duration=900
1824 local cmd="rundbench 1 -t $duration"
1826 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1827 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1828 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1831 log "Started rundbench load pid=$pid ..."
1833 # give rundbench a chance to start, bug 24118
1836 local num_failovers=0
1837 local start_ts=$(date +%s)
1838 while [ $elapsed -lt $duration ]; do
1839 if ! check_for_process $clients rundbench; then
1840 error_noexit "rundbench not found on some of $clients!"
1841 killall_process $clients dbench
1845 replay_barrier $SINGLEMDS
1846 sleep 1 # give clients a time to do operations
1847 # Increment the number of failovers
1848 num_failovers=$((num_failovers+1))
1849 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1851 elapsed=$(($(date +%s) - start_ts))
1854 wait $pid || error "rundbench load on $clients failed!"
1856 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1857 # end multi-client tests
1860 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1864 replay_barrier $SINGLEMDS
1865 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1866 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1869 wait $pid || return 1
1870 [ -e $DIR/$tfile ] && return 2
1873 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1876 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1880 replay_barrier $SINGLEMDS
1881 #define OBD_FAIL_LDLM_REPLY 0x30c
1882 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1885 wait $pid || return 1
1886 [ -e $DIR/$tfile ] && return 2
1889 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1892 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1896 replay_barrier $SINGLEMDS
1897 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1898 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1901 wait $pid || return 1
1902 [ -e $DIR/$tfile ] && return 2
1905 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1909 local clients=${CLIENTS:-$HOSTNAME}
1912 zconf_umount_clients $clients $MOUNT
1913 facet_failover $SINGLEMDS
1914 zconf_mount_clients $clients $MOUNT
1916 touch $DIR/$tfile || return 1
1917 rm $DIR/$tfile || return 2
1918 clients_up || error "client evicted: $?"
1921 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1924 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1928 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1929 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1931 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1934 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1937 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1940 replay_barrier $SINGLEMDS
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 80b "CMD: unlink cross-node dir (fail mds with name)"
1950 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1953 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1955 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1956 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1957 replay_barrier $SINGLEMDS
1958 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1960 stat $DIR/$tdir/f1002
1962 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
1965 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1969 mkdir $dir || error "mkdir $dir failed"
1973 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1975 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
1978 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1981 replay_barrier $SINGLEMDS
1982 mkdir $dir || error "mkdir $dir failed"
1986 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
1988 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
1992 createmany -o $DIR/$tdir/$tfile- 10 || return 1
1993 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
1994 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
1995 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
1997 run_test 83a "fail log_add during unlink recovery"
2001 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2002 replay_barrier $SINGLEMDS
2003 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2004 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2005 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2008 run_test 83b "fail log_add during unlink recovery"
2011 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2012 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2013 createmany -o $DIR/$tfile- 1 &
2017 client_up || client_up || true # reconnect
2019 run_test 84a "stale open during export disconnect"
2021 test_85a() { #bug 16774
2022 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2024 for i in `seq 100`; do
2025 echo "tag-$i" > $DIR/$tfile-$i
2026 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2029 lov_id=`lctl dl | grep "clilov"`
2030 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2031 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2032 echo "before recovery: unused locks count = $count"
2036 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2037 echo "after recovery: unused locks count = $count2"
2039 if [ $count2 -ge $count ]; then
2040 error "unused locks are not canceled"
2043 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2045 test_85b() { #bug 16774
2046 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2048 lfs setstripe -o 0 -c 1 $DIR
2050 for i in `seq 100`; do
2051 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2054 cancel_lru_locks osc
2056 for i in `seq 100`; do
2057 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2060 lov_id=`lctl dl | grep "clilov"`
2061 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2062 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2063 echo "before recovery: unused locks count = $count"
2067 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2068 echo "after recovery: unused locks count = $count2"
2070 if [ $count2 -ge $count ]; then
2071 error "unused locks are not canceled"
2074 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2077 local clients=${CLIENTS:-$HOSTNAME}
2079 zconf_umount_clients $clients $MOUNT
2080 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2081 remount_facet $SINGLEMDS
2082 zconf_mount_clients $clients $MOUNT
2084 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2087 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2090 lfs setstripe -i 0 -c 1 $DIR/$tfile
2091 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2092 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2093 cancel_lru_locks osc
2095 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2096 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2097 if [ $cksum != $cksum2 ] ; then
2098 error "New checksum $cksum2 does not match original $cksum"
2101 run_test 87 "write replay"
2104 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2107 lfs setstripe -i 0 -c 1 $DIR/$tfile
2108 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2109 sleep 1 # Give it a chance to flush dirty data
2110 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2111 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2112 cancel_lru_locks osc
2114 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2115 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2116 if [ $cksum != $cksum2 ] ; then
2117 error "New checksum $cksum2 does not match original $cksum"
2120 run_test 87b "write replay with changed data (checksum resend)"
2122 test_88() { #bug 17485
2126 lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe"
2129 replay_barrier $SINGLEMDS
2131 # exhaust precreations on ost1
2132 local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
2133 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2134 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2135 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2136 echo "before test: last_id = $last_id, next_id = $next_id"
2138 echo "Creating to objid $last_id on ost $OST..."
2139 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2141 #create some files to use some uncommitted objids
2142 last_id=$(($last_id + 1))
2143 createmany -o $DIR/$tdir/f-%d $last_id 8
2145 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2146 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2147 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2149 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2150 # it has to take care about the affected facets, bug20407
2151 local affected_mds1=$(affected_facets mds1)
2152 local affected_ost1=$(affected_facets ost1)
2154 shutdown_facet $SINGLEMDS
2157 reboot_facet $SINGLEMDS
2158 change_active $affected_mds1
2159 wait_for_facet $affected_mds1
2160 mount_facets $affected_mds1 || error "Restart of mds failed"
2163 change_active $affected_ost1
2164 wait_for_facet $affected_ost1
2165 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2169 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2170 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2171 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2173 # create new files, which should use new objids, and ensure the orphan
2174 # cleanup phase for ost1 is completed at the same time
2175 for i in `seq 8`; do
2176 file_id=$(($last_id + 10 + $i))
2177 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2180 # if the objids were not recreated, then "ls" will failed for -ENOENT
2181 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2184 # write into previously created files
2185 for i in `seq 8`; do
2186 file_id=$(($last_id + $i))
2187 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2188 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2191 # compare the content
2192 for i in `seq 8`; do
2193 file_id=$(($last_id + $i))
2194 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2195 "of file is modified!"
2200 run_test 88 "MDS should not assign same objid to different files "
2203 cancel_lru_locks osc
2205 rm -f $DIR/$tdir/$tfile
2207 wait_destroy_complete
2208 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2209 lfs setstripe -i 0 -c 1 $DIR/$tdir/$tfile
2210 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2213 facet_failover $SINGLEMDS
2214 rm $DIR/$tdir/$tfile
2217 zconf_mount $(hostname) $MOUNT
2218 client_up || return 1
2220 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2221 [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2224 run_test 89 "no disk space leak on late ost connection"
2226 complete $(basename $0) $SECONDS
2227 check_and_cleanup_lustre