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)"
62 lctl set_param -n seq.cli-srv-$mds-mdc-*.width=$width
68 lctl get_param -n seq.cli-srv-$mds-mdc-*.width
71 # This test should pass for single-mds and multi-mds configs.
72 # But for different configurations it tests different things.
76 # (1) fld_create replay should happen;
78 # (2) fld_create replay should not return -EEXISTS, if it does
79 # this means sequence manager recovery code is buggy and allocated
80 # same sequence two times after recovery.
84 # (1) fld_create replay may not happen, because its home MDS is
85 # MDS2 which is not involved to revovery;
87 # (2) as fld_create does not happen on MDS1, it does not make any
90 local label=`mdsdevlabel 1`
91 [ -z "$label" ] && echo "No label for mds1" && return 1
93 replay_barrier $SINGLEMDS
94 local sw=`seq_get_width $label`
96 # make seq manager switch to next sequence each
97 # time as new fid is needed.
98 seq_set_width $label 1
100 # make sure that fld has created at least one new
102 touch $DIR/$tfile || return 2
103 seq_set_width $label $sw
105 # fail $SINGLEMDS and start recovery, replay RPCs, etc.
108 # wait for recovery finish
112 # flush fld cache and dentry cache to make it lookup
113 # created entry instead of revalidating existent one
115 zconf_mount `hostname` $MOUNT
117 # issue lookup which should call fld lookup which
118 # should fail if client did not replay fld create
119 # correctly and server has no fld entry
120 touch $DIR/$tfile || return 3
121 rm $DIR/$tfile || return 4
123 start_full_debug_logging
124 run_test 0c "fld create"
125 stop_full_debug_logging
128 replay_barrier $SINGLEMDS
130 facet_failover $SINGLEMDS
131 zconf_mount `hostname` $MOUNT || error "mount fails"
132 client_up || error "post-failover df failed"
134 run_test 0d "expired recovery with no clients"
137 replay_barrier $SINGLEMDS
140 $CHECKSTAT -t file $DIR/$tfile || return 1
143 run_test 1 "simple create"
146 replay_barrier $SINGLEMDS
149 $CHECKSTAT -t file $DIR/$tfile || return 1
156 replay_barrier $SINGLEMDS
159 $CHECKSTAT -t file $DIR/$tfile || return 1
165 local file=$DIR/$tfile
166 replay_barrier $SINGLEMDS
168 openfile -f O_DIRECTORY $file
170 $CHECKSTAT -t file $file || return 2
173 run_test 3a "replay failed open(O_DIRECTORY)"
176 replay_barrier $SINGLEMDS
177 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
178 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
180 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
182 $CHECKSTAT -t file $DIR/$tfile && return 2
185 run_test 3b "replay failed open -ENOMEM"
188 replay_barrier $SINGLEMDS
189 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
190 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
192 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
195 $CHECKSTAT -t file $DIR/$tfile && return 2
198 run_test 3c "replay failed open -ENOMEM"
200 test_4a() { # was test_4
201 replay_barrier $SINGLEMDS
202 for i in `seq 10`; do
203 echo "tag-$i" > $DIR/$tfile-$i
206 for i in `seq 10`; do
207 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
210 run_test 4a "|x| 10 open(O_CREAT)s"
213 replay_barrier $SINGLEMDS
216 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
218 run_test 4b "|x| rm 10 files"
220 # The idea is to get past the first block of precreated files on both
221 # osts, and then replay.
223 replay_barrier $SINGLEMDS
224 for i in `seq 220`; do
225 echo "tag-$i" > $DIR/$tfile-$i
228 for i in `seq 220`; do
229 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
233 # waiting for commitment of removal
235 run_test 5 "|x| 220 open(O_CREAT)"
238 test_6a() { # was test_6
240 replay_barrier $SINGLEMDS
241 mcreate $DIR/$tdir/$tfile
243 $CHECKSTAT -t dir $DIR/$tdir || return 1
244 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
246 # waiting for log process thread
248 run_test 6a "mkdir + contained create"
252 replay_barrier $SINGLEMDS
255 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
257 run_test 6b "|X| rmdir"
261 replay_barrier $SINGLEMDS
262 mcreate $DIR/$tdir/$tfile
264 $CHECKSTAT -t dir $DIR/$tdir || return 1
265 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
268 run_test 7 "mkdir |X| contained create"
271 # make sure no side-effect from previous test.
273 replay_barrier $SINGLEMDS
274 multiop_bg_pause $DIR/$tfile mo_c || return 4
278 $CHECKSTAT -t file $DIR/$tfile || return 1
279 kill -USR1 $MULTIPID || return 2
280 wait $MULTIPID || return 3
283 run_test 8 "creat open |X| close"
286 replay_barrier $SINGLEMDS
288 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
290 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
292 echo " old_inum == $old_inum, new_inum == $new_inum"
293 if [ $old_inum -eq $new_inum ] ;
295 echo " old_inum and new_inum match"
297 echo "!!!! old_inum and new_inum NOT match"
302 run_test 9 "|X| create (same inum/gen)"
306 replay_barrier $SINGLEMDS
307 mv $DIR/$tfile $DIR/$tfile-2
310 $CHECKSTAT $DIR/$tfile && return 1
311 $CHECKSTAT $DIR/$tfile-2 ||return 2
315 run_test 10 "create |X| rename unlink"
319 echo "old" > $DIR/$tfile
320 mv $DIR/$tfile $DIR/$tfile-2
321 replay_barrier $SINGLEMDS
322 echo "new" > $DIR/$tfile
324 grep old $DIR/$tfile-2
326 grep new $DIR/$tfile || return 1
327 grep old $DIR/$tfile-2 || return 2
329 run_test 11 "create open write rename |X| create-old-name read"
333 multiop_bg_pause $DIR/$tfile o_tSc || return 3
336 replay_barrier $SINGLEMDS
338 wait $pid || return 1
341 [ -e $DIR/$tfile ] && return 2
344 run_test 12 "open, unlink |X| close"
347 # 1777 - replay open after committed chmod that would make
348 # a regular open a failure
351 multiop_bg_pause $DIR/$tfile O_wc || return 3
354 $CHECKSTAT -p 0 $DIR/$tfile
355 replay_barrier $SINGLEMDS
358 wait $pid || return 1
360 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
361 rm $DIR/$tfile || return 4
364 run_test 13 "open chmod 0 |x| write close"
367 multiop_bg_pause $DIR/$tfile O_tSc || return 4
370 replay_barrier $SINGLEMDS
371 kill -USR1 $pid || return 1
372 wait $pid || return 2
375 [ -e $DIR/$tfile ] && return 3
378 run_test 14 "open(O_CREAT), unlink |X| close"
381 multiop_bg_pause $DIR/$tfile O_tSc || return 5
384 replay_barrier $SINGLEMDS
385 touch $DIR/g11 || return 1
387 wait $pid || return 2
390 [ -e $DIR/$tfile ] && return 3
391 touch $DIR/h11 || return 4
394 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
398 replay_barrier $SINGLEMDS
401 mcreate $DIR/$tfile-2
403 [ -e $DIR/$tfile ] && return 1
404 [ -e $DIR/$tfile-2 ] || return 2
405 munlink $DIR/$tfile-2 || return 3
407 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
410 replay_barrier $SINGLEMDS
411 multiop_bg_pause $DIR/$tfile O_c || return 4
414 kill -USR1 $pid || return 1
415 wait $pid || return 2
416 $CHECKSTAT -t file $DIR/$tfile || return 3
419 run_test 17 "|X| open(O_CREAT), |replay| close"
422 replay_barrier $SINGLEMDS
423 multiop_bg_pause $DIR/$tfile O_tSc || return 8
426 touch $DIR/$tfile-2 || return 1
427 echo "pid: $pid will close"
429 wait $pid || return 2
432 [ -e $DIR/$tfile ] && return 3
433 [ -e $DIR/$tfile-2 ] || return 4
434 # this touch frequently fails
435 touch $DIR/$tfile-3 || return 5
436 munlink $DIR/$tfile-2 || return 6
437 munlink $DIR/$tfile-3 || return 7
440 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
442 # bug 1855 (a simpler form of test_11 above)
444 replay_barrier $SINGLEMDS
446 echo "old" > $DIR/$tfile
447 mv $DIR/$tfile $DIR/$tfile-2
448 grep old $DIR/$tfile-2
450 grep old $DIR/$tfile-2 || return 2
452 run_test 19 "|X| mcreate, open, write, rename "
454 test_20a() { # was test_20
455 replay_barrier $SINGLEMDS
456 multiop_bg_pause $DIR/$tfile O_tSc || return 3
462 wait $pid || return 1
463 [ -e $DIR/$tfile ] && return 2
466 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
468 test_20b() { # bug 10480
469 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
471 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
473 while [ ! -e $DIR/$tfile ] ; do
474 usleep 60 # give dd a chance to start
477 lfs getstripe $DIR/$tfile || return 1
478 rm -f $DIR/$tfile || return 2 # make it an orphan
480 client_up || client_up || true # reconnect
482 fail $SINGLEMDS # start orphan recovery
483 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
484 wait_mds_ost_sync || return 3
485 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
486 log "before $BEFOREUSED, after $AFTERUSED"
487 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
488 error "after $AFTERUSED > before $BEFOREUSED"
491 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
493 test_20c() { # bug 10480
494 multiop_bg_pause $DIR/$tfile Ow_c || return 1
500 client_up || client_up || true # reconnect
503 wait $pid || return 1
504 [ -s $DIR/$tfile ] || error "File was truncated"
508 run_test 20c "check that client eviction does not affect file content"
511 replay_barrier $SINGLEMDS
512 multiop_bg_pause $DIR/$tfile O_tSc || return 5
515 touch $DIR/g11 || return 1
519 wait $pid || return 2
520 [ -e $DIR/$tfile ] && return 3
521 touch $DIR/h11 || return 4
524 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
527 multiop_bg_pause $DIR/$tfile O_tSc || return 3
530 replay_barrier $SINGLEMDS
535 wait $pid || return 1
536 [ -e $DIR/$tfile ] && return 2
539 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
542 multiop_bg_pause $DIR/$tfile O_tSc || return 5
545 replay_barrier $SINGLEMDS
547 touch $DIR/g11 || return 1
551 wait $pid || return 2
552 [ -e $DIR/$tfile ] && return 3
553 touch $DIR/h11 || return 4
556 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
559 multiop_bg_pause $DIR/$tfile O_tSc || return 3
562 replay_barrier $SINGLEMDS
566 wait $pid || return 1
567 [ -e $DIR/$tfile ] && return 2
570 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
573 multiop_bg_pause $DIR/$tfile O_tSc || return 3
577 replay_barrier $SINGLEMDS
580 wait $pid || return 1
581 [ -e $DIR/$tfile ] && return 2
584 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
587 replay_barrier $SINGLEMDS
588 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
590 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
595 wait $pid2 || return 1
599 wait $pid1 || return 2
600 [ -e $DIR/$tfile-1 ] && return 3
601 [ -e $DIR/$tfile-2 ] && return 4
604 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
607 replay_barrier $SINGLEMDS
608 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
610 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
617 wait $pid1 || return 1
619 wait $pid2 || return 2
620 [ -e $DIR/$tfile-1 ] && return 3
621 [ -e $DIR/$tfile-2 ] && return 4
624 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
627 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
629 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
631 replay_barrier $SINGLEMDS
635 wait $pid2 || return 1
639 wait $pid1 || return 2
640 [ -e $DIR/$tfile-1 ] && return 3
641 [ -e $DIR/$tfile-2 ] && return 4
644 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
647 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
649 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
651 replay_barrier $SINGLEMDS
657 wait $pid1 || return 1
659 wait $pid2 || return 2
660 [ -e $DIR/$tfile-1 ] && return 3
661 [ -e $DIR/$tfile-2 ] && return 4
664 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
667 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
669 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
674 replay_barrier $SINGLEMDS
677 wait $pid1 || return 1
679 wait $pid2 || return 2
680 [ -e $DIR/$tfile-1 ] && return 3
681 [ -e $DIR/$tfile-2 ] && return 4
684 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
687 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
689 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
693 replay_barrier $SINGLEMDS
697 wait $pid1 || return 1
699 wait $pid2 || return 2
700 [ -e $DIR/$tfile-1 ] && return 3
701 [ -e $DIR/$tfile-2 ] && return 4
704 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
706 # tests for bug 2104; completion without crashing is success. The close is
707 # stale, but we always return 0 for close, so the app never sees it.
709 multiop_bg_pause $DIR/$tfile O_c || return 2
711 multiop_bg_pause $DIR/$tfile O_c || return 3
714 client_up || client_up || return 1
717 wait $pid1 || return 4
718 wait $pid2 || return 5
721 run_test 32 "close() notices client eviction; close() after client eviction"
724 createmany -o $DIR/$tfile-%d 10
725 replay_barrier_nosync $SINGLEMDS
726 fail_abort $SINGLEMDS
727 # recreate shouldn't fail
728 createmany -o $DIR/$tfile--%d 10 || return 1
732 run_test 33a "fid seq shouldn't be reused after abort recovery"
735 #define OBD_FAIL_SEQ_ALLOC 0x1311
736 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
738 createmany -o $DIR/$tfile-%d 10
739 replay_barrier_nosync $SINGLEMDS
740 fail_abort $SINGLEMDS
741 # recreate shouldn't fail
742 createmany -o $DIR/$tfile--%d 10 || return 1
746 run_test 33b "test fid seq allocation"
749 multiop_bg_pause $DIR/$tfile O_c || return 2
753 replay_barrier $SINGLEMDS
754 fail_abort $SINGLEMDS
756 wait $pid || return 3
757 [ -e $DIR/$tfile ] && return 1
761 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
763 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
767 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
768 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
773 # give a chance to remove from MDS
774 fail_abort $SINGLEMDS
775 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
777 run_test 35 "test recovery from llog for unlink op"
779 # b=2432 resent cancel after replay uses wrong cookie,
780 # so don't resend cancels
782 replay_barrier $SINGLEMDS
784 checkstat $DIR/$tfile
785 facet_failover $SINGLEMDS
787 if dmesg | grep "unknown lock cookie"; then
788 echo "cancel after replay failed"
792 run_test 36 "don't resend cancel"
795 # directory orphans can't be unlinked from PENDING directory
797 rmdir $DIR/$tfile 2>/dev/null
798 multiop_bg_pause $DIR/$tfile dD_c || return 2
802 replay_barrier $SINGLEMDS
803 # clear the dmesg buffer so we only see errors from this recovery
805 fail_abort $SINGLEMDS
807 dmesg | grep "mds_unlink_orphan.*error .* unlinking orphan" && return 1
808 wait $pid || return 3
812 start_full_debug_logging
813 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
814 stop_full_debug_logging
817 createmany -o $DIR/$tfile-%d 800
818 unlinkmany $DIR/$tfile-%d 0 400
819 replay_barrier $SINGLEMDS
821 unlinkmany $DIR/$tfile-%d 400 400
823 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
825 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
827 test_39() { # bug 4176
828 createmany -o $DIR/$tfile-%d 800
829 replay_barrier $SINGLEMDS
830 unlinkmany $DIR/$tfile-%d 0 400
832 unlinkmany $DIR/$tfile-%d 400 400
834 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
836 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
839 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
844 $LCTL mark multiop $MOUNT/$tfile OS_c
845 multiop $MOUNT/$tfile OS_c &
847 writeme -s $MOUNT/${tfile}-2 &
850 facet_failover $SINGLEMDS
851 #define OBD_FAIL_MDS_CONNECT_NET 0x117
852 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
854 stat1=`count_ost_writes`
856 stat2=`count_ost_writes`
857 echo "$stat1, $stat2"
858 if [ $stat1 -lt $stat2 ]; then
859 echo "writes continuing during recovery"
862 echo "writes not continuing during recovery, bug 2477"
865 echo "waiting for writeme $WRITE_PID"
869 echo "waiting for multiop $PID"
870 wait $PID || return 2
871 do_facet client munlink $MOUNT/$tfile || return 3
872 do_facet client munlink $MOUNT/${tfile}-2 || return 3
875 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
879 # make sure that a read to one osc doesn't try to double-unlock its page just
880 # because another osc is invalid. trigger_group_io used to mistakenly return
881 # an error if any oscs were invalid even after having successfully put rpcs
882 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
883 # the page, guarnateeing that the unlock from the RPC completion would
884 # assert on trying to unlock the unlocked page.
886 [ $OSTCOUNT -lt 2 ] && \
887 skip_env "skipping test 41: we don't have a second OST to test with" && \
890 local f=$MOUNT/$tfile
891 # make sure the start of the file is ost1
892 lfs setstripe $f -s $((128 * 1024)) -i 0
893 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
895 # fail ost2 and read from ost1
896 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
897 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
898 grep $mdtosc | awk '{print $1}')
899 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
900 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
901 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
902 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
905 run_test 41 "read from a valid osc while other oscs are invalid"
907 # test MDS recovery after ost failure
909 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
910 createmany -o $DIR/$tfile-%d 800
912 unlinkmany $DIR/$tfile-%d 0 400
914 lctl set_param debug=-1
917 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
918 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
919 #[ $blocks_after -lt $blocks ] || return 1
920 echo wait for MDS to timeout and recover
921 sleep $((TIMEOUT * 2))
923 unlinkmany $DIR/$tfile-%d 400 400
924 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
926 run_test 42 "recovery after ost failure"
928 # timeout in MDS/OST recovery RPC will LBUG MDS
929 test_43() { # bug 2530
930 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
932 replay_barrier $SINGLEMDS
934 # OBD_FAIL_OST_CREATE_NET 0x204
935 do_facet ost1 "lctl set_param fail_loc=0x80000204"
938 do_facet ost1 "lctl set_param fail_loc=0"
942 run_test 43 "mds osc import failure during recovery; don't LBUG"
944 test_44a() { # was test_44
947 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
948 [ "$mdcdev" ] || return 2
949 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
951 # adaptive timeouts slow this way down
952 if at_is_enabled; then
953 at_max_saved=$(at_max_get mds)
957 for i in `seq 1 10`; do
958 echo "$i of 10 ($(date +%s))"
959 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
960 #define OBD_FAIL_TGT_CONN_RACE 0x701
961 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
962 # lctl below may fail, it is valid case
963 $LCTL --device $mdcdev recover
966 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
967 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
970 run_test 44a "race in target handle connect"
973 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
974 [ "$mdcdev" ] || return 2
975 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
977 for i in `seq 1 10`; do
978 echo "$i of 10 ($(date +%s))"
979 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
980 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
981 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
982 # lctl below may fail, it is valid case
983 $LCTL --device $mdcdev recover
986 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
989 run_test 44b "race in target handle connect"
991 # Handle failed close
993 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
994 [ "$mdcdev" ] || return 2
995 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
997 $LCTL --device $mdcdev recover || return 6
999 multiop_bg_pause $DIR/$tfile O_c || return 1
1002 # This will cause the CLOSE to fail before even
1003 # allocating a reply buffer
1004 $LCTL --device $mdcdev deactivate || return 4
1008 wait $pid || return 1
1010 $LCTL --device $mdcdev activate || return 5
1013 $CHECKSTAT -t file $DIR/$tfile || return 2
1016 run_test 45 "Handle failed close"
1020 drop_reply "touch $DIR/$tfile"
1022 # ironically, the previous test, 45, will cause a real forced close,
1023 # so just look for one for this test
1024 dmesg | grep -i "force closing client file handle for $tfile" && return 1
1027 run_test 46 "Don't leak file handle after open resend (3325)"
1029 test_47() { # bug 2824
1030 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1032 # create some files to make sure precreate has been done on all
1033 # OSTs. (just in case this test is run independently)
1034 createmany -o $DIR/$tfile 20 || return 1
1036 # OBD_FAIL_OST_CREATE_NET 0x204
1038 do_facet ost1 "lctl set_param fail_loc=0x80000204"
1039 client_up || return 2
1041 # let the MDS discover the OST failure, attempt to recover, fail
1042 # and recover again.
1043 sleep $((3 * TIMEOUT))
1045 # Without 2824, this createmany would hang
1046 createmany -o $DIR/$tfile 20 || return 3
1047 unlinkmany $DIR/$tfile 20 || return 4
1049 do_facet ost1 "lctl set_param fail_loc=0"
1052 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1055 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1056 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1058 replay_barrier $SINGLEMDS
1059 createmany -o $DIR/$tfile 20 || return 1
1060 # OBD_FAIL_OST_EROFS 0x216
1061 facet_failover $SINGLEMDS
1062 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1063 client_up || return 2
1065 createmany -o $DIR/$tfile 20 20 || return 2
1066 unlinkmany $DIR/$tfile 40 || return 3
1069 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1072 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1073 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1074 grep $mdtosc | awk '{print $1}')
1075 [ "$oscdev" ] || return 1
1076 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1077 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1078 # give the mds_lov_sync threads a chance to run
1081 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1083 # b3764 timed out lock replay
1086 cancel_lru_locks mdc
1088 multiop $DIR/$tfile s || return 1
1089 replay_barrier $SINGLEMDS
1090 #define OBD_FAIL_LDLM_REPLY 0x30c
1091 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1092 fail $SINGLEMDS || return 2
1093 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1095 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1097 run_test 52 "time out lock replay (3764)"
1099 # bug 3462 - simultaneous MDC requests
1101 cancel_lru_locks mdc # cleanup locks from former test cases
1102 mkdir -p $DIR/${tdir}-1
1103 mkdir -p $DIR/${tdir}-2
1104 multiop $DIR/${tdir}-1/f O_c &
1106 # give multiop a change to open
1109 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1110 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1111 kill -USR1 $close_pid
1112 cancel_lru_locks mdc # force the close
1113 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1115 mcreate $DIR/${tdir}-2/f || return 1
1117 # close should still be here
1118 [ -d /proc/$close_pid ] || return 2
1120 replay_barrier_nodf $SINGLEMDS
1122 wait $close_pid || return 3
1124 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1125 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1126 rm -rf $DIR/${tdir}-*
1128 run_test 53a "|X| 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_bg_pause $DIR/${tdir}-1/f O_c || return 6
1139 #define OBD_FAIL_MDS_REINT_NET 0x107
1140 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1141 mcreate $DIR/${tdir}-2/f &
1145 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1146 kill -USR1 $close_pid
1147 cancel_lru_locks mdc # force the close
1148 wait $close_pid || return 1
1149 # open should still be here
1150 [ -d /proc/$open_pid ] || return 2
1152 replay_barrier_nodf $SINGLEMDS
1154 wait $open_pid || return 3
1156 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1157 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1158 rm -rf $DIR/${tdir}-*
1160 run_test 53b "|X| open request while two MDC requests in flight"
1163 cancel_lru_locks mdc # cleanup locks from former test cases
1164 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1166 mkdir -p $DIR/${tdir}-1
1167 mkdir -p $DIR/${tdir}-2
1168 multiop $DIR/${tdir}-1/f O_c &
1171 #define OBD_FAIL_MDS_REINT_NET 0x107
1172 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1173 mcreate $DIR/${tdir}-2/f &
1177 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1178 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1179 kill -USR1 $close_pid
1180 cancel_lru_locks mdc # force the close
1182 #bz20647: make sure all pids are exists before failover
1183 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1184 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1185 replay_barrier_nodf $SINGLEMDS
1186 fail_nodf $SINGLEMDS
1187 wait $open_pid || return 1
1189 # close should be gone
1190 [ -d /proc/$close_pid ] && return 2
1191 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1193 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1194 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1195 rm -rf $DIR/${tdir}-*
1197 run_test 53c "|X| open request and close request while two MDC requests in flight"
1200 cancel_lru_locks mdc # cleanup locks from former test cases
1201 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1203 mkdir -p $DIR/${tdir}-1
1204 mkdir -p $DIR/${tdir}-2
1205 multiop $DIR/${tdir}-1/f O_c &
1207 # give multiop a chance to open
1210 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1211 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1212 kill -USR1 $close_pid
1213 cancel_lru_locks mdc # force the close
1214 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1215 mcreate $DIR/${tdir}-2/f || return 1
1217 # close should still be here
1218 [ -d /proc/$close_pid ] || return 2
1220 wait $close_pid || return 3
1222 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1223 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1224 rm -rf $DIR/${tdir}-*
1226 run_test 53d "|X| 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 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1244 kill -USR1 $close_pid
1245 cancel_lru_locks mdc # force the close
1246 wait $close_pid || return 1
1247 # open should still be here
1248 [ -d /proc/$open_pid ] || return 2
1250 replay_barrier_nodf $SINGLEMDS
1252 wait $open_pid || return 3
1254 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1255 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1256 rm -rf $DIR/${tdir}-*
1258 run_test 53e "|X| open reply while two MDC requests in flight"
1261 cancel_lru_locks mdc # cleanup locks from former test cases
1262 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1264 mkdir -p $DIR/${tdir}-1
1265 mkdir -p $DIR/${tdir}-2
1266 multiop $DIR/${tdir}-1/f O_c &
1269 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1270 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1271 mcreate $DIR/${tdir}-2/f &
1275 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1276 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1277 kill -USR1 $close_pid
1278 cancel_lru_locks mdc # force the close
1280 #bz20647: make sure all pids are exists before failover
1281 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1282 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1283 replay_barrier_nodf $SINGLEMDS
1284 fail_nodf $SINGLEMDS
1285 wait $open_pid || return 1
1287 # close should be gone
1288 [ -d /proc/$close_pid ] && return 2
1289 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1291 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1292 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1293 rm -rf $DIR/${tdir}-*
1295 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1298 cancel_lru_locks mdc # cleanup locks from former test cases
1299 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1301 mkdir -p $DIR/${tdir}-1
1302 mkdir -p $DIR/${tdir}-2
1303 multiop $DIR/${tdir}-1/f O_c &
1306 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1307 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1308 mcreate $DIR/${tdir}-2/f &
1312 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1313 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1314 kill -USR1 $close_pid
1315 cancel_lru_locks mdc # force the close
1316 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1318 #bz20647: make sure all pids are exists before failover
1319 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1320 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1321 replay_barrier_nodf $SINGLEMDS
1322 fail_nodf $SINGLEMDS
1323 wait $open_pid || return 1
1325 # close should be gone
1326 [ -d /proc/$close_pid ] && return 2
1328 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1329 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1330 rm -rf $DIR/${tdir}-*
1332 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1335 cancel_lru_locks mdc # cleanup locks from former test cases
1336 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1338 mkdir -p $DIR/${tdir}-1
1339 mkdir -p $DIR/${tdir}-2
1340 multiop $DIR/${tdir}-1/f O_c &
1343 #define OBD_FAIL_MDS_REINT_NET 0x107
1344 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1345 mcreate $DIR/${tdir}-2/f &
1349 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1350 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1351 kill -USR1 $close_pid
1352 cancel_lru_locks mdc # force the close
1355 #bz20647: make sure all pids are exists before failover
1356 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1357 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1358 replay_barrier_nodf $SINGLEMDS
1359 fail_nodf $SINGLEMDS
1360 wait $open_pid || return 1
1362 # close should be gone
1363 [ -d /proc/$close_pid ] && return 2
1364 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1366 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1367 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1368 rm -rf $DIR/${tdir}-*
1370 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1372 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1374 #b3761 ASSERTION(hash != 0) failed
1376 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1377 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1379 # give touch a chance to run
1381 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1385 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1387 #b3440 ASSERTION(rec->ur_fid2->id) failed
1389 ln -s foo $DIR/$tfile
1390 replay_barrier $SINGLEMDS
1391 #drop_reply "cat $DIR/$tfile"
1395 run_test 56 "don't replay a symlink open request (3440)"
1397 #recovery one mds-ost setattr from llog
1399 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1400 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1402 replay_barrier $SINGLEMDS
1405 $CHECKSTAT -t file $DIR/$tfile || return 1
1406 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1409 run_test 57 "test recovery from llog for setattr op"
1411 #recovery many mds-ost setattr from llog
1414 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1415 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1416 createmany -o $DIR/$tdir/$tfile-%d 2500
1417 replay_barrier $SINGLEMDS
1420 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1421 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1422 unlinkmany $DIR/$tdir/$tfile-%d 2500
1425 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1428 mount_client $MOUNT2
1430 touch $DIR/$tdir/$tfile
1431 replay_barrier $SINGLEMDS
1432 setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile
1434 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1435 [ x$VAL = x"bar" ] || return 1
1436 rm -f $DIR/$tdir/$tfile
1438 zconf_umount `hostname` $MOUNT2
1440 run_test 58b "test replay of setxattr op"
1442 test_58c() { # bug 16570
1443 mount_client $MOUNT2
1445 touch $DIR/$tdir/$tfile
1446 drop_request "setfattr -n trusted.foo -v bar $DIR/$tdir/$tfile" || \
1448 VAL=`getfattr --absolute-names --only-value -n trusted.foo $MOUNT2/$tdir/$tfile`
1449 [ x$VAL = x"bar" ] || return 2
1450 drop_reint_reply "setfattr -n trusted.foo1 -v bar1 $DIR/$tdir/$tfile" || \
1452 VAL=`getfattr --absolute-names --only-value -n trusted.foo1 $MOUNT2/$tdir/$tfile`
1453 [ x$VAL = x"bar1" ] || return 4
1454 rm -f $DIR/$tdir/$tfile
1456 zconf_umount `hostname` $MOUNT2
1458 run_test 58c "resend/reconstruct setxattr op"
1460 # log_commit_thread vs filter_destroy race used to lead to import use after free
1463 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1466 createmany -o $DIR/$tdir/$tfile-%d 200
1468 unlinkmany $DIR/$tdir/$tfile-%d 200
1469 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1470 do_facet ost1 "lctl set_param fail_loc=0x507"
1473 do_facet ost1 "lctl set_param fail_loc=0x0"
1477 run_test 59 "test log_commit_thread vs filter_destroy race"
1479 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1480 # bug 12086: should no oops and No ctxt error for this test
1483 createmany -o $DIR/$tdir/$tfile-%d 200
1484 replay_barrier $SINGLEMDS
1485 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1487 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1488 local no_ctxt=`dmesg | grep "No ctxt"`
1489 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1491 run_test 60 "test llog post recovery init vs llog unlink"
1493 #test race llog recovery thread vs llog cleanup
1494 test_61a() { # was test_61
1495 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1498 createmany -o $DIR/$tdir/$tfile-%d 800
1500 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1501 unlinkmany $DIR/$tdir/$tfile-%d 800
1502 set_nodes_failloc "$(osts_nodes)" 0x80000221
1507 set_nodes_failloc "$(osts_nodes)" 0x0
1509 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1512 run_test 61a "test race llog recovery vs llog cleanup"
1514 #test race mds llog sync vs llog cleanup
1516 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1517 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1518 facet_failover $SINGLEMDS
1521 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1523 run_test 61b "test race mds llog sync vs llog cleanup"
1525 #test race cancel cookie cb vs llog cleanup
1527 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1529 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1531 set_nodes_failloc "$(osts_nodes)" 0x80000222
1535 set_nodes_failloc "$(osts_nodes)" 0x0
1537 run_test 61c "test race mds llog sync vs llog cleanup"
1539 test_61d() { # bug 16002 # bug 17466 # bug 22137
1540 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1542 do_facet mgs "lctl set_param fail_loc=0x80000605"
1543 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1544 do_facet mgs "lctl set_param fail_loc=0"
1545 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1547 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1549 test_62() { # Bug 15756 - don't mis-drop resent replay
1551 replay_barrier $SINGLEMDS
1552 createmany -o $DIR/$tdir/$tfile- 25
1553 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1554 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1556 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1557 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1560 run_test 62 "don't mis-drop resent replay"
1562 #Adaptive Timeouts (bug 3055)
1570 echo "Cleaning up AT ..."
1571 if [ -n "$ATOLDBASE" ]; then
1572 local at_history=$($LCTL get_param -n at_history)
1573 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1574 do_facet ost1 "lctl set_param at_history=$at_history" || true
1577 if [ $AT_MAX_SET -ne 0 ]; then
1578 for facet in mds client ost; do
1579 var=AT_MAX_SAVE_${facet}
1580 echo restore AT on $facet to saved value ${!var}
1581 at_max_set ${!var} $facet
1582 at_new=$(at_max_get $facet)
1583 echo Restored AT value on $facet $at_new
1584 [ $at_new -eq ${!var} ] || \
1585 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1592 local at_max_new=600
1594 # Save at_max original values
1596 if [ $AT_MAX_SET -eq 0 ]; then
1597 # Suppose that all osts have the same at_max
1598 for facet in mds client ost; do
1599 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1603 for facet in mds client ost; do
1604 at_max=$(at_max_get $facet)
1605 if [ $at_max -ne $at_max_new ]; then
1606 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1607 at_max_set $at_max_new $facet
1612 if [ -z "$ATOLDBASE" ]; then
1613 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1614 # speed up the timebase so we can check decreasing AT
1615 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1616 do_facet ost1 "lctl set_param at_history=8" || true
1618 # sleep for a while to cool down, should be > 8s and also allow
1619 # at least one ping to be sent. simply use TIMEOUT to be safe.
1624 test_65a() #bug 3055
1626 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1628 at_start || return 0
1629 $LCTL dk > /dev/null
1631 sysctl -w lnet.debug="+other"
1632 # Slow down a request to the current service time, this is critical
1633 # because previous tests may have caused this value to increase.
1634 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1635 awk '/portal 12/ {print $5}'`
1636 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1638 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1639 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1640 do_facet $SINGLEMDS sysctl -w lustre.fail_loc=0x8000050a
1641 createmany -o $DIR/$tfile 10 > /dev/null
1642 unlinkmany $DIR/$tfile 10 > /dev/null
1643 # check for log message
1644 $LCTL dk | grep "Early reply #" || error "No early reply"
1646 # client should show REQ_DELAY estimates
1647 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1649 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1651 run_test 65a "AT: verify early replies"
1653 test_65b() #bug 3055
1655 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1657 at_start || return 0
1660 sysctl -w lnet.debug="other trace"
1661 $LCTL dk > /dev/null
1662 # Slow down a request to the current service time, this is critical
1663 # because previous tests may have caused this value to increase.
1664 lfs setstripe $DIR/$tfile --index=0 --count=1
1665 multiop $DIR/$tfile Ow1yc
1666 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1667 awk '/portal 6/ {print $5}'`
1668 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1670 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1671 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1672 do_facet ost1 sysctl -w lustre.fail_loc=0x224
1675 lfs setstripe $DIR/$tfile --index=0 --count=1
1676 # force some real bulk transfer
1677 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1679 do_facet ost1 sysctl -w lustre.fail_loc=0
1680 # check for log message
1681 $LCTL dk | grep "Early reply #" || error "No early reply"
1683 # client should show REQ_DELAY estimates
1684 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1686 run_test 65b "AT: verify early replies on packed reply / bulk"
1688 test_66a() #bug 3055
1690 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1692 at_start || return 0
1693 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1694 # adjust 5s at a time so no early reply is sent (within deadline)
1695 do_facet $SINGLEMDS "sysctl -w lustre.fail_val=5000"
1696 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1697 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1698 createmany -o $DIR/$tfile 20 > /dev/null
1699 unlinkmany $DIR/$tfile 20 > /dev/null
1700 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1701 do_facet $SINGLEMDS "sysctl -w lustre.fail_val=10000"
1702 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0x8000050a"
1703 createmany -o $DIR/$tfile 20 > /dev/null
1704 unlinkmany $DIR/$tfile 20 > /dev/null
1705 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1706 do_facet $SINGLEMDS "sysctl -w lustre.fail_loc=0"
1708 createmany -o $DIR/$tfile 20 > /dev/null
1709 unlinkmany $DIR/$tfile 20 > /dev/null
1710 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1711 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1712 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1713 echo "Current MDT timeout $CUR, worst $WORST"
1714 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1716 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1718 test_66b() #bug 3055
1720 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1722 at_start || return 0
1723 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1724 sysctl -w lustre.fail_val=$(($ORIG + 5))
1725 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1726 sysctl -w lustre.fail_loc=0x50c
1727 ls $DIR/$tfile > /dev/null 2>&1
1728 sysctl -w lustre.fail_loc=0
1729 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1730 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1731 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1732 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1734 run_test 66b "AT: verify net latency adjusts"
1736 test_67a() #bug 3055
1738 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1740 at_start || return 0
1741 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1742 # sleeping threads may drive values above this
1743 do_facet ost1 "sysctl -w lustre.fail_val=400"
1744 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1745 do_facet ost1 "sysctl -w lustre.fail_loc=0x50a"
1746 createmany -o $DIR/$tfile 20 > /dev/null
1747 unlinkmany $DIR/$tfile 20 > /dev/null
1748 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1749 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1750 ATTEMPTS=$(($CONN2 - $CONN1))
1751 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1752 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1755 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1757 test_67b() #bug 3055
1759 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1761 at_start || return 0
1762 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1764 # exhaust precreations on ost1
1765 local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
1766 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1767 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1768 osc.$mdtosc.prealloc_last_id)
1769 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1770 osc.$mdtosc.prealloc_next_id)
1772 mkdir -p $DIR/$tdir/${OST}
1773 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1774 echo "Creating to objid $last_id on ost $OST..."
1775 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1776 do_facet ost1 "sysctl -w lustre.fail_val=20000"
1777 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1778 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1781 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1783 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1784 ATTEMPTS=$(($CONN2 - $CONN1))
1785 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1786 # do it again; should not timeout
1787 do_facet ost1 "sysctl -w lustre.fail_loc=0x80000223"
1788 cp /etc/profile $DIR/$tfile || error "cp failed"
1789 do_facet ost1 "sysctl -w lustre.fail_loc=0"
1791 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1792 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1793 ATTEMPTS=$(($CONN3 - $CONN2))
1794 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1795 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1798 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1800 test_68 () #bug 13813
1802 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1804 at_start || return 0
1805 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1806 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1807 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1808 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1809 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1810 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1811 echo $TIMEOUT >> $ldlm_enqueue_min
1812 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1816 lfs setstripe $DIR/$tdir --index=0 --count=1
1817 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1818 sysctl -w lustre.fail_val=$(($TIMEOUT - 1))
1819 sysctl -w lustre.fail_loc=0x80000312
1820 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1821 sysctl -w lustre.fail_val=$((TIMEOUT * 5 / 4))
1822 sysctl -w lustre.fail_loc=0x80000312
1823 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1824 sysctl -w lustre.fail_loc=0
1826 echo $ENQ_MIN >> $ldlm_enqueue_min
1827 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1831 run_test 68 "AT: verify slowing locks"
1834 # end of AT tests includes above lines
1837 # start multi-client tests
1839 [ -z "$CLIENTS" ] && \
1840 { skip "Need two or more clients." && return; }
1841 [ $CLIENTCOUNT -lt 2 ] && \
1842 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1844 echo "mount clients $CLIENTS ..."
1845 zconf_mount_clients $CLIENTS $MOUNT
1847 local clients=${CLIENTS//,/ }
1848 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1849 for CLIENT in $clients; do
1850 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1851 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1852 error "dd failed on $CLIENT"
1855 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1856 for C in ${CLIENTS//,/ }; do
1857 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1858 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1864 run_test 70a "check multi client t-f"
1866 check_for_process () {
1871 killall_process $clients "$prog" -0
1874 killall_process () {
1875 local clients=${1:-$(hostname)}
1880 do_nodes $clients "killall $signal $name"
1884 local clients=${CLIENTS:-$HOSTNAME}
1886 zconf_mount_clients $clients $MOUNT
1889 [ "$SLOW" = "no" ] && duration=60
1890 # set duration to 900 because it takes some time to boot node
1891 [ "$FAILURE_MODE" = HARD ] && duration=900
1893 local cmd="rundbench 1 -t $duration"
1895 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1896 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1897 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1900 log "Started rundbench load pid=$pid ..."
1902 # give rundbench a chance to start, bug 24118
1905 local num_failovers=0
1906 local start_ts=$(date +%s)
1907 while [ $elapsed -lt $duration ]; do
1908 if ! check_for_process $clients rundbench; then
1909 error_noexit "rundbench not found on some of $clients!"
1910 killall_process $clients dbench
1914 replay_barrier $SINGLEMDS
1915 sleep 1 # give clients a time to do operations
1916 # Increment the number of failovers
1917 num_failovers=$((num_failovers+1))
1918 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1920 elapsed=$(($(date +%s) - start_ts))
1923 wait $pid || error "rundbench load on $clients failed!"
1925 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1926 # end multi-client tests
1929 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1933 replay_barrier $SINGLEMDS
1934 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1935 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1938 wait $pid || return 1
1939 [ -e $DIR/$tfile ] && return 2
1942 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1945 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1949 replay_barrier $SINGLEMDS
1950 #define OBD_FAIL_LDLM_REPLY 0x30c
1951 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1954 wait $pid || return 1
1955 [ -e $DIR/$tfile ] && return 2
1958 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1961 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1965 replay_barrier $SINGLEMDS
1966 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1967 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1970 wait $pid || return 1
1971 [ -e $DIR/$tfile ] && return 2
1974 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1978 local clients=${CLIENTS:-$HOSTNAME}
1981 zconf_umount_clients $clients $MOUNT
1982 facet_failover $SINGLEMDS
1983 zconf_mount_clients $clients $MOUNT
1985 touch $DIR/$tfile || return 1
1986 rm $DIR/$tfile || return 2
1987 clients_up || error "client evicted: $?"
1990 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1993 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1997 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1998 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
2000 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
2003 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
2006 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2009 replay_barrier $SINGLEMDS
2010 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
2011 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
2013 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
2016 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
2019 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2022 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
2024 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
2025 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
2026 replay_barrier $SINGLEMDS
2027 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
2029 stat $DIR/$tdir/f1002
2031 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
2034 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2038 mkdir $dir || error "mkdir $dir failed"
2042 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2044 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
2047 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2050 replay_barrier $SINGLEMDS
2051 mkdir $dir || error "mkdir $dir failed"
2055 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2057 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2061 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2062 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2063 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2064 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2066 run_test 83a "fail log_add during unlink recovery"
2070 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2071 replay_barrier $SINGLEMDS
2072 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2073 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2074 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2077 run_test 83b "fail log_add during unlink recovery"
2080 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2081 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2082 createmany -o $DIR/$tfile- 1 &
2086 client_up || client_up || true # reconnect
2088 run_test 84a "stale open during export disconnect"
2090 test_85a() { #bug 16774
2091 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2093 for i in `seq 100`; do
2094 echo "tag-$i" > $DIR/$tfile-$i
2095 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2098 lov_id=`lctl dl | grep "clilov"`
2099 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2100 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2101 echo "before recovery: unused locks count = $count"
2105 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2106 echo "after recovery: unused locks count = $count2"
2108 if [ $count2 -ge $count ]; then
2109 error "unused locks are not canceled"
2112 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2114 test_85b() { #bug 16774
2115 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2117 lfs setstripe -o 0 -c 1 $DIR
2119 for i in `seq 100`; do
2120 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2123 cancel_lru_locks osc
2125 for i in `seq 100`; do
2126 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2129 lov_id=`lctl dl | grep "clilov"`
2130 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2131 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2132 echo "before recovery: unused locks count = $count"
2136 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2137 echo "after recovery: unused locks count = $count2"
2139 if [ $count2 -ge $count ]; then
2140 error "unused locks are not canceled"
2143 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2146 local clients=${CLIENTS:-$HOSTNAME}
2148 zconf_umount_clients $clients $MOUNT
2149 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2150 remount_facet $SINGLEMDS
2151 zconf_mount_clients $clients $MOUNT
2153 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2156 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2159 lfs setstripe -i 0 -c 1 $DIR/$tfile
2160 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2161 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2162 cancel_lru_locks osc
2164 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2165 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2166 if [ $cksum != $cksum2 ] ; then
2167 error "New checksum $cksum2 does not match original $cksum"
2170 run_test 87 "write replay"
2173 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2176 lfs setstripe -i 0 -c 1 $DIR/$tfile
2177 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2178 sleep 1 # Give it a chance to flush dirty data
2179 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2180 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2181 cancel_lru_locks osc
2183 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2184 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2185 if [ $cksum != $cksum2 ] ; then
2186 error "New checksum $cksum2 does not match original $cksum"
2189 run_test 87b "write replay with changed data (checksum resend)"
2191 test_88() { #bug 17485
2195 lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe"
2198 replay_barrier $SINGLEMDS
2200 # exhaust precreations on ost1
2201 local OST=$(lfs osts | grep ^0": " | awk '{print $2}' | sed -e 's/_UUID$//')
2202 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2203 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2204 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2205 echo "before test: last_id = $last_id, next_id = $next_id"
2207 echo "Creating to objid $last_id on ost $OST..."
2208 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2210 #create some files to use some uncommitted objids
2211 last_id=$(($last_id + 1))
2212 createmany -o $DIR/$tdir/f-%d $last_id 8
2214 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2215 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2216 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2218 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2219 # it has to take care about the affected facets, bug20407
2220 local affected_mds1=$(affected_facets mds1)
2221 local affected_ost1=$(affected_facets ost1)
2223 shutdown_facet $SINGLEMDS
2226 reboot_facet $SINGLEMDS
2227 change_active $affected_mds1
2228 wait_for_facet $affected_mds1
2229 mount_facets $affected_mds1 || error "Restart of mds failed"
2232 change_active $affected_ost1
2233 wait_for_facet $affected_ost1
2234 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2238 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2239 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2240 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2242 # create new files, which should use new objids, and ensure the orphan
2243 # cleanup phase for ost1 is completed at the same time
2244 for i in `seq 8`; do
2245 file_id=$(($last_id + 10 + $i))
2246 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2249 # if the objids were not recreated, then "ls" will failed for -ENOENT
2250 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2253 # write into previously created files
2254 for i in `seq 8`; do
2255 file_id=$(($last_id + $i))
2256 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2257 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2260 # compare the content
2261 for i in `seq 8`; do
2262 file_id=$(($last_id + $i))
2263 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2264 "of file is modified!"
2269 run_test 88 "MDS should not assign same objid to different files "
2272 cancel_lru_locks osc
2274 rm -f $DIR/$tdir/$tfile
2276 wait_destroy_complete
2277 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2278 lfs setstripe -i 0 -c 1 $DIR/$tdir/$tfile
2279 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2282 facet_failover $SINGLEMDS
2283 rm $DIR/$tdir/$tfile
2286 zconf_mount $(hostname) $MOUNT
2287 client_up || return 1
2289 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2290 [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2293 run_test 89 "no disk space leak on late ost connection"
2295 equals_msg `basename $0`: test complete, cleaning up
2296 check_and_cleanup_lustre
2297 [ -f "$TESTSUITELOG" ] && cat $TESTSUITELOG && grep -q FAIL $TESTSUITELOG && exit 1 || true