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 $(kernel_version 2 6 33) ]; then
40 sync; sleep 5; sync; sleep 5; sync; sleep 5
43 test_0a() { # was test_0
45 replay_barrier $SINGLEMDS
49 run_test 0a "empty replay"
52 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
54 # this test attempts to trigger a race in the precreation code,
55 # and must run before any other objects are created on the filesystem
57 createmany -o $DIR/$tfile 20 || return 1
58 unlinkmany $DIR/$tfile 20 || return 2
60 run_test 0b "ensure object created after recover exists. (3284)"
63 replay_barrier $SINGLEMDS
65 facet_failover $SINGLEMDS
66 zconf_mount `hostname` $MOUNT || error "mount fails"
67 client_up || error "post-failover df failed"
69 run_test 0d "expired recovery with no clients"
72 replay_barrier $SINGLEMDS
75 $CHECKSTAT -t file $DIR/$tfile || return 1
78 run_test 1 "simple create"
81 replay_barrier $SINGLEMDS
84 $CHECKSTAT -t file $DIR/$tfile || return 1
91 replay_barrier $SINGLEMDS
94 $CHECKSTAT -t file $DIR/$tfile || return 1
100 local file=$DIR/$tfile
101 replay_barrier $SINGLEMDS
103 openfile -f O_DIRECTORY $file
105 $CHECKSTAT -t file $file || return 2
108 run_test 3a "replay failed open(O_DIRECTORY)"
111 replay_barrier $SINGLEMDS
112 #define OBD_FAIL_MDS_OPEN_PACK | OBD_FAIL_ONCE
113 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000114"
115 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
117 $CHECKSTAT -t file $DIR/$tfile && return 2
120 run_test 3b "replay failed open -ENOMEM"
123 replay_barrier $SINGLEMDS
124 #define OBD_FAIL_MDS_ALLOC_OBDO | OBD_FAIL_ONCE
125 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000128"
127 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
130 $CHECKSTAT -t file $DIR/$tfile && return 2
133 run_test 3c "replay failed open -ENOMEM"
135 test_4a() { # was test_4
136 replay_barrier $SINGLEMDS
137 for i in `seq 10`; do
138 echo "tag-$i" > $DIR/$tfile-$i
141 for i in `seq 10`; do
142 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
145 run_test 4a "|x| 10 open(O_CREAT)s"
148 replay_barrier $SINGLEMDS
151 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
153 run_test 4b "|x| rm 10 files"
155 # The idea is to get past the first block of precreated files on both
156 # osts, and then replay.
158 replay_barrier $SINGLEMDS
159 for i in `seq 220`; do
160 echo "tag-$i" > $DIR/$tfile-$i
163 for i in `seq 220`; do
164 grep -q "tag-$i" $DIR/$tfile-$i || error "$tfile-$i"
168 # waiting for commitment of removal
170 run_test 5 "|x| 220 open(O_CREAT)"
173 test_6a() { # was test_6
175 replay_barrier $SINGLEMDS
176 mcreate $DIR/$tdir/$tfile
178 $CHECKSTAT -t dir $DIR/$tdir || return 1
179 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
181 # waiting for log process thread
183 run_test 6a "mkdir + contained create"
187 replay_barrier $SINGLEMDS
190 $CHECKSTAT -t dir $DIR/$tdir && return 1 || true
192 run_test 6b "|X| rmdir"
196 replay_barrier $SINGLEMDS
197 mcreate $DIR/$tdir/$tfile
199 $CHECKSTAT -t dir $DIR/$tdir || return 1
200 $CHECKSTAT -t file $DIR/$tdir/$tfile || return 2
203 run_test 7 "mkdir |X| contained create"
206 # make sure no side-effect from previous test.
208 replay_barrier $SINGLEMDS
209 multiop_bg_pause $DIR/$tfile mo_c || return 4
213 $CHECKSTAT -t file $DIR/$tfile || return 1
214 kill -USR1 $MULTIPID || return 2
215 wait $MULTIPID || return 3
218 run_test 8 "creat open |X| close"
221 replay_barrier $SINGLEMDS
223 local old_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
225 local new_inum=`ls -i $DIR/$tfile | awk '{print $1}'`
227 echo " old_inum == $old_inum, new_inum == $new_inum"
228 if [ $old_inum -eq $new_inum ] ;
230 echo " old_inum and new_inum match"
232 echo "!!!! old_inum and new_inum NOT match"
237 run_test 9 "|X| create (same inum/gen)"
241 replay_barrier $SINGLEMDS
242 mv $DIR/$tfile $DIR/$tfile-2
245 $CHECKSTAT $DIR/$tfile && return 1
246 $CHECKSTAT $DIR/$tfile-2 ||return 2
250 run_test 10 "create |X| rename unlink"
254 echo "old" > $DIR/$tfile
255 mv $DIR/$tfile $DIR/$tfile-2
256 replay_barrier $SINGLEMDS
257 echo "new" > $DIR/$tfile
259 grep old $DIR/$tfile-2
261 grep new $DIR/$tfile || return 1
262 grep old $DIR/$tfile-2 || return 2
264 run_test 11 "create open write rename |X| create-old-name read"
268 multiop_bg_pause $DIR/$tfile o_tSc || return 3
271 replay_barrier $SINGLEMDS
273 wait $pid || return 1
276 [ -e $DIR/$tfile ] && return 2
279 run_test 12 "open, unlink |X| close"
282 # 1777 - replay open after committed chmod that would make
283 # a regular open a failure
286 multiop_bg_pause $DIR/$tfile O_wc || return 3
289 $CHECKSTAT -p 0 $DIR/$tfile
290 replay_barrier $SINGLEMDS
293 wait $pid || return 1
295 $CHECKSTAT -s 1 -p 0 $DIR/$tfile || return 2
296 rm $DIR/$tfile || return 4
299 run_test 13 "open chmod 0 |x| write close"
302 multiop_bg_pause $DIR/$tfile O_tSc || return 4
305 replay_barrier $SINGLEMDS
306 kill -USR1 $pid || return 1
307 wait $pid || return 2
310 [ -e $DIR/$tfile ] && return 3
313 run_test 14 "open(O_CREAT), unlink |X| close"
316 multiop_bg_pause $DIR/$tfile O_tSc || return 5
319 replay_barrier $SINGLEMDS
320 touch $DIR/g11 || return 1
322 wait $pid || return 2
325 [ -e $DIR/$tfile ] && return 3
326 touch $DIR/h11 || return 4
329 run_test 15 "open(O_CREAT), unlink |X| touch new, close"
333 replay_barrier $SINGLEMDS
336 mcreate $DIR/$tfile-2
338 [ -e $DIR/$tfile ] && return 1
339 [ -e $DIR/$tfile-2 ] || return 2
340 munlink $DIR/$tfile-2 || return 3
342 run_test 16 "|X| open(O_CREAT), unlink, touch new, unlink new"
345 replay_barrier $SINGLEMDS
346 multiop_bg_pause $DIR/$tfile O_c || return 4
349 kill -USR1 $pid || return 1
350 wait $pid || return 2
351 $CHECKSTAT -t file $DIR/$tfile || return 3
354 run_test 17 "|X| open(O_CREAT), |replay| close"
357 replay_barrier $SINGLEMDS
358 multiop_bg_pause $DIR/$tfile O_tSc || return 8
361 touch $DIR/$tfile-2 || return 1
362 echo "pid: $pid will close"
364 wait $pid || return 2
367 [ -e $DIR/$tfile ] && return 3
368 [ -e $DIR/$tfile-2 ] || return 4
369 # this touch frequently fails
370 touch $DIR/$tfile-3 || return 5
371 munlink $DIR/$tfile-2 || return 6
372 munlink $DIR/$tfile-3 || return 7
375 run_test 18 "|X| open(O_CREAT), unlink, touch new, close, touch, unlink"
377 # bug 1855 (a simpler form of test_11 above)
379 replay_barrier $SINGLEMDS
381 echo "old" > $DIR/$tfile
382 mv $DIR/$tfile $DIR/$tfile-2
383 grep old $DIR/$tfile-2
385 grep old $DIR/$tfile-2 || return 2
387 run_test 19 "|X| mcreate, open, write, rename "
389 test_20a() { # was test_20
390 replay_barrier $SINGLEMDS
391 multiop_bg_pause $DIR/$tfile O_tSc || return 3
397 wait $pid || return 1
398 [ -e $DIR/$tfile ] && return 2
401 run_test 20a "|X| open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
403 test_20b() { # bug 10480
404 BEFOREUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
406 dd if=/dev/zero of=$DIR/$tfile bs=4k count=10000 &
408 while [ ! -e $DIR/$tfile ] ; do
409 usleep 60 # give dd a chance to start
412 lfs getstripe $DIR/$tfile || return 1
413 rm -f $DIR/$tfile || return 2 # make it an orphan
415 client_up || client_up || true # reconnect
417 fail $SINGLEMDS # start orphan recovery
418 wait_recovery_complete $SINGLEMDS || error "MDS recovery not done"
419 wait_mds_ost_sync || return 3
420 AFTERUSED=`df -P $DIR | tail -1 | awk '{ print $3 }'`
421 log "before $BEFOREUSED, after $AFTERUSED"
422 [ $AFTERUSED -gt $((BEFOREUSED + 20)) ] && \
423 error "after $AFTERUSED > before $BEFOREUSED"
426 run_test 20b "write, unlink, eviction, replay, (test mds_cleanup_orphans)"
428 test_20c() { # bug 10480
429 multiop_bg_pause $DIR/$tfile Ow_c || return 1
435 client_up || client_up || true # reconnect
438 wait $pid || return 1
439 [ -s $DIR/$tfile ] || error "File was truncated"
443 run_test 20c "check that client eviction does not affect file content"
446 replay_barrier $SINGLEMDS
447 multiop_bg_pause $DIR/$tfile O_tSc || return 5
450 touch $DIR/g11 || return 1
454 wait $pid || return 2
455 [ -e $DIR/$tfile ] && return 3
456 touch $DIR/h11 || return 4
459 run_test 21 "|X| open(O_CREAT), unlink touch new, replay, close (test mds_cleanup_orphans)"
462 multiop_bg_pause $DIR/$tfile O_tSc || return 3
465 replay_barrier $SINGLEMDS
470 wait $pid || return 1
471 [ -e $DIR/$tfile ] && return 2
474 run_test 22 "open(O_CREAT), |X| unlink, replay, close (test mds_cleanup_orphans)"
477 multiop_bg_pause $DIR/$tfile O_tSc || return 5
480 replay_barrier $SINGLEMDS
482 touch $DIR/g11 || return 1
486 wait $pid || return 2
487 [ -e $DIR/$tfile ] && return 3
488 touch $DIR/h11 || return 4
491 run_test 23 "open(O_CREAT), |X| unlink touch new, replay, close (test mds_cleanup_orphans)"
494 multiop_bg_pause $DIR/$tfile O_tSc || return 3
497 replay_barrier $SINGLEMDS
501 wait $pid || return 1
502 [ -e $DIR/$tfile ] && return 2
505 run_test 24 "open(O_CREAT), replay, unlink, close (test mds_cleanup_orphans)"
508 multiop_bg_pause $DIR/$tfile O_tSc || return 3
512 replay_barrier $SINGLEMDS
515 wait $pid || return 1
516 [ -e $DIR/$tfile ] && return 2
519 run_test 25 "open(O_CREAT), unlink, replay, close (test mds_cleanup_orphans)"
522 replay_barrier $SINGLEMDS
523 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
525 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
530 wait $pid2 || return 1
534 wait $pid1 || return 2
535 [ -e $DIR/$tfile-1 ] && return 3
536 [ -e $DIR/$tfile-2 ] && return 4
539 run_test 26 "|X| open(O_CREAT), unlink two, close one, replay, close one (test mds_cleanup_orphans)"
542 replay_barrier $SINGLEMDS
543 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
545 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
552 wait $pid1 || return 1
554 wait $pid2 || return 2
555 [ -e $DIR/$tfile-1 ] && return 3
556 [ -e $DIR/$tfile-2 ] && return 4
559 run_test 27 "|X| open(O_CREAT), unlink two, replay, close two (test mds_cleanup_orphans)"
562 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
564 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
566 replay_barrier $SINGLEMDS
570 wait $pid2 || return 1
574 wait $pid1 || return 2
575 [ -e $DIR/$tfile-1 ] && return 3
576 [ -e $DIR/$tfile-2 ] && return 4
579 run_test 28 "open(O_CREAT), |X| unlink two, close one, replay, close one (test mds_cleanup_orphans)"
582 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
584 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
586 replay_barrier $SINGLEMDS
592 wait $pid1 || return 1
594 wait $pid2 || return 2
595 [ -e $DIR/$tfile-1 ] && return 3
596 [ -e $DIR/$tfile-2 ] && return 4
599 run_test 29 "open(O_CREAT), |X| unlink two, replay, close two (test mds_cleanup_orphans)"
602 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
604 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
609 replay_barrier $SINGLEMDS
612 wait $pid1 || return 1
614 wait $pid2 || return 2
615 [ -e $DIR/$tfile-1 ] && return 3
616 [ -e $DIR/$tfile-2 ] && return 4
619 run_test 30 "open(O_CREAT) two, unlink two, replay, close two (test mds_cleanup_orphans)"
622 multiop_bg_pause $DIR/$tfile-1 O_tSc || return 5
624 multiop_bg_pause $DIR/$tfile-2 O_tSc || return 6
628 replay_barrier $SINGLEMDS
632 wait $pid1 || return 1
634 wait $pid2 || return 2
635 [ -e $DIR/$tfile-1 ] && return 3
636 [ -e $DIR/$tfile-2 ] && return 4
639 run_test 31 "open(O_CREAT) two, unlink one, |X| unlink one, close two (test mds_cleanup_orphans)"
641 # tests for bug 2104; completion without crashing is success. The close is
642 # stale, but we always return 0 for close, so the app never sees it.
644 multiop_bg_pause $DIR/$tfile O_c || return 2
646 multiop_bg_pause $DIR/$tfile O_c || return 3
649 client_up || client_up || return 1
652 wait $pid1 || return 4
653 wait $pid2 || return 5
656 run_test 32 "close() notices client eviction; close() after client eviction"
659 createmany -o $DIR/$tfile-%d 10
660 replay_barrier_nosync $SINGLEMDS
661 fail_abort $SINGLEMDS
662 # recreate shouldn't fail
663 createmany -o $DIR/$tfile--%d 10 || return 1
667 run_test 33a "fid seq shouldn't be reused after abort recovery"
670 #define OBD_FAIL_SEQ_ALLOC 0x1311
671 do_facet $SINGLEMDS "lctl set_param fail_loc=0x1311"
673 createmany -o $DIR/$tfile-%d 10
674 replay_barrier_nosync $SINGLEMDS
675 fail_abort $SINGLEMDS
676 # recreate shouldn't fail
677 createmany -o $DIR/$tfile--%d 10 || return 1
681 run_test 33b "test fid seq allocation"
684 multiop_bg_pause $DIR/$tfile O_c || return 2
688 replay_barrier $SINGLEMDS
689 fail_abort $SINGLEMDS
691 wait $pid || return 3
692 [ -e $DIR/$tfile ] && return 1
696 run_test 34 "abort recovery before client does replay (test mds_cleanup_orphans)"
698 # bug 2278 - generate one orphan on OST, then destroy it during recovery from llog
702 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
703 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000119"
708 # give a chance to remove from MDS
709 fail_abort $SINGLEMDS
710 $CHECKSTAT -t file $DIR/$tfile && return 1 || true
712 run_test 35 "test recovery from llog for unlink op"
714 # b=2432 resent cancel after replay uses wrong cookie,
715 # so don't resend cancels
717 replay_barrier $SINGLEMDS
719 checkstat $DIR/$tfile
720 facet_failover $SINGLEMDS
722 if dmesg | grep "unknown lock cookie"; then
723 echo "cancel after replay failed"
727 run_test 36 "don't resend cancel"
730 # directory orphans can't be unlinked from PENDING directory
732 rmdir $DIR/$tfile 2>/dev/null
733 multiop_bg_pause $DIR/$tfile dD_c || return 2
737 replay_barrier $SINGLEMDS
738 # clear the dmesg buffer so we only see errors from this recovery
739 do_facet $SINGLEMDS dmesg -c >/dev/null
740 fail_abort $SINGLEMDS
742 do_facet $SINGLEMDS dmesg | grep "error .* unlinking .* from PENDING" &&
744 wait $pid || return 3
748 start_full_debug_logging
749 run_test 37 "abort recovery before client does replay (test mds_cleanup_orphans for directories)"
750 stop_full_debug_logging
753 createmany -o $DIR/$tfile-%d 800
754 unlinkmany $DIR/$tfile-%d 0 400
755 replay_barrier $SINGLEMDS
757 unlinkmany $DIR/$tfile-%d 400 400
759 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
761 run_test 38 "test recovery from unlink llog (test llog_gen_rec) "
763 test_39() { # bug 4176
764 createmany -o $DIR/$tfile-%d 800
765 replay_barrier $SINGLEMDS
766 unlinkmany $DIR/$tfile-%d 0 400
768 unlinkmany $DIR/$tfile-%d 400 400
770 $CHECKSTAT -t file $DIR/$tfile-* && return 1 || true
772 run_test 39 "test recovery from unlink llog (test llog_gen_rec) "
775 lctl get_param -n osc.*.stats | awk -vwrites=0 '/ost_write/ { writes += $2 } END { print writes; }'
780 $LCTL mark multiop $MOUNT/$tfile OS_c
781 multiop $MOUNT/$tfile OS_c &
783 writeme -s $MOUNT/${tfile}-2 &
786 facet_failover $SINGLEMDS
787 #define OBD_FAIL_MDS_CONNECT_NET 0x117
788 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000117"
790 stat1=`count_ost_writes`
792 stat2=`count_ost_writes`
793 echo "$stat1, $stat2"
794 if [ $stat1 -lt $stat2 ]; then
795 echo "writes continuing during recovery"
798 echo "writes not continuing during recovery, bug 2477"
801 echo "waiting for writeme $WRITE_PID"
805 echo "waiting for multiop $PID"
806 wait $PID || return 2
807 do_facet client munlink $MOUNT/$tfile || return 3
808 do_facet client munlink $MOUNT/${tfile}-2 || return 3
811 run_test 40 "cause recovery in ptlrpc, ensure IO continues"
815 # make sure that a read to one osc doesn't try to double-unlock its page just
816 # because another osc is invalid. trigger_group_io used to mistakenly return
817 # an error if any oscs were invalid even after having successfully put rpcs
818 # on valid oscs. This was fatal if the caller was ll_readpage who unlocked
819 # the page, guarnateeing that the unlock from the RPC completion would
820 # assert on trying to unlock the unlocked page.
822 [ $OSTCOUNT -lt 2 ] && \
823 skip_env "skipping test 41: we don't have a second OST to test with" && \
826 local f=$MOUNT/$tfile
827 # make sure the start of the file is ost1
828 lfs setstripe $f -s $((128 * 1024)) -i 0
829 do_facet client dd if=/dev/zero of=$f bs=4k count=1 || return 3
831 # fail ost2 and read from ost1
832 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost2_svc)
833 local osc2dev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
834 grep $mdtosc | awk '{print $1}')
835 [ -z "$osc2dev" ] && echo "OST: $ost2_svc" && lctl get_param -n devices && return 4
836 do_facet $SINGLEMDS $LCTL --device $osc2dev deactivate || return 1
837 do_facet client dd if=$f of=/dev/null bs=4k count=1 || return 3
838 do_facet $SINGLEMDS $LCTL --device $osc2dev activate || return 2
841 run_test 41 "read from a valid osc while other oscs are invalid"
843 # test MDS recovery after ost failure
845 blocks=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
846 createmany -o $DIR/$tfile-%d 800
848 unlinkmany $DIR/$tfile-%d 0 400
850 lctl set_param debug=-1
853 # osc is evicted, fs is smaller (but only with failout OSTs (bug 7287)
854 #blocks_after=`df -P $MOUNT | tail -n 1 | awk '{ print $2 }'`
855 #[ $blocks_after -lt $blocks ] || return 1
856 echo wait for MDS to timeout and recover
857 sleep $((TIMEOUT * 2))
859 unlinkmany $DIR/$tfile-%d 400 400
860 $CHECKSTAT -t file $DIR/$tfile-* && return 2 || true
862 run_test 42 "recovery after ost failure"
864 # timeout in MDS/OST recovery RPC will LBUG MDS
865 test_43() { # bug 2530
866 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
868 replay_barrier $SINGLEMDS
870 # OBD_FAIL_OST_CREATE_NET 0x204
871 do_facet ost1 "lctl set_param fail_loc=0x80000204"
874 do_facet ost1 "lctl set_param fail_loc=0"
878 run_test 43 "mds osc import failure during recovery; don't LBUG"
880 test_44a() { # was test_44
883 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
884 [ "$mdcdev" ] || return 2
885 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
887 # adaptive timeouts slow this way down
888 if at_is_enabled; then
889 at_max_saved=$(at_max_get mds)
893 for i in `seq 1 10`; do
894 echo "$i of 10 ($(date +%s))"
895 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
896 #define OBD_FAIL_TGT_CONN_RACE 0x701
897 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000701"
898 # lctl below may fail, it is valid case
899 $LCTL --device $mdcdev recover
902 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
903 [ $at_max_saved -ne 0 ] && at_max_set $at_max_saved mds
906 run_test 44a "race in target handle connect"
909 local mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
910 [ "$mdcdev" ] || return 2
911 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
913 for i in `seq 1 10`; do
914 echo "$i of 10 ($(date +%s))"
915 do_facet $SINGLEMDS "lctl get_param -n mdt.*.mdt.timeouts | grep service"
916 #define OBD_FAIL_TGT_DELAY_RECONNECT 0x704
917 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000704"
918 # lctl below may fail, it is valid case
919 $LCTL --device $mdcdev recover
922 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
925 run_test 44b "race in target handle connect"
928 replay_barrier $SINGLEMDS
929 createmany -m $DIR/$tfile-%d 100
930 #define OBD_FAIL_TGT_RCVG_FLAG 0x712
931 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000712"
932 fail_abort $SINGLEMDS
933 unlinkmany $DIR/$tfile-%d 100 && return 1
935 unlinkmany $DIR/$tfile-%d 100 && return 1
938 run_test 44c "race in target handle connect"
940 # Handle failed close
942 mdcdev=`lctl get_param -n devices | awk '/MDT0000-mdc-/ {print $1}'`
943 [ "$mdcdev" ] || return 2
944 [ $(echo $mdcdev | wc -w) -eq 1 ] || { echo $mdcdev=$mdcdev && return 3; }
946 $LCTL --device $mdcdev recover || return 6
948 multiop_bg_pause $DIR/$tfile O_c || return 1
951 # This will cause the CLOSE to fail before even
952 # allocating a reply buffer
953 $LCTL --device $mdcdev deactivate || return 4
957 wait $pid || return 1
959 $LCTL --device $mdcdev activate || return 5
962 $CHECKSTAT -t file $DIR/$tfile || return 2
965 run_test 45 "Handle failed close"
969 drop_reply "touch $DIR/$tfile"
971 # ironically, the previous test, 45, will cause a real forced close,
972 # so just look for one for this test
973 dmesg | grep -i "force closing client file handle for $tfile" && return 1
976 run_test 46 "Don't leak file handle after open resend (3325)"
978 test_47() { # bug 2824
979 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
981 # create some files to make sure precreate has been done on all
982 # OSTs. (just in case this test is run independently)
983 createmany -o $DIR/$tfile 20 || return 1
985 # OBD_FAIL_OST_CREATE_NET 0x204
987 do_facet ost1 "lctl set_param fail_loc=0x80000204"
988 client_up || return 2
990 # let the MDS discover the OST failure, attempt to recover, fail
992 sleep $((3 * TIMEOUT))
994 # Without 2824, this createmany would hang
995 createmany -o $DIR/$tfile 20 || return 3
996 unlinkmany $DIR/$tfile 20 || return 4
998 do_facet ost1 "lctl set_param fail_loc=0"
1001 run_test 47 "MDS->OSC failure during precreate cleanup (2824)"
1004 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1005 [ "$OSTCOUNT" -lt "2" ] && skip_env "$OSTCOUNT < 2 OSTs -- skipping" && return
1007 replay_barrier $SINGLEMDS
1008 createmany -o $DIR/$tfile 20 || return 1
1009 # OBD_FAIL_OST_EROFS 0x216
1010 facet_failover $SINGLEMDS
1011 do_facet ost1 "lctl set_param fail_loc=0x80000216"
1012 client_up || return 2
1014 createmany -o $DIR/$tfile 20 20 || return 2
1015 unlinkmany $DIR/$tfile 40 || return 3
1018 run_test 48 "MDS->OSC failure during precreate cleanup (2824)"
1021 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $ost1_svc)
1022 local oscdev=$(do_facet $SINGLEMDS "lctl get_param -n devices" | \
1023 grep $mdtosc | awk '{print $1}')
1024 [ "$oscdev" ] || return 1
1025 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 2
1026 do_facet $SINGLEMDS $LCTL --device $oscdev recover || return 3
1027 # give the mds_lov_sync threads a chance to run
1030 run_test 50 "Double OSC recovery, don't LASSERT (3812)"
1032 # b3764 timed out lock replay
1035 cancel_lru_locks mdc
1037 multiop $DIR/$tfile s || return 1
1038 replay_barrier $SINGLEMDS
1039 #define OBD_FAIL_LDLM_REPLY 0x30c
1040 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1041 fail $SINGLEMDS || return 2
1042 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1044 $CHECKSTAT -t file $DIR/$tfile-* && return 3 || true
1046 run_test 52 "time out lock replay (3764)"
1048 # bug 3462 - simultaneous MDC requests
1050 cancel_lru_locks mdc # cleanup locks from former test cases
1051 mkdir -p $DIR/${tdir}-1
1052 mkdir -p $DIR/${tdir}-2
1053 multiop $DIR/${tdir}-1/f O_c &
1055 # give multiop a change to open
1058 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1059 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1060 kill -USR1 $close_pid
1061 cancel_lru_locks mdc # force the close
1062 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1064 mcreate $DIR/${tdir}-2/f || return 1
1066 # close should still be here
1067 [ -d /proc/$close_pid ] || return 2
1069 replay_barrier_nodf $SINGLEMDS
1071 wait $close_pid || return 3
1073 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1074 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1075 rm -rf $DIR/${tdir}-*
1077 run_test 53a "|X| close request while two MDC requests in flight"
1080 cancel_lru_locks mdc # cleanup locks from former test cases
1081 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1083 mkdir -p $DIR/${tdir}-1
1084 mkdir -p $DIR/${tdir}-2
1085 multiop_bg_pause $DIR/${tdir}-1/f O_c || return 6
1088 #define OBD_FAIL_MDS_REINT_NET 0x107
1089 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1090 mcreate $DIR/${tdir}-2/f &
1094 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1095 kill -USR1 $close_pid
1096 cancel_lru_locks mdc # force the close
1097 wait $close_pid || return 1
1098 # open should still be here
1099 [ -d /proc/$open_pid ] || return 2
1101 replay_barrier_nodf $SINGLEMDS
1103 wait $open_pid || return 3
1105 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1106 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1107 rm -rf $DIR/${tdir}-*
1109 run_test 53b "|X| open request while two MDC requests in flight"
1112 cancel_lru_locks mdc # cleanup locks from former test cases
1113 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1115 mkdir -p $DIR/${tdir}-1
1116 mkdir -p $DIR/${tdir}-2
1117 multiop $DIR/${tdir}-1/f O_c &
1120 #define OBD_FAIL_MDS_REINT_NET 0x107
1121 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1122 mcreate $DIR/${tdir}-2/f &
1126 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1127 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1128 kill -USR1 $close_pid
1129 cancel_lru_locks mdc # force the close
1131 #bz20647: make sure all pids are exists before failover
1132 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1133 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1134 replay_barrier_nodf $SINGLEMDS
1135 fail_nodf $SINGLEMDS
1136 wait $open_pid || return 1
1138 # close should be gone
1139 [ -d /proc/$close_pid ] && return 2
1140 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1142 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1143 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1144 rm -rf $DIR/${tdir}-*
1146 run_test 53c "|X| open request and close request while two MDC requests in flight"
1149 cancel_lru_locks mdc # cleanup locks from former test cases
1150 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1152 mkdir -p $DIR/${tdir}-1
1153 mkdir -p $DIR/${tdir}-2
1154 multiop $DIR/${tdir}-1/f O_c &
1156 # give multiop a chance to open
1159 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1160 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1161 kill -USR1 $close_pid
1162 cancel_lru_locks mdc # force the close
1163 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1164 mcreate $DIR/${tdir}-2/f || return 1
1166 # close should still be here
1167 [ -d /proc/$close_pid ] || return 2
1169 wait $close_pid || return 3
1171 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1172 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1173 rm -rf $DIR/${tdir}-*
1175 run_test 53d "|X| close reply while two MDC requests in flight"
1178 cancel_lru_locks mdc # cleanup locks from former test cases
1179 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1181 mkdir -p $DIR/${tdir}-1
1182 mkdir -p $DIR/${tdir}-2
1183 multiop $DIR/${tdir}-1/f O_c &
1186 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1187 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1188 mcreate $DIR/${tdir}-2/f &
1192 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1193 kill -USR1 $close_pid
1194 cancel_lru_locks mdc # force the close
1195 wait $close_pid || return 1
1196 # open should still be here
1197 [ -d /proc/$open_pid ] || return 2
1199 replay_barrier_nodf $SINGLEMDS
1201 wait $open_pid || return 3
1203 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 4
1204 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 5
1205 rm -rf $DIR/${tdir}-*
1207 run_test 53e "|X| open reply while two MDC requests in flight"
1210 cancel_lru_locks mdc # cleanup locks from former test cases
1211 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1213 mkdir -p $DIR/${tdir}-1
1214 mkdir -p $DIR/${tdir}-2
1215 multiop $DIR/${tdir}-1/f O_c &
1218 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1219 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1220 mcreate $DIR/${tdir}-2/f &
1224 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1225 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1226 kill -USR1 $close_pid
1227 cancel_lru_locks mdc # force the close
1229 #bz20647: make sure all pids are exists before failover
1230 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1231 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1232 replay_barrier_nodf $SINGLEMDS
1233 fail_nodf $SINGLEMDS
1234 wait $open_pid || return 1
1236 # close should be gone
1237 [ -d /proc/$close_pid ] && return 2
1238 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1240 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1241 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1242 rm -rf $DIR/${tdir}-*
1244 run_test 53f "|X| open reply and close reply while two MDC requests in flight"
1247 cancel_lru_locks mdc # cleanup locks from former test cases
1248 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1250 mkdir -p $DIR/${tdir}-1
1251 mkdir -p $DIR/${tdir}-2
1252 multiop $DIR/${tdir}-1/f O_c &
1255 #define OBD_FAIL_MDS_REINT_NET_REP 0x119
1256 do_facet $SINGLEMDS "lctl set_param fail_loc=0x119"
1257 mcreate $DIR/${tdir}-2/f &
1261 #define OBD_FAIL_MDS_CLOSE_NET 0x115
1262 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000115"
1263 kill -USR1 $close_pid
1264 cancel_lru_locks mdc # force the close
1265 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1267 #bz20647: make sure all pids are exists before failover
1268 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1269 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1270 replay_barrier_nodf $SINGLEMDS
1271 fail_nodf $SINGLEMDS
1272 wait $open_pid || return 1
1274 # close should be gone
1275 [ -d /proc/$close_pid ] && return 2
1277 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1278 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1279 rm -rf $DIR/${tdir}-*
1281 run_test 53g "|X| drop open reply and close request while close and open are both in flight"
1284 cancel_lru_locks mdc # cleanup locks from former test cases
1285 rm -rf $DIR/${tdir}-1 $DIR/${tdir}-2
1287 mkdir -p $DIR/${tdir}-1
1288 mkdir -p $DIR/${tdir}-2
1289 multiop $DIR/${tdir}-1/f O_c &
1292 #define OBD_FAIL_MDS_REINT_NET 0x107
1293 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000107"
1294 mcreate $DIR/${tdir}-2/f &
1298 #define OBD_FAIL_MDS_CLOSE_NET_REP 0x13b
1299 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013b"
1300 kill -USR1 $close_pid
1301 cancel_lru_locks mdc # force the close
1304 #bz20647: make sure all pids are exists before failover
1305 [ -d /proc/$close_pid ] || error "close_pid doesn't exist"
1306 [ -d /proc/$open_pid ] || error "open_pid doesn't exists"
1307 replay_barrier_nodf $SINGLEMDS
1308 fail_nodf $SINGLEMDS
1309 wait $open_pid || return 1
1311 # close should be gone
1312 [ -d /proc/$close_pid ] && return 2
1313 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1315 $CHECKSTAT -t file $DIR/${tdir}-1/f || return 3
1316 $CHECKSTAT -t file $DIR/${tdir}-2/f || return 4
1317 rm -rf $DIR/${tdir}-*
1319 run_test 53h "|X| open request and close reply while two MDC requests in flight"
1321 #b_cray 54 "|X| open request and close reply while two MDC requests in flight"
1323 #b3761 ASSERTION(hash != 0) failed
1325 # OBD_FAIL_MDS_OPEN_CREATE | OBD_FAIL_ONCE
1326 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012b"
1328 # give touch a chance to run
1330 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1334 run_test 55 "let MDS_CHECK_RESENT return the original return code instead of 0"
1336 #b3440 ASSERTION(rec->ur_fid2->id) failed
1338 ln -s foo $DIR/$tfile
1339 replay_barrier $SINGLEMDS
1340 #drop_reply "cat $DIR/$tfile"
1344 run_test 56 "don't replay a symlink open request (3440)"
1346 #recovery one mds-ost setattr from llog
1348 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1349 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1351 replay_barrier $SINGLEMDS
1354 $CHECKSTAT -t file $DIR/$tfile || return 1
1355 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1358 run_test 57 "test recovery from llog for setattr op"
1360 #recovery many mds-ost setattr from llog
1363 #define OBD_FAIL_MDS_OST_SETATTR 0x12c
1364 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000012c"
1365 createmany -o $DIR/$tdir/$tfile-%d 2500
1366 replay_barrier $SINGLEMDS
1369 $CHECKSTAT -t file $DIR/$tdir/$tfile-* >/dev/null || return 1
1370 do_facet $SINGLEMDS "lctl set_param fail_loc=0x0"
1371 unlinkmany $DIR/$tdir/$tfile-%d 2500
1374 run_test 58a "test recovery from llog for setattr op (test llog_gen_rec)"
1380 large_xattr_enabled &&
1381 orig="$(generate_string $(max_xattr_size))" || orig="bar"
1383 mount_client $MOUNT2
1385 touch $DIR/$tdir/$tfile
1386 replay_barrier $SINGLEMDS
1387 setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile
1389 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1390 [[ "$new" = "$orig" ]] || return 1
1391 rm -f $DIR/$tdir/$tfile
1393 zconf_umount `hostname` $MOUNT2
1395 run_test 58b "test replay of setxattr op"
1397 test_58c() { # bug 16570
1402 if large_xattr_enabled; then
1403 local xattr_size=$(max_xattr_size)
1404 orig="$(generate_string $((xattr_size / 2)))"
1405 orig1="$(generate_string $xattr_size)"
1411 mount_client $MOUNT2
1413 touch $DIR/$tdir/$tfile
1414 drop_request "setfattr -n trusted.foo -v $orig $DIR/$tdir/$tfile" ||
1416 new=$(get_xattr_value trusted.foo $MOUNT2/$tdir/$tfile)
1417 [[ "$new" = "$orig" ]] || return 2
1418 drop_reint_reply "setfattr -n trusted.foo1 -v $orig1 $DIR/$tdir/$tfile" ||
1420 new=$(get_xattr_value trusted.foo1 $MOUNT2/$tdir/$tfile)
1421 [[ "$new" = "$orig1" ]] || return 4
1422 rm -f $DIR/$tdir/$tfile
1424 zconf_umount $HOSTNAME $MOUNT2
1426 run_test 58c "resend/reconstruct setxattr op"
1428 # log_commit_thread vs filter_destroy race used to lead to import use after free
1431 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1434 createmany -o $DIR/$tdir/$tfile-%d 200
1436 unlinkmany $DIR/$tdir/$tfile-%d 200
1437 #define OBD_FAIL_PTLRPC_DELAY_RECOV 0x507
1438 do_facet ost1 "lctl set_param fail_loc=0x507"
1441 do_facet ost1 "lctl set_param fail_loc=0x0"
1445 run_test 59 "test log_commit_thread vs filter_destroy race"
1447 # race between add unlink llog vs cat log init in post_recovery (only for b1_6)
1448 # bug 12086: should no oops and No ctxt error for this test
1451 createmany -o $DIR/$tdir/$tfile-%d 200
1452 replay_barrier $SINGLEMDS
1453 unlinkmany $DIR/$tdir/$tfile-%d 0 100
1455 unlinkmany $DIR/$tdir/$tfile-%d 100 100
1456 local no_ctxt=`dmesg | grep "No ctxt"`
1457 [ -z "$no_ctxt" ] || error "ctxt is not initialized in recovery"
1459 run_test 60 "test llog post recovery init vs llog unlink"
1461 #test race llog recovery thread vs llog cleanup
1462 test_61a() { # was test_61
1463 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1466 createmany -o $DIR/$tdir/$tfile-%d 800
1468 # OBD_FAIL_OST_LLOG_RECOVERY_TIMEOUT 0x221
1469 unlinkmany $DIR/$tdir/$tfile-%d 800
1470 set_nodes_failloc "$(osts_nodes)" 0x80000221
1475 set_nodes_failloc "$(osts_nodes)" 0x0
1477 $CHECKSTAT -t file $DIR/$tdir/$tfile-* && return 1
1480 run_test 61a "test race llog recovery vs llog cleanup"
1482 #test race mds llog sync vs llog cleanup
1484 # OBD_FAIL_MDS_LLOG_SYNC_TIMEOUT 0x13a
1485 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000013a"
1486 facet_failover $SINGLEMDS
1489 do_facet client dd if=/dev/zero of=$DIR/$tfile bs=4k count=1 || return 1
1491 run_test 61b "test race mds llog sync vs llog cleanup"
1493 #test race cancel cookie cb vs llog cleanup
1495 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1497 # OBD_FAIL_OST_CANCEL_COOKIE_TIMEOUT 0x222
1499 set_nodes_failloc "$(osts_nodes)" 0x80000222
1503 set_nodes_failloc "$(osts_nodes)" 0x0
1505 run_test 61c "test race mds llog sync vs llog cleanup"
1507 test_61d() { # bug 16002 # bug 17466 # bug 22137
1508 # OBD_FAIL_OBD_LLOG_SETUP 0x605
1510 do_facet mgs "lctl set_param fail_loc=0x80000605"
1511 start mgs $MGSDEV $MGS_MOUNT_OPTS && error "mgs start should have failed"
1512 do_facet mgs "lctl set_param fail_loc=0"
1513 start mgs $MGSDEV $MGS_MOUNT_OPTS || error "cannot restart mgs"
1515 run_test 61d "error in llog_setup should cleanup the llog context correctly"
1517 test_62() { # Bug 15756 - don't mis-drop resent replay
1519 replay_barrier $SINGLEMDS
1520 createmany -o $DIR/$tdir/$tfile- 25
1521 #define OBD_FAIL_TGT_REPLAY_DROP 0x707
1522 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000707"
1524 do_facet $SINGLEMDS "lctl set_param fail_loc=0"
1525 unlinkmany $DIR/$tdir/$tfile- 25 || return 2
1528 run_test 62 "don't mis-drop resent replay"
1530 #Adaptive Timeouts (bug 3055)
1538 echo "Cleaning up AT ..."
1539 if [ -n "$ATOLDBASE" ]; then
1540 local at_history=$($LCTL get_param -n at_history)
1541 do_facet $SINGLEMDS "lctl set_param at_history=$at_history" || true
1542 do_facet ost1 "lctl set_param at_history=$at_history" || true
1545 if [ $AT_MAX_SET -ne 0 ]; then
1546 for facet in mds client ost; do
1547 var=AT_MAX_SAVE_${facet}
1548 echo restore AT on $facet to saved value ${!var}
1549 at_max_set ${!var} $facet
1550 at_new=$(at_max_get $facet)
1551 echo Restored AT value on $facet $at_new
1552 [ $at_new -eq ${!var} ] || \
1553 error "$facet : AT value was not restored SAVED ${!var} NEW $at_new"
1560 local at_max_new=600
1562 # Save at_max original values
1564 if [ $AT_MAX_SET -eq 0 ]; then
1565 # Suppose that all osts have the same at_max
1566 for facet in mds client ost; do
1567 eval AT_MAX_SAVE_${facet}=$(at_max_get $facet)
1571 for facet in mds client ost; do
1572 at_max=$(at_max_get $facet)
1573 if [ $at_max -ne $at_max_new ]; then
1574 echo "AT value on $facet is $at_max, set it by force temporarily to $at_max_new"
1575 at_max_set $at_max_new $facet
1580 if [ -z "$ATOLDBASE" ]; then
1581 ATOLDBASE=$(do_facet $SINGLEMDS "lctl get_param -n at_history")
1582 # speed up the timebase so we can check decreasing AT
1583 do_facet $SINGLEMDS "lctl set_param at_history=8" || true
1584 do_facet ost1 "lctl set_param at_history=8" || true
1586 # sleep for a while to cool down, should be > 8s and also allow
1587 # at least one ping to be sent. simply use TIMEOUT to be safe.
1592 test_65a() #bug 3055
1594 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1596 at_start || return 0
1597 $LCTL dk > /dev/null
1599 $LCTL set_param debug="other"
1600 # Slow down a request to the current service time, this is critical
1601 # because previous tests may have caused this value to increase.
1602 REQ_DELAY=`lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts |
1603 awk '/portal 12/ {print $5}'`
1604 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1606 do_facet $SINGLEMDS lctl set_param fail_val=$((${REQ_DELAY} * 1000))
1607 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1608 do_facet $SINGLEMDS $LCTL set_param fail_loc=0x8000050a
1609 createmany -o $DIR/$tfile 10 > /dev/null
1610 unlinkmany $DIR/$tfile 10 > /dev/null
1611 # check for log message
1612 $LCTL dk | grep "Early reply #" || error "No early reply"
1614 # client should show REQ_DELAY estimates
1615 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1617 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep portal
1619 run_test 65a "AT: verify early replies"
1621 test_65b() #bug 3055
1623 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1625 at_start || return 0
1628 $LCTL set_param debug="other trace"
1629 $LCTL dk > /dev/null
1630 # Slow down a request to the current service time, this is critical
1631 # because previous tests may have caused this value to increase.
1632 lfs setstripe $DIR/$tfile --index=0 --count=1
1633 multiop $DIR/$tfile Ow1yc
1634 REQ_DELAY=`lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts |
1635 awk '/portal 6/ {print $5}'`
1636 REQ_DELAY=$((${REQ_DELAY} + ${REQ_DELAY} / 4 + 5))
1638 do_facet ost1 lctl set_param fail_val=${REQ_DELAY}
1639 #define OBD_FAIL_OST_BRW_PAUSE_PACK 0x224
1640 do_facet ost1 $LCTL set_param fail_loc=0x224
1643 lfs setstripe $DIR/$tfile --index=0 --count=1
1644 # force some real bulk transfer
1645 multiop $DIR/$tfile oO_CREAT:O_RDWR:O_SYNC:w4096c
1647 do_facet ost1 $LCTL set_param fail_loc=0
1648 # check for log message
1649 $LCTL dk | grep "Early reply #" || error "No early reply"
1651 # client should show REQ_DELAY estimates
1652 lctl get_param -n osc.${FSNAME}-OST0000-osc-*.timeouts | grep portal
1654 run_test 65b "AT: verify early replies on packed reply / bulk"
1656 test_66a() #bug 3055
1658 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1660 at_start || return 0
1661 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1662 # adjust 5s at a time so no early reply is sent (within deadline)
1663 do_facet $SINGLEMDS "$LCTL set_param fail_val=5000"
1664 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1665 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1666 createmany -o $DIR/$tfile 20 > /dev/null
1667 unlinkmany $DIR/$tfile 20 > /dev/null
1668 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1669 do_facet $SINGLEMDS "$LCTL set_param fail_val=10000"
1670 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0x8000050a"
1671 createmany -o $DIR/$tfile 20 > /dev/null
1672 unlinkmany $DIR/$tfile 20 > /dev/null
1673 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1674 do_facet $SINGLEMDS "$LCTL set_param fail_loc=0"
1676 createmany -o $DIR/$tfile 20 > /dev/null
1677 unlinkmany $DIR/$tfile 20 > /dev/null
1678 lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | grep "portal 12"
1679 CUR=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $5}')
1680 WORST=$(lctl get_param -n mdc.${FSNAME}-MDT0000-mdc-*.timeouts | awk '/portal 12/ {print $7}')
1681 echo "Current MDT timeout $CUR, worst $WORST"
1682 [ $CUR -lt $WORST ] || error "Current $CUR should be less than worst $WORST"
1684 run_test 66a "AT: verify MDT service time adjusts with no early replies"
1686 test_66b() #bug 3055
1688 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1690 at_start || return 0
1691 ORIG=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1692 $LCTL set_param fail_val=$(($ORIG + 5))
1693 #define OBD_FAIL_PTLRPC_PAUSE_REP 0x50c
1694 $LCTL set_param fail_loc=0x50c
1695 ls $DIR/$tfile > /dev/null 2>&1
1696 $LCTL set_param fail_loc=0
1697 CUR=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $4}')
1698 WORST=$(lctl get_param -n mdc.${FSNAME}-*.timeouts | awk '/network/ {print $6}')
1699 echo "network timeout orig $ORIG, cur $CUR, worst $WORST"
1700 [ $WORST -gt $ORIG ] || error "Worst $WORST should be worse than orig $ORIG"
1702 run_test 66b "AT: verify net latency adjusts"
1704 test_67a() #bug 3055
1706 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1708 at_start || return 0
1709 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1710 # sleeping threads may drive values above this
1711 do_facet ost1 "$LCTL set_param fail_val=400"
1712 #define OBD_FAIL_PTLRPC_PAUSE_REQ 0x50a
1713 do_facet ost1 "$LCTL set_param fail_loc=0x50a"
1714 createmany -o $DIR/$tfile 20 > /dev/null
1715 unlinkmany $DIR/$tfile 20 > /dev/null
1716 do_facet ost1 "$LCTL set_param fail_loc=0"
1717 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1718 ATTEMPTS=$(($CONN2 - $CONN1))
1719 echo "$ATTEMPTS osc reconnect attempts on gradual slow"
1720 [ $ATTEMPTS -gt 0 ] && error_ignore 13721 "AT should have prevented reconnect"
1723 run_test 67a "AT: verify slow request processing doesn't induce reconnects"
1725 test_67b() #bug 3055
1727 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1729 at_start || return 0
1730 CONN1=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1732 # exhaust precreations on ost1
1733 local OST=$(ostname_from_index 0)
1734 local mdtosc=$(get_mdtosc_proc_path mds $OST)
1735 local last_id=$(do_facet $SINGLEMDS lctl get_param -n \
1736 osc.$mdtosc.prealloc_last_id)
1737 local next_id=$(do_facet $SINGLEMDS lctl get_param -n \
1738 osc.$mdtosc.prealloc_next_id)
1740 mkdir -p $DIR/$tdir/${OST}
1741 lfs setstripe $DIR/$tdir/${OST} -o 0 -c 1 || error "setstripe"
1742 echo "Creating to objid $last_id on ost $OST..."
1743 #define OBD_FAIL_OST_PAUSE_CREATE 0x223
1744 do_facet ost1 "$LCTL set_param fail_val=20000"
1745 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1746 createmany -o $DIR/$tdir/${OST}/f $next_id $((last_id - next_id + 2))
1749 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1751 CONN2=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1752 ATTEMPTS=$(($CONN2 - $CONN1))
1753 echo "$ATTEMPTS osc reconnect attempts on instant slow"
1754 # do it again; should not timeout
1755 do_facet ost1 "$LCTL set_param fail_loc=0x80000223"
1756 cp /etc/profile $DIR/$tfile || error "cp failed"
1757 do_facet ost1 "$LCTL set_param fail_loc=0"
1759 do_facet ost1 "lctl get_param -n ost.OSS.ost_create.timeouts"
1760 CONN3=$(lctl get_param -n osc.*.stats | awk '/_connect/ {total+=$2} END {print total}')
1761 ATTEMPTS=$(($CONN3 - $CONN2))
1762 echo "$ATTEMPTS osc reconnect attempts on 2nd slow"
1763 [ $ATTEMPTS -gt 0 ] && error "AT should have prevented reconnect"
1766 run_test 67b "AT: verify instant slowdown doesn't induce reconnects"
1768 test_68 () #bug 13813
1770 remote_ost_nodsh && skip "remote OST with nodsh" && return 0
1772 at_start || return 0
1773 local ldlm_enqueue_min=$(find /sys -name ldlm_enqueue_min)
1774 [ -z "$ldlm_enqueue_min" ] && skip "missing /sys/.../ldlm_enqueue_min" && return 0
1775 local ldlm_enqueue_min_r=$(do_facet ost1 "find /sys -name ldlm_enqueue_min")
1776 [ -z "$ldlm_enqueue_min_r" ] && skip "missing /sys/.../ldlm_enqueue_min in the ost1" && return 0
1777 local ENQ_MIN=$(cat $ldlm_enqueue_min)
1778 local ENQ_MIN_R=$(do_facet ost1 "cat $ldlm_enqueue_min_r")
1779 echo $TIMEOUT >> $ldlm_enqueue_min
1780 do_facet ost1 "echo $TIMEOUT >> $ldlm_enqueue_min_r"
1784 lfs setstripe $DIR/$tdir --index=0 --count=1
1785 #define OBD_FAIL_LDLM_PAUSE_CANCEL 0x312
1786 $LCTL set_param fail_val=$(($TIMEOUT - 1))
1787 $LCTL set_param fail_loc=0x80000312
1788 cp /etc/profile $DIR/$tdir/${tfile}_1 || error "1st cp failed $?"
1789 $LCTL set_param fail_val=$((TIMEOUT * 5 / 4))
1790 $LCTL set_param fail_loc=0x80000312
1791 cp /etc/profile $DIR/$tdir/${tfile}_2 || error "2nd cp failed $?"
1792 $LCTL set_param fail_loc=0
1794 echo $ENQ_MIN >> $ldlm_enqueue_min
1795 do_facet ost1 "echo $ENQ_MIN_R >> $ldlm_enqueue_min_r"
1799 run_test 68 "AT: verify slowing locks"
1802 # end of AT tests includes above lines
1805 # start multi-client tests
1807 [ -z "$CLIENTS" ] && \
1808 { skip "Need two or more clients." && return; }
1809 [ $CLIENTCOUNT -lt 2 ] && \
1810 { skip "Need two or more clients, have $CLIENTCOUNT" && return; }
1812 echo "mount clients $CLIENTS ..."
1813 zconf_mount_clients $CLIENTS $MOUNT
1815 local clients=${CLIENTS//,/ }
1816 echo "Write/read files on $DIR ; clients $CLIENTS ... "
1817 for CLIENT in $clients; do
1818 do_node $CLIENT dd bs=1M count=10 if=/dev/zero \
1819 of=$DIR/${tfile}_${CLIENT} 2>/dev/null || \
1820 error "dd failed on $CLIENT"
1823 local prev_client=$(echo $clients | sed 's/^.* \(.\+\)$/\1/')
1824 for C in ${CLIENTS//,/ }; do
1825 do_node $prev_client dd if=$DIR/${tfile}_${C} of=/dev/null 2>/dev/null || \
1826 error "dd if=$DIR/${tfile}_${C} failed on $prev_client"
1832 run_test 70a "check multi client t-f"
1834 check_for_process () {
1839 killall_process $clients "$prog" -0
1842 killall_process () {
1843 local clients=${1:-$(hostname)}
1848 do_nodes $clients "killall $signal $name"
1852 local clients=${CLIENTS:-$HOSTNAME}
1854 zconf_mount_clients $clients $MOUNT
1857 [ "$SLOW" = "no" ] && duration=60
1858 # set duration to 900 because it takes some time to boot node
1859 [ "$FAILURE_MODE" = HARD ] && duration=900
1861 local cmd="rundbench 1 -t $duration"
1863 do_nodesv $clients "set -x; MISSING_DBENCH_OK=$MISSING_DBENCH_OK \
1864 PATH=:$PATH:$LUSTRE/utils:$LUSTRE/tests/:$DBENCH_LIB \
1865 DBENCH_LIB=$DBENCH_LIB TESTSUITE=$TESTSUITE TESTNAME=$TESTNAME \
1868 log "Started rundbench load pid=$pid ..."
1870 # give rundbench a chance to start, bug 24118
1873 local num_failovers=0
1874 local start_ts=$(date +%s)
1875 while [ $elapsed -lt $duration ]; do
1876 if ! check_for_process $clients rundbench; then
1877 error_noexit "rundbench not found on some of $clients!"
1878 killall_process $clients dbench
1882 replay_barrier $SINGLEMDS
1883 sleep 1 # give clients a time to do operations
1884 # Increment the number of failovers
1885 num_failovers=$((num_failovers+1))
1886 log "$TESTNAME fail $SINGLEMDS $num_failovers times"
1888 elapsed=$(($(date +%s) - start_ts))
1891 wait $pid || error "rundbench load on $clients failed!"
1893 run_test 70b "mds recovery; $CLIENTCOUNT clients"
1894 # end multi-client tests
1897 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1901 replay_barrier $SINGLEMDS
1902 #define OBD_FAIL_LDLM_ENQUEUE 0x302
1903 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000302"
1906 wait $pid || return 1
1907 [ -e $DIR/$tfile ] && return 2
1910 run_test 73a "open(O_CREAT), unlink, replay, reconnect before open replay , close"
1913 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1917 replay_barrier $SINGLEMDS
1918 #define OBD_FAIL_LDLM_REPLY 0x30c
1919 do_facet $SINGLEMDS "lctl set_param fail_loc=0x8000030c"
1922 wait $pid || return 1
1923 [ -e $DIR/$tfile ] && return 2
1926 run_test 73b "open(O_CREAT), unlink, replay, reconnect at open_replay reply, close"
1929 multiop_bg_pause $DIR/$tfile O_tSc || return 3
1933 replay_barrier $SINGLEMDS
1934 #define OBD_FAIL_TGT_LAST_REPLAY 0x710
1935 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000710"
1938 wait $pid || return 1
1939 [ -e $DIR/$tfile ] && return 2
1942 run_test 73c "open(O_CREAT), unlink, replay, reconnect at last_replay, close"
1946 local clients=${CLIENTS:-$HOSTNAME}
1949 zconf_umount_clients $clients $MOUNT
1950 facet_failover $SINGLEMDS
1951 zconf_mount_clients $clients $MOUNT
1953 touch $DIR/$tfile || return 1
1954 rm $DIR/$tfile || return 2
1955 clients_up || error "client evicted: $?"
1958 run_test 74 "Ensure applications don't fail waiting for OST recovery"
1961 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1965 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1966 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1968 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1971 run_test 80a "CMD: unlink cross-node dir (fail mds with inode)"
1974 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1977 replay_barrier $SINGLEMDS
1978 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir $DIR/$tdir failed"
1979 rmdir $DIR/$tdir || error "rmdir $DIR/$tdir failed"
1981 stat $DIR/$tdir 2&>/dev/null && error "$DIR/$tdir still exist after recovery!"
1984 run_test 80b "CMD: unlink cross-node dir (fail mds with name)"
1987 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
1990 createmany -o $DIR/$tdir/f 3000 || error "createmany failed"
1992 $CHECKSTAT -t dir $DIR/$tdir || error "$CHECKSTAT -t dir failed"
1993 $CHECKSTAT -t file $DIR/$tdir/f1002 || error "$CHECKSTAT -t file failed"
1994 replay_barrier $SINGLEMDS
1995 rm $DIR/$tdir/f1002 || error "rm $DIR/$tdir/f1002 failed"
1997 stat $DIR/$tdir/f1002
1999 run_test 81a "CMD: unlink cross-node file (fail mds with name)"
2002 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2006 mkdir $dir || error "mkdir $dir failed"
2010 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2012 run_test 82a "CMD: mkdir cross-node dir (fail mds with inode)"
2015 [ $MDSCOUNT -lt 2 ] && skip "needs >= 2 MDTs" && return 0
2018 replay_barrier $SINGLEMDS
2019 mkdir $dir || error "mkdir $dir failed"
2023 $CHECKSTAT -t dir $dir || error "$CHECKSTAT -t dir $dir failed"
2025 run_test 82b "CMD: mkdir cross-node dir (fail mds with name)"
2029 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2030 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2031 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2032 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2034 run_test 83a "fail log_add during unlink recovery"
2038 createmany -o $DIR/$tdir/$tfile- 10 || return 1
2039 replay_barrier $SINGLEMDS
2040 unlinkmany $DIR/$tdir/$tfile- 10 || return 2
2041 #define OBD_FAIL_MDS_FAIL_LOV_LOG_ADD 0x140
2042 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000140"
2045 run_test 83b "fail log_add during unlink recovery"
2048 #define OBD_FAIL_MDS_OPEN_WAIT_CREATE 0x144
2049 do_facet $SINGLEMDS "lctl set_param fail_loc=0x80000144"
2050 createmany -o $DIR/$tfile- 1 &
2054 client_up || client_up || true # reconnect
2056 run_test 84a "stale open during export disconnect"
2058 test_85a() { #bug 16774
2059 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2061 for i in `seq 100`; do
2062 echo "tag-$i" > $DIR/$tfile-$i
2063 grep -q "tag-$i" $DIR/$tfile-$i || error "f2-$i"
2066 lov_id=`lctl dl | grep "clilov"`
2067 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2068 count=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2069 echo "before recovery: unused locks count = $count"
2073 count2=`lctl get_param -n ldlm.namespaces.*MDT0000*$addr.lock_unused_count`
2074 echo "after recovery: unused locks count = $count2"
2076 if [ $count2 -ge $count ]; then
2077 error "unused locks are not canceled"
2080 run_test 85a "check the cancellation of unused locks during recovery(IBITS)"
2082 test_85b() { #bug 16774
2083 lctl set_param -n ldlm.cancel_unused_locks_before_replay "1"
2085 do_facet mgs $LCTL pool_new $FSNAME.$TESTNAME || return 1
2086 do_facet mgs $LCTL pool_add $FSNAME.$TESTNAME $FSNAME-OST0000 || return 2
2088 lfs setstripe -c 1 -p $FSNAME.$TESTNAME $DIR
2090 for i in `seq 100`; do
2091 dd if=/dev/urandom of=$DIR/$tfile-$i bs=4096 count=32 >/dev/null 2>&1
2094 cancel_lru_locks osc
2096 for i in `seq 100`; do
2097 dd if=$DIR/$tfile-$i of=/dev/null bs=4096 count=32 >/dev/null 2>&1
2100 lov_id=`lctl dl | grep "clilov"`
2101 addr=`echo $lov_id | awk '{print $4}' | awk -F '-' '{print $3}'`
2102 count=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2103 echo "before recovery: unused locks count = $count"
2104 [ $count != 0 ] || return 3
2108 count2=`lctl get_param -n ldlm.namespaces.*OST0000*$addr.lock_unused_count`
2109 echo "after recovery: unused locks count = $count2"
2111 do_facet mgs $LCTL pool_remove $FSNAME.$TESTNAME $FSNAME-OST0000 || return 4
2112 do_facet mgs $LCTL pool_destroy $FSNAME.$TESTNAME || return 5
2114 if [ $count2 -ge $count ]; then
2115 error "unused locks are not canceled"
2118 run_test 85b "check the cancellation of unused locks during recovery(EXTENT)"
2121 local clients=${CLIENTS:-$HOSTNAME}
2123 zconf_umount_clients $clients $MOUNT
2124 do_facet $SINGLEMDS lctl set_param mdt.${FSNAME}-MDT*.exports.clear=0
2125 remount_facet $SINGLEMDS
2126 zconf_mount_clients $clients $MOUNT
2128 run_test 86 "umount server after clear nid_stats should not hit LBUG"
2131 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2134 lfs setstripe -i 0 -c 1 $DIR/$tfile
2135 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2136 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2137 cancel_lru_locks osc
2139 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2140 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2141 if [ $cksum != $cksum2 ] ; then
2142 error "New checksum $cksum2 does not match original $cksum"
2145 run_test 87 "write replay"
2148 do_facet ost1 "lctl set_param -n obdfilter.${ost1_svc}.sync_journal 0"
2151 lfs setstripe -i 0 -c 1 $DIR/$tfile
2152 dd if=/dev/urandom of=$DIR/$tfile bs=1024k count=8 || error "Cannot write"
2153 sleep 1 # Give it a chance to flush dirty data
2154 echo TESTTEST | dd of=$DIR/$tfile bs=1 count=8 seek=64
2155 cksum=`md5sum $DIR/$tfile | awk '{print $1}'`
2156 cancel_lru_locks osc
2158 dd if=$DIR/$tfile of=/dev/null bs=1024k count=8 || error "Cannot read"
2159 cksum2=`md5sum $DIR/$tfile | awk '{print $1}'`
2160 if [ $cksum != $cksum2 ] ; then
2161 error "New checksum $cksum2 does not match original $cksum"
2164 run_test 87b "write replay with changed data (checksum resend)"
2166 test_88() { #bug 17485
2170 lfs setstripe $DIR/$tdir -o 0 -c 1 || error "setstripe"
2173 replay_barrier $SINGLEMDS
2175 # exhaust precreations on ost1
2176 local OST=$(ostname_from_index 0)
2177 local mdtosc=$(get_mdtosc_proc_path $SINGLEMDS $OST)
2178 local last_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2179 local next_id=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2180 echo "before test: last_id = $last_id, next_id = $next_id"
2182 echo "Creating to objid $last_id on ost $OST..."
2183 createmany -o $DIR/$tdir/f-%d $next_id $((last_id - next_id + 2))
2185 #create some files to use some uncommitted objids
2186 last_id=$(($last_id + 1))
2187 createmany -o $DIR/$tdir/f-%d $last_id 8
2189 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2190 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2191 echo "before recovery: last_id = $last_id2, next_id = $next_id2"
2193 # if test uses shutdown_facet && reboot_facet instead of facet_failover ()
2194 # it has to take care about the affected facets, bug20407
2195 local affected_mds1=$(affected_facets mds1)
2196 local affected_ost1=$(affected_facets ost1)
2198 shutdown_facet $SINGLEMDS
2201 reboot_facet $SINGLEMDS
2202 change_active $affected_mds1
2203 wait_for_facet $affected_mds1
2204 mount_facets $affected_mds1 || error "Restart of mds failed"
2207 change_active $affected_ost1
2208 wait_for_facet $affected_ost1
2209 mount_facets $affected_ost1 || error "Restart of ost1 failed"
2213 last_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_last_id)
2214 next_id2=$(do_facet $SINGLEMDS lctl get_param -n osc.$mdtosc.prealloc_next_id)
2215 echo "after recovery: last_id = $last_id2, next_id = $next_id2"
2217 # create new files, which should use new objids, and ensure the orphan
2218 # cleanup phase for ost1 is completed at the same time
2219 for i in `seq 8`; do
2220 file_id=$(($last_id + 10 + $i))
2221 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2224 # if the objids were not recreated, then "ls" will failed for -ENOENT
2225 ls -l $DIR/$tdir/* || error "can't get the status of precreated files"
2228 # write into previously created files
2229 for i in `seq 8`; do
2230 file_id=$(($last_id + $i))
2231 dd if=/dev/urandom of=$DIR/$tdir/f-$file_id bs=4096 count=128
2232 cp -f $DIR/$tdir/f-$file_id $TMP/$tdir/
2235 # compare the content
2236 for i in `seq 8`; do
2237 file_id=$(($last_id + $i))
2238 cmp $TMP/$tdir/f-$file_id $DIR/$tdir/f-$file_id || error "the content" \
2239 "of file is modified!"
2244 run_test 88 "MDS should not assign same objid to different files "
2247 cancel_lru_locks osc
2249 rm -f $DIR/$tdir/$tfile
2251 wait_destroy_complete
2252 BLOCKS1=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2253 lfs setstripe -i 0 -c 1 $DIR/$tdir/$tfile
2254 dd if=/dev/zero bs=1M count=10 of=$DIR/$tdir/$tfile
2257 facet_failover $SINGLEMDS
2258 rm $DIR/$tdir/$tfile
2261 zconf_mount $(hostname) $MOUNT
2262 client_up || return 1
2264 BLOCKS2=$(df -P $MOUNT | tail -n 1 | awk '{ print $3 }')
2265 [ "$BLOCKS1" == "$BLOCKS2" ] || error $((BLOCKS2 - BLOCKS1)) blocks leaked
2268 run_test 89 "no disk space leak on late ost connection"
2274 change_active $facet
2275 wait_for_facet $facet
2276 mount_facet $facet || error "Restart of $facet failed"
2280 test_90() { # bug 19494
2281 local dir=$DIR/$tdir
2282 local ostfail=$(get_random_entry $(get_facets OST))
2284 if [[ $FAILURE_MODE = HARD ]]; then
2285 local affected=$(affected_facets $ostfail);
2286 if [[ "$affected" != $ostfail ]]; then
2287 skip not functional with FAILURE_MODE=$FAILURE_MODE, affected: $affected
2294 echo "Create the files"
2296 # file "f${index}" striped over 1 OST
2297 # file "all" striped over all OSTs
2299 $LFS setstripe -c $OSTCOUNT $dir/all || error "setstripe failed to create $dir/all"
2301 for (( i=0; i<$OSTCOUNT; i++ )); do
2303 $LFS setstripe -i $i -c 1 $f || error "setstripe failed to create $f"
2305 # confirm that setstripe actually created the stripe on the requested OST
2306 local uuid=$(ostuuid_from_index $i)
2307 for file in f$i all; do
2308 if [[ $dir/$file != $($LFS find --obd $uuid --name $file $dir) ]]; then
2309 $LFS getstripe $dir/file
2310 error wrong stripe: $file, uuid: $uuid
2315 # Before failing an OST, get its obd name and index
2316 local varsvc=${ostfail}_svc
2317 local obd=$(do_facet $ostfail lctl get_param -n obdfilter.${!varsvc}.uuid)
2318 local index=${obd:(-6):1}
2320 echo "Fail $ostfail $obd, display the list of affected files"
2321 shutdown_facet $ostfail || return 2
2323 trap "cleanup_90 $ostfail" EXIT INT
2324 echo "General Query: lfs find $dir"
2325 local list=$($LFS find $dir)
2327 for (( i=0; i<$OSTCOUNT; i++ )); do
2328 list_member "$list" $dir/f$i || error_noexit "lfs find $dir: no file f$i"
2330 list_member "$list" $dir/all || error_noexit "lfs find $dir: no file all"
2332 # focus on the missing OST,
2333 # we expect to see only two files affected: "f$(index)" and "all"
2335 echo "Querying files on shutdown $ostfail: lfs find --obd $obd"
2336 list=$($LFS find --obd $obd $dir)
2338 for file in all f$index; do
2339 list_member "$list" $dir/$file ||
2340 error_noexit "lfs find does not report the affected $obd for $file"
2343 [[ $(echo $list | wc -w) -eq 2 ]] ||
2344 error_noexit "lfs find reports the wrong list of affected files ${#list[@]}"
2346 echo "Check getstripe: lfs getstripe -r --obd $obd"
2347 list=$($LFS getstripe -r --obd $obd $dir)
2349 for file in all f$index; do
2350 echo "$list" | grep $dir/$file ||
2351 error_noexit "lfs getsripe does not report the affected $obd for $file"
2356 run_test 90 "lfs find identifies the missing striped file segments"
2358 complete $(basename $0) $SECONDS
2359 check_and_cleanup_lustre