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 # LU-482 Avert LVM and VM inability to flush caches in pre .33 kernels
39 if [ $LINUX_VERSION_CODE -lt $(version_code 2.6.33) ]; then
41 do_facet $SINGLEMDS sync
44 test_0a() { # was test_0
46 replay_barrier $SINGLEMDS
50 run_test 0a "empty replay"
53 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
55 # this test attempts to trigger a race in the precreation code,
56 # and must run before any other objects are created on the filesystem
58 createmany -o $DIR/$tfile 20 || return 1
59 unlinkmany $DIR/$tfile 20 || return 2
61 run_test 0b "ensure object created after recover exists. (3284)"
64 replay_barrier $SINGLEMDS
66 facet_failover $SINGLEMDS
67 zconf_mount `hostname` $MOUNT || error "mount fails"
68 client_up || error "post-failover df failed"
70 run_test 0d "expired recovery with no clients"
73 replay_barrier $SINGLEMDS
76 $CHECKSTAT -t file $DIR/$tfile || return 1
79 run_test 1 "simple create"
82 replay_barrier $SINGLEMDS
85 $CHECKSTAT -t file $DIR/$tfile || return 1
92 replay_barrier $SINGLEMDS
95 $CHECKSTAT -t file $DIR/$tfile || return 1
101 local file=$DIR/$tfile
102 replay_barrier $SINGLEMDS
104 openfile -f O_DIRECTORY $file
106 $CHECKSTAT -t file $file || return 2
109 run_test 3a "replay failed open(O_DIRECTORY)"
112 replay_barrier $SINGLEMDS
113 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
114 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
116 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
118 $CHECKSTAT -t file $DIR/$tfile && return 2
121 run_test 3b "replay failed open -ENOMEM"
124 replay_barrier $SINGLEMDS
125 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
126 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
128 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
131 $CHECKSTAT -t file $DIR/$tfile && return 2
134 run_test 3c "replay failed open -ENOMEM"
136 test_4a() { # was test_4
137 replay_barrier $SINGLEMDS
138 for i in `seq 10`; do
139 echo "tag-$i" > $DIR/$tfile-$i
142 for i in `seq 10`; do
143 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
146 run_test 4a "|x| 10 open(O_CREAT)s"
149 replay_barrier $SINGLEMDS
152 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
154 run_test 4b "|x| rm 10 files"
156 # The idea is to get past the first block of precreated files on both
157 # osts, and then replay.
159 replay_barrier $SINGLEMDS
160 for i in `seq 220`; do
161 echo "tag-$i" > $DIR/$tfile-$i
164 for i in `seq 220`; do
165 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
169 # waiting for commitment of removal
171 run_test 5 "|x| 220 open(O_CREAT)"
174 test_6a() { # was test_6
176 replay_barrier $SINGLEMDS
177 mcreate $DIR/$tdir/$tfile
179 $CHECKSTAT -t dir $DIR/$tdir || return 1
180 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
182 # waiting for log process thread
184 run_test 6a "mkdir + contained create"
188 replay_barrier $SINGLEMDS
191 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
193 run_test 6b "|X| rmdir"
197 replay_barrier $SINGLEMDS
198 mcreate $DIR/$tdir/$tfile
200 $CHECKSTAT -t dir $DIR/$tdir || return 1
201 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
204 run_test 7 "mkdir |X| contained create"
207 # make sure no side-effect from previous test.
209 replay_barrier $SINGLEMDS
210 multiop_bg_pause $DIR/$tfile mo_c || return 4
214 $CHECKSTAT -t file $DIR/$tfile || return 1
215 kill -USR1 $MULTIPID || return 2
216 wait $MULTIPID || return 3
219 run_test 8 "creat open |X| close"
222 replay_barrier $SINGLEMDS
224 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
226 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
228 echo " old_inum == $old_inum, new_inum == $new_inum"
229 if [ $old_inum -eq $new_inum ] ;
231 echo " old_inum and new_inum match"
233 echo "!!!! old_inum and new_inum NOT match"
238 run_test 9 "|X| create (same inum/gen)"
242 replay_barrier $SINGLEMDS
243 mv $DIR/$tfile $DIR/$tfile-2
246 $CHECKSTAT $DIR/$tfile && return 1
247 $CHECKSTAT $DIR/$tfile-2 ||return 2
251 run_test 10 "create |X| rename unlink"
255 echo "old" > $DIR/$tfile
256 mv $DIR/$tfile $DIR/$tfile-2
257 replay_barrier $SINGLEMDS
258 echo "new" > $DIR/$tfile
260 grep old $DIR/$tfile-2
262 grep new $DIR/$tfile || return 1
263 grep old $DIR/$tfile-2 || return 2
265 run_test 11 "create open write rename |X| create-old-name read"
269 multiop_bg_pause $DIR/$tfile o_tSc || return 3
272 replay_barrier $SINGLEMDS
274 wait $pid || return 1
277 [ -e $DIR/$tfile ] && return 2
280 run_test 12 "open, unlink |X| close"
283 # 1777 - replay open after committed chmod that would make
284 # a regular open a failure
287 multiop_bg_pause $DIR/$tfile O_wc || return 3
290 $CHECKSTAT -p 0 $DIR/$tfile
291 replay_barrier $SINGLEMDS
294 wait $pid || return 1
296 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
297 rm $DIR/$tfile || return 4
300 run_test 13 "open chmod 0 |x| write close"
303 multiop_bg_pause $DIR/$tfile O_tSc || return 4
306 replay_barrier $SINGLEMDS
307 kill -USR1 $pid || return 1
308 wait $pid || return 2
311 [ -e $DIR/$tfile ] && return 3
314 run_test 14 "open(O_CREAT), unlink |X| close"
317 multiop_bg_pause $DIR/$tfile O_tSc || return 5
320 replay_barrier $SINGLEMDS
321 touch $DIR/g11 || return 1
323 wait $pid || return 2
326 [ -e $DIR/$tfile ] && return 3
327 touch $DIR/h11 || return 4
330 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
334 replay_barrier $SINGLEMDS
337 mcreate $DIR/$tfile-2
339 [ -e $DIR/$tfile ] && return 1
340 [ -e $DIR/$tfile-2 ] || return 2
341 munlink $DIR/$tfile-2 || return 3
343 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
346 replay_barrier $SINGLEMDS
347 multiop_bg_pause $DIR/$tfile O_c || return 4
350 kill -USR1 $pid || return 1
351 wait $pid || return 2
352 $CHECKSTAT -t file $DIR/$tfile || return 3
355 run_test 17 "|X| open(O_CREAT), |replay| close"
358 replay_barrier $SINGLEMDS
359 multiop_bg_pause $DIR/$tfile O_tSc || return 8
362 touch $DIR/$tfile-2 || return 1
363 echo "pid: $pid will close"
365 wait $pid || return 2
368 [ -e $DIR/$tfile ] && return 3
369 [ -e $DIR/$tfile-2 ] || return 4
370 # this touch frequently fails
371 touch $DIR/$tfile-3 || return 5
372 munlink $DIR/$tfile-2 || return 6
373 munlink $DIR/$tfile-3 || return 7
376 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
378 # bug 1855 (a simpler form of test_11 above)
380 replay_barrier $SINGLEMDS
382 echo "old" > $DIR/$tfile
383 mv $DIR/$tfile $DIR/$tfile-2
384 grep old $DIR/$tfile-2
386 grep old $DIR/$tfile-2 || return 2
388 run_test 19 "|X| mcreate, open, write, rename "
390 test_20a() { # was test_20
391 replay_barrier $SINGLEMDS
392 multiop_bg_pause $DIR/$tfile O_tSc || return 3
398 wait $pid || return 1
399 [ -e $DIR/$tfile ] && return 2
402 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
404 test_20b() { # bug 10480
405 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
407 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
409 while [ ! -e $DIR/$tfile ] ; do
410 usleep 60 # give dd a chance to start
413 $GETSTRIPE $DIR/$tfile || return 1
414 rm -f $DIR/$tfile || return 2 # make it an orphan
416 client_up || client_up || true # reconnect
418 fail $SINGLEMDS # start orphan recovery
419 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
420 wait_mds_ost_sync || return 3
421 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
422 log "before $BEFOREUSED, after $AFTERUSED"
423 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
424 error "after $AFTERUSED > before $BEFOREUSED"
427 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
429 test_20c() { # bug 10480
430 multiop_bg_pause $DIR/$tfile Ow_c || return 1
436 client_up || client_up || true # reconnect
439 wait $pid || return 1
440 [ -s $DIR/$tfile ] || error "File was truncated"
444 run_test 20c "check that client eviction does not affect file content"
447 replay_barrier $SINGLEMDS
448 multiop_bg_pause $DIR/$tfile O_tSc || return 5
451 touch $DIR/g11 || return 1
455 wait $pid || return 2
456 [ -e $DIR/$tfile ] && return 3
457 touch $DIR/h11 || return 4
460 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
463 multiop_bg_pause $DIR/$tfile O_tSc || return 3
466 replay_barrier $SINGLEMDS
471 wait $pid || return 1
472 [ -e $DIR/$tfile ] && return 2
475 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
478 multiop_bg_pause $DIR/$tfile O_tSc || return 5
481 replay_barrier $SINGLEMDS
483 touch $DIR/g11 || return 1
487 wait $pid || return 2
488 [ -e $DIR/$tfile ] && return 3
489 touch $DIR/h11 || return 4
492 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
495 multiop_bg_pause $DIR/$tfile O_tSc || return 3
498 replay_barrier $SINGLEMDS
502 wait $pid || return 1
503 [ -e $DIR/$tfile ] && return 2
506 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
509 multiop_bg_pause $DIR/$tfile O_tSc || return 3
513 replay_barrier $SINGLEMDS
516 wait $pid || return 1
517 [ -e $DIR/$tfile ] && return 2
520 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
523 replay_barrier $SINGLEMDS
524 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
526 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
531 wait $pid2 || return 1
535 wait $pid1 || return 2
536 [ -e $DIR/$tfile-1 ] && return 3
537 [ -e $DIR/$tfile-2 ] && return 4
540 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
543 replay_barrier $SINGLEMDS
544 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
546 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
553 wait $pid1 || return 1
555 wait $pid2 || return 2
556 [ -e $DIR/$tfile-1 ] && return 3
557 [ -e $DIR/$tfile-2 ] && return 4
560 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
563 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
565 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
567 replay_barrier $SINGLEMDS
571 wait $pid2 || return 1
575 wait $pid1 || return 2
576 [ -e $DIR/$tfile-1 ] && return 3
577 [ -e $DIR/$tfile-2 ] && return 4
580 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
583 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
585 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
587 replay_barrier $SINGLEMDS
593 wait $pid1 || return 1
595 wait $pid2 || return 2
596 [ -e $DIR/$tfile-1 ] && return 3
597 [ -e $DIR/$tfile-2 ] && return 4
600 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
603 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
605 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
610 replay_barrier $SINGLEMDS
613 wait $pid1 || return 1
615 wait $pid2 || return 2
616 [ -e $DIR/$tfile-1 ] && return 3
617 [ -e $DIR/$tfile-2 ] && return 4
620 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
623 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
625 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
629 replay_barrier $SINGLEMDS
633 wait $pid1 || return 1
635 wait $pid2 || return 2
636 [ -e $DIR/$tfile-1 ] && return 3
637 [ -e $DIR/$tfile-2 ] && return 4
640 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
642 # tests for bug 2104; completion without crashing is success. The close is
643 # stale, but we always return 0 for close, so the app never sees it.
645 multiop_bg_pause $DIR/$tfile O_c || return 2
647 multiop_bg_pause $DIR/$tfile O_c || return 3
650 client_up || client_up || return 1
653 wait $pid1 || return 4
654 wait $pid2 || return 5
657 run_test 32 "close() notices client eviction; close() after client eviction"
660 createmany -o $DIR/$tfile-%d 10
661 replay_barrier_nosync $SINGLEMDS
662 fail_abort $SINGLEMDS
663 # recreate shouldn't fail
664 createmany -o $DIR/$tfile--%d 10 || return 1
668 run_test 33a "fid seq shouldn't be reused after abort recovery"
671 #define OBD_FAIL_SEQ_ALLOC 0x1311
672 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
674 createmany -o $DIR/$tfile-%d 10
675 replay_barrier_nosync $SINGLEMDS
676 fail_abort $SINGLEMDS
677 # recreate shouldn't fail
678 createmany -o $DIR/$tfile--%d 10 || return 1
682 run_test 33b "test fid seq allocation"
685 multiop_bg_pause $DIR/$tfile O_c || return 2
689 replay_barrier $SINGLEMDS
690 fail_abort $SINGLEMDS
692 wait $pid || return 3
693 [ -e $DIR/$tfile ] && return 1
697 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
699 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
703 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
704 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
709 # give a chance to remove from MDS
710 fail_abort $SINGLEMDS
711 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
713 run_test 35 "test recovery from llog for unlink op"
715 # b=2432 resent cancel after replay uses wrong cookie,
716 # so don't resend cancels
718 replay_barrier $SINGLEMDS
720 checkstat $DIR/$tfile
721 facet_failover $SINGLEMDS
723 if dmesg | grep "unknown lock cookie"; then
724 echo "cancel after replay failed"
728 run_test 36 "don't resend cancel"
731 # directory orphans can't be unlinked from PENDING directory
733 rmdir $DIR/$tfile 2>/dev/null
734 multiop_bg_pause $DIR/$tfile dD_c || return 2
738 replay_barrier $SINGLEMDS
739 # clear the dmesg buffer so we only see errors from this recovery
740 do_facet $SINGLEMDS dmesg -c >/dev/null
741 fail_abort $SINGLEMDS
743 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
745 wait $pid || return 3
749 start_full_debug_logging
750 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
751 stop_full_debug_logging
754 createmany -o $DIR/$tfile-%d 800
755 unlinkmany $DIR/$tfile-%d 0 400
756 replay_barrier $SINGLEMDS
758 unlinkmany $DIR/$tfile-%d 400 400
760 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
762 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
764 test_39() { # bug 4176
765 createmany -o $DIR/$tfile-%d 800
766 replay_barrier $SINGLEMDS
767 unlinkmany $DIR/$tfile-%d 0 400
769 unlinkmany $DIR/$tfile-%d 400 400
771 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
773 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
776 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
781 $LCTL mark multiop $MOUNT/$tfile OS_c
782 multiop $MOUNT/$tfile OS_c &
784 writeme -s $MOUNT/${tfile}-2 &
787 facet_failover $SINGLEMDS
788 #define OBD_FAIL_MDS_CONNECT_NET 0x117
789 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
791 stat1=`count_ost_writes`
793 stat2=`count_ost_writes`
794 echo "$stat1, $stat2"
795 if [ $stat1 -lt $stat2 ]; then
796 echo "writes continuing during recovery"
799 echo "writes not continuing during recovery, bug 2477"
802 echo "waiting for writeme $WRITE_PID"
806 echo "waiting for multiop $PID"
807 wait $PID || return 2
808 do_facet client munlink $MOUNT/$tfile || return 3
809 do_facet client munlink $MOUNT/${tfile}-2 || return 3
812 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
816 # make sure that a read to one osc doesn't try to double-unlock its page just
817 # because another osc is invalid. trigger_group_io used to mistakenly return
818 # an error if any oscs were invalid even after having successfully put rpcs
819 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
820 # the page, guarnateeing that the unlock from the RPC completion would
821 # assert on trying to unlock the unlocked page.
823 [ $OSTCOUNT -lt 2 ] &&
824 skip_env "skipping test 41: we don't have a second OST to test with" &&
827 local f=$MOUNT/$tfile
828 # make sure the start of the file is ost1
829 $SETSTRIPE -S $((128 * 1024)) -i 0 $f
830 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
832 # fail ost2 and read from ost1
833 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
834 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
835 grep $mdtosc | awk '{print $1}')
836 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices &&
838 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
839 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
840 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
843 run_test 41 "read from a valid osc while other oscs are invalid"
845 # test MDS recovery after ost failure
847 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
848 createmany -o $DIR/$tfile-%d 800
850 unlinkmany $DIR/$tfile-%d 0 400
852 lctl set_param debug=-1
855 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
856 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
857 #[ $blocks_after -lt $blocks ] || return 1
858 echo wait for MDS to timeout and recover
859 sleep $((TIMEOUT * 2))
861 unlinkmany $DIR/$tfile-%d 400 400
862 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
864 run_test 42 "recovery after ost failure"
866 # timeout in MDS/OST recovery RPC will LBUG MDS
867 test_43() { # bug 2530
868 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
870 replay_barrier $SINGLEMDS
872 # OBD_FAIL_OST_CREATE_NET 0x204
873 do_facet ost1 "lctl set_param fail_loc=0x80000204"
876 do_facet ost1 "lctl set_param fail_loc=0"
880 run_test 43 "mds osc import failure during recovery; don't LBUG"
882 test_44a() { # was test_44
885 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
886 [ "$mdcdev" ] || return 2
887 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
889 # adaptive timeouts slow this way down
890 if at_is_enabled; then
891 at_max_saved=$(at_max_get mds)
895 for i in `seq 1 10`; do
896 echo "$i of 10 ($(date +%s))"
897 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
898 #define OBD_FAIL_TGT_CONN_RACE 0x701
899 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
900 # lctl below may fail, it is valid case
901 $LCTL --device $mdcdev recover
904 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
905 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
908 run_test 44a "race in target handle connect"
911 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
912 [ "$mdcdev" ] || return 2
913 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
915 for i in `seq 1 10`; do
916 echo "$i of 10 ($(date +%s))"
917 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
918 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
919 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
920 # lctl below may fail, it is valid case
921 $LCTL --device $mdcdev recover
924 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
927 run_test 44b "race in target handle connect"
930 replay_barrier $SINGLEMDS
931 createmany -m $DIR/$tfile-%d 100
932 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
933 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
934 fail_abort $SINGLEMDS
935 unlinkmany $DIR/$tfile-%d 100 && return 1
937 unlinkmany $DIR/$tfile-%d 100 && return 1
940 run_test 44c "race in target handle connect"
942 # Handle failed close
944 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
945 [ "$mdcdev" ] || return 2
946 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
948 $LCTL --device $mdcdev recover || return 6
950 multiop_bg_pause $DIR/$tfile O_c || return 1
953 # This will cause the CLOSE to fail before even
954 # allocating a reply buffer
955 $LCTL --device $mdcdev deactivate || return 4
959 wait $pid || return 1
961 $LCTL --device $mdcdev activate || return 5
964 $CHECKSTAT -t file $DIR/$tfile || return 2
967 run_test 45 "Handle failed close"
971 drop_reply "touch $DIR/$tfile"
973 # ironically, the previous test, 45, will cause a real forced close,
974 # so just look for one for this test
975 dmesg | grep -i "force closing client file handle for $tfile" && return 1
978 run_test 46 "Don't leak file handle after open resend (3325)"
980 test_47() { # bug 2824
981 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
983 # create some files to make sure precreate has been done on all
984 # OSTs. (just in case this test is run independently)
985 createmany -o $DIR/$tfile 20 || return 1
987 # OBD_FAIL_OST_CREATE_NET 0x204
989 do_facet ost1 "lctl set_param fail_loc=0x80000204"
990 client_up || return 2
992 # let the MDS discover the OST failure, attempt to recover, fail
994 sleep $((3 * TIMEOUT))
996 # Without 2824, this createmany would hang
997 createmany -o $DIR/$tfile 20 || return 3
998 unlinkmany $DIR/$tfile 20 || return 4
1000 do_facet ost1 "lctl set_param fail_loc=0"
1003 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1006 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1007 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1009 replay_barrier $SINGLEMDS
1010 createmany -o $DIR/$tfile 20 || return 1
1011 # OBD_FAIL_OST_EROFS 0x216
1012 facet_failover $SINGLEMDS
1013 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1014 client_up || return 2
1016 createmany -o $DIR/$tfile 20 20 || return 2
1017 unlinkmany $DIR/$tfile 40 || return 3
1020 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1023 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1024 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1025 grep $mdtosc | awk '{print $1}')
1026 [ "$oscdev" ] || return 1
1027 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1028 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1029 # give the mds_lov_sync threads a chance to run
1032 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1034 # b3764 timed out lock replay
1037 cancel_lru_locks mdc
1039 multiop $DIR/$tfile s || return 1
1040 replay_barrier $SINGLEMDS
1041 #define OBD_FAIL_LDLM_REPLY 0x30c
1042 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1043 fail $SINGLEMDS || return 2
1044 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1046 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1048 run_test 52 "time out lock replay (3764)"
1050 # bug 3462 - simultaneous MDC requests
1052 cancel_lru_locks mdc # cleanup locks from former test cases
1053 mkdir -p $DIR/${tdir}-1
1054 mkdir -p $DIR/${tdir}-2
1055 multiop $DIR/${tdir}-1/f O_c &
1057 # give multiop a change to open
1060 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1061 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1062 kill -USR1 $close_pid
1063 cancel_lru_locks mdc # force the close
1064 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1066 mcreate $DIR/${tdir}-2/f || return 1
1068 # close should still be here
1069 [ -d /proc/$close_pid ] || return 2
1071 replay_barrier_nodf $SINGLEMDS
1073 wait $close_pid || return 3
1075 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1076 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1077 rm -rf $DIR/${tdir}-*
1079 run_test 53a "|X| close request while two MDC requests in flight"
1082 cancel_lru_locks mdc # cleanup locks from former test cases
1083 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1085 mkdir -p $DIR/${tdir}-1
1086 mkdir -p $DIR/${tdir}-2
1087 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1090 #define OBD_FAIL_MDS_REINT_NET 0x107
1091 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1092 mcreate $DIR/${tdir}-2/f &
1096 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1097 kill -USR1 $close_pid
1098 cancel_lru_locks mdc # force the close
1099 wait $close_pid || return 1
1100 # open should still be here
1101 [ -d /proc/$open_pid ] || return 2
1103 replay_barrier_nodf $SINGLEMDS
1105 wait $open_pid || return 3
1107 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1108 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1109 rm -rf $DIR/${tdir}-*
1111 run_test 53b "|X| open request while two MDC requests in flight"
1114 cancel_lru_locks mdc # cleanup locks from former test cases
1115 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1117 mkdir -p $DIR/${tdir}-1
1118 mkdir -p $DIR/${tdir}-2
1119 multiop $DIR/${tdir}-1/f O_c &
1122 #define OBD_FAIL_MDS_REINT_NET 0x107
1123 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1124 mcreate $DIR/${tdir}-2/f &
1128 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1129 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1130 kill -USR1 $close_pid
1131 cancel_lru_locks mdc # force the close
1133 #bz20647: make sure all pids are exists before failover
1134 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1135 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1136 replay_barrier_nodf $SINGLEMDS
1137 fail_nodf $SINGLEMDS
1138 wait $open_pid || return 1
1140 # close should be gone
1141 [ -d /proc/$close_pid ] && return 2
1142 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1144 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1145 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1146 rm -rf $DIR/${tdir}-*
1148 run_test 53c "|X| open request and close request while two MDC requests in flight"
1151 cancel_lru_locks mdc # cleanup locks from former test cases
1152 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1154 mkdir -p $DIR/${tdir}-1
1155 mkdir -p $DIR/${tdir}-2
1156 multiop $DIR/${tdir}-1/f O_c &
1158 # give multiop a chance to open
1161 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1162 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1163 kill -USR1 $close_pid
1164 cancel_lru_locks mdc # force the close
1165 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1166 mcreate $DIR/${tdir}-2/f || return 1
1168 # close should still be here
1169 [ -d /proc/$close_pid ] || return 2
1171 wait $close_pid || return 3
1173 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1174 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1175 rm -rf $DIR/${tdir}-*
1177 run_test 53d "|X| close reply while two MDC requests in flight"
1180 cancel_lru_locks mdc # cleanup locks from former test cases
1181 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1183 mkdir -p $DIR/${tdir}-1
1184 mkdir -p $DIR/${tdir}-2
1185 multiop $DIR/${tdir}-1/f O_c &
1188 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1189 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1190 mcreate $DIR/${tdir}-2/f &
1194 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1195 kill -USR1 $close_pid
1196 cancel_lru_locks mdc # force the close
1197 wait $close_pid || return 1
1198 # open should still be here
1199 [ -d /proc/$open_pid ] || return 2
1201 replay_barrier_nodf $SINGLEMDS
1203 wait $open_pid || return 3
1205 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1206 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1207 rm -rf $DIR/${tdir}-*
1209 run_test 53e "|X| open reply while two MDC requests in flight"
1212 cancel_lru_locks mdc # cleanup locks from former test cases
1213 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1215 mkdir -p $DIR/${tdir}-1
1216 mkdir -p $DIR/${tdir}-2
1217 multiop $DIR/${tdir}-1/f O_c &
1220 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1221 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1222 mcreate $DIR/${tdir}-2/f &
1226 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1227 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1228 kill -USR1 $close_pid
1229 cancel_lru_locks mdc # force the close
1231 #bz20647: make sure all pids are exists before failover
1232 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1233 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1234 replay_barrier_nodf $SINGLEMDS
1235 fail_nodf $SINGLEMDS
1236 wait $open_pid || return 1
1238 # close should be gone
1239 [ -d /proc/$close_pid ] && return 2
1240 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1242 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1243 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1244 rm -rf $DIR/${tdir}-*
1246 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1249 cancel_lru_locks mdc # cleanup locks from former test cases
1250 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1252 mkdir -p $DIR/${tdir}-1
1253 mkdir -p $DIR/${tdir}-2
1254 multiop $DIR/${tdir}-1/f O_c &
1257 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1258 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1259 mcreate $DIR/${tdir}-2/f &
1263 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1264 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1265 kill -USR1 $close_pid
1266 cancel_lru_locks mdc # force the close
1267 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1269 #bz20647: make sure all pids are exists before failover
1270 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1271 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1272 replay_barrier_nodf $SINGLEMDS
1273 fail_nodf $SINGLEMDS
1274 wait $open_pid || return 1
1276 # close should be gone
1277 [ -d /proc/$close_pid ] && return 2
1279 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1280 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1281 rm -rf $DIR/${tdir}-*
1283 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1286 cancel_lru_locks mdc # cleanup locks from former test cases
1287 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1289 mkdir -p $DIR/${tdir}-1
1290 mkdir -p $DIR/${tdir}-2
1291 multiop $DIR/${tdir}-1/f O_c &
1294 #define OBD_FAIL_MDS_REINT_NET 0x107
1295 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1296 mcreate $DIR/${tdir}-2/f &
1300 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1301 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1302 kill -USR1 $close_pid
1303 cancel_lru_locks mdc # force the close
1306 #bz20647: make sure all pids are exists before failover
1307 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1308 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1309 replay_barrier_nodf $SINGLEMDS
1310 fail_nodf $SINGLEMDS
1311 wait $open_pid || return 1
1313 # close should be gone
1314 [ -d /proc/$close_pid ] && return 2
1315 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1317 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1318 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1319 rm -rf $DIR/${tdir}-*
1321 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1323 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1325 #b3761 ASSERTION(hash != 0) failed
1327 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1328 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1330 # give touch a chance to run
1332 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1336 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1338 #b3440 ASSERTION(rec->ur_fid2->id) failed
1340 ln -s foo $DIR/$tfile
1341 replay_barrier $SINGLEMDS
1342 #drop_reply "cat $DIR/$tfile"
1346 run_test 56 "don't replay a symlink open request (3440)"
1348 #recovery one mds-ost setattr from llog
1350 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1351 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1353 replay_barrier $SINGLEMDS
1356 $CHECKSTAT -t file $DIR/$tfile || return 1
1357 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1360 run_test 57 "test recovery from llog for setattr op"
1362 #recovery many mds-ost setattr from llog
1365 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1366 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1367 createmany -o $DIR/$tdir/$tfile-%d 2500
1368 replay_barrier $SINGLEMDS
1371 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1372 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1373 unlinkmany $DIR/$tdir/$tfile-%d 2500
1376 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1382 large_xattr_enabled &&
1383 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1385 mount_client $MOUNT2
1387 touch $DIR/$tdir/$tfile
1388 replay_barrier $SINGLEMDS
1389 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1391 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1392 [[ "$new" = "$orig" ]] || return 1
1393 rm -f $DIR/$tdir/$tfile
1395 zconf_umount `hostname` $MOUNT2
1397 run_test 58b "test replay of setxattr op"
1399 test_58c() { # bug 16570
1404 if large_xattr_enabled; then
1405 local xattr_size=$(max_xattr_size)
1406 orig="$(generate_string $((xattr_size / 2)))"
1407 orig1="$(generate_string $xattr_size)"
1413 mount_client $MOUNT2
1415 touch $DIR/$tdir/$tfile
1416 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1418 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1419 [[ "$new" = "$orig" ]] || return 2
1420 drop_reint_reply "setfattr -n trusted.foo1 -v $orig1 $DIR/$tdir/$tfile" ||
1422 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1423 [[ "$new" = "$orig1" ]] || return 4
1424 rm -f $DIR/$tdir/$tfile
1426 zconf_umount $HOSTNAME $MOUNT2
1428 run_test 58c "resend/reconstruct setxattr op"
1430 # log_commit_thread vs filter_destroy race used to lead to import use after free
1433 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1436 createmany -o $DIR/$tdir/$tfile-%d 200
1438 unlinkmany $DIR/$tdir/$tfile-%d 200
1439 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1440 do_facet ost1 "lctl set_param fail_loc=0x507"
1443 do_facet ost1 "lctl set_param fail_loc=0x0"
1447 run_test 59 "test log_commit_thread vs filter_destroy race"
1449 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1450 # bug 12086: should no oops and No ctxt error for this test
1453 createmany -o $DIR/$tdir/$tfile-%d 200
1454 replay_barrier $SINGLEMDS
1455 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1457 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1458 local no_ctxt=`dmesg | grep "No ctxt"`
1459 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1461 run_test 60 "test llog post recovery init vs llog unlink"
1463 #test race llog recovery thread vs llog cleanup
1464 test_61a() { # was test_61
1465 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1468 createmany -o $DIR/$tdir/$tfile-%d 800
1470 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1471 unlinkmany $DIR/$tdir/$tfile-%d 800
1472 set_nodes_failloc "$(osts_nodes)" 0x80000221
1477 set_nodes_failloc "$(osts_nodes)" 0x0
1479 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1482 run_test 61a "test race llog recovery vs llog cleanup"
1484 #test race mds llog sync vs llog cleanup
1486 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1487 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1488 facet_failover $SINGLEMDS
1491 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1493 run_test 61b "test race mds llog sync vs llog cleanup"
1495 #test race cancel cookie cb vs llog cleanup
1497 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1499 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1501 set_nodes_failloc "$(osts_nodes)" 0x80000222
1505 set_nodes_failloc "$(osts_nodes)" 0x0
1507 run_test 61c "test race mds llog sync vs llog cleanup"
1509 test_61d() { # bug 16002 # bug 17466 # bug 22137
1510 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1512 do_facet mgs "lctl set_param fail_loc=0x80000605"
1513 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1514 do_facet mgs "lctl set_param fail_loc=0"
1515 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1517 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1519 test_62() { # Bug 15756 - don't mis-drop resent replay
1521 replay_barrier $SINGLEMDS
1522 createmany -o $DIR/$tdir/$tfile- 25
1523 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1524 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1526 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1527 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1530 run_test 62 "don't mis-drop resent replay"
1532 #Adaptive Timeouts (bug 3055)
1540 echo "Cleaning up AT ..."
1541 if [ -n "$ATOLDBASE" ]; then
1542 local at_history=$($LCTL get_param -n at_history)
1543 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1544 do_facet ost1 "lctl set_param at_history=$at_history" || true
1547 if [ $AT_MAX_SET -ne 0 ]; then
1548 for facet in mds client ost; do
1549 var=AT_MAX_SAVE_${facet}
1550 echo restore AT on $facet to saved value ${!var}
1551 at_max_set ${!var} $facet
1552 at_new=$(at_max_get $facet)
1553 echo Restored AT value on $facet $at_new
1554 [ $at_new -eq ${!var} ] || \
1555 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1562 local at_max_new=600
1564 # Save at_max original values
1566 if [ $AT_MAX_SET -eq 0 ]; then
1567 # Suppose that all osts have the same at_max
1568 for facet in mds client ost; do
1569 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1573 for facet in mds client ost; do
1574 at_max=$(at_max_get $facet)
1575 if [ $at_max -ne $at_max_new ]; then
1576 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1577 at_max_set $at_max_new $facet
1582 if [ -z "$ATOLDBASE" ]; then
1583 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1584 # speed up the timebase so we can check decreasing AT
1585 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1586 do_facet ost1 "lctl set_param at_history=8" || true
1588 # sleep for a while to cool down, should be > 8s and also allow
1589 # at least one ping to be sent. simply use TIMEOUT to be safe.
1594 test_65a() #bug 3055
1596 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1598 at_start || return 0
1599 $LCTL dk > /dev/null
1601 $LCTL set_param debug="other"
1602 # Slow down a request to the current service time, this is critical
1603 # because previous tests may have caused this value to increase.
1604 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1605 awk '/portal 12/ {print $5}'`
1606 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1608 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1609 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1610 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1611 createmany -o $DIR/$tfile 10 > /dev/null
1612 unlinkmany $DIR/$tfile 10 > /dev/null
1613 # check for log message
1614 $LCTL dk | grep "Early reply #" || error "No early reply"
1616 # client should show REQ_DELAY estimates
1617 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1619 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1621 run_test 65a "AT: verify early replies"
1623 test_65b() #bug 3055
1625 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1627 at_start || return 0
1630 $LCTL set_param debug="other trace"
1631 $LCTL dk > /dev/null
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 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1635 multiop $DIR/$tfile Ow1yc
1636 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1637 awk '/portal 6/ {print $5}'`
1638 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1640 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1641 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1642 do_facet ost1 $LCTL set_param fail_loc=0x224
1645 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tfile
1646 # force some real bulk transfer
1647 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1649 do_facet ost1 $LCTL set_param fail_loc=0
1650 # check for log message
1651 $LCTL dk | grep "Early reply #" || error "No early reply"
1653 # client should show REQ_DELAY estimates
1654 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1656 run_test 65b "AT: verify early replies on packed reply / bulk"
1658 test_66a() #bug 3055
1660 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1662 at_start || return 0
1663 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1664 # adjust 5s at a time so no early reply is sent (within deadline)
1665 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1666 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1667 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1668 createmany -o $DIR/$tfile 20 > /dev/null
1669 unlinkmany $DIR/$tfile 20 > /dev/null
1670 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1671 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1672 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1673 createmany -o $DIR/$tfile 20 > /dev/null
1674 unlinkmany $DIR/$tfile 20 > /dev/null
1675 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1676 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1678 createmany -o $DIR/$tfile 20 > /dev/null
1679 unlinkmany $DIR/$tfile 20 > /dev/null
1680 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1681 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1682 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1683 echo "Current MDT timeout $CUR, worst $WORST"
1684 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1686 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1688 test_66b() #bug 3055
1690 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1692 at_start || return 0
1693 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1694 $LCTL set_param fail_val=$(($ORIG + 5))
1695 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1696 $LCTL set_param fail_loc=0x50c
1697 ls $DIR/$tfile > /dev/null 2>&1
1698 $LCTL set_param fail_loc=0
1699 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1700 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1701 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1702 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1704 run_test 66b "AT: verify net latency adjusts"
1706 test_67a() #bug 3055
1708 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1710 at_start || return 0
1711 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1712 # sleeping threads may drive values above this
1713 do_facet ost1 "$LCTL set_param fail_val=400"
1714 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1715 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1716 createmany -o $DIR/$tfile 20 > /dev/null
1717 unlinkmany $DIR/$tfile 20 > /dev/null
1718 do_facet ost1 "$LCTL set_param fail_loc=0"
1719 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1720 ATTEMPTS=$(($CONN2 - $CONN1))
1721 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1722 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1725 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1727 test_67b() #bug 3055
1729 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1731 at_start || return 0
1732 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1734 # exhaust precreations on ost1
1735 local OST=$(ostname_from_index 0)
1736 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1737 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1738 osc.$mdtosc.prealloc_last_id)
1739 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1740 osc.$mdtosc.prealloc_next_id)
1742 mkdir -p $DIR/$tdir/${OST}
1743 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/${OST} || error "$SETSTRIPE"
1744 echo "Creating to objid $last_id on ost $OST..."
1745 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1746 do_facet ost1 "$LCTL set_param fail_val=20000"
1747 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1748 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1751 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1753 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1754 ATTEMPTS=$(($CONN2 - $CONN1))
1755 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1756 # do it again; should not timeout
1757 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1758 cp /etc/profile $DIR/$tfile || error "cp failed"
1759 do_facet ost1 "$LCTL set_param fail_loc=0"
1761 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1762 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1763 ATTEMPTS=$(($CONN3 - $CONN2))
1764 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1765 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1768 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1770 test_68 () #bug 13813
1772 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1774 at_start || return 0
1775 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1776 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1777 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1778 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1779 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1780 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1781 echo $TIMEOUT >> $ldlm_enqueue_min
1782 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1786 $SETSTRIPE --stripe-index=0 --count=1 $DIR/$tdir
1787 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1788 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1789 $LCTL set_param fail_loc=0x80000312
1790 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1791 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1792 $LCTL set_param fail_loc=0x80000312
1793 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1794 $LCTL set_param fail_loc=0
1796 echo $ENQ_MIN >> $ldlm_enqueue_min
1797 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1801 run_test 68 "AT: verify slowing locks"
1804 # end of AT tests includes above lines
1807 # start multi-client tests
1809 [ -z "$CLIENTS" ] && \
1810 { skip "Need two or more clients." && return; }
1811 [ $CLIENTCOUNT -lt 2 ] && \
1812 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1814 echo "mount clients $CLIENTS ..."
1815 zconf_mount_clients $CLIENTS $MOUNT
1817 local clients=${CLIENTS//,/ }
1818 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1819 for CLIENT in $clients; do
1820 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1821 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1822 error "dd failed on $CLIENT"
1825 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1826 for C in ${CLIENTS//,/ }; do
1827 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1828 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1834 run_test 70a "check multi client t-f"
1836 check_for_process () {
1841 killall_process $clients "$prog" -0
1844 killall_process () {
1845 local clients=${1:-$(hostname)}
1850 do_nodes $clients "killall $signal $name"
1854 local clients=${CLIENTS:-$HOSTNAME}
1856 zconf_mount_clients $clients $MOUNT
1859 [ "$SLOW" = "no" ] && duration=60
1860 # set duration to 900 because it takes some time to boot node
1861 [ "$FAILURE_MODE" = HARD ] && duration=900
1863 local cmd="rundbench 1 -t $duration"
1865 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1866 PATH=\$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1867 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1868 MOUNT=$MOUNT DIR=$DIR/$tdir/\\\$(hostname) LCTL=$LCTL $cmd" &
1870 log "Started rundbench load pid=$pid ..."
1872 # give rundbench a chance to start, bug 24118
1875 local num_failovers=0
1876 local start_ts=$(date +%s)
1877 while [ $elapsed -lt $duration ]; do
1878 if ! check_for_process $clients dbench; then
1879 error_noexit "dbench not found on some of $clients!"
1880 killall_process $clients dbench
1884 replay_barrier $SINGLEMDS
1885 sleep 1 # give clients a time to do operations
1886 # Increment the number of failovers
1887 num_failovers=$((num_failovers+1))
1888 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1890 elapsed=$(($(date +%s) - start_ts))
1893 wait $pid || error "rundbench load on $clients failed!"
1895 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1896 # end multi-client tests
1899 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1903 replay_barrier $SINGLEMDS
1904 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1905 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1908 wait $pid || return 1
1909 [ -e $DIR/$tfile ] && return 2
1912 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1915 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1919 replay_barrier $SINGLEMDS
1920 #define OBD_FAIL_LDLM_REPLY 0x30c
1921 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1924 wait $pid || return 1
1925 [ -e $DIR/$tfile ] && return 2
1928 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1931 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1935 replay_barrier $SINGLEMDS
1936 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1937 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1940 wait $pid || return 1
1941 [ -e $DIR/$tfile ] && return 2
1944 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1948 local clients=${CLIENTS:-$HOSTNAME}
1951 zconf_umount_clients $clients $MOUNT
1952 facet_failover $SINGLEMDS
1953 zconf_mount_clients $clients $MOUNT
1955 touch $DIR/$tfile || return 1
1956 rm $DIR/$tfile || return 2
1957 clients_up || error "client evicted: $?"
1960 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1963 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1967 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1968 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1970 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1973 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1976 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1979 replay_barrier $SINGLEMDS
1980 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1981 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1983 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1986 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1989 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1992 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1994 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1995 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1996 replay_barrier $SINGLEMDS
1997 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1999 stat $DIR/$tdir/f1002
2001 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
2004 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2008 mkdir $dir || error "mkdir $dir failed"
2012 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2014 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
2017 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2020 replay_barrier $SINGLEMDS
2021 mkdir $dir || error "mkdir $dir failed"
2025 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2027 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2031 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2032 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2033 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2034 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2036 run_test 83a "fail log_add during unlink recovery"
2040 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2041 replay_barrier $SINGLEMDS
2042 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2043 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2044 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2047 run_test 83b "fail log_add during unlink recovery"
2050 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2051 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2052 createmany -o $DIR/$tfile- 1 &
2056 client_up || client_up || true # reconnect
2058 run_test 84a "stale open during export disconnect"
2060 test_85a() { #bug 16774
2061 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2063 for i in `seq 100`; do
2064 echo "tag-$i" > $DIR/$tfile-$i
2065 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2068 lov_id=`lctl dl | grep "clilov"`
2069 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2070 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2071 echo "before recovery: unused locks count = $count"
2075 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2076 echo "after recovery: unused locks count = $count2"
2078 if [ $count2 -ge $count ]; then
2079 error "unused locks are not canceled"
2082 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2084 test_85b() { #bug 16774
2085 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2087 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
2088 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 || return 2
2090 $SETSTRIPE -c 1 -p $FSNAME.$TESTNAME $DIR
2092 for i in `seq 100`; do
2093 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2096 cancel_lru_locks osc
2098 for i in `seq 100`; do
2099 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2102 lov_id=`lctl dl | grep "clilov"`
2103 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2104 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2105 echo "before recovery: unused locks count = $count"
2106 [ $count != 0 ] || return 3
2110 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2111 echo "after recovery: unused locks count = $count2"
2113 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 || return 4
2114 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
2116 if [ $count2 -ge $count ]; then
2117 error "unused locks are not canceled"
2120 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2123 local clients=${CLIENTS:-$HOSTNAME}
2125 zconf_umount_clients $clients $MOUNT
2126 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2127 remount_facet $SINGLEMDS
2128 zconf_mount_clients $clients $MOUNT
2130 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2133 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2136 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2137 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2138 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2139 cancel_lru_locks osc
2141 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2142 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2143 if [ $cksum != $cksum2 ] ; then
2144 error "New checksum $cksum2 does not match original $cksum"
2147 run_test 87 "write replay"
2150 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2153 $SETSTRIPE -i 0 -c 1 $DIR/$tfile
2154 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2155 sleep 1 # Give it a chance to flush dirty data
2156 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2157 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2158 cancel_lru_locks osc
2160 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2161 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2162 if [ $cksum != $cksum2 ] ; then
2163 error "New checksum $cksum2 does not match original $cksum"
2166 run_test 87b "write replay with changed data (checksum resend)"
2168 test_88() { #bug 17485
2172 $SETSTRIPE -i 0 -c 1 $DIR/$tdir || error "$SETSTRIPE"
2175 replay_barrier $SINGLEMDS
2177 # exhaust precreations on ost1
2178 local OST=$(ostname_from_index 0)
2179 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2180 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2181 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2182 echo "before test: last_id = $last_id, next_id = $next_id"
2184 echo "Creating to objid $last_id on ost $OST..."
2185 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2187 #create some files to use some uncommitted objids
2188 last_id=$(($last_id + 1))
2189 createmany -o $DIR/$tdir/f-%d $last_id 8
2191 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2192 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2193 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2195 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2196 # it has to take care about the affected facets, bug20407
2197 local affected_mds1=$(affected_facets mds1)
2198 local affected_ost1=$(affected_facets ost1)
2200 shutdown_facet $SINGLEMDS
2203 reboot_facet $SINGLEMDS
2204 change_active $affected_mds1
2205 wait_for_facet $affected_mds1
2206 mount_facets $affected_mds1 || error "Restart of mds failed"
2209 change_active $affected_ost1
2210 wait_for_facet $affected_ost1
2211 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2215 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2216 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2217 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2219 # create new files, which should use new objids, and ensure the orphan
2220 # cleanup phase for ost1 is completed at the same time
2221 for i in `seq 8`; do
2222 file_id=$(($last_id + 10 + $i))
2223 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2226 # if the objids were not recreated, then "ls" will failed for -ENOENT
2227 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2230 # write into previously created files
2231 for i in `seq 8`; do
2232 file_id=$(($last_id + $i))
2233 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2234 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2237 # compare the content
2238 for i in `seq 8`; do
2239 file_id=$(($last_id + $i))
2240 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2241 "of file is modified!"
2246 run_test 88 "MDS should not assign same objid to different files "
2249 cancel_lru_locks osc
2251 rm -f $DIR/$tdir/$tfile
2253 wait_destroy_complete
2254 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2255 $SETSTRIPE -i 0 -c 1 $DIR/$tdir/$tfile
2256 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2259 facet_failover $SINGLEMDS
2260 rm $DIR/$tdir/$tfile
2263 zconf_mount $(hostname) $MOUNT
2264 client_up || return 1
2266 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2267 [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2270 run_test 89 "no disk space leak on late ost connection"
2276 change_active $facet
2277 wait_for_facet $facet
2278 mount_facet $facet || error "Restart of $facet failed"
2282 test_90() { # bug 19494
2283 local dir=$DIR/$tdir
2284 local ostfail=$(get_random_entry $(get_facets OST))
2286 if [[ $FAILURE_MODE = HARD ]]; then
2287 local affected=$(affected_facets $ostfail);
2288 if [[ "$affected" != $ostfail ]]; then
2289 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2296 echo "Create the files"
2298 # file "f${index}" striped over 1 OST
2299 # file "all" striped over all OSTs
2301 $SETSTRIPE -c $OSTCOUNT $dir/all ||
2302 error "setstripe failed to create $dir/all"
2304 for (( i=0; i<$OSTCOUNT; i++ )); do
2306 $SETSTRIPE -i $i -c 1 $f || error "$SETSTRIPE failed to create $f"
2308 # confirm setstripe actually created the stripe on the requested OST
2309 local uuid=$(ostuuid_from_index $i)
2310 for file in f$i all; do
2311 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2312 $GETSTRIPE $dir/file
2313 error wrong stripe: $file, uuid: $uuid
2318 # Before failing an OST, get its obd name and index
2319 local varsvc=${ostfail}_svc
2320 local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
2321 local index=${obd:(-6):1}
2323 echo "Fail $ostfail $obd, display the list of affected files"
2324 shutdown_facet $ostfail || return 2
2326 trap "cleanup_90 $ostfail" EXIT INT
2327 echo "General Query: lfs find $dir"
2328 local list=$($LFS find $dir)
2330 for (( i=0; i<$OSTCOUNT; i++ )); do
2331 list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
2333 list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
2335 # focus on the missing OST,
2336 # we expect to see only two files affected: "f$(index)" and "all"
2338 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2339 list=$($LFS find --obd $obd $dir)
2341 for file in all f$index; do
2342 list_member "$list" $dir/$file ||
2343 error_noexit "lfs find does not report the affected $obd for $file"
2346 [[ $(echo $list | wc -w) -eq 2 ]] ||
2347 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2349 echo "Check getstripe: $GETSTRIPE -r --obd $obd"
2350 list=$($GETSTRIPE -r --obd $obd $dir)
2352 for file in all f$index; do
2353 echo "$list" | grep $dir/$file ||
2354 error_noexit "lfs getsripe does not report the affected $obd for $file"
2359 run_test 90 "lfs find identifies the missing striped file segments"
2361 complete $(basename $0) $SECONDS
2362 check_and_cleanup_lustre